aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickcontrols/ios/impl/DialogButtonBoxDelegate.qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/quickcontrols/ios/impl/DialogButtonBoxDelegate.qml')
-rw-r--r--src/quickcontrols/ios/impl/DialogButtonBoxDelegate.qml68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/quickcontrols/ios/impl/DialogButtonBoxDelegate.qml b/src/quickcontrols/ios/impl/DialogButtonBoxDelegate.qml
new file mode 100644
index 0000000000..2be1f9535e
--- /dev/null
+++ b/src/quickcontrols/ios/impl/DialogButtonBoxDelegate.qml
@@ -0,0 +1,68 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Controls.impl
+import QtQuick.Controls.iOS.impl
+
+Button {
+ id: delegate
+
+ implicitHeight: 44
+
+ readonly property var dialogButtonBox: DialogButtonBox.buttonBox
+ readonly property bool hasVerticalLayout: dialogButtonBox && (dialogButtonBox.count !== 2)
+ readonly property bool isLastItem: dialogButtonBox
+ && (dialogButtonBox.contentChildren)
+ && (dialogButtonBox.itemAt(count - 1) == delegate)
+ readonly property int count: dialogButtonBox ? dialogButtonBox.count : 0
+
+ flat: true
+
+ contentItem: IconLabel {
+ readonly property var redColor: Qt.styleHints.colorScheme === Qt.Light ? "#ff3b30" : "#ff453a"
+ text: delegate.text
+ font: delegate.font
+ spacing: delegate.spacing
+ color: delegate.DialogButtonBox.buttonRole === DialogButtonBox.DestructiveRole
+ ? redColor
+ : (delegate.down ? delegate.palette.highlight : delegate.palette.button)
+ }
+
+ background: Item {
+ // The assets below only support the typical iOS Dialog look with buttons
+ // positioned at the bottom and that fill the entire width of the parent.
+ // Don't draw a background if these conditions are not met
+ visible: delegate.dialogButtonBox
+ && delegate.dialogButtonBox.position === DialogButtonBox.Footer
+ && delegate.dialogButtonBox.alignment === 0
+ implicitHeight: 44
+ readonly property bool leftItem: !delegate.hasVerticalLayout && !delegate.isLastItem
+ readonly property bool rightItem: !delegate.hasVerticalLayout && !leftItem
+ readonly property bool flip: delegate.mirrored ? leftItem : rightItem
+
+ NinePatchImage {
+ transform: [
+ // flip
+ Translate { x: (!delegate.background.flip ? 0 : -width) },
+ Scale { xScale: (!delegate.background.flip ? 1 : -1) }
+ ]
+ width: parent.width
+ height: parent.height
+ source: IOS.url + "dialogbuttonbox-delegate"
+ NinePatchImageSelector on source {
+ states: [
+ {"horizontal": !delegate.hasVerticalLayout},
+ {"vertical": delegate.hasVerticalLayout},
+ {"last": delegate.hasVerticalLayout && delegate.isLastItem},
+ {"pressed": delegate.down},
+ {"light": Qt.styleHints.colorScheme === Qt.Light},
+ {"dark": Qt.styleHints.colorScheme === Qt.Dark},
+ ]
+ }
+ }
+
+
+ }
+}