16#include <Wt/WContainerWidget.h>
18#include <Wt/WLineEdit.h>
19#include <Wt/WLocalDateTime.h>
20#include <Wt/WPushButton.h>
23#include <Wt/WTableCell.h>
24#include <Wt/WStringUtil.h>
32 std::unique_ptr<WContainerWidget> layout
33 = std::make_unique<WContainerWidget>();
35 setImplementation(std::move(layout));
85 std::vector<Attachment> toadd =
attachments_[i]->attachments();
100 setStyleClass(
"darker");
103 WContainerWidget *horiz;
108 horiz =
layout_->addWidget(std::make_unique<WContainerWidget>());
109 horiz->setPadding(5);
110 topSendButton_ = horiz->addWidget(std::make_unique<WPushButton>(tr(
"msg.send")));
112 topSaveNowButton_ = horiz->addWidget(std::make_unique<WPushButton>(tr(
"msg.savenow")));
113 topDiscardButton_ = horiz->addWidget(std::make_unique<WPushButton>(tr(
"msg.discard")));
116 statusMsg_ = horiz->addWidget(std::make_unique<WText>());
126 edits_->setStyleClass(
"lighter");
127 edits_->resize(WLength(100, LengthUnit::Percentage), WLength::Auto);
128 edits_->elementAt(0, 0)->resize(WLength(1, LengthUnit::Percentage),
134 toEdit_ =
edits_->elementAt(0,1)->addWidget(std::make_unique<AddresseeEdit>(tr(
"msg.to"),
edits_->elementAt(0, 0)));
136 edits_->elementAt(0, 1)->setMargin(5, Side::Top);
137 ccEdit_ =
edits_->elementAt(1,1)->addWidget(std::make_unique<AddresseeEdit>(tr(
"msg.cc"),
edits_->elementAt(1, 0)));
138 bccEdit_ =
edits_->elementAt(2,1)->addWidget(std::make_unique<AddresseeEdit>(tr(
"msg.bcc"),
edits_->elementAt(2, 0)));
157 options_ =
edits_->elementAt(3, 1)->addWidget(std::make_unique<OptionList>());
158 std::unique_ptr<Option> addcc(
new Option(tr(
"msg.addcc")));
160 std::unique_ptr<Option> addbcc(
new Option(tr(
"msg.addbcc")));
169 edits_->elementAt(4, 0)->addWidget(std::make_unique<Label>(tr(
"msg.subject"),
edits_->elementAt(4, 0)));
170 subject_ =
edits_->elementAt(4, 1)->addWidget(std::make_unique<WLineEdit>());
171 subject_->resize(WLength(99, LengthUnit::Percentage), WLength::Auto);
176 edits_->elementAt(5, 0)->addWidget(std::make_unique<WImage>(
"icons/paperclip.png"));
177 edits_->elementAt(5, 0)->setContentAlignment(AlignmentFlag::Right | AlignmentFlag::Top);
178 edits_->elementAt(5, 0)->setPadding(3);
183 AttachmentEdit *attachmentEdit =
edits_->elementAt(5, 1)->addWidget(std::make_unique<AttachmentEdit>(
this));
190 attachFile_ =
edits_->elementAt(5, 1)->addWidget(std::make_unique<Option>(tr(
"msg.attachfile")));
205 horiz =
layout_->addWidget(std::make_unique<WContainerWidget>());
206 horiz->setPadding(5);
207 botSendButton_ = horiz->addWidget(std::make_unique<WPushButton>(tr(
"msg.send")));
209 botSaveNowButton_ = horiz->addWidget(std::make_unique<WPushButton>(tr(
"msg.savenow")));
210 botDiscardButton_ = horiz->addWidget(std::make_unique<WPushButton>(tr(
"msg.discard")));
259 std::unique_ptr<AttachmentEdit> edit
260 = std::make_unique<AttachmentEdit>(
this);
276 std::vector<AttachmentEdit *>::iterator i
281 attachment->removeFromParent();
321 for (
unsigned i = 0; i <
attachments_.size() - 1; ++i) {
332 setStatus(tr(
"msg.uploading"),
"status");
361 bool attachmentsFailed =
false;
364 attachmentsFailed =
true;
368 if (attachmentsFailed) {
369 setStatus(tr(
"msg.attachment.failed"),
"error");
372 WString timeStr = Wt::WLocalDateTime::currentDateTime().toString(
"HH:mm");
373 statusMsg_->setText(Wt::utf8(
"Draft saved at {1}").arg(timeStr));
std::vector< Contact > addressees() const
Get a list of addressees.
void setAddressees(const std::vector< Contact > &contacts)
Set a list of addressees.
An edit field for an email attachment.
WPushButton * botSaveNowButton_
void sendIt()
Slot attached to the Send button.
Option * attachOtherFile_
Option for attaching another file.
void setMessage(const WString &message)
Set the message.
void saved()
All attachments have been processed, determine the result of saving the message.
WTextArea * message_
WTextArea for the main message.
WPushButton * topSaveNowButton_
Wt::Signal send
The message is ready to be sent...
std::vector< Contact > bcc() const
Get the Bc: contacts.
Wt::Signal discard
The message must be discarded.
const WString & message() const
Get the message.
WPushButton * topSendButton_
void setStatus(const WString &text, const WString &style)
Set the status, and apply the given style.
AddresseeEdit * toEdit_
To: Addressees edit.
void discardIt()
Slot attached to the Discard button.
std::vector< Contact > to() const
Get the To: contacts.
void attachMore()
Add an attachment edit.
void saveNow()
Slot attached to the Save now button.
WPushButton * botSendButton_
bool saving_
state when waiting asyncrhonously for attachments to be uploaded
WLineEdit * subject_
The subject line edit.
WPushButton * topDiscardButton_
int attachmentsPending_
number of attachments waiting to be uploaded during saving
void setTo(const std::vector< Contact > &to)
Set message To: contacts.
ContactSuggestions * contactSuggestions_
The suggestions popup for the addressee edits.
Composer()
Construct a new Composer.
Option * attachFile_
Option for attaching a file.
WPushButton * botDiscardButton_
std::vector< AttachmentEdit * > attachments_
Array which holds all the attachments, including one extra invisible one.
Option * addbcc_
Option for editing Bcc:
AddresseeEdit * ccEdit_
Cc: Addressees edit.
void attachmentDone()
Slotcalled when an attachment has been uploaded.
WContainerWidget * layout_
void setSubject(const WString &subject)
Set subject.
void removeAttachment(AttachmentEdit *attachment)
Remove the given attachment edit.
const WString & subject() const
Get the subject.
Option * addcc_
Option for editing Cc:
void setAddressBook(const std::vector< Contact > &addressBook)
Set the address book, for autocomplete suggestions.
std::vector< Contact > cc() const
Get the Cc: contacts.
AddresseeEdit * bccEdit_
Bcc: Addressees edit.
OptionList * options_
OptionsList for editing Cc or Bcc.
std::vector< Attachment > attachments() const
Get the list of attachments.
void update()
Updates the stateless implementations after an Option has been hidden or shown.
void add(std::unique_ptr< Option > option)
Add an Option to the list.
WInteractWidget * item()
Returns the clickable part.