Commit 0f70dbf7 authored by Nate Graham's avatar Nate Graham 🔩

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.
parent 2ccef9fb
......@@ -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
......
......@@ -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
}
......
......@@ -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: [
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment