You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
3.4 KiB
105 lines
3.4 KiB
/* |
|
This file is part of KMail, the KDE mail client. |
|
Copyright (c) 2004 Till Adam <adam@kde.org> |
|
Copyright (c) 2013 Jonathan Marten <jjm@keelhaul.me.uk> |
|
|
|
KMail 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. |
|
|
|
KMail 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 "collectionshortcutpage.h" |
|
#include "kmkernel.h" |
|
#include "kmmainwidget.h" |
|
#include "foldershortcutactionmanager.h" |
|
|
|
#include <QLabel> |
|
#include <QSpacerItem> |
|
#include <QVBoxLayout> |
|
|
|
#include <QDialog> |
|
#include <QHBoxLayout> |
|
#include <KLocalizedString> |
|
#include <KKeySequenceWidget> |
|
#include <KConfigGroup> |
|
|
|
using namespace MailCommon; |
|
|
|
CollectionShortcutPage::CollectionShortcutPage(QWidget *parent) : |
|
CollectionPropertiesPage(parent), |
|
mShortcutChanged(false) |
|
{ |
|
setObjectName(QStringLiteral("KMail::CollectionShortcutPage")); |
|
setPageTitle(i18nc("@title:tab Shortcut settings for a folder.", "Shortcut")); |
|
} |
|
|
|
CollectionShortcutPage::~CollectionShortcutPage() |
|
{ |
|
} |
|
|
|
void CollectionShortcutPage::init(const Akonadi::Collection &col) |
|
{ |
|
mFolder = FolderCollection::forCollection(col, false); |
|
|
|
QVBoxLayout *topLayout = new QVBoxLayout(this); |
|
|
|
QLabel *label = new QLabel(i18n("<qt>To choose a key or a combination " |
|
"of keys which select the current folder, " |
|
"click the button below and then press the key(s) " |
|
"you wish to associate with this folder.</qt>"), this); |
|
label->setWordWrap(true); |
|
topLayout->addWidget(label); |
|
|
|
QWidget *hb = new QWidget(this); |
|
QHBoxLayout *hbHBoxLayout = new QHBoxLayout(hb); |
|
hbHBoxLayout->setMargin(0); |
|
|
|
new QWidget(hb); |
|
mKeySeqWidget = new KKeySequenceWidget(hb); |
|
hbHBoxLayout->addWidget(mKeySeqWidget); |
|
mKeySeqWidget->setObjectName(QStringLiteral("FolderShortcutSelector")); |
|
connect(mKeySeqWidget, &KKeySequenceWidget::keySequenceChanged, this, &CollectionShortcutPage::slotShortcutChanged); |
|
new QWidget(hb); |
|
|
|
topLayout->addItem(new QSpacerItem(0, 10)); |
|
topLayout->addWidget(hb); |
|
topLayout->addStretch(1); |
|
|
|
mKeySeqWidget->setCheckActionCollections(KMKernel::self()->getKMMainWidget()->actionCollections()); |
|
} |
|
|
|
void CollectionShortcutPage::load(const Akonadi::Collection &col) |
|
{ |
|
init(col); |
|
if (mFolder) { |
|
mKeySeqWidget->setKeySequence(mFolder->shortcut(), |
|
KKeySequenceWidget::NoValidate); |
|
mShortcutChanged = false; |
|
} |
|
} |
|
|
|
void CollectionShortcutPage::save(Akonadi::Collection &col) |
|
{ |
|
if (mFolder) { |
|
if (mShortcutChanged) { |
|
mKeySeqWidget->applyStealShortcut(); |
|
mFolder->setShortcut(mKeySeqWidget->keySequence()); |
|
KMKernel::self()->getKMMainWidget()->folderShortcutActionManager()->shortcutChanged(mFolder->collection()); |
|
} |
|
} |
|
} |
|
|
|
void CollectionShortcutPage::slotShortcutChanged() |
|
{ |
|
mShortcutChanged = true; |
|
} |
|
|
|
|