diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-11-17 18:35:24 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-11-17 18:35:24 +0100 |
commit | 4f2bb3e5a1ecbb1728209c7b2525c2c645ef49a2 (patch) | |
tree | f3be806d0301078e69d3043c2ac1d370aca14825 /src | |
parent | 170869fe1457fc68e96d46c9ff804071f86bd029 (diff) | |
parent | 4ef7af98e69bf676dd39e6aad5e6a5f980648e75 (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
src/quickcontrols2/qquickstyle.cpp
src/quicktemplates2/qquickslider.cpp
Change-Id: Ie12132690680706def6f516334a6ef0ba27336b3
Diffstat (limited to 'src')
41 files changed, 102 insertions, 114 deletions
diff --git a/src/imports/controls/doc/src/includes/qquickswitch.qdocinc b/src/imports/controls/doc/src/includes/qquickswitch.qdocinc index 32ccbb89..985f85d9 100644 --- a/src/imports/controls/doc/src/includes/qquickswitch.qdocinc +++ b/src/imports/controls/doc/src/includes/qquickswitch.qdocinc @@ -2,7 +2,7 @@ This property holds the logical position of the thumb indicator. -The position is defined as a percentage of the indicator's size, scaled to +The position is expressed as a fraction of the indicator's size, in the range \c 0.0 - \c 1.0. The position can be used for example to determine whether the thumb has been dragged past the halfway point. For visualizing a thumb indicator, the right-to-left aware \l visualPosition should be used instead. @@ -16,7 +16,7 @@ indicator, the right-to-left aware \l visualPosition should be used instead. This property holds the visual position of the thumb indicator. -The position is defined as a percentage of the indicator's size, scaled to +The position is expressed as a fraction of the indicator's size, in the range \c 0.0 - \c 1.0. When the control is \l {Control::mirrored}{mirrored}, the value is equal to \c {1.0 - position}. This makes the value suitable for visualizing the thumb indicator taking right-to-left support into account. diff --git a/src/imports/controls/material/Button.qml b/src/imports/controls/material/Button.qml index 8842f0ac..9b3ced25 100644 --- a/src/imports/controls/material/Button.qml +++ b/src/imports/controls/material/Button.qml @@ -62,7 +62,7 @@ T.Button { font: control.font color: !control.enabled ? control.Material.hintTextColor : control.flat && control.highlighted ? control.Material.accentColor : - control.highlighted ? control.Material.primaryHighlightedTextColor : control.Material.primaryTextColor + control.highlighted ? control.Material.primaryHighlightedTextColor : control.Material.foreground horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter elide: Text.ElideRight diff --git a/src/imports/controls/material/CheckBox.qml b/src/imports/controls/material/CheckBox.qml index bb760bbd..979654f7 100644 --- a/src/imports/controls/material/CheckBox.qml +++ b/src/imports/controls/material/CheckBox.qml @@ -78,7 +78,7 @@ T.CheckBox { text: control.text font: control.font - color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor + color: control.enabled ? control.Material.foreground : control.Material.hintTextColor elide: Text.ElideRight visible: control.text horizontalAlignment: Text.AlignLeft diff --git a/src/imports/controls/material/CheckDelegate.qml b/src/imports/controls/material/CheckDelegate.qml index e77e0a9c..aec48bf1 100644 --- a/src/imports/controls/material/CheckDelegate.qml +++ b/src/imports/controls/material/CheckDelegate.qml @@ -66,7 +66,7 @@ T.CheckDelegate { text: control.text font: control.font - color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor + color: control.enabled ? control.Material.foreground : control.Material.hintTextColor elide: Text.ElideRight visible: control.text horizontalAlignment: Text.AlignLeft diff --git a/src/imports/controls/material/ComboBox.qml b/src/imports/controls/material/ComboBox.qml index 814f8ae7..ab6fd17c 100644 --- a/src/imports/controls/material/ComboBox.qml +++ b/src/imports/controls/material/ComboBox.qml @@ -57,7 +57,7 @@ T.ComboBox { Material.elevation: flat ? control.pressed || control.hovered ? 2 : 0 : control.pressed ? 8 : 2 Material.background: flat ? "transparent" : undefined - Material.foreground: flat ? undefined : Material.foreground + Material.foreground: flat ? undefined : Material.primaryTextColor delegate: MenuItem { width: parent.width @@ -70,7 +70,7 @@ T.ComboBox { indicator: Image { x: control.mirrored ? control.padding : control.width - width - control.padding y: control.topPadding + (control.availableHeight - height) / 2 - source: "image://material/drop-indicator/" + (control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor) + source: "image://material/drop-indicator/" + (control.enabled ? control.Material.foreground : control.Material.hintTextColor) } contentItem: Text { @@ -80,7 +80,7 @@ T.ComboBox { text: control.displayText font: control.font - color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor + color: control.enabled ? control.Material.foreground : control.Material.hintTextColor horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter elide: Text.ElideRight diff --git a/src/imports/controls/material/GroupBox.qml b/src/imports/controls/material/GroupBox.qml index afd1c8d1..64b589af 100644 --- a/src/imports/controls/material/GroupBox.qml +++ b/src/imports/controls/material/GroupBox.qml @@ -60,7 +60,7 @@ T.GroupBox { text: control.title font: control.font - color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor + color: control.enabled ? control.Material.foreground : control.Material.hintTextColor elide: Text.ElideRight horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter diff --git a/src/imports/controls/material/ItemDelegate.qml b/src/imports/controls/material/ItemDelegate.qml index ad9604fd..ec74fbee 100644 --- a/src/imports/controls/material/ItemDelegate.qml +++ b/src/imports/controls/material/ItemDelegate.qml @@ -58,7 +58,7 @@ T.ItemDelegate { text: control.text font: control.font - color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor + color: control.enabled ? control.Material.foreground : control.Material.hintTextColor elide: Text.ElideRight visible: control.text horizontalAlignment: Text.AlignLeft diff --git a/src/imports/controls/material/Label.qml b/src/imports/controls/material/Label.qml index f4e12813..3a728dc8 100644 --- a/src/imports/controls/material/Label.qml +++ b/src/imports/controls/material/Label.qml @@ -41,6 +41,6 @@ import QtQuick.Controls.Material 2.1 T.Label { id: control - color: enabled ? Material.primaryTextColor : Material.hintTextColor + color: enabled ? Material.foreground : Material.hintTextColor linkColor: Material.accentColor } diff --git a/src/imports/controls/material/MenuItem.qml b/src/imports/controls/material/MenuItem.qml index 15c2d392..a6dbba2c 100644 --- a/src/imports/controls/material/MenuItem.qml +++ b/src/imports/controls/material/MenuItem.qml @@ -67,7 +67,7 @@ T.MenuItem { text: control.text font: control.font - color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor + color: control.enabled ? control.Material.foreground : control.Material.hintTextColor elide: Text.ElideRight visible: control.text horizontalAlignment: Text.AlignLeft diff --git a/src/imports/controls/material/PageIndicator.qml b/src/imports/controls/material/PageIndicator.qml index 7378dbbf..5a68df6b 100644 --- a/src/imports/controls/material/PageIndicator.qml +++ b/src/imports/controls/material/PageIndicator.qml @@ -54,7 +54,7 @@ T.PageIndicator { implicitHeight: 8 radius: width / 2 - color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor + color: control.enabled ? control.Material.foreground : control.Material.hintTextColor opacity: index === currentIndex ? 0.95 : pressed ? 0.7 : 0.45 Behavior on opacity { OpacityAnimator { duration: 100 } } diff --git a/src/imports/controls/material/RadioButton.qml b/src/imports/controls/material/RadioButton.qml index 6faf1caa..32bf1cbd 100644 --- a/src/imports/controls/material/RadioButton.qml +++ b/src/imports/controls/material/RadioButton.qml @@ -78,7 +78,7 @@ T.RadioButton { text: control.text font: control.font - color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor + color: control.enabled ? control.Material.foreground : control.Material.hintTextColor elide: Text.ElideRight visible: control.text horizontalAlignment: Text.AlignLeft diff --git a/src/imports/controls/material/RadioDelegate.qml b/src/imports/controls/material/RadioDelegate.qml index 4b7af82a..349352b4 100644 --- a/src/imports/controls/material/RadioDelegate.qml +++ b/src/imports/controls/material/RadioDelegate.qml @@ -66,7 +66,7 @@ T.RadioDelegate { text: control.text font: control.font - color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor + color: control.enabled ? control.Material.foreground : control.Material.hintTextColor elide: Text.ElideRight visible: control.text horizontalAlignment: Text.AlignLeft diff --git a/src/imports/controls/material/RangeSlider.qml b/src/imports/controls/material/RangeSlider.qml index 2442a38b..c46ddd2b 100644 --- a/src/imports/controls/material/RangeSlider.qml +++ b/src/imports/controls/material/RangeSlider.qml @@ -76,7 +76,7 @@ T.RangeSlider { implicitHeight: horizontal ? 48 : 200 width: horizontal ? control.availableWidth : 1 height: horizontal ? 1 : control.availableHeight - color: control.Material.primaryTextColor + color: control.Material.foreground scale: horizontal && control.mirrored ? -1 : 1 readonly property bool horizontal: control.orientation === Qt.Horizontal diff --git a/src/imports/controls/material/RoundButton.qml b/src/imports/controls/material/RoundButton.qml index e385ac1b..f6899dea 100644 --- a/src/imports/controls/material/RoundButton.qml +++ b/src/imports/controls/material/RoundButton.qml @@ -60,7 +60,7 @@ T.RoundButton { font: control.font color: !control.enabled ? control.Material.hintTextColor : control.flat && control.highlighted ? control.Material.accentColor : - control.highlighted ? control.Material.primaryHighlightedTextColor : control.Material.primaryTextColor + control.highlighted ? control.Material.primaryHighlightedTextColor : control.Material.foreground horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter elide: Text.ElideRight diff --git a/src/imports/controls/material/Slider.qml b/src/imports/controls/material/Slider.qml index fb871a02..5677193a 100644 --- a/src/imports/controls/material/Slider.qml +++ b/src/imports/controls/material/Slider.qml @@ -65,7 +65,7 @@ T.Slider { implicitHeight: horizontal ? 48 : 200 width: horizontal ? control.availableWidth : 1 height: horizontal ? 1 : control.availableHeight - color: control.Material.primaryTextColor + color: control.Material.foreground scale: horizontal && control.mirrored ? -1 : 1 readonly property bool horizontal: control.orientation === Qt.Horizontal diff --git a/src/imports/controls/material/SpinBox.qml b/src/imports/controls/material/SpinBox.qml index c48cb56f..18c5affd 100644 --- a/src/imports/controls/material/SpinBox.qml +++ b/src/imports/controls/material/SpinBox.qml @@ -68,9 +68,9 @@ T.SpinBox { text: control.textFromValue(control.value, control.locale) font: control.font - color: enabled ? control.Material.primaryTextColor : control.Material.hintTextColor + color: enabled ? control.Material.foreground : control.Material.hintTextColor selectionColor: control.Material.textSelectionColor - selectedTextColor: control.Material.primaryTextColor + selectedTextColor: control.Material.foreground horizontalAlignment: Qt.AlignHCenter verticalAlignment: Qt.AlignVCenter @@ -104,14 +104,14 @@ T.SpinBox { y: (parent.height - height) / 2 width: Math.min(parent.width / 3, parent.width / 3) height: 2 - color: enabled ? control.Material.primaryTextColor : control.Material.spinBoxDisabledIconColor + color: enabled ? control.Material.foreground : control.Material.spinBoxDisabledIconColor } Rectangle { x: (parent.width - width) / 2 y: (parent.height - height) / 2 width: 2 height: Math.min(parent.width / 3, parent.width / 3) - color: enabled ? control.Material.primaryTextColor : control.Material.spinBoxDisabledIconColor + color: enabled ? control.Material.foreground : control.Material.spinBoxDisabledIconColor } } @@ -138,7 +138,7 @@ T.SpinBox { y: (parent.height - height) / 2 width: parent.width / 3 height: 2 - color: enabled ? control.Material.primaryTextColor : control.Material.spinBoxDisabledIconColor + color: enabled ? control.Material.foreground : control.Material.spinBoxDisabledIconColor } } diff --git a/src/imports/controls/material/SwipeDelegate.qml b/src/imports/controls/material/SwipeDelegate.qml index 23db44fd..da54b0c3 100644 --- a/src/imports/controls/material/SwipeDelegate.qml +++ b/src/imports/controls/material/SwipeDelegate.qml @@ -60,7 +60,7 @@ T.SwipeDelegate { text: control.text font: control.font - color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor + color: control.enabled ? control.Material.foreground : control.Material.hintTextColor elide: Text.ElideRight visible: control.text horizontalAlignment: Text.AlignLeft diff --git a/src/imports/controls/material/Switch.qml b/src/imports/controls/material/Switch.qml index 3c9fbe51..645dc55a 100644 --- a/src/imports/controls/material/Switch.qml +++ b/src/imports/controls/material/Switch.qml @@ -73,7 +73,7 @@ T.Switch { text: control.text font: control.font - color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor + color: control.enabled ? control.Material.foreground : control.Material.hintTextColor elide: Text.ElideRight visible: control.text horizontalAlignment: Text.AlignLeft diff --git a/src/imports/controls/material/SwitchDelegate.qml b/src/imports/controls/material/SwitchDelegate.qml index 1a590774..9fb18271 100644 --- a/src/imports/controls/material/SwitchDelegate.qml +++ b/src/imports/controls/material/SwitchDelegate.qml @@ -66,7 +66,7 @@ T.SwitchDelegate { text: control.text font: control.font - color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor + color: control.enabled ? control.Material.foreground : control.Material.hintTextColor elide: Text.ElideRight visible: control.text horizontalAlignment: Text.AlignLeft diff --git a/src/imports/controls/material/TabButton.qml b/src/imports/controls/material/TabButton.qml index a900747a..a76df820 100644 --- a/src/imports/controls/material/TabButton.qml +++ b/src/imports/controls/material/TabButton.qml @@ -54,7 +54,7 @@ T.TabButton { text: control.text font: control.font elide: Text.ElideRight - color: !control.enabled ? control.Material.hintTextColor : control.down || control.checked ? control.Material.accentColor : control.Material.primaryTextColor + color: !control.enabled ? control.Material.hintTextColor : control.down || control.checked ? control.Material.accentColor : control.Material.foreground horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/material/TextArea.qml b/src/imports/controls/material/TextArea.qml index 9018df2e..db67d059 100644 --- a/src/imports/controls/material/TextArea.qml +++ b/src/imports/controls/material/TextArea.qml @@ -52,7 +52,7 @@ T.TextArea { topPadding: 8 bottomPadding: 16 - color: enabled ? Material.primaryTextColor : Material.hintTextColor + color: enabled ? Material.foreground : Material.hintTextColor selectionColor: Material.accentColor selectedTextColor: Material.primaryHighlightedTextColor diff --git a/src/imports/controls/material/TextField.qml b/src/imports/controls/material/TextField.qml index ef7ae200..e6876f1c 100644 --- a/src/imports/controls/material/TextField.qml +++ b/src/imports/controls/material/TextField.qml @@ -52,7 +52,7 @@ T.TextField { topPadding: 8 bottomPadding: 16 - color: enabled ? Material.primaryTextColor : Material.hintTextColor + color: enabled ? Material.foreground : Material.hintTextColor selectionColor: Material.accentColor selectedTextColor: Material.primaryHighlightedTextColor verticalAlignment: TextInput.AlignVCenter diff --git a/src/imports/controls/material/ToolButton.qml b/src/imports/controls/material/ToolButton.qml index d11e41ae..78b15ac2 100644 --- a/src/imports/controls/material/ToolButton.qml +++ b/src/imports/controls/material/ToolButton.qml @@ -54,7 +54,7 @@ T.ToolButton { text: control.text font: control.font color: !control.enabled ? control.Material.hintTextColor : - control.checked || control.highlighted ? control.Material.accent : control.Material.primaryTextColor + control.checked || control.highlighted ? control.Material.accent : control.Material.foreground elide: Text.ElideRight horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter diff --git a/src/imports/controls/material/ToolTip.qml b/src/imports/controls/material/ToolTip.qml index 455f79c6..559b85da 100644 --- a/src/imports/controls/material/ToolTip.qml +++ b/src/imports/controls/material/ToolTip.qml @@ -72,7 +72,7 @@ T.ToolTip { text: control.text font: control.font // TODO: wrapMode: Label.Wrap - color: control.Material.primaryTextColor + color: control.Material.foreground } background: Rectangle { diff --git a/src/imports/controls/material/Tumbler.qml b/src/imports/controls/material/Tumbler.qml index 06a012f6..b8d0e975 100644 --- a/src/imports/controls/material/Tumbler.qml +++ b/src/imports/controls/material/Tumbler.qml @@ -48,7 +48,7 @@ T.Tumbler { delegate: Text { id: label text: modelData - color: control.Material.primaryTextColor + color: control.Material.foreground font: control.font opacity: (1.0 - Math.abs(Tumbler.displacement) / (visibleItemCount / 2)) * (control.enabled ? 1 : 0.6) horizontalAlignment: Text.AlignHCenter diff --git a/src/imports/controls/material/qquickmaterialstyle.cpp b/src/imports/controls/material/qquickmaterialstyle.cpp index a4041d0d..08203482 100644 --- a/src/imports/controls/material/qquickmaterialstyle.cpp +++ b/src/imports/controls/material/qquickmaterialstyle.cpp @@ -638,7 +638,13 @@ void QQuickMaterialStyle::resetAccent() QVariant QQuickMaterialStyle::foreground() const { - return primaryTextColor(); + if (!m_hasForeground) + return QColor::fromRgba(m_theme == Light ? primaryTextColorLight : primaryTextColorDark); + if (m_customForeground) + return QColor::fromRgba(m_foreground); + if (m_foreground > BlueGrey) + return QColor(); + return QColor::fromRgba(colors[m_foreground][Shade500]); } void QQuickMaterialStyle::setForeground(const QVariant &var) @@ -814,13 +820,7 @@ QColor QQuickMaterialStyle::backgroundColor() const QColor QQuickMaterialStyle::primaryTextColor() const { - if (!m_hasForeground) - return QColor::fromRgba(m_theme == Light ? primaryTextColorLight : primaryTextColorDark); - if (m_customForeground) - return QColor::fromRgba(m_foreground); - if (m_foreground > BlueGrey) - return QColor(); - return colors[m_foreground][Shade500]; + return QColor::fromRgba(m_theme == Light ? primaryTextColorLight : primaryTextColorDark); } QColor QQuickMaterialStyle::primaryHighlightedTextColor() const diff --git a/src/imports/controls/material/qquickmaterialstyle_p.h b/src/imports/controls/material/qquickmaterialstyle_p.h index aec665f6..dbf366cd 100644 --- a/src/imports/controls/material/qquickmaterialstyle_p.h +++ b/src/imports/controls/material/qquickmaterialstyle_p.h @@ -66,7 +66,7 @@ class QQuickMaterialStyle : public QQuickStyleAttached Q_PROPERTY(QColor primaryColor READ primaryColor NOTIFY primaryChanged FINAL) // TODO: remove? Q_PROPERTY(QColor accentColor READ accentColor NOTIFY accentChanged FINAL) // TODO: remove? Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY backgroundChanged FINAL) - Q_PROPERTY(QColor primaryTextColor READ primaryTextColor NOTIFY foregroundChanged FINAL) // TODO: rename to foregroundColor()? + Q_PROPERTY(QColor primaryTextColor READ primaryTextColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor primaryHighlightedTextColor READ primaryHighlightedTextColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor secondaryTextColor READ secondaryTextColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor hintTextColor READ hintTextColor NOTIFY paletteChanged FINAL) diff --git a/src/imports/controls/plugins.qmltypes b/src/imports/controls/plugins.qmltypes index 0a89a8b0..de4e26f8 100644 --- a/src/imports/controls/plugins.qmltypes +++ b/src/imports/controls/plugins.qmltypes @@ -508,6 +508,7 @@ Module { Property { name: "down"; type: "bool" } Property { name: "pressed"; type: "bool"; isReadonly: true } Property { name: "checked"; type: "bool" } + Property { name: "checkable"; type: "bool" } Property { name: "autoExclusive"; type: "bool" } Property { name: "indicator"; type: "QQuickItem"; isPointer: true } Signal { name: "pressed" } @@ -559,7 +560,6 @@ Module { prototype: "QQuickAbstractButton" exports: ["QtQuick.Templates/Button 2.0"] exportMetaObjectRevisions: [0] - Property { name: "checkable"; type: "bool" } Property { name: "autoRepeat"; type: "bool" } Property { name: "highlighted"; type: "bool" } Property { name: "flat"; type: "bool" } @@ -894,7 +894,6 @@ Module { prototype: "QQuickAbstractButton" exports: ["QtQuick.Templates/MenuItem 2.0"] exportMetaObjectRevisions: [0] - Property { name: "checkable"; type: "bool" } Property { name: "highlighted"; type: "bool" } Signal { name: "triggered" } } diff --git a/src/imports/templates/plugins.qmltypes b/src/imports/templates/plugins.qmltypes index 31267ce2..6b644437 100644 --- a/src/imports/templates/plugins.qmltypes +++ b/src/imports/templates/plugins.qmltypes @@ -18,6 +18,7 @@ Module { Property { name: "down"; type: "bool" } Property { name: "pressed"; type: "bool"; isReadonly: true } Property { name: "checked"; type: "bool" } + Property { name: "checkable"; type: "bool" } Property { name: "autoExclusive"; type: "bool" } Property { name: "indicator"; type: "QQuickItem"; isPointer: true } Signal { name: "pressed" } @@ -69,7 +70,6 @@ Module { prototype: "QQuickAbstractButton" exports: ["QtQuick.Templates/Button 2.0"] exportMetaObjectRevisions: [0] - Property { name: "checkable"; type: "bool" } Property { name: "autoRepeat"; type: "bool" } Property { name: "highlighted"; type: "bool" } Property { name: "flat"; type: "bool" } @@ -404,7 +404,6 @@ Module { prototype: "QQuickAbstractButton" exports: ["QtQuick.Templates/MenuItem 2.0"] exportMetaObjectRevisions: [0] - Property { name: "checkable"; type: "bool" } Property { name: "highlighted"; type: "bool" } Signal { name: "triggered" } } diff --git a/src/quickcontrols2/qquickstyle.cpp b/src/quickcontrols2/qquickstyle.cpp index 4247b204..aa168301 100644 --- a/src/quickcontrols2/qquickstyle.cpp +++ b/src/quickcontrols2/qquickstyle.cpp @@ -41,6 +41,7 @@ #include <QtCore/qdir.h> #include <QtCore/qdebug.h> #include <QtCore/qsettings.h> +#include <QtCore/qlibraryinfo.h> #include <QtGui/private/qguiapplication_p.h> #include <QtQml/private/qqmlmetatype_p.h> #include <QtQml/qqmlengine.h> @@ -96,6 +97,23 @@ QT_BEGIN_NAMESPACE \sa {Styling Qt Quick Controls 2} */ +// TODO: QQmlImportDatabase::defaultImportPathList() +static QStringList defaultImportPathList() +{ + QStringList importPaths; + importPaths.reserve(3); + importPaths += QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath); + + if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty("QML2_IMPORT_PATH"))) { + const QByteArray envImportPath = qgetenv("QML2_IMPORT_PATH"); + importPaths += QString::fromLatin1(envImportPath).split(QDir::listSeparator(), QString::SkipEmptyParts); + } + + importPaths += QStringLiteral("qrc:/qt-project.org/imports"); + importPaths += QCoreApplication::applicationDirPath(); + return importPaths; +} + struct QQuickStyleSpec { QQuickStyleSpec() : custom(false), resolved(false) { } @@ -222,7 +240,7 @@ QStringList QQuickStylePrivate::stylePaths() // built-in import paths const QString targetPath = QStringLiteral("QtQuick/Controls.2"); - const QStringList importPaths = QQmlEngine().importPathList(); + const QStringList importPaths = defaultImportPathList(); for (const QString &importPath : importPaths) { QDir dir(importPath); if (dir.cd(targetPath)) diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp index 85f58fd5..350af84a 100644 --- a/src/quicktemplates2/qquickabstractbutton.cpp +++ b/src/quicktemplates2/qquickabstractbutton.cpp @@ -332,6 +332,8 @@ void QQuickAbstractButton::setPressed(bool isPressed) \qmlproperty bool QtQuick.Controls::AbstractButton::checked This property holds whether the button is checked. + + \sa checkable */ bool QQuickAbstractButton::isChecked() const { @@ -354,11 +356,21 @@ void QQuickAbstractButton::setChecked(bool checked) emit checkedChanged(); } -// We define these in QQuickAbstractButton without exposing checkable as a -// property, and instead expose it as a property in QQuickButton. -// QQuickRadioButton, QQuickSwitch and QQuickCheckBox are checkable by default, -// but if we removed the checkable code from here, they'd each have to -// duplicate it. +/*! + \qmlproperty bool QtQuick.Controls::AbstractButton::checkable + + This property holds whether the button is checkable. + + A checkable button toggles between checked (on) and unchecked (off) when + the user clicks on it or presses the space bar while the button has active + focus. + + Setting \l checked to \c true forces this property to \c true. + + The default value is \c false. + + \sa checked +*/ bool QQuickAbstractButton::isCheckable() const { Q_D(const QQuickAbstractButton); @@ -374,6 +386,7 @@ void QQuickAbstractButton::setCheckable(bool checkable) d->checkable = checkable; setAccessibleProperty("checkable", checkable); checkableChange(); + emit checkableChanged(); } /*! @@ -529,7 +542,7 @@ void QQuickAbstractButton::mouseMoveEvent(QMouseEvent *event) QQuickControl::mouseMoveEvent(event); setPressed(d->keepPressed || contains(event->pos())); - if (d->autoRepeat) + if (!d->pressed && d->autoRepeat) d->stopPressRepeat(); else if (d->holdTimer > 0 && (!d->pressed || QLineF(d->pressPoint, event->localPos()).length() > QGuiApplication::styleHints()->startDragDistance())) d->stopPressAndHold(); diff --git a/src/quicktemplates2/qquickabstractbutton_p.h b/src/quicktemplates2/qquickabstractbutton_p.h index 3b4fff6b..524dd130 100644 --- a/src/quicktemplates2/qquickabstractbutton_p.h +++ b/src/quicktemplates2/qquickabstractbutton_p.h @@ -61,6 +61,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickAbstractButton : public QQuickContr Q_PROPERTY(bool down READ isDown WRITE setDown NOTIFY downChanged RESET resetDown FINAL) Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged FINAL) Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged FINAL) + Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged FINAL) Q_PROPERTY(bool autoExclusive READ autoExclusive WRITE setAutoExclusive NOTIFY autoExclusiveChanged FINAL) Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL) @@ -107,6 +108,7 @@ Q_SIGNALS: void downChanged(); void pressedChanged(); void checkedChanged(); + void checkableChanged(); void autoExclusiveChanged(); void indicatorChanged(); diff --git a/src/quicktemplates2/qquickbutton.cpp b/src/quicktemplates2/qquickbutton.cpp index 3d00e40c..b11d2179 100644 --- a/src/quicktemplates2/qquickbutton.cpp +++ b/src/quicktemplates2/qquickbutton.cpp @@ -96,28 +96,6 @@ QQuickButton::QQuickButton(QQuickButtonPrivate &dd, QQuickItem *parent) : } /*! - \qmlproperty bool QtQuick.Controls::Button::checkable - - This property holds whether the button is checkable. - - A checkable button toggles between checked (on) and unchecked (off) when - the user clicks on it or presses the space bar while the button has active - focus. - - Setting \l {AbstractButton::}{checked} to \c true forces this property to - \c true. - - The default value is \c false. - - \sa CheckBox, Switch -*/ - -void QQuickButton::checkableChange() -{ - emit checkableChanged(); -} - -/*! \qmlproperty bool QtQuick.Controls::Button::autoRepeat This property holds whether the button repeats diff --git a/src/quicktemplates2/qquickbutton_p.h b/src/quicktemplates2/qquickbutton_p.h index 95f94f10..5edbbe4e 100644 --- a/src/quicktemplates2/qquickbutton_p.h +++ b/src/quicktemplates2/qquickbutton_p.h @@ -57,7 +57,6 @@ class QQuickButtonPrivate; class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickButton : public QQuickAbstractButton { Q_OBJECT - Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged FINAL) Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY autoRepeatChanged FINAL) Q_PROPERTY(bool highlighted READ isHighlighted WRITE setHighlighted NOTIFY highlightedChanged FINAL) Q_PROPERTY(bool flat READ isFlat WRITE setFlat NOTIFY flatChanged FINAL) @@ -72,7 +71,6 @@ public: void setFlat(bool flat); Q_SIGNALS: - void checkableChanged(); void autoRepeatChanged(); void highlightedChanged(); void flatChanged(); @@ -80,7 +78,6 @@ Q_SIGNALS: protected: QQuickButton(QQuickButtonPrivate &dd, QQuickItem *parent); - void checkableChange() override; void autoRepeatChange() override; QFont defaultFont() const override; diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp index 4c8576a7..9475cff7 100644 --- a/src/quicktemplates2/qquickdial.cpp +++ b/src/quicktemplates2/qquickdial.cpp @@ -283,8 +283,8 @@ void QQuickDial::setValue(qreal value) This property holds the logical position of the handle. - The position is defined as a percentage of the control's angle range (the - range within which the handle can be moved) scaled to \c {0.0 - 1.0}. + The position is expressed as a fraction of the control's angle range (the + range within which the handle can be moved) in the range \c {0.0 - 1.0}. Unlike the \l value property, the \c position is continuously updated while the handle is dragged. diff --git a/src/quicktemplates2/qquickmenuitem.cpp b/src/quicktemplates2/qquickmenuitem.cpp index 564d3f38..cb23df07 100644 --- a/src/quicktemplates2/qquickmenuitem.cpp +++ b/src/quicktemplates2/qquickmenuitem.cpp @@ -110,22 +110,6 @@ QQuickMenuItem::QQuickMenuItem(QQuickItem *parent) : connect(this, &QQuickAbstractButton::clicked, this, &QQuickMenuItem::triggered); } -/*! - \qmlproperty bool QtQuick.Controls::MenuItem::checkable - - This property holds whether the menu item is checkable. - - A checkable menu item toggles between checked (on) and unchecked (off) when - the user clicks on it or interacts with it via the keyboard. - - \sa {AbstractButton::}{checked} -*/ - -void QQuickMenuItem::checkableChange() -{ - emit checkableChanged(); -} - QFont QQuickMenuItem::defaultFont() const { return QQuickControlPrivate::themeFont(QPlatformTheme::MenuItemFont); diff --git a/src/quicktemplates2/qquickmenuitem_p.h b/src/quicktemplates2/qquickmenuitem_p.h index 6c717e13..258a096f 100644 --- a/src/quicktemplates2/qquickmenuitem_p.h +++ b/src/quicktemplates2/qquickmenuitem_p.h @@ -57,7 +57,6 @@ class QQuickMenuItemPrivate; class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickMenuItem : public QQuickAbstractButton { Q_OBJECT - Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged FINAL) Q_PROPERTY(bool highlighted READ isHighlighted WRITE setHighlighted NOTIFY highlightedChanged FINAL) public: @@ -67,12 +66,10 @@ public: void setHighlighted(bool highlighted); Q_SIGNALS: - void checkableChanged(); void triggered(); void highlightedChanged(); protected: - void checkableChange() override; QFont defaultFont() const override; #ifndef QT_NO_ACCESSIBILITY diff --git a/src/quicktemplates2/qquickprogressbar.cpp b/src/quicktemplates2/qquickprogressbar.cpp index 5d5503e6..d8ada6f4 100644 --- a/src/quicktemplates2/qquickprogressbar.cpp +++ b/src/quicktemplates2/qquickprogressbar.cpp @@ -192,7 +192,7 @@ void QQuickProgressBar::setValue(qreal value) This property holds the logical position of the progress. - The position is defined as a percentage of the value, scaled to + The position is expressed as a fraction of the value, in the range \c {0.0 - 1.0}. For visualizing the progress, the right-to-left aware \l visualPosition should be used instead. @@ -212,7 +212,7 @@ qreal QQuickProgressBar::position() const This property holds the visual position of the progress. - The position is defined as a percentage of the value, scaled to \c {0.0 - 1.0}. + The position is expressed as a fraction of the value, in the range \c {0.0 - 1.0}. When the control is \l {Control::mirrored}{mirrored}, \c visuaPosition is equal to \c {1.0 - position}. This makes \c visualPosition suitable for visualizing the progress, taking right-to-left support into account. diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp index ffe2e976..cd6395bd 100644 --- a/src/quicktemplates2/qquickrangeslider.cpp +++ b/src/quicktemplates2/qquickrangeslider.cpp @@ -68,8 +68,8 @@ QT_BEGIN_NAMESPACE } \endcode - The \l {first.position} and \l {second.position} properties are defined as a - percentage of the control's size, scaled within the range \c {0.0 - 1.0}. + The \l {first.position} and \l {second.position} properties are expressed as + fractions of the control's size, in the range \c {0.0 - 1.0}. The \l {first.visualPosition} and \l {second.visualPosition} properties are the same, except that they are reversed in a \l {Right-to-left User Interfaces}{right-to-left} application. @@ -489,7 +489,7 @@ void QQuickRangeSlider::setTo(qreal to) \li visualPosition \li This property holds the visual position of the first handle. - The position is defined as a percentage of the control's size, scaled to + The position is expressed as a fraction of the control's size, in the range \c {0.0 - 1.0}. When the control is \l {Control::mirrored}{mirrored}, the value is equal to \c {1.0 - position}. This makes the value suitable for visualizing the slider, taking right-to-left support into account. @@ -497,8 +497,8 @@ void QQuickRangeSlider::setTo(qreal to) \li position \li This property holds the logical position of the first handle. - The position is defined as a percentage of the control's size, scaled - to \c {0.0 - 1.0}. Unlike \l {first.value}{value}, position is + The position is expressed as a fraction of the control's size, in the range + \c {0.0 - 1.0}. Unlike \l {first.value}{value}, position is continuously updated while the handle is dragged. For visualizing a slider, the right-to-left aware \l {first.visualPosition}{visualPosition} should be used instead. @@ -553,7 +553,7 @@ QQuickRangeSliderNode *QQuickRangeSlider::first() const \li visualPosition \li This property holds the visual position of the second handle. - The position is defined as a percentage of the control's size, scaled to + The position is expressed as a fraction of the control's size, in the range \c {0.0 - 1.0}. When the control is \l {Control::mirrored}{mirrored}, the value is equal to \c {1.0 - position}. This makes the value suitable for visualizing the slider, taking right-to-left support into account. @@ -561,8 +561,8 @@ QQuickRangeSliderNode *QQuickRangeSlider::first() const \li position \li This property holds the logical position of the second handle. - The position is defined as a percentage of the control's size, scaled - to \c {0.0 - 1.0}. Unlike \l {second.value}{value}, position is + The position is expressed as a fraction of the control's size, in the range + \c {0.0 - 1.0}. Unlike \l {second.value}{value}, position is continuously updated while the handle is dragged. For visualizing a slider, the right-to-left aware \l {second.visualPosition}{visualPosition} should be used instead. diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp index 0b91d61d..d2d5da89 100644 --- a/src/quicktemplates2/qquickslider.cpp +++ b/src/quicktemplates2/qquickslider.cpp @@ -64,8 +64,8 @@ QT_BEGIN_NAMESPACE } \endcode - The \l position property is defined as a percentage of the control's size, - scaled within the range \c {0.0 - 1.0}. The \l visualPosition property is + The \l position property is expressed as a fraction of the control's size, + in the range \c {0.0 - 1.0}. The \l visualPosition property is the same, except that it is reversed in a \l {Right-to-left User Interfaces}{right-to-left} application. The visualPosition is useful for positioning the handle when styling Slider. @@ -259,8 +259,8 @@ void QQuickSlider::setValue(qreal value) This property holds the logical position of the handle. - The position is defined as a percentage of the control's size, scaled - to \c {0.0 - 1.0}. The \c position is continuously updated while the + The position is expressed as a fraction of the control's size, in the range + \c {0.0 - 1.0}. The \c position is continuously updated while the handle is dragged. For visualizing a slider, the right-to-left aware \l visualPosition should be used instead. @@ -278,7 +278,7 @@ qreal QQuickSlider::position() const This property holds the visual position of the handle. - The position is defined as a percentage of the control's size, scaled to + The position is expressed as a fraction of the control's size, in the range \c {0.0 - 1.0}. When the control is \l {Control::mirrored}{mirrored}, the value is equal to \c {1.0 - position}. This makes the value suitable for visualizing the slider, taking right-to-left support into account. diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp index 957200a4..506405fe 100644 --- a/src/quicktemplates2/qquickspinbox.cpp +++ b/src/quicktemplates2/qquickspinbox.cpp @@ -252,7 +252,8 @@ bool QQuickSpinBoxPrivate::handleMouseMoveEvent(QQuickItem *child, QMouseEvent * bool pressed = up->isPressed() || down->isPressed(); q->setAccessibleProperty("pressed", pressed); - stopPressRepeat(); + if (!pressed) + stopPressRepeat(); return pressed; } |