From 128f797d73ba8118072767cbead7f22590b522db Mon Sep 17 00:00:00 2001 From: Akseli Lahtinen Date: Thu, 30 Jan 2025 09:25:12 +0000 Subject: [PATCH] Change three view buttons into one with menu arrow 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 | 7 ++----- src/tests/dolphinmainwindowtest.cpp | 2 +- src/views/dolphinviewactionhandler.cpp | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/dolphinui.rc b/src/dolphinui.rc index 5c9afa03d..7c2cb2bfc 100644 --- a/src/dolphinui.rc +++ b/src/dolphinui.rc @@ -1,6 +1,6 @@ - + @@ -106,10 +106,7 @@ Main Toolbar - - - - + diff --git a/src/tests/dolphinmainwindowtest.cpp b/src/tests/dolphinmainwindowtest.cpp index 37e042219..b22afa142 100644 --- a/src/tests/dolphinmainwindowtest.cpp +++ b/src/tests/dolphinmainwindowtest.cpp @@ -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? } diff --git a/src/views/dolphinviewactionhandler.cpp b/src/views/dolphinviewactionhandler.cpp index 2934e8005..88d5c015b 100644 --- a/src/views/dolphinviewactionhandler.cpp +++ b/src/views/dolphinviewactionhandler.cpp @@ -211,12 +211,25 @@ void DolphinViewActionHandler::createActions(SelectionMode::ActionTextHelper *ac "view the contents of multiple folders in the same list.")); KSelectAction *viewModeActions = m_actionCollection->add(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.")); -- 2.47.3