aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitch Curtis <[email protected]>2022-07-21 16:02:13 +0800
committerMitch Curtis <[email protected]>2022-07-25 14:20:30 +0800
commit6c4c8665c5c9ec9bb79c2a9a05ae3c6eb38001e3 (patch)
treed0c8e17286447e82cce2e6a1fa5667682f97e46a
parent90d3fac73a10b9363fd34e6757cc730d7a0c086c (diff)
macOS: Add Dialog and DialogButtonBox
This fixes the issue where Fusion style Buttons were displayed by DialogButtonBox for its standardButtons. We need to provide our own implementations of Dialog and DialogButtonBox to ensure that the correct files get picked up. The implementations themselves are almost identical copies of the Fusion style's, with some imports removed. The Fusion style is the macOS style's fallback. Fixes: QTBUG-104658 Pick-to: 6.2 6.3 6.4 Change-Id: Ib7958565ee62f6f4286f87298ab98209e916b6b0 Reviewed-by: Fabian Kosmale <[email protected]>
-rw-r--r--src/quickcontrols2/macos/CMakeLists.txt2
-rw-r--r--src/quickcontrols2/macos/Dialog.qml70
-rw-r--r--src/quickcontrols2/macos/DialogButtonBox.qml40
3 files changed, 112 insertions, 0 deletions
diff --git a/src/quickcontrols2/macos/CMakeLists.txt b/src/quickcontrols2/macos/CMakeLists.txt
index c7bf3f6793..0ccb20eef4 100644
--- a/src/quickcontrols2/macos/CMakeLists.txt
+++ b/src/quickcontrols2/macos/CMakeLists.txt
@@ -21,6 +21,8 @@ set(qml_files
"ScrollBar.qml"
"ProgressBar.qml"
"Dial.qml"
+ "Dialog.qml"
+ "DialogButtonBox.qml"
)
if (QT_FEATURE_quick_treeview)
diff --git a/src/quickcontrols2/macos/Dialog.qml b/src/quickcontrols2/macos/Dialog.qml
new file mode 100644
index 0000000000..69e9d9bf46
--- /dev/null
+++ b/src/quickcontrols2/macos/Dialog.qml
@@ -0,0 +1,70 @@
+// Copyright (C) 2022 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.Templates as T
+import QtQuick.Controls.macOS
+// We want to use the Fusion style's Dialog and DialogButtonBox implementation,
+// (at least until we come up with macOS styling for them) but our
+// Button implementation, so both are copied from Fusion.
+import QtQuick.Controls.Fusion.impl
+
+T.Dialog {
+ id: control
+
+ implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
+ contentWidth + leftPadding + rightPadding,
+ implicitHeaderWidth,
+ implicitFooterWidth)
+ implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
+ contentHeight + topPadding + bottomPadding
+ + (implicitHeaderHeight > 0 ? implicitHeaderHeight + spacing : 0)
+ + (implicitFooterHeight > 0 ? implicitFooterHeight + spacing : 0))
+
+ padding: 6
+
+ background: Rectangle {
+ color: control.palette.window
+ border.color: control.palette.mid
+ radius: 2
+
+ Rectangle {
+ x: 1
+ y: 1
+ z: -1
+ width: parent.width
+ height: parent.height
+ color: control.palette.shadow
+ opacity: 0.2
+ radius: 2
+ }
+ }
+
+ header: Label {
+ text: control.title
+ visible: control.title
+ elide: Label.ElideRight
+ font.bold: true
+ padding: 6
+ background: Rectangle {
+ x: 1
+ y: 1
+ width: parent.width - 2
+ height: parent.height - 1
+ color: control.palette.window
+ radius: 2
+ }
+ }
+
+ footer: DialogButtonBox {
+ visible: count > 0
+ }
+
+ T.Overlay.modal: Rectangle {
+ color: Fusion.topShadow
+ }
+
+ T.Overlay.modeless: Rectangle {
+ color: Fusion.topShadow
+ }
+}
diff --git a/src/quickcontrols2/macos/DialogButtonBox.qml b/src/quickcontrols2/macos/DialogButtonBox.qml
new file mode 100644
index 0000000000..b99de3354c
--- /dev/null
+++ b/src/quickcontrols2/macos/DialogButtonBox.qml
@@ -0,0 +1,40 @@
+// Copyright (C) 2022 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.Templates as T
+import QtQuick.Controls.impl
+
+T.DialogButtonBox {
+ id: control
+
+ implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
+ contentWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
+ contentHeight + topPadding + bottomPadding)
+
+ spacing: 6
+ padding: 6
+ alignment: Qt.AlignRight
+
+ delegate: Button { }
+
+ contentItem: ListView {
+ implicitWidth: contentWidth
+ model: control.contentModel
+ spacing: control.spacing
+ orientation: ListView.Horizontal
+ boundsBehavior: Flickable.StopAtBounds
+ snapMode: ListView.SnapToItem
+ }
+
+ background: Rectangle {
+ x: 1
+ y: 1
+ implicitHeight: 32
+ width: parent.width - 2
+ height: parent.height - 2
+ color: control.palette.window
+ radius: 2
+ }
+}