From 0f70dbf7cc58d680e62fa7a6010436cbb5486cc8 Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Tue, 1 Sep 2020 15:34:04 -0600 Subject: [PATCH] Use enums for HeaderFooterToolbar types rather than strings I don't know that QML enums existed back when this component was created (they were introduced in Qt 5.10). Either way, they do now, so we should use them. --- src/qml/ContextView.qml | 4 ++-- src/qml/HeaderFooterToolbar.qml | 21 ++++++++++++--------- src/qml/MediaPlayListView.qml | 4 ++-- src/qml/NavigationActionBar.qml | 5 +++-- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/qml/ContextView.qml b/src/qml/ContextView.qml index f9785919..94a470e8 100644 --- a/src/qml/ContextView.qml +++ b/src/qml/ContextView.qml @@ -44,7 +44,7 @@ FocusScope { // Header with title HeaderFooterToolbar { Layout.fillWidth: true - type: "header" + toolbarType: HeaderFooterToolbar.ToolbarType.Header contentItems: [ Image { id: mainIcon @@ -248,7 +248,7 @@ FocusScope { // Footer with file path label HeaderFooterToolbar { visible: !topItem.nothingPlaying - type: "footer" + toolbarType: HeaderFooterToolbar.ToolbarType.Footer Layout.fillWidth: true Layout.preferredHeight: Kirigami.Units.gridUnit * 2 contentLayoutSpacing: Kirigami.Units.largeSpacing diff --git a/src/qml/HeaderFooterToolbar.qml b/src/qml/HeaderFooterToolbar.qml index 86831e9e..abe0f339 100644 --- a/src/qml/HeaderFooterToolbar.qml +++ b/src/qml/HeaderFooterToolbar.qml @@ -12,11 +12,14 @@ import org.kde.kirigami 2.5 as Kirigami import org.kde.elisa 1.0 Rectangle { - // Is this a header or a footer? Acceptable values are - // "header" (separator drawn on bottom) - // "footer" (separator drawn on top) - // "other" (no separator drawn) - property string type + enum ToolbarType { + Header, // separator drawn on bottom + Footer, // separator drawn on top + Other // no separator drawn; used for stacking toolbars + } + + // The type of toolbar it is + property int toolbarType: HeaderFooterToolbar.ToolbarType.Header // A list of items to be shown within the header or footer property alias contentItems: contentLayout.children @@ -28,9 +31,9 @@ Rectangle { color: myPalette.window - // Separator line above the header + // Top separator line for a footer Kirigami.Separator { - visible: type == "footer" && type != "other" + visible: toolbarType == HeaderFooterToolbar.ToolbarType.Footer width: parent.width anchors.top: parent.top } @@ -48,9 +51,9 @@ Rectangle { // Items provided by the contentItems property will go here } - // Separator line under the header + // Bottom separator line for a header Kirigami.Separator { - visible: type == "header" && type != "other" + visible: toolbarType == HeaderFooterToolbar.ToolbarType.Header width: parent.width anchors.bottom: parent.bottom } diff --git a/src/qml/MediaPlayListView.qml b/src/qml/MediaPlayListView.qml index be59108b..862064dd 100644 --- a/src/qml/MediaPlayListView.qml +++ b/src/qml/MediaPlayListView.qml @@ -119,7 +119,7 @@ FocusScope { // Header with title and toolbar buttons HeaderFooterToolbar { Layout.fillWidth: true - type: "header" + toolbarType: HeaderFooterToolbar.ToolbarType.Header contentItems: [ // Header title @@ -240,7 +240,7 @@ FocusScope { // Footer with number of tracks label HeaderFooterToolbar { - type: "footer" + toolbarType: HeaderFooterToolbar.ToolbarType.Footer Layout.fillWidth: true Layout.preferredHeight: Kirigami.Units.gridUnit * 2 contentItems: [ diff --git a/src/qml/NavigationActionBar.qml b/src/qml/NavigationActionBar.qml index c1ba4e58..d458fc18 100644 --- a/src/qml/NavigationActionBar.qml +++ b/src/qml/NavigationActionBar.qml @@ -40,7 +40,8 @@ ColumnLayout { signal sort(var order); HeaderFooterToolbar { - type: filterRow.visible? "other" : "header" + toolbarType: filterRow.visible ? HeaderFooterToolbar.ToolbarType.Other + : HeaderFooterToolbar.ToolbarType.Header Layout.fillWidth: true contentItems: [ @@ -151,7 +152,7 @@ ColumnLayout { HeaderFooterToolbar { id: filterRow - type: "header" + toolbarType: HeaderFooterToolbar.ToolbarType.Header Layout.fillWidth: true visible: opacity > 0.0 -- GitLab