Make shortcut categories work
authorManuel Nickschas <sputnick@quassel-irc.org>
Mon, 31 May 2010 22:45:12 +0000 (00:45 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 31 May 2010 22:45:12 +0000 (00:45 +0200)
We now support translateable titles for ActionCollections, and also support
multiple collections in KDE-integrated Quassel (this did work for !KDE already).

src/qtui/mainwin.cpp
src/uisupport/graphicalui.cpp
src/uisupport/graphicalui.h

index 878168e..cdfa65b 100644 (file)
@@ -310,7 +310,7 @@ void MainWin::updateIcon() {
 }
 
 void MainWin::setupActions() {
-  ActionCollection *coll = QtUi::actionCollection("General");
+  ActionCollection *coll = QtUi::actionCollection("General", tr("General"));
   // File
   coll->addAction("ConnectCore", new Action(SmallIcon("network-connect"), tr("&Connect to Core..."), coll,
                                              this, SLOT(showCoreConnectionDlg())));
@@ -367,6 +367,8 @@ void MainWin::setupActions() {
                                        QtUi::style(), SLOT(reload()), QKeySequence::Refresh));
 
   // Navigation
+  coll = QtUi::actionCollection("Navigation", tr("Navigation"));
+
   coll->addAction("JumpHotBuffer", new Action(tr("Jump to hot chat"), coll,
                                               this, SLOT(on_jumpHotBuffer_triggered()), QKeySequence(Qt::META + Qt::Key_A)));
 }
@@ -984,7 +986,10 @@ void MainWin::showAboutDlg() {
 
 void MainWin::showShortcutsDlg() {
 #ifdef HAVE_KDE
-  KShortcutsDialog::configure(QtUi::actionCollection("General"), KShortcutsEditor::LetterShortcutsDisallowed);
+  KShortcutsDialog dlg(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsDisallowed, this);
+  foreach(KActionCollection *coll, QtUi::actionCollections())
+    dlg.addCollection(coll, coll->property("Category").toString());
+  dlg.exec();
 #else
   SettingsPageDlg dlg(new ShortcutsSettingsPage(QtUi::actionCollections(), this), this);
   dlg.exec();
index 59ea321..ba772f0 100644 (file)
@@ -59,11 +59,16 @@ void GraphicalUi::init() {
 #endif
 }
 
-ActionCollection *GraphicalUi::actionCollection(const QString &category) {
+ActionCollection *GraphicalUi::actionCollection(const QString &category, const QString &translatedCategory) {
   if(_actionCollections.contains(category))
     return _actionCollections.value(category);
   ActionCollection *coll = new ActionCollection(_mainWidget);
-  coll->setProperty("Category", category);
+
+  if(!translatedCategory.isEmpty())
+    coll->setProperty("Category", translatedCategory);
+  else
+    coll->setProperty("Category", category);
+
   if(_mainWidget)
     coll->addAssociatedWidget(_mainWidget);
   _actionCollections.insert(category, coll);
index 42a0a01..269e079 100644 (file)
@@ -45,7 +45,7 @@ public:
   *  create appropriate Action objects using GraphicalUi::actionCollection(cat)->add\<Action\>().
   *  @param category The category (default: "General")
   */
-  static ActionCollection *actionCollection(const QString &category = "General");
+  static ActionCollection *actionCollection(const QString &category = "General", const QString &translatedCategory = QString());
   static QHash<QString, ActionCollection *> actionCollections();
 
   //! Load custom shortcuts from ShortcutSettings