summaryrefslogtreecommitdiff
path: root/src/gui/windows/maileditwindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-08-25 23:55:43 +0300
committerAndrei Karas <akaras@inbox.ru>2017-08-25 23:55:43 +0300
commitd0768817618143739b8fd81cfa9124e8f60e1b12 (patch)
tree94450009f3bf4cd7726250633865f0a112f625fb /src/gui/windows/maileditwindow.cpp
parentf7d3792df9fd01ea7baabaf9b612031b1f28d7ab (diff)
downloadplus-d0768817618143739b8fd81cfa9124e8f60e1b12.tar.gz
plus-d0768817618143739b8fd81cfa9124e8f60e1b12.tar.bz2
plus-d0768817618143739b8fd81cfa9124e8f60e1b12.tar.xz
plus-d0768817618143739b8fd81cfa9124e8f60e1b12.zip
Validate destination name after it entered in mail edit window.
Diffstat (limited to 'src/gui/windows/maileditwindow.cpp')
-rw-r--r--src/gui/windows/maileditwindow.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/gui/windows/maileditwindow.cpp b/src/gui/windows/maileditwindow.cpp
index 47b4d409e..b3cfd560b 100644
--- a/src/gui/windows/maileditwindow.cpp
+++ b/src/gui/windows/maileditwindow.cpp
@@ -52,6 +52,7 @@ MailEditWindow::MailEditWindow() :
// TRANSLATORS: mail edit window name
Window(_("Edit mail"), Modal_false, nullptr, "mailedit.xml"),
ActionListener(),
+ FocusListener(),
// TRANSLATORS: mail edit window button
mSendButton(new Button(this, _("Send"), "send", this)),
// TRANSLATORS: mail edit window button
@@ -101,8 +102,8 @@ MailEditWindow::MailEditWindow() :
mSubjectField->setWidth(100);
mMessageField->setWidth(100);
mItemScrollArea->setHeight(100);
-
mItemScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
+ mToField->addFocusListener(this);
placer(0, 0, mToLabel);
placer(1, 0, mToField, 3);
@@ -120,6 +121,7 @@ MailEditWindow::MailEditWindow() :
placer(3, 6, mCloseButton);
loadWindowState();
+ mSendButton->setEnabled(false);
enableVisibleSound(true);
}
@@ -177,6 +179,7 @@ void MailEditWindow::setSubject(const std::string &str)
void MailEditWindow::setTo(const std::string &str)
{
mToField->setText(str);
+ mSendButton->setEnabled(true);
}
void MailEditWindow::setMessage(const std::string &str)
@@ -240,3 +243,32 @@ void MailEditWindow::updateItems()
{
mItemContainer->updateMatrix();
}
+
+void MailEditWindow::focusLost(const Event &event)
+{
+ if (!mUseMail2)
+ return;
+
+ if (event.getSource() == mToField)
+ {
+ const std::string to = mToField->getText();
+ if (to != mail2Handler->getCheckedName())
+ {
+ mail2Handler->queueCheckName(MailQueueType::ValidateTo,
+ to,
+ std::string(),
+ std::string(),
+ 0);
+ mSendButton->setEnabled(false);
+ }
+ else
+ {
+ mSendButton->setEnabled(true);
+ }
+ }
+}
+
+void MailEditWindow::validatedTo()
+{
+ mSendButton->setEnabled(true);
+}