From 7c1b29575db0f1e892d68fb2bd0cf894f18fafd5 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 26 Aug 2019 21:06:14 +0300 Subject: Modernize Gallery example by using Action where suitable Change-Id: I45c693941e88074eb63f9e6a498c85c1dfa93e9a Reviewed-by: Mitch Curtis --- examples/quickcontrols2/gallery/gallery.qml | 41 +++++++++++++++++------------ 1 file 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() } -- cgit v1.2.3