]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Use a separate menu action for split view action
authorJoshua Goins <josh@redstrate.com>
Thu, 30 Nov 2023 03:14:06 +0000 (22:14 -0500)
committerLoren Burkholder <computersemiexpert@outlook.com>
Thu, 18 Jan 2024 23:29:23 +0000 (23:29 +0000)
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
src/dolphinmainwindow.h
src/dolphinui.rc

index af217eab4651b9e77c77dbc5a846ac8f01523965..e3591bcaf2d917e5d6e3d5626a284572a75416b0 100644 (file)
@@ -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<KActionMenu>(QStringLiteral("split_view"));
+    m_splitViewMenuAction = actionCollection()->addAction(QStringLiteral("split_view_menu"));
+
     m_splitViewAction->setWhatsThis(xi18nc("@info:whatsthis find",
                                            "<para>This splits "
                                            "the folder view below into two autonomous views.</para><para>This "
                                            "way you can see two locations at once and move items between them "
                                            "quickly.</para>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()
index 7360fffbfe5034b184b635839fc9387d4ef9c3ce..62f8ceb6e489422cbce04f5902f160c6aced8d3f 100644 (file)
@@ -737,6 +737,7 @@ private:
     KToolBarPopupAction *m_backAction;
     KToolBarPopupAction *m_forwardAction;
     KActionMenu *m_splitViewAction;
+    QAction *m_splitViewMenuAction;
 
     QMenu m_searchTools;
     KFileItemActions m_fileItemActions;
index 05eb3346959cf76452ce8b7644ac993bd86219b9..dca0b61a98da00b5550077c45e015053c529d55e 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!DOCTYPE gui SYSTEM "kpartgui.dtd">
-<gui name="dolphin" version="38">
+<gui name="dolphin" version="39">
     <MenuBar>
         <Menu name="file">
             <Action name="new_menu" />
@@ -49,7 +49,7 @@
             <Action name="show_in_groups" />
             <Action name="show_hidden_files" />
             <Separator/>
-            <Action name="split_view" />
+            <Action name="split_view_menu" />
             <Action name="popout_split_view" />
             <Action name="split_stash" />
             <Action name="redisplay" />