Check for already used shortcuts and refuse them.

svn path=/trunk/kdepim/; revision=353343
wilder-work
Till Adam 22 years ago
parent 9ebffe966e
commit 8a9abb9aea
  1. 15
      foldershortcutdialog.cpp
  2. 5
      foldershortcutdialog.h
  3. 4
      kmfoldertree.cpp
  4. 11
      kmmainwidget.cpp
  5. 6
      kmmainwidget.h

@ -43,19 +43,22 @@
#include <kkeybutton.h>
#include <klocale.h>
#include <kmessagebox.h>
#include "kmmainwidget.h"
#include "foldershortcutdialog.h"
#include "kmfolder.h"
using namespace KMail;
FolderShortcutDialog::FolderShortcutDialog( KMFolder *folder,
KMMainWidget *mainwidget,
QWidget *parent,
const char *name )
: KDialogBase( parent, name, true,
i18n( "Shortcut for Folder %1" ).arg( folder->label() ),
KDialogBase::Ok | KDialogBase::Cancel ),
mFolder( folder )
mFolder( folder ), mMainWidget( mainwidget )
{
QVBox *box = makeVBoxMainWidget();
QVGroupBox *gb = new QVGroupBox( i18n("Select shortcut for folder"), box );
@ -79,8 +82,14 @@ FolderShortcutDialog::~FolderShortcutDialog()
void FolderShortcutDialog::slotCapturedShortcut( const KShortcut& sc )
{
// hm, check if it's valid?
mKeyButton->setShortcut( sc, false );
if ( sc == mKeyButton->shortcut() ) return;
if ( !mMainWidget->shortcutIsValid( sc ) ) {
QString msg( i18n( "The selected shortcut is already used, "
"please select a different one." ) );
KMessageBox::sorry( mMainWidget, msg );
} else {
mKeyButton->setShortcut( sc, false );
}
}
void FolderShortcutDialog::slotOk()

@ -43,6 +43,7 @@
class KShortcut;
class KMFolder;
class KKeyButton;
class KMMainWidget;
namespace KMail
{
@ -51,7 +52,8 @@ class FolderShortcutDialog : public KDialogBase
{
Q_OBJECT
public:
FolderShortcutDialog( KMFolder *folder, QWidget *parent=0, const char *name=0 );
FolderShortcutDialog( KMFolder *folder, KMMainWidget *mw,
QWidget *parent=0, const char *name=0 );
~FolderShortcutDialog();
@ -61,6 +63,7 @@ protected slots:
private:
KMFolder *mFolder;
KMMainWidget *mMainWidget;
KKeyButton *mKeyButton;
}; // End of class FolderShortcutDialog

@ -258,7 +258,9 @@ void KMFolderTreeItem::assignShortcut()
return;
KMail::FolderShortcutDialog *shorty =
new KMail::FolderShortcutDialog( mFolder, listView() );
new KMail::FolderShortcutDialog( mFolder,
static_cast<KMFolderTree *>( listView() )->mainWidget(),
listView() );
shorty->exec();
return;
}

@ -86,6 +86,7 @@ using KMail::HeaderListQuickSearch;
#include <assert.h>
#include <kstatusbar.h>
#include <kstaticdeleter.h>
#include <kaction.h>
#include <kmime_mdn.h>
#include <kmime_header_parsing.h>
@ -3371,6 +3372,16 @@ void KMMainWidget::slotFolderRemoved( KMFolder *folder )
mFolderShortcutCommands.remove( folder->idString() );
}
bool KMMainWidget::shortcutIsValid( const KShortcut &sc ) const
{
KActionPtrList actions = actionCollection()->actions();
KActionPtrList::Iterator it( actions.begin() );
for ( ; it != actions.end(); it++ ) {
if ( (*it)->shortcut() == sc ) return false;
}
return true;
}
void KMMainWidget::slotShortcutChanged( KMFolder *folder )
{
// remove the old one, autodelete

@ -142,6 +142,10 @@ public:
static QPtrList<KMMainWidget>* mainWidgetList() { return s_mainWidgetList; }
KMSystemTray *systray() const;
/** Checks a shortcut against the actioncollection and returns whether it
* is already used and therefor not valid or not. */
bool shortcutIsValid( const KShortcut& ) const;
public slots:
@ -205,7 +209,7 @@ protected:
void updateFileMenu();
void updateViewMenu();
KActionCollection * actionCollection() { return mActionCollection; }
KActionCollection * actionCollection() const { return mActionCollection; }
KRadioAction * actionForHeaderStyle( const KMail::HeaderStyle *,
const KMail::HeaderStrategy * );

Loading…
Cancel
Save