diff options
| author | Peter Penz <[email protected]> | 2011-10-10 22:05:32 +0200 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2011-10-10 22:08:23 +0200 |
| commit | 90e39e3116b5821addce8035b82619b726a49eab (patch) | |
| tree | cd012f014b73df8adab9b5634e36482eea754720 /src | |
| parent | c9156fdaf9dd3f5bad649659a2533a561deb90e0 (diff) | |
Allow changing shortcuts for the Panel actions
Until now the shortcuts of the Panel actions could not be changed
as they did not show up in the "Configure shortcuts..." dialog.
The patch is based on the work of "SiegeLord" and Fabian Henze
attached to bug 273050.
BUG: 273050
FIXED-IN: 4.8.0
Diffstat (limited to 'src')
| -rw-r--r-- | src/dolphinmainwindow.cpp | 36 | ||||
| -rw-r--r-- | src/dolphinmainwindow.h | 14 |
2 files changed, 24 insertions, 26 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 1b2b971c2..34ff8b71b 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1769,9 +1769,7 @@ void DolphinMainWindow::setupDockWidgets() infoDock->setWidget(infoPanel); QAction* infoAction = infoDock->toggleViewAction(); - infoAction->setIcon(KIcon("dialog-information")); - infoAction->setShortcut(Qt::Key_F11); - addActionCloneToCollection(infoAction, "show_information_panel"); + createPanelAction(KIcon("dialog-information"), Qt::Key_F11, infoAction, "show_information_panel"); addDockWidget(Qt::RightDockWidgetArea, infoDock); connect(this, SIGNAL(urlChanged(KUrl)), @@ -1791,9 +1789,7 @@ void DolphinMainWindow::setupDockWidgets() foldersDock->setWidget(foldersPanel); QAction* foldersAction = foldersDock->toggleViewAction(); - foldersAction->setShortcut(Qt::Key_F7); - foldersAction->setIcon(KIcon("folder")); - addActionCloneToCollection(foldersAction, "show_folders_panel"); + createPanelAction(KIcon("folder"), Qt::Key_F7, foldersAction, "show_folders_panel"); addDockWidget(Qt::LeftDockWidgetArea, foldersDock); connect(this, SIGNAL(urlChanged(KUrl)), @@ -1816,9 +1812,7 @@ void DolphinMainWindow::setupDockWidgets() terminalPanel, SLOT(dockVisibilityChanged())); QAction* terminalAction = terminalDock->toggleViewAction(); - terminalAction->setShortcut(Qt::Key_F4); - terminalAction->setIcon(KIcon("utilities-terminal")); - addActionCloneToCollection(terminalAction, "show_terminal_panel"); + createPanelAction(KIcon("utilities-terminal"), Qt::Key_F4, terminalAction, "show_terminal_panel"); addDockWidget(Qt::BottomDockWidgetArea, terminalDock); connect(this, SIGNAL(urlChanged(KUrl)), @@ -1837,9 +1831,7 @@ void DolphinMainWindow::setupDockWidgets() searchDock->setWidget(searchPanel); QAction* searchAction = searchDock->toggleViewAction(); - searchAction->setShortcut(Qt::Key_F12); - searchAction->setIcon(KIcon("system-search")); - addActionCloneToCollection(searchAction, "show_search_panel"); + createPanelAction(KIcon("system-search"), Qt::Key_F12, searchAction, "show_search_panel"); addDockWidget(Qt::RightDockWidgetArea, searchDock); connect(this, SIGNAL(urlChanged(KUrl)), searchPanel, SLOT(setUrl(KUrl))); @@ -1874,9 +1866,7 @@ void DolphinMainWindow::setupDockWidgets() placesDock->setWidget(placesPanel); QAction* placesAction = placesDock->toggleViewAction(); - placesAction->setShortcut(Qt::Key_F9); - placesAction->setIcon(KIcon("bookmarks")); - addActionCloneToCollection(placesAction, "show_places_panel"); + createPanelAction(KIcon("bookmarks"), Qt::Key_F9, placesAction, "show_places_panel"); addDockWidget(Qt::LeftDockWidgetArea, placesDock); connect(placesPanel, SIGNAL(urlChanged(KUrl,Qt::MouseButtons)), @@ -2222,12 +2212,18 @@ QString DolphinMainWindow::squeezedText(const QString& text) const return fm.elidedText(text, Qt::ElideMiddle, fm.maxWidth() * 10); } -void DolphinMainWindow::addActionCloneToCollection(QAction* action, const QString& actionName) +void DolphinMainWindow::createPanelAction(const KIcon& icon, + const QKeySequence& shortcut, + QAction* dockAction, + const QString& actionName) { - KAction* actionClone = actionCollection()->addAction(actionName); - actionClone->setText(action->text()); - actionClone->setIcon(action->icon()); - connect(actionClone, SIGNAL(triggered()), action, SLOT(trigger())); + KAction* panelAction = actionCollection()->addAction(actionName); + panelAction->setText(dockAction->text()); + panelAction->setIcon(icon); + panelAction->setShortcut(shortcut); + + dockAction->setIcon(icon); + connect(panelAction, SIGNAL(triggered()), dockAction, SLOT(trigger())); } DolphinMainWindow::UndoUiInterface::UndoUiInterface() : diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index 6736e24aa..fd9e10329 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -531,13 +531,15 @@ private: QString squeezedText(const QString& text) const; /** - * Adds a clone of the action \a action to the action-collection with - * the name \a actionName, so that the action \a action also can be - * added to the toolbar by the user. This is useful if the creation of - * \a action is e.g. done in Qt and hence cannot be added directly - * to the action-collection. + * Creates an action for showing/hiding a panel, that is accessible + * in "Configure toolbars..." and "Configure shortcuts...". This is necessary + * as the action for toggling the dock visibility is done by Qt which + * is no KAction instance. */ - void addActionCloneToCollection(QAction* action, const QString& actionName); + void createPanelAction(const KIcon& icon, + const QKeySequence& shortcut, + QAction* dockAction, + const QString& actionName); private: /** |
