aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2019-08-26 21:06:14 +0300
committerKonstantin Ritt <ritt.ks@gmail.com>2019-09-05 14:34:54 +0300
commit7c1b29575db0f1e892d68fb2bd0cf894f18fafd5 (patch)
tree5a4cbd96b7a9a45812c7b586a6433af5a62abf21
parent7ce1bdfe79d5c9aeb7202fb38b4174028ea2bf9c (diff)
Modernize Gallery example by using Action where suitable
Change-Id: I45c693941e88074eb63f9e6a498c85c1dfa93e9a Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--examples/quickcontrols2/gallery/gallery.qml41
1 files changed, 24 insertions, 17 deletions
diff --git a/examples/quickcontrols2/gallery/gallery.qml b/examples/quickcontrols2/gallery/gallery.qml
index e9f0b432..44987ada 100644
--- a/examples/quickcontrols2/gallery/gallery.qml
+++ b/examples/quickcontrols2/gallery/gallery.qml
@@ -70,15 +70,31 @@ ApplicationWindow {
Shortcut {
sequences: ["Esc", "Back"]
enabled: stackView.depth > 1
- onActivated: {
- stackView.pop()
- listView.currentIndex = -1
+ onActivated: navigateBackAction.trigger()
+ }
+
+ Action {
+ id: navigateBackAction
+ icon.name: stackView.depth > 1 ? "back" : "drawer"
+ onTriggered: {
+ if (stackView.depth > 1) {
+ stackView.pop()
+ listView.currentIndex = -1
+ } else {
+ drawer.open()
+ }
}
}
Shortcut {
sequence: "Menu"
- onActivated: optionsMenu.open()
+ onActivated: optionsMenuAction.trigger()
+ }
+
+ Action {
+ id: optionsMenuAction
+ icon.name: "menu"
+ onTriggered: optionsMenu.open()
}
header: ToolBar {
@@ -89,15 +105,7 @@ ApplicationWindow {
anchors.fill: parent
ToolButton {
- icon.name: stackView.depth > 1 ? "back" : "drawer"
- onClicked: {
- if (stackView.depth > 1) {
- stackView.pop()
- listView.currentIndex = -1
- } else {
- drawer.open()
- }
- }
+ action: navigateBackAction
}
Label {
@@ -111,19 +119,18 @@ ApplicationWindow {
}
ToolButton {
- icon.name: "menu"
- onClicked: optionsMenu.open()
+ action: optionsMenuAction
Menu {
id: optionsMenu
x: parent.width - width
transformOrigin: Menu.TopRight
- MenuItem {
+ Action {
text: "Settings"
onTriggered: settingsDialog.open()
}
- MenuItem {
+ Action {
text: "About"
onTriggered: aboutDialog.open()
}