aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/nativestyle
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports/nativestyle')
-rw-r--r--src/imports/nativestyle/CMakeLists.txt148
-rw-r--r--src/imports/nativestyle/controls/DefaultButton.qml10
-rw-r--r--src/imports/nativestyle/controls/DefaultCheckBox.qml10
-rw-r--r--src/imports/nativestyle/controls/DefaultComboBox.qml12
-rw-r--r--src/imports/nativestyle/controls/DefaultDial.qml58
-rw-r--r--src/imports/nativestyle/controls/DefaultFrame.qml9
-rw-r--r--src/imports/nativestyle/controls/DefaultGroupBox.qml9
-rw-r--r--src/imports/nativestyle/controls/DefaultProgressBar.qml9
-rw-r--r--src/imports/nativestyle/controls/DefaultRadioButton.qml10
-rw-r--r--src/imports/nativestyle/controls/DefaultScrollBar.qml10
-rw-r--r--src/imports/nativestyle/controls/DefaultSlider.qml9
-rw-r--r--src/imports/nativestyle/controls/DefaultSpinBox.qml9
-rw-r--r--src/imports/nativestyle/controls/DefaultTextArea.qml16
-rw-r--r--src/imports/nativestyle/controls/DefaultTextField.qml10
-rw-r--r--src/imports/nativestyle/controls/controls.pri1
-rw-r--r--src/imports/nativestyle/items/items.pri4
-rw-r--r--src/imports/nativestyle/items/qquickstyleitem.h3
-rw-r--r--src/imports/nativestyle/items/qquickstyleitemdial.cpp110
-rw-r--r--src/imports/nativestyle/items/qquickstyleitemdial.h (renamed from src/imports/nativestyle/items/qquickstyleitemtextarea.h)14
-rw-r--r--src/imports/nativestyle/items/qquickstyleitemscrollbar.cpp11
-rw-r--r--src/imports/nativestyle/items/qquickstyleitemscrollbar.h17
-rw-r--r--src/imports/nativestyle/items/qquickstyleitemtextarea.cpp85
-rw-r--r--src/imports/nativestyle/nativestyle.pro3
-rw-r--r--src/imports/nativestyle/qmldir1
-rw-r--r--src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm22
-rw-r--r--src/imports/nativestyle/qstyle/qquickcommonstyle.cpp2
-rw-r--r--src/imports/nativestyle/qstyle/qquickstyle.h1
-rw-r--r--src/imports/nativestyle/qstyle/qstyle.pri2
-rw-r--r--src/imports/nativestyle/qtquickcontrols2nativestyleplugin.cpp27
29 files changed, 464 insertions, 168 deletions
diff --git a/src/imports/nativestyle/CMakeLists.txt b/src/imports/nativestyle/CMakeLists.txt
new file mode 100644
index 00000000..2039f102
--- /dev/null
+++ b/src/imports/nativestyle/CMakeLists.txt
@@ -0,0 +1,148 @@
+# Generated from nativestyle.pro.
+
+#####################################################################
+## qtquickcontrols2nativestyleplugin Plugin:
+#####################################################################
+
+qt_add_qml_module(qtquickcontrols2nativestyleplugin
+ URI "QtQuick.NativeStyle"
+ VERSION "6.0"
+ CLASSNAME QtQuickControls2NativeStylePlugin
+ DEPENDENCIES
+ QtQuick.Controls/2.5
+ GENERATE_QMLTYPES
+ SOURCES
+ items/qquickstyleitem.cpp items/qquickstyleitem.h
+ items/qquickstyleitembutton.cpp items/qquickstyleitembutton.h
+ items/qquickstyleitemcheckbox.cpp items/qquickstyleitemcheckbox.h
+ items/qquickstyleitemcombobox.cpp items/qquickstyleitemcombobox.h
+ items/qquickstyleitemdial.cpp items/qquickstyleitemdial.h
+ items/qquickstyleitemframe.cpp items/qquickstyleitemframe.h
+ items/qquickstyleitemgroupbox.cpp items/qquickstyleitemgroupbox.h
+ items/qquickstyleitemprogressbar.cpp items/qquickstyleitemprogressbar.h
+ items/qquickstyleitemradiobutton.cpp items/qquickstyleitemradiobutton.h
+ items/qquickstyleitemscrollbar.cpp items/qquickstyleitemscrollbar.h
+ items/qquickstyleitemslider.cpp items/qquickstyleitemslider.h
+ items/qquickstyleitemspinbox.cpp items/qquickstyleitemspinbox.h
+ items/qquickstyleitemtextfield.cpp items/qquickstyleitemtextfield.h
+ qstyle/qquickcommonstyle.cpp qstyle/qquickcommonstyle.h qstyle/qquickcommonstyle_p.h
+ qstyle/qquickcommonstylepixmaps_p.h
+ qstyle/qquickdrawutil.cpp qstyle/qquickdrawutil.h
+ qstyle/qquicknativestyle.cpp qstyle/qquicknativestyle.h
+ qstyle/qquickstyle.cpp qstyle/qquickstyle.h qstyle/qquickstyle_p.h
+ qstyle/qquickstylehelper.cpp qstyle/qquickstylehelper_p.h
+ qstyle/qquickstyleoption.cpp qstyle/qquickstyleoption.h
+ qtquickcontrols2nativestyleplugin.cpp
+ DEFINES
+ QT_NO_CAST_FROM_ASCII
+ QT_NO_CAST_TO_ASCII
+ INCLUDE_DIRECTORIES
+ items
+ qstyle
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::GuiPrivate
+ Qt::QmlPrivate
+ Qt::QuickControls2Private
+ Qt::QuickPrivate
+ Qt::QuickTemplates2Private
+ PUBLIC_LIBRARIES
+ Qt::Core
+ Qt::Gui
+ Qt::Qml
+ Qt::Quick
+ Qt::QuickControls2
+ Qt::QuickTemplates2
+)
+
+#### Keys ignored in scope 1:.:.:nativestyle.pro:<TRUE>:
+# OTHER_FILES = "qmldir" "$$QML_FILES"
+# QML_IMPORT_MAJOR_VERSION = "6"
+# QML_IMPORT_NAME = "QtQuick.NativeStyle"
+# TARGETPATH = "QtQuick/NativeStyle"
+# _REQUIREMENTS = "qtConfig(quickcontrols2-macos)|qtConfig(quickcontrols2-windows)"
+
+## Scopes:
+#####################################################################
+
+qt_extend_target(qtquickcontrols2nativestyleplugin CONDITION MACOS
+ SOURCES
+ qstyle/mac/qquickmacstyle_mac.mm qstyle/mac/qquickmacstyle_mac_p.h
+ qstyle/mac/qquickmacstyle_mac_p_p.h
+ INCLUDE_DIRECTORIES
+ qstyle/mac
+ LIBRARIES
+ ${FWAppKit}
+)
+
+qt_extend_target(qtquickcontrols2nativestyleplugin CONDITION WIN32
+ SOURCES
+ qstyle/windows/qquickwindowsstyle.cpp qstyle/windows/qquickwindowsstyle_p.h
+ qstyle/windows/qquickwindowsstyle_p_p.h
+ INCLUDE_DIRECTORIES
+ qstyle/windows
+ LIBRARIES
+ gdi32
+ user32
+ uxtheme
+)
+
+set(qml_files
+ "controls/DefaultButton.qml"
+ "controls/DefaultSlider.qml"
+ "controls/DefaultGroupBox.qml"
+ "controls/DefaultCheckBox.qml"
+ "controls/DefaultRadioButton.qml"
+ "controls/DefaultSpinBox.qml"
+ "controls/DefaultTextField.qml"
+ "controls/DefaultFrame.qml"
+ "controls/DefaultTextArea.qml"
+ "controls/DefaultComboBox.qml"
+ "controls/DefaultScrollBar.qml"
+ "controls/DefaultProgressBar.qml"
+ "controls/DefaultDial.qml"
+)
+set_source_files_properties(controls/DefaultButton.qml PROPERTIES
+ QT_QML_SOURCE_VERSION "6.0"
+)
+set_source_files_properties(controls/DefaultSlider.qml PROPERTIES
+ QT_QML_SOURCE_VERSION "6.0"
+)
+set_source_files_properties(controls/DefaultGroupBox.qml PROPERTIES
+ QT_QML_SOURCE_VERSION "6.0"
+)
+set_source_files_properties(controls/DefaultCheckBox.qml PROPERTIES
+ QT_QML_SOURCE_VERSION "6.0"
+)
+set_source_files_properties(controls/DefaultRadioButton.qml PROPERTIES
+ QT_QML_SOURCE_VERSION "6.0"
+)
+set_source_files_properties(controls/DefaultSpinBox.qml PROPERTIES
+ QT_QML_SOURCE_VERSION "6.0"
+)
+set_source_files_properties(controls/DefaultTextField.qml PROPERTIES
+ QT_QML_SOURCE_VERSION "6.0"
+)
+set_source_files_properties(controls/DefaultFrame.qml PROPERTIES
+ QT_QML_SOURCE_VERSION "6.0"
+)
+set_source_files_properties(controls/DefaultTextArea.qml PROPERTIES
+ QT_QML_SOURCE_VERSION "6.0"
+)
+set_source_files_properties(controls/DefaultComboBox.qml PROPERTIES
+ QT_QML_SOURCE_VERSION "6.0"
+)
+set_source_files_properties(controls/DefaultScrollBar.qml PROPERTIES
+ QT_QML_SOURCE_VERSION "6.0"
+)
+set_source_files_properties(controls/DefaultProgressBar.qml PROPERTIES
+ QT_QML_SOURCE_VERSION "6.0"
+)
+set_source_files_properties(controls/DefaultDial.qml PROPERTIES
+ QT_QML_SOURCE_VERSION "6.0"
+)
+
+qt6_target_qml_files(qtquickcontrols2nativestyleplugin
+ FILES
+ ${qml_files}
+)
diff --git a/src/imports/nativestyle/controls/DefaultButton.qml b/src/imports/nativestyle/controls/DefaultButton.qml
index d98916ca..de0c8b70 100644
--- a/src/imports/nativestyle/controls/DefaultButton.qml
+++ b/src/imports/nativestyle/controls/DefaultButton.qml
@@ -34,11 +34,11 @@
**
****************************************************************************/
-import QtQuick 2.12
-import QtQuick.Controls 2.12
-import QtQuick.Controls.impl 2.12
-import QtQuick.Templates 2.12 as T
-import QtQuick.NativeStyle 6.0 as NativeStyle
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Controls.impl
+import QtQuick.Templates as T
+import QtQuick.NativeStyle as NativeStyle
T.Button {
id: control
diff --git a/src/imports/nativestyle/controls/DefaultCheckBox.qml b/src/imports/nativestyle/controls/DefaultCheckBox.qml
index c75e755e..09166820 100644
--- a/src/imports/nativestyle/controls/DefaultCheckBox.qml
+++ b/src/imports/nativestyle/controls/DefaultCheckBox.qml
@@ -34,11 +34,11 @@
**
****************************************************************************/
-import QtQuick 2.12
-import QtQuick.Templates 2.12 as T
-import QtQuick.Controls 2.12
-import QtQuick.Controls.impl 2.12
-import QtQuick.NativeStyle 6.0 as NativeStyle
+import QtQuick
+import QtQuick.Templates as T
+import QtQuick.Controls
+import QtQuick.Controls.impl
+import QtQuick.NativeStyle as NativeStyle
T.CheckBox {
id: control
diff --git a/src/imports/nativestyle/controls/DefaultComboBox.qml b/src/imports/nativestyle/controls/DefaultComboBox.qml
index ec6fe7c8..9d0ed5cf 100644
--- a/src/imports/nativestyle/controls/DefaultComboBox.qml
+++ b/src/imports/nativestyle/controls/DefaultComboBox.qml
@@ -34,12 +34,12 @@
**
****************************************************************************/
-import QtQuick 2.15
-import QtQuick.Window 2.15
-import QtQuick.Controls 2.15
-import QtQuick.Controls.impl 2.15
-import QtQuick.Templates 2.15 as T
-import QtQuick.NativeStyle 6.0 as NativeStyle
+import QtQuick
+import QtQuick.Window
+import QtQuick.Controls
+import QtQuick.Controls.impl
+import QtQuick.Templates as T
+import QtQuick.NativeStyle as NativeStyle
T.ComboBox {
id: control
diff --git a/src/imports/nativestyle/controls/DefaultDial.qml b/src/imports/nativestyle/controls/DefaultDial.qml
new file mode 100644
index 00000000..0f1d2c7d
--- /dev/null
+++ b/src/imports/nativestyle/controls/DefaultDial.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Templates as T
+import QtQuick.NativeStyle as NativeStyle
+
+T.Dial {
+ id: control
+
+ readonly property bool nativeBackground: background instanceof NativeStyle.StyleItem
+
+ implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
+ implicitContentWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
+ implicitContentHeight + topPadding + bottomPadding)
+
+ font.pixelSize: nativeBackground ? background.styleFont(control).pixelSize : undefined
+
+ background: NativeStyle.Dial {
+ control: control
+ useNinePatchImage: false
+ }
+}
diff --git a/src/imports/nativestyle/controls/DefaultFrame.qml b/src/imports/nativestyle/controls/DefaultFrame.qml
index 3dffd4d1..6241a91e 100644
--- a/src/imports/nativestyle/controls/DefaultFrame.qml
+++ b/src/imports/nativestyle/controls/DefaultFrame.qml
@@ -34,11 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.12
-import QtQuick.Controls 2.12
-import QtQuick.Controls.impl 2.12
-import QtQuick.Templates 2.12 as T
-import QtQuick.NativeStyle 6.0 as NativeStyle
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Templates as T
+import QtQuick.NativeStyle as NativeStyle
T.Frame {
id: control
diff --git a/src/imports/nativestyle/controls/DefaultGroupBox.qml b/src/imports/nativestyle/controls/DefaultGroupBox.qml
index 0d29fd7d..d5265bc0 100644
--- a/src/imports/nativestyle/controls/DefaultGroupBox.qml
+++ b/src/imports/nativestyle/controls/DefaultGroupBox.qml
@@ -34,11 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.12
-import QtQuick.Controls 2.12
-import QtQuick.Controls.impl 2.12
-import QtQuick.Templates 2.12 as T
-import QtQuick.NativeStyle 6.0 as NativeStyle
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Templates as T
+import QtQuick.NativeStyle as NativeStyle
T.GroupBox {
id: control
diff --git a/src/imports/nativestyle/controls/DefaultProgressBar.qml b/src/imports/nativestyle/controls/DefaultProgressBar.qml
index e86f9410..646a0ab5 100644
--- a/src/imports/nativestyle/controls/DefaultProgressBar.qml
+++ b/src/imports/nativestyle/controls/DefaultProgressBar.qml
@@ -34,11 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.12
-import QtQuick.Templates 2.12 as T
-import QtQuick.Controls 2.12
-import QtQuick.Controls.impl 2.12
-import QtQuick.NativeStyle 6.0 as NativeStyle
+import QtQuick
+import QtQuick.Templates as T
+import QtQuick.Controls
+import QtQuick.NativeStyle as NativeStyle
T.ProgressBar {
id: control
diff --git a/src/imports/nativestyle/controls/DefaultRadioButton.qml b/src/imports/nativestyle/controls/DefaultRadioButton.qml
index e22e2f2f..29746ba7 100644
--- a/src/imports/nativestyle/controls/DefaultRadioButton.qml
+++ b/src/imports/nativestyle/controls/DefaultRadioButton.qml
@@ -34,11 +34,11 @@
**
****************************************************************************/
-import QtQuick 2.12
-import QtQuick.Templates 2.12 as T
-import QtQuick.Controls 2.12
-import QtQuick.Controls.impl 2.12
-import QtQuick.NativeStyle 6.0 as NativeStyle
+import QtQuick
+import QtQuick.Templates as T
+import QtQuick.Controls
+import QtQuick.Controls.impl
+import QtQuick.NativeStyle as NativeStyle
T.RadioButton {
id: control
diff --git a/src/imports/nativestyle/controls/DefaultScrollBar.qml b/src/imports/nativestyle/controls/DefaultScrollBar.qml
index 1e563bbc..0f42bc80 100644
--- a/src/imports/nativestyle/controls/DefaultScrollBar.qml
+++ b/src/imports/nativestyle/controls/DefaultScrollBar.qml
@@ -34,11 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.12
-import QtQuick.Controls 2.12
-import QtQuick.Controls.impl 2.12
-import QtQuick.Templates 2.12 as T
-import QtQuick.NativeStyle 6.0 as NativeStyle
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Templates as T
+import QtQuick.NativeStyle as NativeStyle
T.ScrollBar {
id: control
@@ -62,6 +61,5 @@ T.ScrollBar {
contentItem: NativeStyle.ScrollBar {
control: control
subControl: NativeStyle.ScrollBar.Handle
- width: control.width
}
}
diff --git a/src/imports/nativestyle/controls/DefaultSlider.qml b/src/imports/nativestyle/controls/DefaultSlider.qml
index 00069137..8648143d 100644
--- a/src/imports/nativestyle/controls/DefaultSlider.qml
+++ b/src/imports/nativestyle/controls/DefaultSlider.qml
@@ -34,11 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.12
-import QtQuick.Controls 2.12
-import QtQuick.Controls.impl 2.12
-import QtQuick.Templates 2.12 as T
-import QtQuick.NativeStyle 6.0 as NativeStyle
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Templates as T
+import QtQuick.NativeStyle as NativeStyle
T.Slider {
id: control
diff --git a/src/imports/nativestyle/controls/DefaultSpinBox.qml b/src/imports/nativestyle/controls/DefaultSpinBox.qml
index 11cf345d..c959516a 100644
--- a/src/imports/nativestyle/controls/DefaultSpinBox.qml
+++ b/src/imports/nativestyle/controls/DefaultSpinBox.qml
@@ -34,11 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.12
-import QtQuick.Controls 2.12
-import QtQuick.Controls.impl 2.12
-import QtQuick.Templates 2.12 as T
-import QtQuick.NativeStyle 6.0 as NativeStyle
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Templates as T
+import QtQuick.NativeStyle as NativeStyle
T.SpinBox {
id: control
diff --git a/src/imports/nativestyle/controls/DefaultTextArea.qml b/src/imports/nativestyle/controls/DefaultTextArea.qml
index 29277414..819e32ad 100644
--- a/src/imports/nativestyle/controls/DefaultTextArea.qml
+++ b/src/imports/nativestyle/controls/DefaultTextArea.qml
@@ -34,11 +34,11 @@
**
****************************************************************************/
-import QtQuick 2.12
-import QtQuick.Controls 2.12
-import QtQuick.Controls.impl 2.12
-import QtQuick.Templates 2.12 as T
-import QtQuick.NativeStyle 6.0 as NativeStyle
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Controls.impl
+import QtQuick.Templates as T
+import QtQuick.NativeStyle as NativeStyle
T.TextArea {
id: control
@@ -81,9 +81,7 @@ T.TextArea {
renderType: control.renderType
}
- background: NativeStyle.TextArea {
- control: control
- contentWidth: Math.max(control.contentWidth, placeholder.implicitWidth)
- contentHeight: control.contentHeight
+ background: Rectangle {
+ color: control.palette.light
}
}
diff --git a/src/imports/nativestyle/controls/DefaultTextField.qml b/src/imports/nativestyle/controls/DefaultTextField.qml
index 8df069d8..c2081d61 100644
--- a/src/imports/nativestyle/controls/DefaultTextField.qml
+++ b/src/imports/nativestyle/controls/DefaultTextField.qml
@@ -34,11 +34,11 @@
**
****************************************************************************/
-import QtQuick 2.12
-import QtQuick.Controls 2.12
-import QtQuick.Controls.impl 2.12
-import QtQuick.Templates 2.12 as T
-import QtQuick.NativeStyle 6.0 as NativeStyle
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Controls.impl
+import QtQuick.Templates as T
+import QtQuick.NativeStyle as NativeStyle
T.TextField {
id: control
diff --git a/src/imports/nativestyle/controls/controls.pri b/src/imports/nativestyle/controls/controls.pri
index 55f84703..8675989e 100644
--- a/src/imports/nativestyle/controls/controls.pri
+++ b/src/imports/nativestyle/controls/controls.pri
@@ -11,3 +11,4 @@ QML_FILES += \
$$PWD/DefaultComboBox.qml \
$$PWD/DefaultScrollBar.qml \
$$PWD/DefaultProgressBar.qml \
+ $$PWD/DefaultDial.qml \
diff --git a/src/imports/nativestyle/items/items.pri b/src/imports/nativestyle/items/items.pri
index a5c33b86..f572cf24 100644
--- a/src/imports/nativestyle/items/items.pri
+++ b/src/imports/nativestyle/items/items.pri
@@ -10,10 +10,10 @@ HEADERS += \
$$PWD/qquickstyleitemspinbox.h \
$$PWD/qquickstyleitemtextfield.h \
$$PWD/qquickstyleitemframe.h \
- $$PWD/qquickstyleitemtextarea.h \
$$PWD/qquickstyleitemcombobox.h \
$$PWD/qquickstyleitemscrollbar.h \
$$PWD/qquickstyleitemprogressbar.h \
+ $$PWD/qquickstyleitemdial.h \
SOURCES += \
$$PWD/qquickstyleitem.cpp \
@@ -25,7 +25,7 @@ SOURCES += \
$$PWD/qquickstyleitemspinbox.cpp \
$$PWD/qquickstyleitemtextfield.cpp \
$$PWD/qquickstyleitemframe.cpp \
- $$PWD/qquickstyleitemtextarea.cpp \
$$PWD/qquickstyleitemcombobox.cpp \
$$PWD/qquickstyleitemscrollbar.cpp \
$$PWD/qquickstyleitemprogressbar.cpp \
+ $$PWD/qquickstyleitemdial.cpp \
diff --git a/src/imports/nativestyle/items/qquickstyleitem.h b/src/imports/nativestyle/items/qquickstyleitem.h
index 37e9dc3d..ad315b96 100644
--- a/src/imports/nativestyle/items/qquickstyleitem.h
+++ b/src/imports/nativestyle/items/qquickstyleitem.h
@@ -154,7 +154,7 @@ class QQuickStyleItem : public QQuickItem
Q_OBJECT
// Input
- Q_PROPERTY(QQuickItem *control MEMBER m_control)
+ Q_PROPERTY(QQuickItem *control MEMBER m_control NOTIFY controlChanged)
Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth)
Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight)
Q_PROPERTY(bool useNinePatchImage MEMBER m_useNinePatchImage)
@@ -208,6 +208,7 @@ public:
void markImageDirty();
signals:
+ void controlChanged();
void contentPaddingChanged();
void layoutMarginsChanged();
void fontChanged();
diff --git a/src/imports/nativestyle/items/qquickstyleitemdial.cpp b/src/imports/nativestyle/items/qquickstyleitemdial.cpp
new file mode 100644
index 00000000..f214fb2e
--- /dev/null
+++ b/src/imports/nativestyle/items/qquickstyleitemdial.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickstyleitemdial.h"
+
+QFont QQuickStyleItemDial::styleFont(QQuickItem *control)
+{
+ return style()->font(QStyle::CE_ProgressBarLabel, controlSize(control));
+}
+
+void QQuickStyleItemDial::connectToControl()
+{
+ QQuickStyleItem::connectToControl();
+ auto dial = control<QQuickDial>();
+ connect(dial, &QQuickDial::fromChanged, this, &QQuickStyleItem::markImageDirty);
+ connect(dial, &QQuickDial::toChanged, this, &QQuickStyleItem::markImageDirty);
+ connect(dial, &QQuickDial::positionChanged, this, &QQuickStyleItem::markImageDirty);
+ connect(dial, &QQuickDial::valueChanged, this, &QQuickStyleItem::markImageDirty);
+ connect(dial, &QQuickDial::stepSizeChanged, this, &QQuickStyleItem::markImageDirty);
+ connect(dial, &QQuickDial::pressedChanged, this, &QQuickStyleItem::markImageDirty);
+}
+
+StyleItemGeometry QQuickStyleItemDial::calculateGeometry()
+{
+ QStyleOptionSlider styleOption;
+ initStyleOption(styleOption);
+
+ StyleItemGeometry geometry;
+ geometry.minimumSize = style()->sizeFromContents(QStyle::CT_Dial, &styleOption, QSize(0, 0));
+ geometry.implicitSize = geometry.minimumSize;
+ geometry.layoutRect = style()->subElementRect(QStyle::SE_SliderLayoutItem, &styleOption);
+ geometry.ninePatchMargins = style()->ninePatchMargins(QStyle::CC_Dial, &styleOption, geometry.minimumSize);
+
+ return geometry;
+}
+
+void QQuickStyleItemDial::paintEvent(QPainter *painter)
+{
+ QStyleOptionSlider styleOption;
+ initStyleOption(styleOption);
+ style()->drawComplexControl(QStyle::CC_Dial, &styleOption, painter);
+}
+
+void QQuickStyleItemDial::initStyleOption(QStyleOptionSlider &styleOption)
+{
+ initStyleOptionBase(styleOption);
+ auto dial = control<QQuickDial>();
+
+ styleOption.subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle;
+ styleOption.activeSubControls = QStyle::SC_None;
+ styleOption.tickInterval = dial->stepSize();
+ styleOption.dialWrapping = dial->wrap();
+ styleOption.upsideDown = true;
+
+ if (dial->isPressed())
+ styleOption.state |= QStyle::State_Sunken;
+
+ if (dial->stepSize() == 0) {
+ styleOption.minimum = 0;
+ styleOption.maximum = 10000;
+ styleOption.sliderPosition = dial->position() * styleOption.maximum;
+ } else {
+ styleOption.minimum = dial->from();
+ styleOption.maximum = dial->to();
+ styleOption.sliderPosition = dial->value();
+ }
+
+ // TODO: add proper API for tickmarks
+ const int index = dial->metaObject()->indexOfProperty("qqc2_style_tickPosition");
+ if (index != -1) {
+ const int tickPosition = dial->metaObject()->property(index).read(dial).toInt();
+ styleOption.tickPosition = QStyleOptionSlider::TickPosition(tickPosition);
+ if (styleOption.tickPosition != QStyleOptionSlider::NoTicks)
+ styleOption.subControls |= QStyle::SC_DialTickmarks;
+ }
+
+}
diff --git a/src/imports/nativestyle/items/qquickstyleitemtextarea.h b/src/imports/nativestyle/items/qquickstyleitemdial.h
index 90d83ad7..3eefa734 100644
--- a/src/imports/nativestyle/items/qquickstyleitemtextarea.h
+++ b/src/imports/nativestyle/items/qquickstyleitemdial.h
@@ -34,16 +34,16 @@
**
****************************************************************************/
-#ifndef QQUICKSTYLEITEMTEXTAREA_H
-#define QQUICKSTYLEITEMTEXTAREA_H
+#ifndef QQUICKSTYLEITEMDIAL_H
+#define QQUICKSTYLEITEMDIAL_H
#include "qquickstyleitem.h"
-#include <QtQuickTemplates2/private/qquicktextarea_p.h>
+#include <QtQuickTemplates2/private/qquickdial_p.h>
-class QQuickStyleItemTextArea : public QQuickStyleItem
+class QQuickStyleItemDial : public QQuickStyleItem
{
Q_OBJECT
- QML_NAMED_ELEMENT(TextArea)
+ QML_NAMED_ELEMENT(Dial)
public:
QFont styleFont(QQuickItem *control) override;
@@ -54,7 +54,7 @@ protected:
StyleItemGeometry calculateGeometry() override;
private:
- void initStyleOption(QStyleOptionFrame &styleOption);
+ void initStyleOption(QStyleOptionSlider &styleOption);
};
-#endif // QQUICKSTYLEITEMTEXTAREA_H
+#endif // QQUICKSTYLEITEMDIAL_H
diff --git a/src/imports/nativestyle/items/qquickstyleitemscrollbar.cpp b/src/imports/nativestyle/items/qquickstyleitemscrollbar.cpp
index 7a462082..72f850a8 100644
--- a/src/imports/nativestyle/items/qquickstyleitemscrollbar.cpp
+++ b/src/imports/nativestyle/items/qquickstyleitemscrollbar.cpp
@@ -83,6 +83,17 @@ void QQuickStyleItemScrollBar::initStyleOption(QStyleOptionSlider &styleOption)
if (scrollBar->isPressed())
styleOption.state |= QStyle::State_Sunken;
+#ifdef Q_OS_MACOS
+ if (m_overrideState != None) {
+ // In ScrollBar.qml we fade between two versions of
+ // the handle, depending on if it's hovered or not
+ if (m_overrideState & AlwaysHovered)
+ styleOption.state |= QStyle::State_Sunken;
+ else if (m_overrideState & NeverHovered)
+ styleOption.state &= ~QStyle::State_Sunken;
+ }
+#endif
+
// The following values will let the handle fill 100% of the
// groove / imageSize. But when the handle is resized by
// QQuickScrollBar, it will end up with the correct size visually.
diff --git a/src/imports/nativestyle/items/qquickstyleitemscrollbar.h b/src/imports/nativestyle/items/qquickstyleitemscrollbar.h
index e181d4ec..db241ad8 100644
--- a/src/imports/nativestyle/items/qquickstyleitemscrollbar.h
+++ b/src/imports/nativestyle/items/qquickstyleitemscrollbar.h
@@ -46,6 +46,10 @@ class QQuickStyleItemScrollBar : public QQuickStyleItem
Q_PROPERTY(SubControl subControl MEMBER m_subControl)
+#ifdef Q_OS_MACOS
+ Q_PROPERTY(OverrideState overrideState MEMBER m_overrideState)
+#endif
+
QML_NAMED_ELEMENT(ScrollBar)
public:
@@ -55,6 +59,15 @@ public:
};
Q_ENUM(SubControl)
+#ifdef Q_OS_MACOS
+ enum OverrideState {
+ None = 0,
+ AlwaysHovered,
+ NeverHovered,
+ };
+ Q_ENUM(OverrideState)
+#endif
+
QFont styleFont(QQuickItem *control) override;
protected:
@@ -67,6 +80,10 @@ private:
private:
SubControl m_subControl = Groove;
+
+#ifdef Q_OS_MACOS
+ OverrideState m_overrideState = None;
+#endif
};
#endif // QQUICKSTYLEITEMSCROLLBAR_H
diff --git a/src/imports/nativestyle/items/qquickstyleitemtextarea.cpp b/src/imports/nativestyle/items/qquickstyleitemtextarea.cpp
deleted file mode 100644
index c149444b..00000000
--- a/src/imports/nativestyle/items/qquickstyleitemtextarea.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qquickstyleitemtextarea.h"
-
-QFont QQuickStyleItemTextArea::styleFont(QQuickItem *control)
-{
- return style()->font(QStyle::CE_ComboBoxLabel, controlSize(control));
-}
-
-void QQuickStyleItemTextArea::connectToControl()
-{
- QQuickStyleItem::connectToControl();
- auto textArea = control<QQuickTextArea>();
- connect(textArea, &QQuickTextArea::readOnlyChanged, this, &QQuickStyleItem::markImageDirty);
- connect(textArea, &QQuickTextArea::focusChanged, this, &QQuickStyleItem::markImageDirty);
-}
-
-StyleItemGeometry QQuickStyleItemTextArea::calculateGeometry()
-{
- QStyleOptionFrame styleOption;
- initStyleOption(styleOption);
- StyleItemGeometry geometry;
-
- // There is no CT_TextEdit in QStyle, so we "borrow" CT_LineEdit for now
- geometry.minimumSize = style()->sizeFromContents(QStyle::CT_LineEdit, &styleOption, QSize(0, 0));
- geometry.implicitSize = style()->sizeFromContents(QStyle::CT_LineEdit, &styleOption, contentSize());
- styleOption.rect = QRect(QPoint(0, 0), geometry.implicitSize);
- geometry.contentRect = style()->subElementRect(QStyle::SE_LineEditContents, &styleOption);
- geometry.ninePatchMargins = style()->ninePatchMargins(QStyle::CE_ShapedFrame, &styleOption, geometry.minimumSize);
-
- return geometry;
-}
-
-void QQuickStyleItemTextArea::paintEvent(QPainter *painter)
-{
- QStyleOptionFrame styleOption;
- initStyleOption(styleOption);
- style()->drawPrimitive(QStyle::PE_PanelLineEdit, &styleOption, painter);
-}
-
-void QQuickStyleItemTextArea::initStyleOption(QStyleOptionFrame &styleOption)
-{
- initStyleOptionBase(styleOption);
- auto textArea = control<QQuickTextArea>();
-
- styleOption.lineWidth = 1;
- styleOption.midLineWidth = 0;
- styleOption.state |= QStyle::State_Sunken;
- if (textArea->isReadOnly())
- styleOption.state |= QStyle::State_ReadOnly;
-}
diff --git a/src/imports/nativestyle/nativestyle.pro b/src/imports/nativestyle/nativestyle.pro
index aa8b28b5..b06e5daf 100644
--- a/src/imports/nativestyle/nativestyle.pro
+++ b/src/imports/nativestyle/nativestyle.pro
@@ -25,7 +25,6 @@ CONFIG += qmltypes install_qmltypes
load(qml_plugin)
-# TODO: add config flag
-#requires(qtConfig(quickcontrols2-nativestyle))
+requires(qtConfig(quickcontrols2-macos)|qtConfig(quickcontrols2-windows))
HEADERS +=
diff --git a/src/imports/nativestyle/qmldir b/src/imports/nativestyle/qmldir
index 799a9609..3b6ce6c5 100644
--- a/src/imports/nativestyle/qmldir
+++ b/src/imports/nativestyle/qmldir
@@ -15,3 +15,4 @@ DefaultTextArea 6.0 controls/DefaultTextArea.qml
DefaultComboBox 6.0 controls/DefaultComboBox.qml
DefaultScrollBar 6.0 controls/DefaultScrollBar.qml
DefaultProgressBar 6.0 controls/DefaultProgressBar.qml
+DefaultDial 6.0 controls/DefaultDial.qml
diff --git a/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm b/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm
index 6ad3be5c..e61bdafa 100644
--- a/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm
+++ b/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm
@@ -1903,6 +1903,7 @@ NSCell *QMacStylePrivate::cocoaCell(CocoaControl cocoaControl) const
void QMacStylePrivate::drawNSViewInRect(NSView *view, const QRectF &rect, QPainter *p, DrawRectBlock drawRectBlock) const
{
+ QMacAutoReleasePool pool;
QMacCGContext ctx(p);
setupNSGraphicsContext(ctx, YES);
@@ -2857,6 +2858,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
// if (QTabWidget *tabWidget = qobject_cast<QTabWidget *>(opt->styleObject))
// clipTabBarFrame(opt, this, ctx);
//#endif
+ QMacAutoReleasePool pool;
CGContextTranslateCTM(ctx, 0, rect.origin.y + rect.size.height);
CGContextScaleCTM(ctx, 1, -1);
if (QOperatingSystemVersion::current() < QOperatingSystemVersion::MacOSMojave
@@ -3026,6 +3028,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
return cs == QStyleHelper::SizeSmall ? 0.5 : 0.0;
} ();
d->drawNSViewInRect(tb, opt->rect, p, ^(CGContextRef ctx, const CGRect &rect) {
+ QMacAutoReleasePool pool;
CGContextTranslateCTM(ctx, 0, vOffset);
[tb.cell drawInteriorWithFrame:rect inView:tb];
});
@@ -3080,6 +3083,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
static_cast<NSTextFieldCell *>(tf.cell).bezelStyle = isRounded ? NSTextFieldRoundedBezel : NSTextFieldSquareBezel;
tf.frame = opt->rect.toCGRect();
d->drawNSViewInRect(tf, opt->rect, p, ^(CGContextRef, const CGRect &rect) {
+ QMacAutoReleasePool pool;
if (!qt_mac_applicationIsInDarkMode()) {
// In 'Dark' mode controls are transparent, so we do not
// over-paint the (potentially custom) color in the background.
@@ -3444,6 +3448,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
[pb highlight:isPressed];
pb.state = isHighlighted && !isPressed ? NSOnState : NSOffState;
d->drawNSViewInRect(pb, frameRect, p, ^(CGContextRef, const CGRect &r) {
+ QMacAutoReleasePool pool;
[pb.cell drawBezelWithFrame:r inView:pb.superview];
});
[pb highlight:NO];
@@ -3658,6 +3663,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
pb.state = (isActive && isSelected && !isPressed) ? NSOnState : NSOffState;
const auto drawBezelBlock = ^(CGContextRef ctx, const CGRect &r) {
+ QMacAutoReleasePool pool;
CGContextClipToRect(ctx, opt->rect.toCGRect());
if (!isSelected || needsInactiveHack) {
// Final stage of the pressed state hack: flip NSPopupButton rendering
@@ -3711,6 +3717,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
tabPixmap.fill(Qt::transparent);
QPainter tabPainter(&tabPixmap);
d->drawNSViewInRect(pb, frameRect, &tabPainter, ^(CGContextRef ctx, const CGRect &r) {
+ QMacAutoReleasePool pool;
CGContextTranslateCTM(ctx, -opt->rect.left(), -opt->rect.top());
drawBezelBlock(ctx, r);
});
@@ -4150,6 +4157,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
const auto cw = QMacStylePrivate::CocoaControl(QMacStylePrivate::ProgressIndicator_Determinate, aquaSize);
auto *pi = static_cast<NSProgressIndicator *>(d->cocoaControl(cw));
d->drawNSViewInRect(pi, rect, p, ^(CGContextRef ctx, const CGRect &rect) {
+ QMacAutoReleasePool pool;
d->setupVerticalInvertedXform(ctx, reverse, false, rect);
pi.minValue = pb->minimum;
pi.maxValue = pb->maximum;
@@ -4200,6 +4208,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
auto *sv = static_cast<NSSplitView *>(d->cocoaControl(cw));
sv.frame = opt->rect.toCGRect();
d->drawNSViewInRect(sv, opt->rect, p, ^(CGContextRef, const CGRect &rect) {
+ QMacAutoReleasePool pool;
[sv drawDividerInRect:rect];
});
} else {
@@ -5058,6 +5067,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
}
d->drawNSViewInRect(slider, opt->rect, p, ^(CGContextRef ctx, const CGRect &rect) {
+ QMacAutoReleasePool pool;
// Since the GC is flipped, upsideDown means *not* inverted when vertical.
const bool verticalFlip = !isHorizontal && !sl->upsideDown; // FIXME: && !isSierraOrLater
@@ -5224,6 +5234,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
pb.frame = frameRect.toCGRect();
[pb highlight:isPressed];
d->drawNSViewInRect(pb, frameRect, p, ^(CGContextRef, const CGRect &r) {
+ QMacAutoReleasePool pool;
[pb.cell drawBezelWithFrame:r inView:pb.superview];
});
} else if (cw.type == QMacStylePrivate::ComboBox) {
@@ -5241,6 +5252,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
d->drawNSViewInRect(cb, frameRect, p, ^(CGContextRef, const CGRect &r) {
// FIXME This is usually drawn in the control's superview, but we wouldn't get inactive look in this case
+ QMacAutoReleasePool pool;
[cb.cell drawWithFrame:r inView:cb];
});
}
@@ -5311,6 +5323,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
const auto buttonRect = proxy()->subControlRect(CC_TitleBar, titlebar, sc);
d->drawNSViewInRect(wb, buttonRect, p, ^(CGContextRef, const CGRect &rect) {
+ QMacAutoReleasePool pool;
auto *wbCell = static_cast<NSButtonCell *>(wb.cell);
[wbCell drawWithFrame:rect inView:wb];
});
@@ -5417,6 +5430,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
pb.state = isHighlighted && !isPressed ? NSOnState : NSOffState;
const auto buttonRect = proxy()->subControlRect(cc, tb, SC_ToolButton);
d->drawNSViewInRect(pb, buttonRect, p, ^(CGContextRef, const CGRect &rect) {
+ QMacAutoReleasePool pool;
[pb.cell drawBezelWithFrame:rect inView:pb];
});
}
@@ -5894,7 +5908,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, cons
case CT_SpinBox:
if (const QStyleOptionSpinBox *vopt = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
if (vopt->subControls == SC_SpinBoxFrame) {
- const QSize minimumSize(10, 10);
+ const QSize minimumSize(20, 24);
if (sz.width() < minimumSize.width())
sz.setWidth(minimumSize.width());
if (sz.height() < minimumSize.height())
@@ -6030,9 +6044,9 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, cons
case CT_LineEdit:
if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
if (sz.isEmpty()) {
- // Minimum size (10, 10)
- sz.rwidth() += 2;
- sz.rheight() += 6;
+ // Minimum size (with padding: 18x24)
+ sz.rwidth() = 10;
+ sz.rheight() = 20;
}
// From using pixelTool with XCode/NSTextTextField
int leftPadding = 4;
diff --git a/src/imports/nativestyle/qstyle/qquickcommonstyle.cpp b/src/imports/nativestyle/qstyle/qquickcommonstyle.cpp
index 16e05abd..41f12545 100644
--- a/src/imports/nativestyle/qstyle/qquickcommonstyle.cpp
+++ b/src/imports/nativestyle/qstyle/qquickcommonstyle.cpp
@@ -4666,6 +4666,8 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, c
if (const QStyleOptionSlider *option = qstyleoption_cast<const QStyleOptionSlider *>(opt))
sz = subControlRect(QStyle::CC_Slider, option, QStyle::SC_SliderHandle).size();
break;
+ case CT_Dial:
+ sz = QSize(20, 20);
case CT_Frame:
if (const QStyleOptionFrame *option = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
const int ninePatchSplit = 1;
diff --git a/src/imports/nativestyle/qstyle/qquickstyle.h b/src/imports/nativestyle/qstyle/qquickstyle.h
index 8fd3a5ae..4a2e5287 100644
--- a/src/imports/nativestyle/qstyle/qquickstyle.h
+++ b/src/imports/nativestyle/qstyle/qquickstyle.h
@@ -543,6 +543,7 @@ public:
CT_Menu,
CT_TabBarTab,
CT_Slider,
+ CT_Dial,
CT_ScrollBar,
CT_LineEdit,
CT_SpinBox,
diff --git a/src/imports/nativestyle/qstyle/qstyle.pri b/src/imports/nativestyle/qstyle/qstyle.pri
index 33257845..4d025498 100644
--- a/src/imports/nativestyle/qstyle/qstyle.pri
+++ b/src/imports/nativestyle/qstyle/qstyle.pri
@@ -20,4 +20,4 @@ SOURCES += \
$$PWD/qquickstyleoption.cpp
macos: include(mac/mac.pri)
-windows: include(windows/windows.pri)
+win32: include(windows/windows.pri)
diff --git a/src/imports/nativestyle/qtquickcontrols2nativestyleplugin.cpp b/src/imports/nativestyle/qtquickcontrols2nativestyleplugin.cpp
index 8aedcdb8..dd34d2f8 100644
--- a/src/imports/nativestyle/qtquickcontrols2nativestyleplugin.cpp
+++ b/src/imports/nativestyle/qtquickcontrols2nativestyleplugin.cpp
@@ -36,6 +36,9 @@
#include <QtQml/qqml.h>
#include <QtQuickControls2/private/qquickstyleplugin_p.h>
+#include <QtGui/qguiapplication.h>
+
+#include <QtQuickTemplates2/private/qquicktheme_p.h>
#include "qquicknativestyle.h"
#include "qquickcommonstyle.h"
@@ -63,8 +66,28 @@ public:
QString name() const override;
};
+static void deleteQStyle()
+{
+ // When we delete QStyle, it will free up it's own internal resources. Especially
+ // on macOS, this means releasing a lot of NSViews and NSCells from the QMacStyle
+ // destructor. If we did this from ~QtQuickControls2NativeStylePlugin, it would
+ // happen when the plugin was unloaded from a Q_DESTRUCTOR_FUNCTION in QLibrary,
+ // which is very late in the tear-down process, and after qGuiApp has been set to
+ // nullptr, NSApplication has stopped running, and perhaps also other static platform
+ // variables (e.g in AppKit?) has been deleted. And to our best guess, this is also why
+ // we see a crash in AppKit from the destructor in QMacStyle. So for this reason, we
+ // delete QStyle from a post routine rather than from the destructor.
+ QQuickNativeStyle::setStyle(nullptr);
+}
+
QtQuickControls2NativeStylePlugin::~QtQuickControls2NativeStylePlugin()
{
+ if (!qGuiApp)
+ return;
+
+ // QGuiApplication is still running, so we need to remove the post
+ // routine to not be called after we have been unloaded.
+ qRemovePostRoutine(deleteQStyle);
QQuickNativeStyle::setStyle(nullptr);
}
@@ -106,12 +129,16 @@ void QtQuickControls2NativeStylePlugin::initializeEngine(QQmlEngine *engine, con
#endif
}
}
+
+ qAddPostRoutine(deleteQStyle);
QQuickNativeStyle::setStyle(style);
}
void QtQuickControls2NativeStylePlugin::registerTypes(const char *uri)
{
Q_UNUSED(uri);
+ QQuickTheme::instance()->setPalette(QQuickTheme::System, QPalette());
+ QQuickTheme::instance()->setFont(QQuickTheme::System, QFont());
}
QT_END_NAMESPACE