diff options
Diffstat (limited to 'src/quickcontrols/fusion')
19 files changed, 89 insertions, 46 deletions
diff --git a/src/quickcontrols/fusion/BusyIndicator.qml b/src/quickcontrols/fusion/BusyIndicator.qml index dcd2f23f49..8de02b6aea 100644 --- a/src/quickcontrols/fusion/BusyIndicator.qml +++ b/src/quickcontrols/fusion/BusyIndicator.qml @@ -27,7 +27,7 @@ T.BusyIndicator { Behavior on opacity { OpacityAnimator { duration: 250 } } RotationAnimator on rotation { - running: control.running || control.contentItem.visible + running: control.running && control.contentItem.visible from: 0 to: 360 duration: 1000 diff --git a/src/quickcontrols/fusion/CMakeLists.txt b/src/quickcontrols/fusion/CMakeLists.txt index 69f8f5f96d..0c751db621 100644 --- a/src/quickcontrols/fusion/CMakeLists.txt +++ b/src/quickcontrols/fusion/CMakeLists.txt @@ -92,7 +92,9 @@ set_source_files_properties(VerticalHeaderView.qml PROPERTIES QT_QML_SOURCE_VERSIONS "2.15;6.0" ) -qt_internal_add_qml_module(qtquickcontrols2fusionstyleplugin +add_subdirectory(impl) + +qt_internal_add_qml_module(QuickControls2Fusion URI "QtQuick.Controls.Fusion" VERSION "${PROJECT_VERSION}" PAST_MAJOR_VERSIONS 2 @@ -107,7 +109,6 @@ qt_internal_add_qml_module(qtquickcontrols2fusionstyleplugin SOURCES qquickfusionstyle.cpp qquickfusionstyle_p.h qquickfusiontheme.cpp qquickfusiontheme_p.h - qtquickcontrols2fusionstyleplugin.cpp QML_FILES ${qml_files} DEFINES @@ -117,12 +118,23 @@ qt_internal_add_qml_module(qtquickcontrols2fusionstyleplugin Qt::CorePrivate Qt::GuiPrivate Qt::QmlPrivate + Qt::QuickControls2FusionStyleImpl Qt::QuickControls2Private Qt::QuickPrivate Qt::QuickTemplates2Private ) -qt_internal_add_resource(qtquickcontrols2fusionstyleplugin "qtquickcontrols2fusionstyle" +target_sources(qtquickcontrols2fusionstyleplugin + PRIVATE + qtquickcontrols2fusionstyleplugin.cpp +) + +target_link_libraries(qtquickcontrols2fusionstyleplugin + PRIVATE + Qt::QuickControls2Private +) + +qt_internal_add_resource(QuickControls2Fusion "qtquickcontrols2fusionstyle" PREFIX "/qt-project.org/imports/QtQuick/Controls/Fusion" FILES @@ -140,8 +152,6 @@ qt_internal_add_resource(qtquickcontrols2fusionstyleplugin "qtquickcontrols2fusi "images/progressmask@4x.png" ) -add_subdirectory(impl) - _qt_internal_add_qml_static_plugin_dependency(qtquickcontrols2fusionstyleplugin quickwindow) _qt_internal_add_qml_static_plugin_dependency(qtquickcontrols2fusionstyleplugin qtquickcontrols2fusionstyleimplplugin) diff --git a/src/quickcontrols/fusion/CheckBox.qml b/src/quickcontrols/fusion/CheckBox.qml index 414414804d..a996b67afe 100644 --- a/src/quickcontrols/fusion/CheckBox.qml +++ b/src/quickcontrols/fusion/CheckBox.qml @@ -22,6 +22,7 @@ T.CheckBox { indicator: CheckIndicator { x: control.text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 y: control.topPadding + (control.availableHeight - height) / 2 + baseLightness: control.enabled ? 1.25 : 1.0 control: control } diff --git a/src/quickcontrols/fusion/ComboBox.qml b/src/quickcontrols/fusion/ComboBox.qml index 6caa7d3f94..decc43f1f7 100644 --- a/src/quickcontrols/fusion/ComboBox.qml +++ b/src/quickcontrols/fusion/ComboBox.qml @@ -1,6 +1,8 @@ // Copyright (C) 2017 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 +pragma ComponentBehavior: Bound + import QtQuick import QtQuick.Window import QtQuick.Templates as T @@ -21,8 +23,11 @@ T.ComboBox { rightPadding: padding + (control.mirrored || !indicator || !indicator.visible ? 0 : indicator.width + spacing) delegate: MenuItem { + required property var model + required property int index + width: ListView.view.width - text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] : model[control.textRole]) : modelData + text: model[control.textRole] font.weight: control.currentIndex === index ? Font.DemiBold : Font.Normal highlighted: control.highlightedIndex === index hoverEnabled: control.hoverEnabled @@ -111,6 +116,7 @@ T.ComboBox { topMargin: 6 bottomMargin: 6 padding: 1 + palette: control.palette contentItem: ListView { clip: true diff --git a/src/quickcontrols/fusion/Dial.qml b/src/quickcontrols/fusion/Dial.qml index 7fa0af3379..6efd2581c3 100644 --- a/src/quickcontrols/fusion/Dial.qml +++ b/src/quickcontrols/fusion/Dial.qml @@ -28,12 +28,13 @@ T.Dial { height: control.height / 7 transform: [ Translate { - y: -Math.min(control.background.width, control.background.height) * 0.42 + control.handle.height + y: -Math.min(control.background.width, control.background.height) * 0.35 + + (control.handle ? control.handle.height / 2 : 0) }, Rotation { angle: control.angle - origin.x: control.handle.width / 2 - origin.y: control.handle.height / 2 + origin.x: control.handle ? control.handle.width / 2 : 0 + origin.y: control.handle ? control.handle.height / 2 : 0 } ] } diff --git a/src/quickcontrols/fusion/HorizontalHeaderView.qml b/src/quickcontrols/fusion/HorizontalHeaderView.qml index 4e4a2ec7d7..dbea743aca 100644 --- a/src/quickcontrols/fusion/HorizontalHeaderView.qml +++ b/src/quickcontrols/fusion/HorizontalHeaderView.qml @@ -1,6 +1,8 @@ // Copyright (C) 2020 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 +pragma ComponentBehavior: Bound + import QtQuick import QtQuick.Templates as T import QtQuick.Controls.Fusion.impl @@ -17,6 +19,10 @@ T.HorizontalHeaderView { implicitHeight: Math.max(1, contentHeight) delegate: Rectangle { + id: delegate + + required property var model + // Qt6: add cellPadding (and font etc) as public API in headerview readonly property real cellPadding: 8 @@ -37,11 +43,9 @@ T.HorizontalHeaderView { Label { id: text - text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] - : model[control.textRole]) - : modelData - width: parent.width - height: parent.height + text: delegate.model[control.textRole] + width: delegate.width + height: delegate.height horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } diff --git a/src/quickcontrols/fusion/Menu.qml b/src/quickcontrols/fusion/Menu.qml index e0f565a69b..bfd1feddb6 100644 --- a/src/quickcontrols/fusion/Menu.qml +++ b/src/quickcontrols/fusion/Menu.qml @@ -26,8 +26,8 @@ T.Menu { implicitHeight: contentHeight model: control.contentModel interactive: Window.window - ? contentHeight + control.topPadding + control.bottomPadding > Window.window.height - : false + ? contentHeight + control.topPadding + control.bottomPadding > control.height + : false clip: true currentIndex: control.currentIndex diff --git a/src/quickcontrols/fusion/TabButton.qml b/src/quickcontrols/fusion/TabButton.qml index add96a8fa3..48ee303f63 100644 --- a/src/quickcontrols/fusion/TabButton.qml +++ b/src/quickcontrols/fusion/TabButton.qml @@ -35,6 +35,7 @@ T.TabButton { color: control.palette.buttonText } + background: Rectangle { y: control.checked || control.TabBar.position !== T.TabBar.Header ? 0 : 2 implicitHeight: 21 diff --git a/src/quickcontrols/fusion/TreeViewDelegate.qml b/src/quickcontrols/fusion/TreeViewDelegate.qml index f8bbfb24b8..195693614b 100644 --- a/src/quickcontrols/fusion/TreeViewDelegate.qml +++ b/src/quickcontrols/fusion/TreeViewDelegate.qml @@ -64,6 +64,7 @@ T.TreeViewDelegate { // The edit delegate is a separate component, and doesn't need // to follow the same strict rules that are applied to a control. // qmllint disable attached-property-reuse + // qmllint disable controls-attached-property-reuse // qmllint disable controls-sanity TableView.editDelegate: FocusScope { width: parent.width @@ -71,7 +72,7 @@ T.TreeViewDelegate { readonly property int __role: { let model = control.treeView.model - let index = control.treeView.modelIndex(column, row) + let index = control.treeView.index(row, column) let editText = model.data(index, Qt.EditRole) return editText !== undefined ? Qt.EditRole : Qt.DisplayRole } @@ -81,17 +82,18 @@ T.TreeViewDelegate { x: control.contentItem.x y: (parent.height - height) / 2 width: control.contentItem.width - text: control.treeView.model.data(control.treeView.modelIndex(column, row), __role) + text: control.treeView.model.data(control.treeView.index(row, column), __role) focus: true } TableView.onCommit: { - let index = TableView.view.modelIndex(column, row) + let index = TableView.view.index(row, column) TableView.view.model.setData(index, textField.text, __role) } Component.onCompleted: textField.selectAll() } // qmllint enable attached-property-reuse + // qmllint enable controls-attached-property-reuse // qmllint enable controls-sanity } diff --git a/src/quickcontrols/fusion/Tumbler.qml b/src/quickcontrols/fusion/Tumbler.qml index 447765dce7..4a5ccd8348 100644 --- a/src/quickcontrols/fusion/Tumbler.qml +++ b/src/quickcontrols/fusion/Tumbler.qml @@ -15,6 +15,8 @@ T.Tumbler { implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitContentHeight + topPadding + bottomPadding) + readonly property real __delegateHeight: availableHeight / visibleItemCount + delegate: Text { text: modelData color: control.palette.windowText @@ -34,13 +36,11 @@ T.Tumbler { delegate: control.delegate path: Path { startX: control.contentItem.width / 2 - startY: -control.contentItem.delegateHeight / 2 + startY: -control.__delegateHeight / 2 PathLine { x: control.contentItem.width / 2 - y: (control.visibleItemCount + 1) * control.contentItem.delegateHeight - control.contentItem.delegateHeight / 2 + y: (control.visibleItemCount + 1) * control.__delegateHeight - control.__delegateHeight / 2 } } - - property real delegateHeight: control.availableHeight / control.visibleItemCount } } diff --git a/src/quickcontrols/fusion/VerticalHeaderView.qml b/src/quickcontrols/fusion/VerticalHeaderView.qml index b35c9b6d6c..c2cb281a24 100644 --- a/src/quickcontrols/fusion/VerticalHeaderView.qml +++ b/src/quickcontrols/fusion/VerticalHeaderView.qml @@ -1,6 +1,8 @@ // Copyright (C) 2020 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 +pragma ComponentBehavior: Bound + import QtQuick import QtQuick.Templates as T import QtQuick.Controls.Fusion.impl @@ -17,6 +19,10 @@ T.VerticalHeaderView { implicitHeight: syncView ? syncView.height : 0 delegate: Rectangle { + id: delegate + + required property var model + // Qt6: add cellPadding (and font etc) as public API in headerview readonly property real cellPadding: 8 @@ -36,11 +42,9 @@ T.VerticalHeaderView { Label { id: text - text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] - : model[control.textRole]) - : modelData - width: parent.width - height: parent.height + text: delegate.model[control.textRole] + width: delegate.width + height: delegate.height horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } diff --git a/src/quickcontrols/fusion/impl/CMakeLists.txt b/src/quickcontrols/fusion/impl/CMakeLists.txt index e52f1ecc06..64ee4851fb 100644 --- a/src/quickcontrols/fusion/impl/CMakeLists.txt +++ b/src/quickcontrols/fusion/impl/CMakeLists.txt @@ -14,7 +14,7 @@ set(qml_files "SwitchIndicator.qml" ) -qt_internal_add_qml_module(qtquickcontrols2fusionstyleimplplugin +qt_internal_add_qml_module(QuickControls2FusionStyleImpl URI "QtQuick.Controls.Fusion.impl" VERSION "${PROJECT_VERSION}" PAST_MAJOR_VERSIONS 2 @@ -22,7 +22,6 @@ qt_internal_add_qml_module(qtquickcontrols2fusionstyleimplplugin DEPENDENCIES QtQuick/auto PLUGIN_TARGET qtquickcontrols2fusionstyleimplplugin - NO_PLUGIN_OPTIONAL SOURCES qquickfusionbusyindicator.cpp qquickfusionbusyindicator_p.h qquickfusiondial.cpp qquickfusiondial_p.h diff --git a/src/quickcontrols/fusion/impl/CheckIndicator.qml b/src/quickcontrols/fusion/impl/CheckIndicator.qml index 58de99654a..40e3471f10 100644 --- a/src/quickcontrols/fusion/impl/CheckIndicator.qml +++ b/src/quickcontrols/fusion/impl/CheckIndicator.qml @@ -10,13 +10,15 @@ Rectangle { id: indicator property Item control + property real baseLightness: 1.6 + readonly property color pressedColor: Fusion.mergedColors(control.palette.base, control.palette.windowText, 85) readonly property color checkMarkColor: Qt.darker(control.palette.text, 1.2) implicitWidth: 14 implicitHeight: 14 - color: control.down ? indicator.pressedColor : control.palette.base + color: control.down ? indicator.pressedColor : Qt.lighter(control.palette.base, baseLightness) border.color: control.visualFocus ? Fusion.highlightedOutline(control.palette) : Qt.lighter(Fusion.outline(control.palette), 1.1) diff --git a/src/quickcontrols/fusion/impl/RadioIndicator.qml b/src/quickcontrols/fusion/impl/RadioIndicator.qml index 0949b904a9..818b246953 100644 --- a/src/quickcontrols/fusion/impl/RadioIndicator.qml +++ b/src/quickcontrols/fusion/impl/RadioIndicator.qml @@ -17,7 +17,7 @@ Rectangle { implicitHeight: 14 radius: width / 2 - color: control.down ? indicator.pressedColor : control.palette.base + color: control.down ? indicator.pressedColor : Qt.lighter(control.palette.base, 1.75) border.color: control.visualFocus ? Fusion.highlightedOutline(control.palette) : Qt.darker(control.palette.window, 1.5) diff --git a/src/quickcontrols/fusion/impl/SwitchIndicator.qml b/src/quickcontrols/fusion/impl/SwitchIndicator.qml index 8bc9238228..39e47c0e91 100644 --- a/src/quickcontrols/fusion/impl/SwitchIndicator.qml +++ b/src/quickcontrols/fusion/impl/SwitchIndicator.qml @@ -2,6 +2,7 @@ // 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.Window import QtQuick.Templates as T import QtQuick.Controls.impl import QtQuick.Controls.Fusion @@ -49,11 +50,13 @@ Rectangle { gradient: Gradient { GradientStop { position: 0 - color: Fusion.highlight(indicator.control.palette) + color: Qt.alpha(indicator.control.palette.active.highlight, + indicator.Window ? indicator.Window.active ? 1 : 0.5 : 1) } GradientStop { position: 1 - color: Qt.lighter(Fusion.highlight(indicator.control.palette), 1.2) + color: Qt.alpha(Qt.lighter(indicator.control.palette.active.highlight, 1.2), + indicator.Window ? indicator.Window.active ? 1 : 0.5 : 1) } } } diff --git a/src/quickcontrols/fusion/impl/qquickfusionbusyindicator.cpp b/src/quickcontrols/fusion/impl/qquickfusionbusyindicator.cpp index cce69b0e4b..8e58b09ed3 100644 --- a/src/quickcontrols/fusion/impl/qquickfusionbusyindicator.cpp +++ b/src/quickcontrols/fusion/impl/qquickfusionbusyindicator.cpp @@ -71,8 +71,17 @@ void QQuickFusionBusyIndicator::itemChange(ItemChange change, const ItemChangeDa { QQuickPaintedItem::itemChange(change, data); - if (change == ItemOpacityHasChanged && qFuzzyIsNull(data.realValue)) - setVisible(false); + switch (change) { + case ItemOpacityHasChanged: + if (qFuzzyIsNull(data.realValue)) + setVisible(false); + break; + case ItemVisibleHasChanged: + update(); + break; + default: + break; + } } QT_END_NAMESPACE diff --git a/src/quickcontrols/fusion/qquickfusionstyle_p.h b/src/quickcontrols/fusion/qquickfusionstyle_p.h index a264201211..47fdd77fd7 100644 --- a/src/quickcontrols/fusion/qquickfusionstyle_p.h +++ b/src/quickcontrols/fusion/qquickfusionstyle_p.h @@ -18,17 +18,19 @@ #include <QtCore/qobject.h> #include <QtGui/qcolor.h> #include <QtQml/qqml.h> -#include <QtQuick/private/qquickpalette_p.h> +#include <QtQuickControls2Fusion/qtquickcontrols2fusionexports.h> QT_BEGIN_NAMESPACE -class QQuickFusionStyle : public QObject +class QQuickPalette; + +class Q_QUICKCONTROLS2FUSION_EXPORT QQuickFusionStyle : public QObject { Q_OBJECT - Q_PROPERTY(QColor lightShade READ lightShade CONSTANT) - Q_PROPERTY(QColor darkShade READ darkShade CONSTANT) - Q_PROPERTY(QColor topShadow READ topShadow CONSTANT) - Q_PROPERTY(QColor innerContrastLine READ innerContrastLine CONSTANT) + Q_PROPERTY(QColor lightShade READ lightShade CONSTANT FINAL) + Q_PROPERTY(QColor darkShade READ darkShade CONSTANT FINAL) + Q_PROPERTY(QColor topShadow READ topShadow CONSTANT FINAL) + Q_PROPERTY(QColor innerContrastLine READ innerContrastLine CONSTANT FINAL) QML_NAMED_ELEMENT(Fusion) QML_SINGLETON QML_ADDED_IN_VERSION(2, 3) diff --git a/src/quickcontrols/fusion/qquickfusiontheme_p.h b/src/quickcontrols/fusion/qquickfusiontheme_p.h index a41c9d7315..b60521394c 100644 --- a/src/quickcontrols/fusion/qquickfusiontheme_p.h +++ b/src/quickcontrols/fusion/qquickfusiontheme_p.h @@ -15,13 +15,13 @@ // We mean it. // -#include <QtCore/private/qglobal_p.h> +#include <QtQuickControls2Fusion/qtquickcontrols2fusionexports.h> QT_BEGIN_NAMESPACE class QQuickTheme; -class QQuickFusionTheme +class Q_QUICKCONTROLS2FUSION_EXPORT QQuickFusionTheme { public: static void initialize(QQuickTheme *theme); diff --git a/src/quickcontrols/fusion/qtquickcontrols2fusionstyleplugin.cpp b/src/quickcontrols/fusion/qtquickcontrols2fusionstyleplugin.cpp index 532d7597ce..f61dafa478 100644 --- a/src/quickcontrols/fusion/qtquickcontrols2fusionstyleplugin.cpp +++ b/src/quickcontrols/fusion/qtquickcontrols2fusionstyleplugin.cpp @@ -6,7 +6,6 @@ #include <QtQml/qqml.h> #include <QtQuickControls2/private/qquickstyleplugin_p.h> -#include <QtQuickTemplates2/private/qquicktheme_p.h> QT_BEGIN_NAMESPACE |