From 830dd0148a26d91ba7f3e0316da1e021fe2b83e4 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Wed, 29 Nov 2023 22:14:06 -0500 Subject: [PATCH] Use a separate menu action for split view action Now that it's a KMenuAction, it becomes impossible to trigger the root action when it's in a menu. To work around this, we create a new action that mirrors the state of the original. It also takes the default shortcut. --- src/dolphinmainwindow.cpp | 15 ++++++++++++++- src/dolphinmainwindow.h | 1 + src/dolphinui.rc | 4 ++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index af217eab4..e3591bcaf 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -119,6 +119,7 @@ DolphinMainWindow::DolphinMainWindow() , m_sessionSaveWatcher(nullptr) , m_sessionSaveScheduled(false) , m_splitViewAction(nullptr) + , m_splitViewMenuAction(nullptr) { Q_INIT_RESOURCE(dolphin); @@ -1832,14 +1833,21 @@ void DolphinMainWindow::setupActions() // (note that most of it is set up in DolphinViewActionHandler) m_splitViewAction = actionCollection()->add(QStringLiteral("split_view")); + m_splitViewMenuAction = actionCollection()->addAction(QStringLiteral("split_view_menu")); + m_splitViewAction->setWhatsThis(xi18nc("@info:whatsthis find", "This splits " "the folder view below into two autonomous views.This " "way you can see two locations at once and move items between them " "quickly.Click this again afterwards to recombine the views.")); + m_splitViewMenuAction->setWhatsThis(m_splitViewAction->whatsThis()); + + // only set it for the menu version + actionCollection()->setDefaultShortcut(m_splitViewMenuAction, Qt::Key_F3); + m_splitViewAction->setPopupMode(QToolButton::MenuButtonPopup); - actionCollection()->setDefaultShortcut(m_splitViewAction, Qt::Key_F3); connect(m_splitViewAction, &QAction::triggered, this, &DolphinMainWindow::toggleSplitView); + connect(m_splitViewMenuAction, &QAction::triggered, this, &DolphinMainWindow::toggleSplitView); QAction *popoutSplit = actionCollection()->addAction(QStringLiteral("popout_split_view")); popoutSplit->setWhatsThis(xi18nc("@info:whatsthis", @@ -2552,6 +2560,11 @@ void DolphinMainWindow::updateSplitActions() popoutSplitAction->setText(i18nc("@action:intoolbar Move active split view to a new window", "Pop out")); popoutSplitAction->setEnabled(false); } + + // Update state from toolbar action + m_splitViewMenuAction->setText(m_splitViewAction->text()); + m_splitViewMenuAction->setToolTip(m_splitViewAction->toolTip()); + m_splitViewMenuAction->setIcon(m_splitViewAction->icon()); } void DolphinMainWindow::updateAllowedToolbarAreas() diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index 7360fffbf..62f8ceb6e 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -737,6 +737,7 @@ private: KToolBarPopupAction *m_backAction; KToolBarPopupAction *m_forwardAction; KActionMenu *m_splitViewAction; + QAction *m_splitViewMenuAction; QMenu m_searchTools; KFileItemActions m_fileItemActions; diff --git a/src/dolphinui.rc b/src/dolphinui.rc index 05eb33469..dca0b61a9 100644 --- a/src/dolphinui.rc +++ b/src/dolphinui.rc @@ -1,6 +1,6 @@ - + @@ -49,7 +49,7 @@ - + -- 2.47.3