Commit a3944c6c authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix Bug 338033 - confirmation dialog on sending mail

FIXED-IN: 4.14
BUG: 338033
parent 48049e14
......@@ -226,7 +226,8 @@ KMComposeWin::KMComposeWin( const KMime::Message::Ptr &aMsg, bool lastSignState,
mIgnoreStickyFields( false ),
mWasModified( false ),
mCryptoStateIndicatorWidget(0),
mStorageService(new KMStorageService(this, this))
mStorageService(new KMStorageService(this, this)),
mSendNowByShortcutUsed(false)
{
m_verifyMissingAttachment = 0;
mComposerBase = new MessageComposer::ComposerViewBase( this, this );
......@@ -1102,10 +1103,15 @@ void KMComposeWin::setupActions( void )
if ( MessageComposer::MessageComposerSettings::self()->sendImmediate() ) {
//default = send now, alternative = queue
KAction *action = new KAction(KIcon(QLatin1String("mail-send")), i18n("&Send Mail"), this);
actionCollection()->addAction(QLatin1String("send_default"), action );
action->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_Return ) );
actionCollection()->addAction(QLatin1String("send_mail_default"), action );
connect( action, SIGNAL(triggered(bool)), SLOT(slotSendNow()));
action = new KAction(KIcon(QLatin1String("mail-send")), i18n("Send Mail Using Shortcut"), this);
actionCollection()->addAction(QLatin1String("send_mail"), action );
action->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_Return ) );
connect( action, SIGNAL(triggered(bool)), SLOT(slotSendNowByShortcut()));
// FIXME: change to mail_send_via icon when this exist.
actActionNowMenu = new KActionMenu( KIcon( QLatin1String("mail-send") ), i18n("&Send Mail Via"), this );
actActionNowMenu->setIconText( i18n( "Send" ) );
......@@ -1121,7 +1127,7 @@ void KMComposeWin::setupActions( void )
} else {
//default = queue, alternative = send now
KAction *action = new KAction( KIcon( QLatin1String("mail-queue") ), i18n("Send &Later"), this );
actionCollection()->addAction( QLatin1String("send_default"), action );
actionCollection()->addAction( QLatin1String("send_mail"), action );
connect( action, SIGNAL(triggered(bool)), SLOT(slotSendLater()) );
action->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_Return ) );
actActionLaterMenu = new KActionMenu( KIcon( QLatin1String("mail-queue") ), i18n("Send &Later Via"), this );
......@@ -2926,7 +2932,7 @@ void KMComposeWin::slotSendLaterVia( QAction *item )
}
//----------------------------------------------------------------------------
void KMComposeWin::slotSendNow()
void KMComposeWin::sendNow(bool shortcutUsed)
{
if ( !mComposerBase->editor()->checkExternalEditorFinished() ) {
return;
......@@ -2935,7 +2941,7 @@ void KMComposeWin::slotSendNow()
return;
if ( !checkRecipientNumber() )
return;
mSendNowByShortcutUsed = shortcutUsed;
if( GlobalSettings::self()->checkSpellingBeforeSend()) {
mComposerBase->editor()->forceSpellChecking();
} else {
......@@ -2943,24 +2949,45 @@ void KMComposeWin::slotSendNow()
}
}
void KMComposeWin::slotSendNowByShortcut()
{
sendNow(true);
}
void KMComposeWin::slotSendNow()
{
sendNow(false);
}
void KMComposeWin::confirmBeforeSend()
{
const int rc = KMessageBox::warningYesNoCancel( mMainWidget,
i18n("About to send email..."),
i18n("Send Confirmation"),
KGuiItem( i18n("&Send Now") ),
KGuiItem( i18n("Send &Later") ) );
if ( rc == KMessageBox::Yes ) {
doSend( MessageComposer::MessageSender::SendImmediate );
} else if ( rc == KMessageBox::No ) {
doSend( MessageComposer::MessageSender::SendLater );
}
}
void KMComposeWin::slotCheckSendNow()
{
if ( GlobalSettings::self()->confirmBeforeSend() ) {
const int rc = KMessageBox::warningYesNoCancel( mMainWidget,
i18n("About to send email..."),
i18n("Send Confirmation"),
KGuiItem( i18n("&Send Now") ),
KGuiItem( i18n("Send &Later") ) );
if ( rc == KMessageBox::Yes ) {
doSend( MessageComposer::MessageSender::SendImmediate );
} else if ( rc == KMessageBox::No ) {
doSend( MessageComposer::MessageSender::SendLater );
}
confirmBeforeSend();
} else {
if (!GlobalSettings::self()->checkSendDefaultShortcut()) {
ValidateSendMailShortcut validateShortcut(actionCollection(), this);
if (!validateShortcut.validate()) {
if (mSendNowByShortcutUsed) {
if (!GlobalSettings::self()->checkSendDefaultActionShortcut()) {
ValidateSendMailShortcut validateShortcut(actionCollection(), this);
if (!validateShortcut.validate()) {
return;
}
}
if (GlobalSettings::self()->confirmBeforeSendWhenUseShortcut()) {
confirmBeforeSend();
return;
}
}
......
......@@ -456,6 +456,7 @@ private slots:
void slotTransportChanged();
void slotFollowUpMail();
void slotSendNowByShortcut();
public: // kmcommand
// FIXME we need to remove these, but they're pure virtual in Composer.
void addAttach( KMime::Content *msgPart );
......@@ -477,6 +478,9 @@ public: // kmcommand
void ignoreStickyFields();
private:
void confirmBeforeSend();
void sendNow(bool shortcutUsed);
void updateSignature(uint uoid, uint uOldId);
Kleo::CryptoMessageFormat cryptoMessageFormat() const;
QString overwriteModeStr() const;
......@@ -687,6 +691,7 @@ private:
QMap<QByteArray, QString> mExtraHeaders;
CryptoStateIndicatorWidget *mCryptoStateIndicatorWidget;
KMStorageService *mStorageService;
bool mSendNowByShortcutUsed;
};
#endif
......@@ -44,7 +44,7 @@ bool ValidateSendMailShortcut::validate()
KGuiItem(i18n("Remove Shortcut")),
KGuiItem(i18n("Ask Before Sending")),
KGuiItem(i18n("Sending Without Confirmation")) );
GlobalSettings::self()->setCheckSendDefaultShortcut(true);
GlobalSettings::self()->setCheckSendDefaultActionShortcut(true);
if (result == KMessageBox::Yes) {
QAction *act = mActionCollection->action( QLatin1String("send_default") );
act->setShortcut(QKeySequence());
......@@ -52,9 +52,9 @@ bool ValidateSendMailShortcut::validate()
configWasSaved = true;
sendNow = false;
} else if (result == KMessageBox::No) {
GlobalSettings::self()->setConfirmBeforeSend(true);
GlobalSettings::self()->setConfirmBeforeSendWhenUseShortcut(true);
GlobalSettings::self()->writeConfig();
sendNow = false;
sendNow = true;
} else if (result == KMessageBox::Cancel) {
sendNow = true;
}
......
......@@ -226,6 +226,9 @@
<label>Confirm &amp;before send</label>
<default>false</default>
</entry>
<entry name="ConfirmBeforeSendWhenUseShortcut" type="Bool" key="confirm-before-send-when-use-shortcut">
<default>false</default>
</entry>
<entry name="CheckSpellingBeforeSend" type="Bool" key="check-spelling-before-send">
<label>Check spelling before send</label>
<default>false</default>
......@@ -296,7 +299,7 @@
<label>Show crypto label indicator</label>
<default>true</default>
</entry>
<entry name="CheckSendDefaultShortcut" type="Bool">
<entry name="CheckSendDefaultActionShortcut" type="Bool">
<label>Validate Send Default Shortcut</label>
<default>false</default>
</entry>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment