]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Change three view buttons into one with menu arrow
authorAkseli Lahtinen <akselmo@akselmo.dev>
Thu, 30 Jan 2025 09:25:12 +0000 (09:25 +0000)
committerMéven Car <meven@kde.org>
Thu, 30 Jan 2025 09:25:12 +0000 (09:25 +0000)
Instead of showing three buttons, which is quite visually noisy, show
only one button that is split: First button, when clicked, loops
through the view modes. Second smaller button with the down arrow
shows menu of the available view modes.

See also
https://invent.kde.org/system/dolphin/-/issues/68#toolbar-button-changes

Alternative for https://invent.kde.org/system/dolphin/-/merge_requests/893

![Screencast_20250121_123718](/uploads/e8625c485c58a9c47e8168106b3e7419/Screencast_20250121_123718.mp4)

src/dolphinui.rc
src/tests/dolphinmainwindowtest.cpp
src/views/dolphinviewactionhandler.cpp

index 5c9afa03d0ec0d876bf5e949601bffff124f3e8f..7c2cb2bfc60bdd70653d766bd819c8d59a247986 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!DOCTYPE gui SYSTEM "kpartgui.dtd">
-<gui name="dolphin" version="41">
+<gui name="dolphin" version="42">
     <MenuBar>
         <Menu name="file">
             <Action name="new_menu" />
         <text context="@title:menu">Main Toolbar</text>
         <Action name="go_back" />
         <Action name="go_forward" />
-        <Separator name="separator_1" />
-        <Action name="icons" />
-        <Action name="compact" />
-        <Action name="details" />
+        <Action name="view_mode" />
         <Action name="url_navigators" />
         <Action name="split_view" />
         <Action name="split_stash" />
index 37e042219208f1e4080a0af68dc7be2d96aa4699..b22afa142f6022f692852cf305850624d19c6781 100644 (file)
@@ -846,7 +846,7 @@ void DolphinMainWindowTest::testAccessibilityTree()
                                                                                       // after going forwards which is probably not intended.
         }
     }
-    QCOMPARE_GE(testedObjectsSizeAfterTraversingForwards, 12); // The test did not reach many objects while using the Tab key to move through Dolphin. Did the
+    QCOMPARE_GE(testedObjectsSizeAfterTraversingForwards, 11); // The test did not reach many objects while using the Tab key to move through Dolphin. Did the
                                                                // test run correctly?
 }
 
index 2934e800582e28dd48d7da835a8361d4cf56e93a..88d5c015b589d09c269a709143bec3049fddfde4 100644 (file)
@@ -211,12 +211,25 @@ void DolphinViewActionHandler::createActions(SelectionMode::ActionTextHelper *ac
                                        "view the contents of multiple folders in the same list.</para>"));
 
     KSelectAction *viewModeActions = m_actionCollection->add<KSelectAction>(QStringLiteral("view_mode"));
-    viewModeActions->setText(i18nc("@action:intoolbar", "View Mode"));
+    viewModeActions->setText(i18nc("@action:intoolbar", "Change View Mode"));
+    viewModeActions->setWhatsThis(xi18nc("@info:whatsthis View Mode Toolbutton", "This cycles through all view modes."));
     viewModeActions->addAction(iconsAction);
     viewModeActions->addAction(compactAction);
     viewModeActions->addAction(detailsAction);
     viewModeActions->setToolBarMode(KSelectAction::MenuMode);
+    viewModeActions->setToolButtonPopupMode(QToolButton::ToolButtonPopupMode::MenuButtonPopup);
     connect(viewModeActions, &KSelectAction::actionTriggered, this, &DolphinViewActionHandler::slotViewModeActionTriggered);
+    connect(viewModeActions, &KSelectAction::triggered, this, [this, viewModeActions, iconsAction, compactAction, detailsAction]() {
+        // Loop through the actions when button is clicked
+        const auto currentAction = viewModeActions->currentAction();
+        if (currentAction == iconsAction) {
+            slotViewModeActionTriggered(compactAction);
+        } else if (currentAction == compactAction) {
+            slotViewModeActionTriggered(detailsAction);
+        } else if (currentAction == detailsAction) {
+            slotViewModeActionTriggered(iconsAction);
+        }
+    });
 
     QAction *zoomInAction = KStandardAction::zoomIn(this, &DolphinViewActionHandler::zoomIn, m_actionCollection);
     zoomInAction->setWhatsThis(i18nc("@info:whatsthis zoom in", "This increases the icon size."));