From 59e39f536be6a646b93ad6403aa375ec7ec4181b Mon Sep 17 00:00:00 2001 From: Dirk Hohndel <dirk@hohndel.org> Date: Thu, 3 Dec 2020 13:51:36 -0800 Subject: [PATCH 7/11] improve the title bar visual Subsurface doesn't do theming the way Kirigami intends us to do this. Part of the reason is that our original approach pre-dates Kirigami doing this at all, part of it is that we want to allow theme changes independent from the OS which doesn't seem to be something that the Kirigami developers have considered. I'm sure we could do a better job using what is available in Kirigami, this seems a little brute force, but it works. This commit hard codes some colors to use the ones from the Subsurface theme (which is of course the wrong thing to do for a generic library), makes sure we find the icons, and makes sure that size of the title bar stays correct. Signed-off-by: Dirk Hohndel <dirk@hohndel.org> --- .../globaltoolbar/PageRowGlobalToolBarUI.qml | 22 +++++++++++++++---- src/controls/templates/private/BackButton.qml | 1 + .../templates/private/ForwardButton.qml | 1 + 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/controls/private/globaltoolbar/PageRowGlobalToolBarUI.qml b/src/controls/private/globaltoolbar/PageRowGlobalToolBarUI.qml index 4404faae..afbfce89 100644 --- a/src/controls/private/globaltoolbar/PageRowGlobalToolBarUI.qml +++ b/src/controls/private/globaltoolbar/PageRowGlobalToolBarUI.qml @@ -29,12 +29,23 @@ Kirigami.AbstractApplicationHeader { maximumHeight: globalToolBar.maximumHeight separatorVisible: globalToolBar.separatorVisible - Kirigami.Theme.textColor: currentItem ? currentItem.Kirigami.Theme.textColor : parent.Kirigami.Theme.textColor + // provide consistent color for the Subsurface title bar - I couldn't figure + // how to do this without modifying Kirigami itself + Kirigami.Theme.backgroundColor: subsurfaceTheme.primaryColor + Kirigami.Theme.textColor: subsurfaceTheme.primaryTextColor RowLayout { anchors.fill: parent spacing: 0 + // I can't make the layout work without this invisible rectangle to anchor things on + Rectangle { + id: correct + height: parent.height + width: 0 + color: "transparent" + } + Item { id: leftHandleAnchor visible: (typeof applicationWindow() !== "undefined" && applicationWindow().globalDrawer && applicationWindow().globalDrawer.enabled && applicationWindow().globalDrawer.handleVisible && @@ -67,6 +78,7 @@ Kirigami.AbstractApplicationHeader { Layout.fillHeight: true Layout.leftMargin: leftHandleAnchor.visible ? Kirigami.Units.smallSpacing : 0 + Layout.alignment: Qt.AlignTop | Qt.AlignVCenter visible: (globalToolBar.showNavigationButtons != Kirigami.ApplicationHeaderStyle.NoNavigationButtons || root.layers.depth > 0) && (globalToolBar.actualStyle != Kirigami.ApplicationHeaderStyle.None) @@ -76,16 +88,18 @@ Kirigami.AbstractApplicationHeader { id: backButton Layout.leftMargin: leftHandleAnchor.visible ? 0 : Kirigami.Units.smallSpacing Layout.preferredWidth: height - Layout.maximumHeight: buttonsLayout.height + Layout.topMargin: 0 + Layout.maximumHeight: correct.height } TemplatesPrivate.ForwardButton { - Layout.maximumHeight: buttonsLayout.height + Layout.maximumHeight: correct.height Layout.preferredWidth: height } } QQC2.ToolSeparator { visible: (menuButton.visible || (buttonsLayout.visible && buttonsLayout.visibleChildren.length > 0)) && breadcrumbVisible && pageRow.depth > 1 + Layout.maximumHeight: correct.height } Loader { @@ -124,6 +138,6 @@ Kirigami.AbstractApplicationHeader { Layout.preferredWidth: height } } - background.opacity: breadcrumbLoader.opacity + //background.opacity: breadcrumbLoader.opacity } diff --git a/src/controls/templates/private/BackButton.qml b/src/controls/templates/private/BackButton.qml index 85a46d15..d1076080 100644 --- a/src/controls/templates/private/BackButton.qml +++ b/src/controls/templates/private/BackButton.qml @@ -14,6 +14,7 @@ Controls.ToolButton { id: button icon.name: (LayoutMirroring.enabled ? "go-previous-symbolic-rtl" : "go-previous-symbolic") + icon.source: (LayoutMirroring.enabled ? "go-previous-symbolic-rtl" : "go-previous-symbolic") enabled: applicationWindow().pageStack.layers.depth > 1 || (applicationWindow().pageStack.depth > 1 && (applicationWindow().pageStack.currentIndex > 0 || applicationWindow().pageStack.contentItem.contentX > 0)) diff --git a/src/controls/templates/private/ForwardButton.qml b/src/controls/templates/private/ForwardButton.qml index c756e030..68a3901b 100644 --- a/src/controls/templates/private/ForwardButton.qml +++ b/src/controls/templates/private/ForwardButton.qml @@ -14,6 +14,7 @@ Controls.ToolButton { id: button icon.name: (LayoutMirroring.enabled ? "go-next-symbolic-rtl" : "go-next-symbolic") + icon.source: (LayoutMirroring.enabled ? "go-next-symbolic-rtl" : "go-next-symbolic") enabled: applicationWindow().pageStack.currentIndex < applicationWindow().pageStack.depth-1 -- 2.25.1