Bug 75212

Summary: Shortcuts for selecting active application with keyboard
Product: [Applications] kontact Reporter: Sebastian Kratzert <krase>
Component: generalAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: ivansanchez, schumacher
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Sebastian Kratzert 2004-02-14 11:09:00 UTC
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
Comment 1 Ingo Klöcker 2004-06-06 13:26:34 UTC
*** Bug 79485 has been marked as a duplicate of this bug. ***
Comment 2 Michael Jahn 2004-07-25 23:39:17 UTC
*** Bug 83051 has been marked as a duplicate of this bug. ***
Comment 3 Michael Jahn 2004-07-25 23:43:02 UTC
According to Cornelius comment in bug 83051 this is a bug. Changing severity to normal.
Comment 4 Tobias Koenig 2004-08-03 01:09:00 UTC
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;
 };