2022-11-09 03:16:20 +00:00
|
|
|
// Copyright (C) 2022 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls.Material
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
|
|
|
ApplicationWindow {
|
|
|
|
id: window
|
|
|
|
title: "Material"
|
|
|
|
width: screen.desktopAvailableWidth * 0.8
|
|
|
|
height: screen.desktopAvailableHeight * 0.8
|
|
|
|
visible: true
|
|
|
|
|
2022-11-23 06:48:18 +00:00
|
|
|
Material.theme: darkThemeSwitch.checked ? Material.Dark : Material.Light
|
|
|
|
|
2022-11-09 03:16:20 +00:00
|
|
|
Shortcut {
|
|
|
|
sequences: ["Esc", "Back"]
|
|
|
|
onActivated: openDrawerAction.trigger()
|
|
|
|
}
|
|
|
|
|
|
|
|
Shortcut {
|
|
|
|
sequence: "Ctrl+Q"
|
|
|
|
onActivated: Qt.quit()
|
|
|
|
}
|
|
|
|
|
|
|
|
Action {
|
|
|
|
id: openDrawerAction
|
|
|
|
text: "Controls"
|
|
|
|
onTriggered: drawer.open()
|
|
|
|
}
|
|
|
|
|
|
|
|
header: ToolBar {
|
|
|
|
RowLayout {
|
|
|
|
spacing: 20
|
|
|
|
anchors.fill: parent
|
|
|
|
|
2022-11-23 06:48:18 +00:00
|
|
|
Material.theme: Material.Dark
|
|
|
|
|
2022-11-09 03:16:20 +00:00
|
|
|
ToolButton {
|
|
|
|
action: openDrawerAction
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: titleLabel
|
|
|
|
text: listView.currentItem ? listView.currentItem.text : "Material"
|
|
|
|
font.pixelSize: 20
|
|
|
|
elide: Label.ElideRight
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
|
|
|
verticalAlignment: Qt.AlignVCenter
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2022-11-23 06:48:18 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
Switch {
|
|
|
|
id: darkThemeSwitch
|
|
|
|
text: "Dark"
|
|
|
|
}
|
2022-11-09 03:16:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function showPageForControl(controlName, index) {
|
|
|
|
listView.currentIndex = index
|
|
|
|
stackView.replace("qrc:/pages/" + controlName + "Page.qml")
|
|
|
|
drawer.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
Drawer {
|
|
|
|
id: drawer
|
|
|
|
width: window.width / 3
|
|
|
|
height: window.height
|
|
|
|
interactive: stackView.depth === 1
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: listView
|
|
|
|
focus: true
|
|
|
|
currentIndex: -1
|
|
|
|
anchors.fill: parent
|
|
|
|
|
2022-11-16 06:39:48 +00:00
|
|
|
model: ["Button", "DelayButton", "RoundButton"]
|
2022-11-09 03:16:20 +00:00
|
|
|
delegate: ItemDelegate {
|
|
|
|
width: listView.width
|
|
|
|
text: modelData
|
|
|
|
highlighted: ListView.isCurrentItem
|
|
|
|
onClicked: window.showPageForControl(modelData, index)
|
|
|
|
}
|
|
|
|
|
|
|
|
ScrollIndicator.vertical: ScrollIndicator { }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StackView {
|
|
|
|
id: stackView
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
Component.onCompleted: window.showPageForControl("Button", 0)
|
|
|
|
}
|
|
|
|
}
|