diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-05-21 10:17:39 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-06-15 13:25:16 +0000 |
commit | bfb0a9ebe3b1dc6b0f06ec2d66469ba878fbe98b (patch) | |
tree | 984345e8bba2d1ba892f159971315b5f0dd786b3 /examples | |
parent | bf82b95088f552a5f62d333662c7a9202d293359 (diff) |
Add DialogButtonBox
[ChangeLog][Controls] Added DialogButtonBox to provide convenience for
handling dialog buttons. DialogButtonBox is able to create a set of standard
buttons with a single line of QML code, and provides convenient accepted()
and rejected() signals.
Task-number: QTBUG-51090
Change-Id: I9b3c6ba1b2836dadf9a2ac9086be1eba214e7c4d
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/quickcontrols2/gallery/gallery.qml | 45 |
1 files changed, 11 insertions, 34 deletions
diff --git a/examples/quickcontrols2/gallery/gallery.qml b/examples/quickcontrols2/gallery/gallery.qml index 113874a9..38e60632 100644 --- a/examples/quickcontrols2/gallery/gallery.qml +++ b/examples/quickcontrols2/gallery/gallery.qml @@ -40,7 +40,7 @@ import QtQuick 2.6 import QtQuick.Layouts 1.3 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 import QtQuick.Controls.Material 2.0 import QtQuick.Controls.Universal 2.0 import Qt.labs.settings 1.0 @@ -100,7 +100,7 @@ ApplicationWindow { MenuItem { text: "Settings" - onTriggered: settingsPopup.open() + onTriggered: settingsDialog.open() } MenuItem { text: "About" @@ -208,7 +208,7 @@ ApplicationWindow { } Popup { - id: settingsPopup + id: settingsDialog x: (window.width - width) / 2 y: window.height / 6 width: Math.min(window.width, window.height) / 3 * 2 @@ -255,38 +255,15 @@ ApplicationWindow { Layout.fillHeight: true } - RowLayout { - spacing: 10 - - Button { - id: okButton - text: "Ok" - onClicked: { - settings.style = styleBox.displayText - settingsPopup.close() - } - - Material.foreground: Material.primary - Material.background: "transparent" - Material.elevation: 0 - - Layout.preferredWidth: 0 - Layout.fillWidth: true + DialogButtonBox { + standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel + onAccepted: { + settings.style = styleBox.displayText + settingsDialog.close() } - - Button { - id: cancelButton - text: "Cancel" - onClicked: { - styleBox.currentIndex = styleBox.styleIndex - settingsPopup.close() - } - - Material.background: "transparent" - Material.elevation: 0 - - Layout.preferredWidth: 0 - Layout.fillWidth: true + onRejected: { + styleBox.currentIndex = styleBox.styleIndex + settingsDialog.close() } } } |