Version: (using KDE Devel) Installed from: Compiled sources Hi, would be nice to have shortcuts to select the current active application in Kontact. Maybe something like: ctrl-1 ... ctrl-x
*** Bug 79485 has been marked as a duplicate of this bug. ***
*** Bug 83051 has been marked as a duplicate of this bug. ***
According to Cornelius comment in bug 83051 this is a bug. Changing severity to normal.
CVS commit by tokoe: Add shortcuts to IconSidePane, that fixes #75212. CCMAIL:75212-done@bugs.kde.org M +22 -0 iconsidepane.cpp 1.17 M +6 -0 iconsidepane.h 1.10 M +2 -0 mainwindow.cpp 1.122 M +10 -0 sidepanebase.cpp 1.4 M +4 -0 sidepanebase.h 1.4 --- kdepim/kontact/src/iconsidepane.cpp #1.16:1.17 @@ -28,4 +28,5 @@ #include <qbitmap.h> #include <qfontmetrics.h> +#include <qsignalmapper.h> #include <qstyle.h> #include <qframe.h> @@ -127,4 +128,7 @@ Navigator::Navigator( SidePaneBase *pare connect( this, SIGNAL( currentChanged( QListBoxItem * ) ), SLOT( slotExecuted( QListBoxItem * ) ) ); + + mMapper = new QSignalMapper( this ); + connect( mMapper, SIGNAL( mapped( int ) ), SLOT( shortCutSelected( int ) ) ); } @@ -149,4 +153,9 @@ void Navigator::updatePlugins( QValueLis clear(); + mActions.setAutoDelete( true ); + mActions.clear(); + mActions.setAutoDelete( false ); + + int counter = 0; int minWidth = 0; QValueList<Kontact::Plugin*>::ConstIterator end = plugins.end(); @@ -161,4 +170,11 @@ void Navigator::updatePlugins( QValueLis if ( item->width( this ) > minWidth ) minWidth = item->width( this ); + + QString name = QString( "CTRL+%1" ).arg( counter + 1 ); + KAction *action = new KAction( plugin->title(), KShortcut( name ), + mMapper, SLOT( map() ), + mSidePane->actionCollection(), name.latin1() ); + mMapper->setMapping( action, counter ); + counter++; } @@ -225,4 +241,10 @@ void Navigator::resizeEvent( QResizeEven } +void Navigator::shortCutSelected( int pos ) +{ + setCurrentItem( pos ); +} + + IconSidePane::IconSidePane( Core *core, QWidget *parent, const char *name ) : SidePaneBase( core, parent, name ) --- kdepim/kontact/src/iconsidepane.h #1.9:1.10 @@ -28,4 +28,6 @@ #include <qlistbox.h> +class QSignalMapper; + namespace KParts { class Part; } @@ -93,7 +95,11 @@ class Navigator : public KListBox private slots: void slotExecuted( QListBoxItem *item ); + void shortCutSelected( int ); private: SidePaneBase *mSidePane; + + QSignalMapper *mMapper; + QPtrList<KAction> mActions; }; --- kdepim/kontact/src/mainwindow.cpp #1.121:1.122 @@ -216,4 +216,6 @@ void MainWindow::initWidgets() } + mSidePane->setActionCollection( actionCollection() ); + connect( mSidePane, SIGNAL( pluginSelected( Kontact::Plugin * ) ), SLOT( selectPlugin( Kontact::Plugin * ) ) ); --- kdepim/kontact/src/sidepanebase.cpp #1.3:1.4 @@ -40,3 +40,13 @@ Core* SidePaneBase::core() const } +void SidePaneBase::setActionCollection( KActionCollection *actionCollection ) +{ + mActionCollection = actionCollection; +} + +KActionCollection *SidePaneBase::actionCollection() const +{ + return mActionCollection; +} + #include "sidepanebase.moc" --- kdepim/kontact/src/sidepanebase.h #1.3:1.4 @@ -39,4 +39,7 @@ class SidePaneBase : public QVBox virtual ~SidePaneBase(); + void setActionCollection( KActionCollection *actionCollection ); + KActionCollection *actionCollection() const; + signals: void pluginSelected( Kontact::Plugin* ); @@ -66,4 +69,5 @@ class SidePaneBase : public QVBox private: Core* mCore; + KActionCollection *mActionCollection; };