]> cloud.milkyroute.net Git - dolphin.git/commitdiff
DolphinNavigator: Hide the KUrlNavigator background if DolphinNavigator is outside...
authorAkseli Lahtinen <akselmo@akselmo.dev>
Sat, 12 Apr 2025 16:28:38 +0000 (16:28 +0000)
committerAkseli Lahtinen <akselmo@akselmo.dev>
Sat, 12 Apr 2025 16:28:38 +0000 (16:28 +0000)
When the DolphinNavigator is outside of the toolbar, it's better to hide
the background for better looks.

This change works only when Dolphin is built against KIO 6.14.

src/dolphinmainwindow.cpp
src/dolphinmainwindow.h
src/dolphinnavigatorswidgetaction.cpp
src/dolphinnavigatorswidgetaction.h

index 12b8be955949fca38e21a12cb427d1947e37f797..efcd4190e36e066c6cec9d86438e0084d44acde6 100644 (file)
@@ -236,6 +236,7 @@ DolphinMainWindow::DolphinMainWindow()
     }
 
     updateAllowedToolbarAreas();
+    updateNavigatorsBackground();
 
     // enable middle-click on back/forward/up to open in a new tab
     auto *middleClickEventFilter = new MiddleClickActionEventFilter(this);
@@ -2760,6 +2761,12 @@ void DolphinMainWindow::updateAllowedToolbarAreas()
     }
 }
 
+void DolphinMainWindow::updateNavigatorsBackground()
+{
+    auto navigators = static_cast<DolphinNavigatorsWidgetAction *>(actionCollection()->action(QStringLiteral("url_navigators")));
+    navigators->setBackgroundEnabled(navigators->isInToolbar());
+}
+
 bool DolphinMainWindow::isKompareInstalled() const
 {
     static bool initialized = false;
@@ -2946,6 +2953,7 @@ void DolphinMainWindow::saveNewToolbarConfig()
         m_tabWidget->currentTabPage()->insertNavigatorsWidget(navigators);
     }
     updateAllowedToolbarAreas();
+    updateNavigatorsBackground();
     (static_cast<KHamburgerMenu *>(actionCollection()->action(KStandardAction::name(KStandardAction::HamburgerMenu))))->hideActionsOf(toolBar());
 }
 
index ecc84b97123d0a0b4c0eb220f6e726134466649d..b6aa9c020903c429736e96a23347277a0f643f92 100644 (file)
@@ -704,6 +704,12 @@ private:
      */
     void updateAllowedToolbarAreas();
 
+    /**
+     * Sets the background of the location bar(s) on if they are inside the toolbar,
+     * or off if they are outside the toolbar.
+     */
+    void updateNavigatorsBackground();
+
     bool isKompareInstalled() const;
 
     /**
index 0095869b16446f2aacdd9ad2aefcbaa21a8e37b5..1e4e5df9cddbcf62bcb330dcf0e41745cad653f9 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "trash/dolphintrash.h"
 
+#include <KCoreAddons>
 #include <KLocalizedString>
 #include <KNotificationJobUiDelegate>
 #include <KService>
@@ -102,6 +103,7 @@ void DolphinNavigatorsWidgetAction::createSecondaryUrlNavigator()
     Q_ASSERT(m_splitter->count() == 1);
     m_splitter->addWidget(createNavigatorWidget(Secondary));
     Q_ASSERT(m_splitter->count() == 2);
+    secondaryUrlNavigator()->setBackgroundEnabled(primaryUrlNavigator()->isBackgroundEnabled());
     updateText();
 }
 
@@ -148,6 +150,18 @@ void DolphinNavigatorsWidgetAction::setSecondaryNavigatorVisible(bool visible)
     updateText();
 }
 
+void DolphinNavigatorsWidgetAction::setBackgroundEnabled(bool enabled)
+{
+#if KIO_VERSION >= QT_VERSION_CHECK(6, 14, 0)
+    m_splitter->setAutoFillBackground(!enabled);
+    m_splitter->setBackgroundRole(enabled ? QPalette::Window : QPalette::Base);
+    primaryUrlNavigator()->setBackgroundEnabled(enabled);
+    if (secondaryUrlNavigator()) {
+        secondaryUrlNavigator()->setBackgroundEnabled(enabled);
+    }
+#endif
+}
+
 QWidget *DolphinNavigatorsWidgetAction::createWidget(QWidget *parent)
 {
     QWidget *oldParent = m_splitter->parentWidget();
index 6f068e27da6a777fa9a8a6b555264af9e03382b3..c9ce4ece2c5682fb44f7a64e799c3c2606f4aa9a 100644 (file)
@@ -85,6 +85,13 @@ public:
      */
     void setSecondaryNavigatorVisible(bool visible);
 
+    /**
+     * Sets the background cosmetic of the location bar(s) visible or hidden.
+     * In frameless designs it's better to hide the background.
+     * @param enabled True for showing background cosmetic, false for hiding it.
+     */
+    void setBackgroundEnabled(bool enabled);
+
 protected:
     /**
      * There should always ever be one navigatorsWidget for this action so