kmail

foldershortcutdialog.cpp
1 /*******************************************************************************
2 **
3 ** Filename : foldershortcutdialog.cpp
4 ** Created on : 09 October, 2004
5 ** Copyright : (c) 2004 Till Adam
6 ** Email : adam@kde.org
7 **
8 *******************************************************************************/
9 
10 /*******************************************************************************
11 **
12 ** This program is free software; you can redistribute it and/or modify
13 ** it under the terms of the GNU General Public License as published by
14 ** the Free Software Foundation; either version 2 of the License, or
15 ** (at your option) any later version.
16 **
17 ** This program is distributed in the hope that it will be useful,
18 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ** GNU General Public License for more details.
21 **
22 ** You should have received a copy of the GNU General Public License
23 ** along with this program; if not, write to the Free Software
24 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 **
26 ** In addition, as a special exception, the copyright holders give
27 ** permission to link the code of this program with any edition of
28 ** the TQt library by Trolltech AS, Norway (or with modified versions
29 ** of TQt that use the same license as TQt), and distribute linked
30 ** combinations including the two. You must obey the GNU General
31 ** Public License in all respects for all of the code used other than
32 ** TQt. If you modify this file, you may extend this exception to
33 ** your version of the file, but you are not obligated to do so. If
34 ** you do not wish to do so, delete this exception statement from
35 ** your version.
36 **
37 *******************************************************************************/
38 
39 #include <tqlabel.h>
40 #include <tqvbox.h>
41 #include <tqvgroupbox.h>
42 #include <tqwhatsthis.h>
43 
44 #include <kkeybutton.h>
45 #include <tdelocale.h>
46 #include <tdemessagebox.h>
47 
48 #include "kmmainwidget.h"
49 #include "foldershortcutdialog.h"
50 #include "kmfolder.h"
51 
52 using namespace KMail;
53 
54 FolderShortcutDialog::FolderShortcutDialog( KMFolder *folder,
55  KMMainWidget *mainwidget,
56  TQWidget *parent,
57  const char *name )
58 : KDialogBase( parent, name, true,
59  i18n( "Shortcut for Folder %1" ).arg( folder->label() ),
60  KDialogBase::Ok | KDialogBase::Cancel ),
61  mFolder( folder ), mMainWidget( mainwidget )
62 {
63  TQVBox *box = makeVBoxMainWidget();
64  TQVGroupBox *gb = new TQVGroupBox( i18n("Select Shortcut for Folder"), box );
65  TQWhatsThis::add( gb, i18n( "<qt>To choose a key or a combination "
66  "of keys which select the current folder, "
67  "click the button below and then press the key(s) "
68  "you wish to associate with this folder.</qt>" ) );
69  TQHBox *hb = new TQHBox( gb );
70  new TQWidget(hb);
71  mKeyButton = new KKeyButton( hb, "FolderShortcutSelector" );
72  new TQWidget(hb);
73 
74  connect( mKeyButton, TQ_SIGNAL( capturedShortcut( const TDEShortcut& ) ),
75  this, TQ_SLOT( slotCapturedShortcut( const TDEShortcut& ) ) );
76  mKeyButton->setShortcut( folder->shortcut(), false );
77 }
78 
79 FolderShortcutDialog::~FolderShortcutDialog()
80 {
81 }
82 
83 void FolderShortcutDialog::slotCapturedShortcut( const TDEShortcut& sc )
84 {
85  if ( sc == mKeyButton->shortcut() ) return;
86  if ( sc.toString().isNull() ) {
87  // null is fine, that's reset, but sc.Ń–sNull() will be false :/
88  mKeyButton->setShortcut( TDEShortcut::null(), false );
89  } else {
90  if( !mMainWidget->shortcutIsValid( sc ) ) {
91  TQString msg( i18n( "The selected shortcut is already used, "
92  "please select a different one." ) );
93  KMessageBox::sorry( mMainWidget, msg );
94  } else {
95  mKeyButton->setShortcut( sc, false );
96  }
97  }
98 }
99 
100 void FolderShortcutDialog::slotOk()
101 {
102  mFolder->setShortcut( mKeyButton->shortcut() );
103  KDialogBase::slotOk();
104 }
105 
106 #include "foldershortcutdialog.moc"
107 
108 
Mail folder.
Definition: kmfolder.h:69
@ Ok
The user rights/ACL have been fetched from the server sucessfully.
Definition: acljobs.h:66
folderdiaquotatab.h
Definition: aboutdata.cpp:40