From bfb0a9ebe3b1dc6b0f06ec2d66469ba878fbe98b Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sat, 21 May 2016 10:17:39 +0200 Subject: 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 --- examples/quickcontrols2/gallery/gallery.qml | 45 +++++++---------------------- 1 file changed, 11 insertions(+), 34 deletions(-) (limited to 'examples/quickcontrols2/gallery/gallery.qml') 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() } } } -- cgit v1.2.3