kmail
foldershortcutdialog.cppGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include <qlabel.h>
00040 #include <qvbox.h>
00041 #include <qvgroupbox.h>
00042 #include <qwhatsthis.h>
00043
00044 #include <kkeybutton.h>
00045 #include <klocale.h>
00046 #include <kmessagebox.h>
00047
00048 #include "kmmainwidget.h"
00049 #include "foldershortcutdialog.h"
00050 #include "kmfolder.h"
00051
00052 using namespace KMail;
00053
00054 FolderShortcutDialog::FolderShortcutDialog( KMFolder *folder,
00055 KMMainWidget *mainwidget,
00056 QWidget *parent,
00057 const char *name )
00058 : KDialogBase( parent, name, true,
00059 i18n( "Shortcut for Folder %1" ).arg( folder->label() ),
00060 KDialogBase::Ok | KDialogBase::Cancel ),
00061 mFolder( folder ), mMainWidget( mainwidget )
00062 {
00063 QVBox *box = makeVBoxMainWidget();
00064 QVGroupBox *gb = new QVGroupBox( i18n("Select Shortcut for Folder"), box );
00065 QWhatsThis::add( gb, i18n( "<qt>To choose a key or a combination "
00066 "of keys which select the current folder, "
00067 "click the button below and then press the key(s) "
00068 "you wish to associate with this folder.</qt>" ) );
00069 QHBox *hb = new QHBox( gb );
00070 new QWidget(hb);
00071 mKeyButton = new KKeyButton( hb, "FolderShortcutSelector" );
00072 new QWidget(hb);
00073
00074 connect( mKeyButton, SIGNAL( capturedShortcut( const KShortcut& ) ),
00075 this, SLOT( slotCapturedShortcut( const KShortcut& ) ) );
00076 mKeyButton->setShortcut( folder->shortcut(), false );
00077 }
00078
00079 FolderShortcutDialog::~FolderShortcutDialog()
00080 {
00081 }
00082
00083 void FolderShortcutDialog::slotCapturedShortcut( const KShortcut& sc )
00084 {
00085 if ( sc == mKeyButton->shortcut() ) return;
00086 if ( sc.toString().isNull() ) {
00087
00088 mKeyButton->setShortcut( KShortcut::null(), false );
00089 } else {
00090 if( !mMainWidget->shortcutIsValid( sc ) ) {
00091 QString msg( i18n( "The selected shortcut is already used, "
00092 "please select a different one." ) );
00093 KMessageBox::sorry( mMainWidget, msg );
00094 } else {
00095 mKeyButton->setShortcut( sc, false );
00096 }
00097 }
00098 }
00099
00100 void FolderShortcutDialog::slotOk()
00101 {
00102 mFolder->setShortcut( mKeyButton->shortcut() );
00103 KDialogBase::slotOk();
00104 }
00105
00106 #include "foldershortcutdialog.moc"
00107
00108
|