opaque/Toolbar.qml

117 lines
2.6 KiB
QML
Raw Permalink Normal View History

2020-05-19 19:49:52 +00:00
import QtGraphicalEffects 1.0
import QtQuick 2.7
import QtQuick.Controls 2.4
import QtQuick.Controls.Material 2.0
import QtQuick.Layouts 1.3
2020-12-15 01:16:49 +00:00
import "." as Opaque
2020-05-19 20:25:56 +00:00
import "theme"
2020-12-15 01:16:49 +00:00
import "fonts"
2020-05-19 19:49:52 +00:00
Rectangle { // Global Toolbar
id: toolbar
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
2020-12-15 01:16:49 +00:00
height: 2 * Theme.paddingSmall + Math.max(iconSize, paneTitleTextMetric.height)
property int iconSize: Theme.uiIconSizeM
2020-05-19 19:49:52 +00:00
Layout.minimumHeight: height
Layout.maximumHeight: height
2020-08-28 22:08:33 +00:00
color: Theme.toolbarMainColor
2020-05-19 19:49:52 +00:00
property alias leftMenuVisible: btnLeftMenu.visible
property alias backVisible: btnLeftBack.visible
property alias rightMenuVisible: btnRightMenu.visible
2020-12-15 01:16:49 +00:00
property int rightPaneWidth: 0
2020-05-19 19:49:52 +00:00
signal leftMenu()
signal back()
signal rightMenu()
Icon {
id: btnLeftMenu
iconColor: Theme.toolbarIconColor
2020-11-17 20:02:12 +00:00
source: gcd.assetPath + "core/menu-24px.webp"
2020-05-19 19:49:52 +00:00
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
2020-12-15 01:16:49 +00:00
width: toolbar.iconSize
height: toolbar.iconSize
2020-05-19 19:49:52 +00:00
onClicked: { leftMenu() }
}
Icon {
id: btnLeftBack
iconColor: Theme.toolbarIconColor
2020-11-17 20:02:12 +00:00
source: gcd.assetPath + "core/chevron_left-24px.webp"
2020-05-19 19:49:52 +00:00
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
2020-12-15 01:16:49 +00:00
width: toolbar.iconSize
height: toolbar.iconSize
2020-05-19 19:49:52 +00:00
onClicked: { back() }
}
2020-12-15 01:16:49 +00:00
Opaque.Label {
id: paneTitle
width: rightPaneWidth - (btnRightMenu.visible ? btnRightMenu.width : 0) - 2 * Theme.paddingStandard
horizontalAlignment: Text.AlignHCenter
anchors.right: btnRightMenu.visible ? btnRightMenu.left : parent.right
anchors.rightMargin: Theme.paddingStandard
anchors.verticalCenter: parent.verticalCenter
header: true
multiline: false
text: "global toolbar"
}
TextMetrics {
id: paneTitleTextMetric
text: paneTitle.text
font: paneTitle.font
}
2020-05-19 19:49:52 +00:00
Icon {
id: btnRightMenu
iconColor: Theme.toolbarIconColor
2020-11-17 20:02:12 +00:00
source: gcd.assetPath + "core/more_vert-24px.webp"
2020-05-19 19:49:52 +00:00
visible: false
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
2020-12-15 01:16:49 +00:00
width: toolbar.iconSize
height: toolbar.iconSize
2020-05-19 19:49:52 +00:00
onClicked: { rightMenu() }
}
2020-12-15 01:16:49 +00:00
function setTitle(text) {
2020-05-19 19:49:52 +00:00
paneTitle.text = text
paneTitle.visible = true
}
function hideTitle() {
paneTitle.visible = false
}
Connections {
target: gcd
onSetToolbarTitle: function(handle) {
setTitle(handle)
2020-05-19 19:49:52 +00:00
btnRightMenu.visible = true
}
}
}