16 #include <Wt/WContainerWidget.h> 17 #include <Wt/WImage.h> 18 #include <Wt/WLineEdit.h> 19 #include <Wt/WPushButton.h> 21 #include <Wt/WTable.h> 22 #include <Wt/WTableCell.h> 23 #include <Wt/WStringUtil.h> 31 std::unique_ptr<WContainerWidget> layout
32 = cpp14::make_unique<WContainerWidget>();
34 setImplementation(std::move(layout));
84 std::vector<Attachment> toadd =
attachments_[i]->attachments();
99 setStyleClass(
"darker");
102 WContainerWidget *horiz;
107 horiz =
layout_->addWidget(cpp14::make_unique<WContainerWidget>());
108 horiz->setPadding(5);
109 topSendButton_ = horiz->addWidget(cpp14::make_unique<WPushButton>(tr(
"msg.send")));
111 topSaveNowButton_ = horiz->addWidget(cpp14::make_unique<WPushButton>(tr(
"msg.savenow")));
112 topDiscardButton_ = horiz->addWidget(cpp14::make_unique<WPushButton>(tr(
"msg.discard")));
115 statusMsg_ = horiz->addWidget(cpp14::make_unique<WText>());
125 edits_->setStyleClass(
"lighter");
126 edits_->resize(WLength(100, LengthUnit::Percentage), WLength::Auto);
127 edits_->elementAt(0, 0)->resize(WLength(1, LengthUnit::Percentage),
133 toEdit_ =
edits_->elementAt(0,1)->addWidget(cpp14::make_unique<AddresseeEdit>(tr(
"msg.to"),
edits_->elementAt(0, 0)));
135 edits_->elementAt(0, 1)->setMargin(5, Side::Top);
136 ccEdit_ =
edits_->elementAt(1,1)->addWidget(cpp14::make_unique<AddresseeEdit>(tr(
"msg.cc"),
edits_->elementAt(1, 0)));
137 bccEdit_ =
edits_->elementAt(2,1)->addWidget(cpp14::make_unique<AddresseeEdit>(tr(
"msg.bcc"),
edits_->elementAt(2, 0)));
156 options_ =
edits_->elementAt(3, 1)->addWidget(cpp14::make_unique<OptionList>());
157 std::unique_ptr<Option> addcc(
new Option(tr(
"msg.addcc")));
159 std::unique_ptr<Option> addbcc(
new Option(tr(
"msg.addbcc")));
168 edits_->elementAt(4, 0)->addWidget(cpp14::make_unique<Label>(tr(
"msg.subject"),
edits_->elementAt(4, 0)));
169 subject_ =
edits_->elementAt(4, 1)->addWidget(cpp14::make_unique<WLineEdit>());
170 subject_->resize(WLength(99, LengthUnit::Percentage), WLength::Auto);
175 edits_->elementAt(5, 0)->addWidget(cpp14::make_unique<WImage>(
"icons/paperclip.png"));
176 edits_->elementAt(5, 0)->setContentAlignment(AlignmentFlag::Right | AlignmentFlag::Top);
177 edits_->elementAt(5, 0)->setPadding(3);
182 AttachmentEdit *attachmentEdit =
edits_->elementAt(5, 1)->addWidget(cpp14::make_unique<AttachmentEdit>(
this));
189 attachFile_ =
edits_->elementAt(5, 1)->addWidget(cpp14::make_unique<Option>(tr(
"msg.attachfile")));
190 attachOtherFile_ =
edits_->elementAt(5, 1)->addWidget(cpp14::make_unique<Option>(tr(
"msg.attachanother")));
204 horiz =
layout_->addWidget(cpp14::make_unique<WContainerWidget>());
205 horiz->setPadding(5);
206 botSendButton_ = horiz->addWidget(cpp14::make_unique<WPushButton>(tr(
"msg.send")));
208 botSaveNowButton_ = horiz->addWidget(cpp14::make_unique<WPushButton>(tr(
"msg.savenow")));
209 botDiscardButton_ = horiz->addWidget(cpp14::make_unique<WPushButton>(tr(
"msg.discard")));
258 std::unique_ptr<AttachmentEdit> edit
259 = cpp14::make_unique<AttachmentEdit>(
this);
275 std::vector<AttachmentEdit *>::iterator i
280 attachment->removeFromParent();
320 for (
unsigned i = 0; i <
attachments_.size() - 1; ++i) {
331 setStatus(tr(
"msg.uploading"),
"status");
360 bool attachmentsFailed =
false;
363 attachmentsFailed =
true;
367 if (attachmentsFailed) {
368 setStatus(tr(
"msg.attachment.failed"),
"error");
375 strftime(buffer, 100,
"%H:%M", &td);
377 char buffer[] =
"server";
380 statusMsg_->setText(std::string(
"Draft saved at ") + buffer);
const WString & subject() const
Get the subject.
std::vector< Contact > cc() const
Get the Cc: contacts.
std::vector< Attachment > attachments() const
Get the list of attachments.
AddresseeEdit * bccEdit_
Bcc: Addressees edit.
WInteractWidget * item()
Returns the clickable part.
AddresseeEdit * toEdit_
To: Addressees edit.
const WString & message() const
Get the message.
void discardIt()
Slot attached to the Discard button.
WContainerWidget * layout_
Option * attachOtherFile_
Option for attaching another file.
Option * addbcc_
Option for editing Bcc:
An edit field for an email attachment.
Composer()
Construct a new Composer.
void saved()
All attachments have been processed, determine the result of saving the message.
WPushButton * botSaveNowButton_
std::vector< AttachmentEdit * > attachments_
Array which holds all the attachments, including one extra invisible one.
WTextArea * message_
WTextArea for the main message.
Wt::Signal send
The message is ready to be sent...
void setSubject(const WString &subject)
Set subject.
void removeAttachment(AttachmentEdit *attachment)
Remove the given attachment edit.
void saveNow()
Slot attached to the Save now button.
void update()
Updates the stateless implementations after an Option has been hidden or shown.
WPushButton * botSendButton_
WPushButton * topDiscardButton_
void sendIt()
Slot attached to the Send button.
void setAddressBook(const std::vector< Contact > &addressBook)
Set the address book, for autocomplete suggestions.
void setAddressees(const std::vector< Contact > &contacts)
Set a list of addressees.
WPushButton * botDiscardButton_
std::vector< Contact > bcc() const
Get the Bc: contacts.
bool saving_
state when waiting asyncrhonously for attachments to be uploaded
Option * attachFile_
Option for attaching a file.
std::vector< Contact > to() const
Get the To: contacts.
WPushButton * topSaveNowButton_
WLineEdit * subject_
The subject line edit.
Wt::Signal discard
The message must be discarded.
WPushButton * topSendButton_
void add(std::unique_ptr< Option > option)
Add an Option to the list.
std::vector< Contact > addressees() const
Get a list of addressees.
void attachmentDone()
Slotcalled when an attachment has been uploaded.
Option * addcc_
Option for editing Cc:
ContactSuggestions * contactSuggestions_
The suggestions popup for the addressee edits.
void setMessage(const WString &message)
Set the message.
void setTo(const std::vector< Contact > &to)
Set message To: contacts.
void attachMore()
Add an attachment edit.
AddresseeEdit * ccEdit_
Cc: Addressees edit.
int attachmentsPending_
number of attachments waiting to be uploaded during saving
OptionList * options_
OptionsList for editing Cc or Bcc.
void setStatus(const WString &text, const WString &style)
Set the status, and apply the given style.