• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kmail

  • sources
  • kde-4.12
  • kdepim
  • kmail
  • collectionpage
collectionshortcutpage.cpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-file-style: "gnu" -*-
2  This file is part of KMail, the KDE mail client.
3  Copyright (c) 2004 Till Adam <adam@kde.org>
4  Copyright (c) 2013 Jonathan Marten <jjm@keelhaul.me.uk>
5 
6  KMail is free software; you can redistribute it and/or modify it
7  under the terms of the GNU General Public License, version 2, as
8  published by the Free Software Foundation.
9 
10  KMail is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 
20 #include "collectionshortcutpage.h"
21 #include "kmkernel.h"
22 #include "kmmainwidget.h"
23 #include "foldershortcutactionmanager.h"
24 
25 #include <QLabel>
26 #include <QSpacerItem>
27 #include <QVBoxLayout>
28 
29 #include <KDialog>
30 #include <KHBox>
31 #include <KLocale>
32 #include <KKeySequenceWidget>
33 
34 using namespace MailCommon;
35 
36 
37 CollectionShortcutPage::CollectionShortcutPage(QWidget * parent) :
38  CollectionPropertiesPage( parent ),
39  mShortcutChanged( false )
40 {
41  setObjectName( QLatin1String( "KMail::CollectionShortcutPage" ) );
42  setPageTitle( i18nc( "@title:tab Shortcut settings for a folder.", "Shortcut" ) );
43 }
44 
45 CollectionShortcutPage::~CollectionShortcutPage()
46 {
47 }
48 
49 void CollectionShortcutPage::init(const Akonadi::Collection & col)
50 {
51  mFolder = FolderCollection::forCollection( col, false );
52 
53  QVBoxLayout *topLayout = new QVBoxLayout( this );
54  topLayout->setSpacing( KDialog::spacingHint() );
55 
56  QLabel *label = new QLabel( i18n( "<qt>To choose a key or a combination "
57  "of keys which select the current folder, "
58  "click the button below and then press the key(s) "
59  "you wish to associate with this folder.</qt>" ), this );
60  label->setWordWrap(true);
61  topLayout->addWidget(label);
62 
63  KHBox *hb = new KHBox( this );
64 
65  new QWidget(hb);
66  mKeySeqWidget = new KKeySequenceWidget( hb );
67  mKeySeqWidget->setObjectName( QLatin1String("FolderShortcutSelector") );
68  connect( mKeySeqWidget, SIGNAL(keySequenceChanged(QKeySequence)),
69  SLOT(slotShortcutChanged()) );
70  new QWidget(hb);
71 
72  topLayout->addItem( new QSpacerItem( 0, 10 ));
73  topLayout->addWidget( hb );
74  topLayout->addStretch( 1 );
75 
76  mKeySeqWidget->setCheckActionCollections( KMKernel::self()->getKMMainWidget()->actionCollections() );
77 }
78 
79 void CollectionShortcutPage::load( const Akonadi::Collection & col )
80 {
81  init( col );
82  if ( mFolder ) {
83  mKeySeqWidget->setKeySequence( mFolder->shortcut().primary(),
84  KKeySequenceWidget::NoValidate );
85  mShortcutChanged = false;
86  }
87 }
88 
89 void CollectionShortcutPage::save( Akonadi::Collection & col )
90 {
91  if ( mFolder ) {
92  if ( mShortcutChanged ) {
93  mKeySeqWidget->applyStealShortcut();
94  mFolder->setShortcut( KShortcut( mKeySeqWidget->keySequence(), QKeySequence() ) );
95  KMKernel::self()->getKMMainWidget()->folderShortcutActionManager()->shortcutChanged( mFolder->collection() );
96  }
97  }
98 }
99 
100 void CollectionShortcutPage::slotShortcutChanged()
101 {
102  mShortcutChanged = true;
103 }
104 
105 
106 
107 #include "collectionshortcutpage.moc"
CollectionShortcutPage::save
void save(Akonadi::Collection &col)
Definition: collectionshortcutpage.cpp:89
collectionshortcutpage.h
kmmainwidget.h
QWidget
KMMainWidget::folderShortcutActionManager
KMail::FolderShortcutActionManager * folderShortcutActionManager() const
Definition: kmmainwidget.h:151
KMKernel::self
static KMKernel * self()
normal control stuff
Definition: kmkernel.cpp:1451
CollectionShortcutPage::load
void load(const Akonadi::Collection &col)
Definition: collectionshortcutpage.cpp:79
KMail::FolderShortcutActionManager::shortcutChanged
void shortcutChanged(const Akonadi::Collection &collection)
Updates the shortcut action for this collection.
Definition: foldershortcutactionmanager.cpp:120
CollectionShortcutPage::CollectionShortcutPage
CollectionShortcutPage(QWidget *parent=0)
Definition: collectionshortcutpage.cpp:37
CollectionShortcutPage::~CollectionShortcutPage
~CollectionShortcutPage()
Definition: collectionshortcutpage.cpp:45
kmkernel.h
foldershortcutactionmanager.h
QLabel
KHBox
KMKernel::getKMMainWidget
KMMainWidget * getKMMainWidget()
Get first mainwidget.
Definition: kmkernel.cpp:1515
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:58:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal