Commit 66e86458 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix Bug 328591 - 'Send Mail' keyboard shortcut (CTRL+ENTER) should not be set...

Fix Bug 328591 - 'Send Mail' keyboard shortcut (CTRL+ENTER) should not be set by default or require confirmation

FIXED-IN: 4.14
BUG: 328591
parent 588a8ba4
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "validatesendmailshortcut.h"
#include "settings/globalsettings.h"
#include <KMessageBox>
#include <KActionCollection>
#include <KLocalizedString>
#include <kaction.h>
ValidateSendMailShortcut::ValidateSendMailShortcut(KActionCollection *actionCollection, QWidget *parent)
: mParent(parent),
mActionCollection(actionCollection)
{
}
ValidateSendMailShortcut::~ValidateSendMailShortcut()
{
}
bool ValidateSendMailShortcut::validate()
{
bool sendNow = false;
bool configWasSaved = false;
const int result = KMessageBox::questionYesNoCancel(mParent,
i18n("This shortcut allows to send mail directly. Mail can be send accidentally. What do you want to do?"), i18n("Configure shortcut"),
KGuiItem(i18n("Remove Shortcut")),
KGuiItem(i18n("Ask Before Sending")),
KGuiItem(i18n("Sending Without Confirmation")) );
GlobalSettings::self()->setCheckSendDefaultShortcut(true);
if (result == KMessageBox::Yes) {
QAction *act = mActionCollection->action( QLatin1String("send_default") );
act->setShortcut(QKeySequence());
mActionCollection->writeSettings();
configWasSaved = true;
sendNow = false;
} else if (result == KMessageBox::No) {
GlobalSettings::self()->setConfirmBeforeSend(true);
GlobalSettings::self()->writeConfig();
sendNow = false;
} else if (result == KMessageBox::Cancel) {
sendNow = true;
}
if (!configWasSaved) {
GlobalSettings::self()->writeConfig();
}
return sendNow;
}
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef VALIDATESENDMAILSHORTCUT_H
#define VALIDATESENDMAILSHORTCUT_H
#include <QWidget>
class KActionCollection;
class ValidateSendMailShortcut
{
public:
ValidateSendMailShortcut(KActionCollection *actionCollection, QWidget *parent = 0);
~ValidateSendMailShortcut();
bool validate();
private:
QWidget *mParent;
KActionCollection *mActionCollection;
};
#endif // VALIDATESENDMAILSHORTCUT_H
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