diff options
54 files changed, 214 insertions, 103 deletions
diff --git a/src/imports/controls/material/Button.qml b/src/imports/controls/material/Button.qml index 971992ab..8842f0ac 100644 --- a/src/imports/controls/material/Button.qml +++ b/src/imports/controls/material/Button.qml @@ -53,8 +53,6 @@ T.Button { leftPadding: padding - 4 rightPadding: padding - 4 - hoverEnabled: Qt.styleHints.useHoverEffects - Material.elevation: flat ? control.down || control.hovered ? 2 : 0 : control.down ? 8 : 2 Material.background: flat ? "transparent" : undefined diff --git a/src/imports/controls/material/CheckBox.qml b/src/imports/controls/material/CheckBox.qml index 60b23004..bb760bbd 100644 --- a/src/imports/controls/material/CheckBox.qml +++ b/src/imports/controls/material/CheckBox.qml @@ -54,8 +54,6 @@ T.CheckBox { topPadding: padding + 7 bottomPadding: padding + 7 - hoverEnabled: Qt.styleHints.useHoverEffects - indicator: CheckIndicator { x: text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 y: control.topPadding + (control.availableHeight - height) / 2 diff --git a/src/imports/controls/material/CheckDelegate.qml b/src/imports/controls/material/CheckDelegate.qml index c932b69e..e77e0a9c 100644 --- a/src/imports/controls/material/CheckDelegate.qml +++ b/src/imports/controls/material/CheckDelegate.qml @@ -54,8 +54,6 @@ T.CheckDelegate { bottomPadding: 14 spacing: 16 - hoverEnabled: Qt.styleHints.useHoverEffects - indicator: CheckIndicator { x: text ? (control.mirrored ? control.leftPadding : control.width - width - control.rightPadding) : control.leftPadding + (control.availableWidth - width) / 2 y: control.topPadding + (control.availableHeight - height) / 2 diff --git a/src/imports/controls/material/ComboBox.qml b/src/imports/controls/material/ComboBox.qml index 6847ba6a..a87b5a86 100644 --- a/src/imports/controls/material/ComboBox.qml +++ b/src/imports/controls/material/ComboBox.qml @@ -54,8 +54,6 @@ T.ComboBox { spacing: 6 padding: 16 - hoverEnabled: Qt.styleHints.useHoverEffects - Material.elevation: flat ? control.pressed || control.hovered ? 2 : 0 : control.pressed ? 8 : 2 Material.background: flat ? "transparent" : undefined diff --git a/src/imports/controls/material/Dial.qml b/src/imports/controls/material/Dial.qml index 9f5d88c3..ce76c2a7 100644 --- a/src/imports/controls/material/Dial.qml +++ b/src/imports/controls/material/Dial.qml @@ -45,8 +45,6 @@ T.Dial { implicitWidth: 100 implicitHeight: 100 - hoverEnabled: Qt.styleHints.useHoverEffects - background: Rectangle { x: control.width / 2 - width / 2 y: control.height / 2 - height / 2 diff --git a/src/imports/controls/material/ItemDelegate.qml b/src/imports/controls/material/ItemDelegate.qml index ec03b129..ad9604fd 100644 --- a/src/imports/controls/material/ItemDelegate.qml +++ b/src/imports/controls/material/ItemDelegate.qml @@ -52,8 +52,6 @@ T.ItemDelegate { padding: 16 spacing: 16 - hoverEnabled: Qt.styleHints.useHoverEffects - contentItem: Text { leftPadding: control.checkable && !control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0 rightPadding: control.checkable && control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0 diff --git a/src/imports/controls/material/MenuItem.qml b/src/imports/controls/material/MenuItem.qml index 09a9909c..15c2d392 100644 --- a/src/imports/controls/material/MenuItem.qml +++ b/src/imports/controls/material/MenuItem.qml @@ -54,8 +54,6 @@ T.MenuItem { bottomPadding: 12 spacing: 16 - hoverEnabled: Qt.styleHints.useHoverEffects - indicator: CheckIndicator { x: text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 y: control.topPadding + (control.availableHeight - height) / 2 diff --git a/src/imports/controls/material/RadioButton.qml b/src/imports/controls/material/RadioButton.qml index c3afbfd9..6faf1caa 100644 --- a/src/imports/controls/material/RadioButton.qml +++ b/src/imports/controls/material/RadioButton.qml @@ -54,8 +54,6 @@ T.RadioButton { topPadding: padding + 6 bottomPadding: padding + 6 - hoverEnabled: Qt.styleHints.useHoverEffects - indicator: RadioIndicator { x: text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 y: control.topPadding + (control.availableHeight - height) / 2 diff --git a/src/imports/controls/material/RadioDelegate.qml b/src/imports/controls/material/RadioDelegate.qml index 150d72ae..4b7af82a 100644 --- a/src/imports/controls/material/RadioDelegate.qml +++ b/src/imports/controls/material/RadioDelegate.qml @@ -54,8 +54,6 @@ T.RadioDelegate { bottomPadding: 8 spacing: 16 - hoverEnabled: Qt.styleHints.useHoverEffects - indicator: RadioIndicator { x: text ? (control.mirrored ? control.leftPadding : control.width - width - control.rightPadding) : control.leftPadding + (control.availableWidth - width) / 2 y: control.topPadding + (control.availableHeight - height) / 2 diff --git a/src/imports/controls/material/RangeSlider.qml b/src/imports/controls/material/RangeSlider.qml index 641c00f1..4381fd41 100644 --- a/src/imports/controls/material/RangeSlider.qml +++ b/src/imports/controls/material/RangeSlider.qml @@ -51,8 +51,6 @@ T.RangeSlider { padding: 6 - hoverEnabled: Qt.styleHints.useHoverEffects - first.handle: SliderHandle { x: control.leftPadding + (horizontal ? control.first.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) y: control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.first.visualPosition * (control.availableHeight - height)) diff --git a/src/imports/controls/material/RoundButton.qml b/src/imports/controls/material/RoundButton.qml index c020db74..e385ac1b 100644 --- a/src/imports/controls/material/RoundButton.qml +++ b/src/imports/controls/material/RoundButton.qml @@ -51,8 +51,6 @@ T.RoundButton { // external vertical padding is 6 (to increase touch area) padding: 12 - hoverEnabled: Qt.styleHints.useHoverEffects - Material.elevation: flat ? control.down || control.hovered ? 2 : 0 : control.down ? 8 : 2 Material.background: flat ? "transparent" : undefined diff --git a/src/imports/controls/material/ScrollBar.qml b/src/imports/controls/material/ScrollBar.qml index afc30723..2874f125 100644 --- a/src/imports/controls/material/ScrollBar.qml +++ b/src/imports/controls/material/ScrollBar.qml @@ -48,8 +48,6 @@ T.ScrollBar { padding: 1 - hoverEnabled: Qt.styleHints.useHoverEffects - contentItem: Rectangle { id: handle diff --git a/src/imports/controls/material/Slider.qml b/src/imports/controls/material/Slider.qml index 1c915b32..7cf858e7 100644 --- a/src/imports/controls/material/Slider.qml +++ b/src/imports/controls/material/Slider.qml @@ -49,8 +49,6 @@ T.Slider { padding: 6 - hoverEnabled: Qt.styleHints.useHoverEffects - handle: SliderHandle { x: control.leftPadding + (horizontal ? control.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) y: control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.visualPosition * (control.availableHeight - height)) diff --git a/src/imports/controls/material/SpinBox.qml b/src/imports/controls/material/SpinBox.qml index 257e9bf2..b371f714 100644 --- a/src/imports/controls/material/SpinBox.qml +++ b/src/imports/controls/material/SpinBox.qml @@ -58,8 +58,6 @@ T.SpinBox { leftPadding: (control.mirrored ? (up.indicator ? up.indicator.width : 0) : (down.indicator ? down.indicator.width : 0)) rightPadding: (control.mirrored ? (down.indicator ? down.indicator.width : 0) : (up.indicator ? up.indicator.width : 0)) - hoverEnabled: Qt.styleHints.useHoverEffects - validator: IntValidator { locale: control.locale.name bottom: Math.min(control.from, control.to) diff --git a/src/imports/controls/material/SwipeDelegate.qml b/src/imports/controls/material/SwipeDelegate.qml index 6f614833..23db44fd 100644 --- a/src/imports/controls/material/SwipeDelegate.qml +++ b/src/imports/controls/material/SwipeDelegate.qml @@ -54,8 +54,6 @@ T.SwipeDelegate { bottomPadding: 8 spacing: 16 - hoverEnabled: Qt.styleHints.useHoverEffects - contentItem: Text { leftPadding: !control.mirrored ? (control.indicator ? control.indicator.width + control.spacing : 0) : 0 rightPadding: control.mirrored ? (control.indicator ? control.indicator.width + control.spacing : 0) : 0 diff --git a/src/imports/controls/material/Switch.qml b/src/imports/controls/material/Switch.qml index b833fbbf..3c9fbe51 100644 --- a/src/imports/controls/material/Switch.qml +++ b/src/imports/controls/material/Switch.qml @@ -52,8 +52,6 @@ T.Switch { padding: 8 spacing: 8 - hoverEnabled: Qt.styleHints.useHoverEffects - indicator: SwitchIndicator { x: text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 y: control.topPadding + (control.availableHeight - height) / 2 diff --git a/src/imports/controls/material/SwitchDelegate.qml b/src/imports/controls/material/SwitchDelegate.qml index da084168..1a590774 100644 --- a/src/imports/controls/material/SwitchDelegate.qml +++ b/src/imports/controls/material/SwitchDelegate.qml @@ -54,8 +54,6 @@ T.SwitchDelegate { bottomPadding: 8 spacing: 16 - hoverEnabled: Qt.styleHints.useHoverEffects - indicator: SwitchIndicator { x: text ? (control.mirrored ? control.leftPadding : control.width - width - control.rightPadding) : control.leftPadding + (control.availableWidth - width) / 2 y: control.topPadding + (control.availableHeight - height) / 2 diff --git a/src/imports/controls/material/TabButton.qml b/src/imports/controls/material/TabButton.qml index 0fb16e63..a900747a 100644 --- a/src/imports/controls/material/TabButton.qml +++ b/src/imports/controls/material/TabButton.qml @@ -50,8 +50,6 @@ T.TabButton { padding: 12 - hoverEnabled: Qt.styleHints.useHoverEffects - contentItem: Text { text: control.text font: control.font diff --git a/src/imports/controls/material/TextArea.qml b/src/imports/controls/material/TextArea.qml index 3f30af00..8fdead60 100644 --- a/src/imports/controls/material/TextArea.qml +++ b/src/imports/controls/material/TextArea.qml @@ -51,8 +51,6 @@ T.TextArea { topPadding: 8 bottomPadding: 16 - hoverEnabled: Qt.styleHints.useHoverEffects - color: enabled ? Material.primaryTextColor : 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 edab2385..be51fd13 100644 --- a/src/imports/controls/material/TextField.qml +++ b/src/imports/controls/material/TextField.qml @@ -51,8 +51,6 @@ T.TextField { topPadding: 8 bottomPadding: 16 - hoverEnabled: Qt.styleHints.useHoverEffects - color: enabled ? Material.primaryTextColor : Material.hintTextColor selectionColor: Material.accentColor selectedTextColor: Material.primaryHighlightedTextColor diff --git a/src/imports/controls/material/ToolButton.qml b/src/imports/controls/material/ToolButton.qml index dbeb7a05..d11e41ae 100644 --- a/src/imports/controls/material/ToolButton.qml +++ b/src/imports/controls/material/ToolButton.qml @@ -50,8 +50,6 @@ T.ToolButton { padding: 6 - hoverEnabled: Qt.styleHints.useHoverEffects - contentItem: Text { text: control.text font: control.font diff --git a/src/imports/controls/universal/Button.qml b/src/imports/controls/universal/Button.qml index 30d30380..aa65e714 100644 --- a/src/imports/controls/universal/Button.qml +++ b/src/imports/controls/universal/Button.qml @@ -47,8 +47,6 @@ T.Button { contentItem.implicitHeight + topPadding + bottomPadding) baselineOffset: contentItem.y + contentItem.baselineOffset - hoverEnabled: Qt.styleHints.useHoverEffects - padding: 8 topPadding: padding - 4 bottomPadding: padding - 4 diff --git a/src/imports/controls/universal/CheckBox.qml b/src/imports/controls/universal/CheckBox.qml index bfaf266e..916348f9 100644 --- a/src/imports/controls/universal/CheckBox.qml +++ b/src/imports/controls/universal/CheckBox.qml @@ -49,8 +49,6 @@ T.CheckBox { indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) baselineOffset: contentItem.y + contentItem.baselineOffset - hoverEnabled: Qt.styleHints.useHoverEffects - padding: 6 spacing: 8 diff --git a/src/imports/controls/universal/CheckDelegate.qml b/src/imports/controls/universal/CheckDelegate.qml index e48687e5..42e7b10c 100644 --- a/src/imports/controls/universal/CheckDelegate.qml +++ b/src/imports/controls/universal/CheckDelegate.qml @@ -48,8 +48,6 @@ T.CheckDelegate { indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) baselineOffset: contentItem.y + contentItem.baselineOffset - hoverEnabled: Qt.styleHints.useHoverEffects - spacing: 12 padding: 12 diff --git a/src/imports/controls/universal/ComboBox.qml b/src/imports/controls/universal/ComboBox.qml index 39cd7d20..2d768a1d 100644 --- a/src/imports/controls/universal/ComboBox.qml +++ b/src/imports/controls/universal/ComboBox.qml @@ -50,8 +50,6 @@ T.ComboBox { indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) baselineOffset: contentItem.y + contentItem.baselineOffset - hoverEnabled: Qt.styleHints.useHoverEffects - spacing: 10 padding: 12 topPadding: padding - 7 diff --git a/src/imports/controls/universal/Dial.qml b/src/imports/controls/universal/Dial.qml index d50b066b..9eaf69ba 100644 --- a/src/imports/controls/universal/Dial.qml +++ b/src/imports/controls/universal/Dial.qml @@ -44,8 +44,6 @@ T.Dial { implicitWidth: 100 implicitHeight: 100 - hoverEnabled: Qt.styleHints.useHoverEffects - background: Rectangle { x: control.width / 2 - width / 2 y: control.height / 2 - height / 2 diff --git a/src/imports/controls/universal/ItemDelegate.qml b/src/imports/controls/universal/ItemDelegate.qml index afba2b10..a8d55ba6 100644 --- a/src/imports/controls/universal/ItemDelegate.qml +++ b/src/imports/controls/universal/ItemDelegate.qml @@ -48,8 +48,6 @@ T.ItemDelegate { indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) baselineOffset: contentItem.y + contentItem.baselineOffset - hoverEnabled: Qt.styleHints.useHoverEffects - spacing: 12 padding: 12 diff --git a/src/imports/controls/universal/MenuItem.qml b/src/imports/controls/universal/MenuItem.qml index 24f34440..380a5b0e 100644 --- a/src/imports/controls/universal/MenuItem.qml +++ b/src/imports/controls/universal/MenuItem.qml @@ -48,8 +48,6 @@ T.MenuItem { indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) baselineOffset: contentItem.y + contentItem.baselineOffset - hoverEnabled: Qt.styleHints.useHoverEffects - padding: 12 topPadding: padding - 1 bottomPadding: padding + 1 diff --git a/src/imports/controls/universal/RadioButton.qml b/src/imports/controls/universal/RadioButton.qml index 99a5c6d6..8f599e55 100644 --- a/src/imports/controls/universal/RadioButton.qml +++ b/src/imports/controls/universal/RadioButton.qml @@ -49,8 +49,6 @@ T.RadioButton { indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) baselineOffset: contentItem.y + contentItem.baselineOffset - hoverEnabled: Qt.styleHints.useHoverEffects - padding: 6 spacing: 8 diff --git a/src/imports/controls/universal/RadioDelegate.qml b/src/imports/controls/universal/RadioDelegate.qml index 0794a082..14680cd6 100644 --- a/src/imports/controls/universal/RadioDelegate.qml +++ b/src/imports/controls/universal/RadioDelegate.qml @@ -48,8 +48,6 @@ T.RadioDelegate { indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) baselineOffset: contentItem.y + contentItem.baselineOffset - hoverEnabled: Qt.styleHints.useHoverEffects - spacing: 12 padding: 12 diff --git a/src/imports/controls/universal/RangeSlider.qml b/src/imports/controls/universal/RangeSlider.qml index 0b78962e..fec8bb18 100644 --- a/src/imports/controls/universal/RangeSlider.qml +++ b/src/imports/controls/universal/RangeSlider.qml @@ -48,8 +48,6 @@ T.RangeSlider { Math.max(first.handle ? first.handle.implicitHeight : 0, second.handle ? second.handle.implicitHeight : 0) + topPadding + bottomPadding) - hoverEnabled: Qt.styleHints.useHoverEffects - padding: 6 first.handle: Rectangle { diff --git a/src/imports/controls/universal/RoundButton.qml b/src/imports/controls/universal/RoundButton.qml index 6062b985..9a50c0fe 100644 --- a/src/imports/controls/universal/RoundButton.qml +++ b/src/imports/controls/universal/RoundButton.qml @@ -47,8 +47,6 @@ T.RoundButton { contentItem.implicitHeight + topPadding + bottomPadding) baselineOffset: contentItem.y + contentItem.baselineOffset - hoverEnabled: Qt.styleHints.useHoverEffects - padding: 8 property bool useSystemFocusVisuals: true diff --git a/src/imports/controls/universal/ScrollBar.qml b/src/imports/controls/universal/ScrollBar.qml index 7c1242fb..6d5c84fe 100644 --- a/src/imports/controls/universal/ScrollBar.qml +++ b/src/imports/controls/universal/ScrollBar.qml @@ -46,8 +46,6 @@ T.ScrollBar { implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem.implicitHeight + topPadding + bottomPadding) - hoverEnabled: Qt.styleHints.useHoverEffects - // TODO: arrows contentItem: Rectangle { diff --git a/src/imports/controls/universal/Slider.qml b/src/imports/controls/universal/Slider.qml index b059a9c5..472f5455 100644 --- a/src/imports/controls/universal/Slider.qml +++ b/src/imports/controls/universal/Slider.qml @@ -46,8 +46,6 @@ T.Slider { implicitHeight: Math.max(background ? background.implicitHeight : 0, (handle ? handle.implicitHeight : 0) + topPadding + bottomPadding) - hoverEnabled: Qt.styleHints.useHoverEffects - padding: 6 property bool useSystemFocusVisuals: true diff --git a/src/imports/controls/universal/SpinBox.qml b/src/imports/controls/universal/SpinBox.qml index b527fc8f..57120a7b 100644 --- a/src/imports/controls/universal/SpinBox.qml +++ b/src/imports/controls/universal/SpinBox.qml @@ -51,8 +51,6 @@ T.SpinBox { down.indicator ? down.indicator.implicitHeight : 0) baselineOffset: contentItem.y + contentItem.baselineOffset - hoverEnabled: Qt.styleHints.useHoverEffects - // TextControlThemePadding + 2 (border) padding: 12 topPadding: padding - 7 diff --git a/src/imports/controls/universal/SwipeDelegate.qml b/src/imports/controls/universal/SwipeDelegate.qml index 71720ef2..bc82e40e 100644 --- a/src/imports/controls/universal/SwipeDelegate.qml +++ b/src/imports/controls/universal/SwipeDelegate.qml @@ -48,8 +48,6 @@ T.SwipeDelegate { indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) baselineOffset: contentItem.y + contentItem.baselineOffset - hoverEnabled: Qt.styleHints.useHoverEffects - spacing: 12 padding: 12 diff --git a/src/imports/controls/universal/Switch.qml b/src/imports/controls/universal/Switch.qml index 23703dee..2b0012d5 100644 --- a/src/imports/controls/universal/Switch.qml +++ b/src/imports/controls/universal/Switch.qml @@ -48,8 +48,6 @@ T.Switch { indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) baselineOffset: contentItem.y + contentItem.baselineOffset - hoverEnabled: Qt.styleHints.useHoverEffects - padding: 5 spacing: 8 diff --git a/src/imports/controls/universal/SwitchDelegate.qml b/src/imports/controls/universal/SwitchDelegate.qml index b45a3795..5e4a1c52 100644 --- a/src/imports/controls/universal/SwitchDelegate.qml +++ b/src/imports/controls/universal/SwitchDelegate.qml @@ -48,8 +48,6 @@ T.SwitchDelegate { indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) baselineOffset: contentItem.y + contentItem.baselineOffset - hoverEnabled: Qt.styleHints.useHoverEffects - spacing: 12 padding: 12 diff --git a/src/imports/controls/universal/TabButton.qml b/src/imports/controls/universal/TabButton.qml index 2b54b30f..04f04291 100644 --- a/src/imports/controls/universal/TabButton.qml +++ b/src/imports/controls/universal/TabButton.qml @@ -47,8 +47,6 @@ T.TabButton { contentItem.implicitHeight + topPadding + bottomPadding) baselineOffset: contentItem.y + contentItem.baselineOffset - hoverEnabled: Qt.styleHints.useHoverEffects - padding: 12 // PivotItemMargin contentItem: Text { diff --git a/src/imports/controls/universal/TextArea.qml b/src/imports/controls/universal/TextArea.qml index 57ccaac2..8d422a2c 100644 --- a/src/imports/controls/universal/TextArea.qml +++ b/src/imports/controls/universal/TextArea.qml @@ -48,8 +48,6 @@ T.TextArea { background ? background.implicitHeight : 0, placeholder.implicitHeight + topPadding + bottomPadding) - hoverEnabled: Qt.styleHints.useHoverEffects - // TextControlThemePadding + 2 (border) padding: 12 topPadding: padding - 7 diff --git a/src/imports/controls/universal/TextField.qml b/src/imports/controls/universal/TextField.qml index 6395e995..5723e484 100644 --- a/src/imports/controls/universal/TextField.qml +++ b/src/imports/controls/universal/TextField.qml @@ -48,8 +48,6 @@ T.TextField { background ? background.implicitHeight : 0, placeholder.implicitHeight + topPadding + bottomPadding) - hoverEnabled: Qt.styleHints.useHoverEffects - // TextControlThemePadding + 2 (border) padding: 12 topPadding: padding - 7 diff --git a/src/imports/controls/universal/ToolButton.qml b/src/imports/controls/universal/ToolButton.qml index ee00ca54..4dad17f7 100644 --- a/src/imports/controls/universal/ToolButton.qml +++ b/src/imports/controls/universal/ToolButton.qml @@ -47,8 +47,6 @@ T.ToolButton { contentItem.implicitHeight + topPadding + bottomPadding) baselineOffset: contentItem.y + contentItem.baselineOffset - hoverEnabled: Qt.styleHints.useHoverEffects - padding: 6 property bool useSystemFocusVisuals: true diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index e89cc54d..1db532b9 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -109,7 +109,8 @@ QQuickControlPrivate::ExtraData::ExtraData() } QQuickControlPrivate::QQuickControlPrivate() : - hasTopPadding(false), hasLeftPadding(false), hasRightPadding(false), hasBottomPadding(false), hasLocale(false), hovered(false), wheelEnabled(false), + hasTopPadding(false), hasLeftPadding(false), hasRightPadding(false), hasBottomPadding(false), + hasLocale(false), hovered(false), wheelEnabled(false), explicitHoverEnabled(false), padding(0), topPadding(0), leftPadding(0), rightPadding(0), bottomPadding(0), spacing(0), focusPolicy(Qt::NoFocus), focusReason(Qt::OtherFocusReason), background(nullptr), contentItem(nullptr), accessibleAttached(nullptr) @@ -361,6 +362,62 @@ void QQuickControlPrivate::updateFontRecur(QQuickItem *item, const QFont &f) } } +void QQuickControlPrivate::updateHoverEnabled(bool enabled, bool xplicit) +{ + Q_Q(QQuickControl); + if (!xplicit && explicitHoverEnabled) + return; + + bool wasEnabled = q->isHoverEnabled(); + explicitHoverEnabled = xplicit; + if (wasEnabled != enabled) { + q->setAcceptHoverEvents(enabled); + QQuickControlPrivate::updateHoverEnabledRecur(q, enabled); + emit q->hoverEnabledChanged(); + } +} + +void QQuickControlPrivate::updateHoverEnabledRecur(QQuickItem *item, bool enabled) +{ + const auto childItems = item->childItems(); + for (QQuickItem *child : childItems) { + if (QQuickControl *control = qobject_cast<QQuickControl *>(child)) + QQuickControlPrivate::get(control)->updateHoverEnabled(enabled, false); + else + updateHoverEnabledRecur(child, enabled); + } +} + +bool QQuickControlPrivate::calcHoverEnabled(const QQuickItem *item) +{ + const QQuickItem *p = item; + while (p) { + // QQuickPopupItem accepts hover events to avoid leaking them through. + // Don't inherit that to the children of the popup, but fallback to the + // environment variable or style hint. + if (qobject_cast<const QQuickPopupItem *>(p)) + break; + + if (const QQuickControl *control = qobject_cast<const QQuickControl *>(p)) + return control->isHoverEnabled(); + + QVariant v = p->property("hoverEnabled"); + if (v.isValid() && v.userType() == QMetaType::Bool) + return v.toBool(); + + p = p->parentItem(); + } + + bool ok = false; + int env = qEnvironmentVariableIntValue("QT_QUICK_CONTROLS_HOVER_ENABLED", &ok); + if (ok) + return env != 0; + + // TODO: QQuickApplicationWindow::isHoverEnabled() + + return QGuiApplication::styleHints()->useHoverEffects(); +} + QString QQuickControl::accessibleName() const { #ifndef QT_NO_ACCESSIBILITY @@ -429,6 +486,8 @@ void QQuickControl::itemChange(QQuickItem::ItemChange change, const QQuickItem:: d->resolveFont(); if (!d->hasLocale) d->updateLocale(QQuickControlPrivate::calcLocale(d->parentItem), false); // explicit=false + if (!d->explicitHoverEnabled) + d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false } break; case ItemActiveFocusHasChanged: @@ -958,7 +1017,11 @@ void QQuickControl::setHovered(bool hovered) /*! \qmlproperty bool QtQuick.Controls::Control::hoverEnabled - This property determines whether the control accepts hover events. The default value is \c false. + This property determines whether the control accepts hover events. The default value + is \c Qt.styleHints.useHoverEffects. + + Setting this property propagates the value to all child controls that do not have + \c hoverEnabled explicitly set. \sa hovered */ @@ -971,11 +1034,20 @@ bool QQuickControl::isHoverEnabled() const void QQuickControl::setHoverEnabled(bool enabled) { Q_D(QQuickControl); - if (enabled == d->hoverEnabled) + if (d->explicitHoverEnabled && enabled == d->hoverEnabled) + return; + + d->updateHoverEnabled(enabled, true); // explicit=true +} + +void QQuickControl::resetHoverEnabled() +{ + Q_D(QQuickControl); + if (!d->explicitHoverEnabled) return; - setAcceptHoverEvents(enabled); - emit hoverEnabledChanged(); + d->explicitHoverEnabled = false; + d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false } /*! @@ -1122,6 +1194,8 @@ void QQuickControl::componentComplete() QQuickItem::componentComplete(); if (!d->hasLocale) d->locale = QQuickControlPrivate::calcLocale(d->parentItem); + if (!d->explicitHoverEnabled) + setAcceptHoverEvents(QQuickControlPrivate::calcHoverEnabled(d->parentItem)); #ifndef QT_NO_ACCESSIBILITY if (!d->accessibleAttached && QAccessible::isActive()) accessibilityActiveChanged(true); diff --git a/src/quicktemplates2/qquickcontrol_p.h b/src/quicktemplates2/qquickcontrol_p.h index 9027743a..81dd615f 100644 --- a/src/quicktemplates2/qquickcontrol_p.h +++ b/src/quicktemplates2/qquickcontrol_p.h @@ -74,7 +74,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickControl : public QQuickItem Q_PROPERTY(Qt::FocusReason focusReason READ focusReason WRITE setFocusReason NOTIFY focusReasonChanged FINAL) Q_PROPERTY(bool visualFocus READ hasVisualFocus NOTIFY visualFocusChanged FINAL) Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged FINAL) - Q_PROPERTY(bool hoverEnabled READ isHoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged FINAL) + Q_PROPERTY(bool hoverEnabled READ isHoverEnabled WRITE setHoverEnabled RESET resetHoverEnabled NOTIFY hoverEnabledChanged FINAL) Q_PROPERTY(bool wheelEnabled READ isWheelEnabled WRITE setWheelEnabled NOTIFY wheelEnabledChanged FINAL) Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL) Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged FINAL) @@ -132,6 +132,7 @@ public: bool isHoverEnabled() const; void setHoverEnabled(bool enabled); + void resetHoverEnabled(); bool isWheelEnabled() const; void setWheelEnabled(bool enabled); diff --git a/src/quicktemplates2/qquickcontrol_p_p.h b/src/quicktemplates2/qquickcontrol_p_p.h index 26760510..cae1ae59 100644 --- a/src/quicktemplates2/qquickcontrol_p_p.h +++ b/src/quicktemplates2/qquickcontrol_p_p.h @@ -111,6 +111,10 @@ public: static void updateLocaleRecur(QQuickItem *item, const QLocale &l); static QLocale calcLocale(const QQuickItem *item); + void updateHoverEnabled(bool enabled, bool xplicit); + static void updateHoverEnabledRecur(QQuickItem *item, bool enabled); + static bool calcHoverEnabled(const QQuickItem *item); + void deleteDelegate(QObject *object); struct ExtraData { @@ -131,6 +135,7 @@ public: bool hasLocale; bool hovered; bool wheelEnabled; + bool explicitHoverEnabled; qreal padding; qreal topPadding; qreal leftPadding; diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index 45d0e67c..3f7d6907 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -406,7 +406,7 @@ QQuickPopupItem::QQuickPopupItem(QQuickPopup *popup) : setAcceptedMouseButtons(Qt::AllButtons); // TODO: switch to QStyleHints::useHoverEffects in Qt 5.8 - setAcceptHoverEvents(true); + setHoverEnabled(true); // setAcceptHoverEvents(QGuiApplication::styleHints()->useHoverEffects()); // connect(QGuiApplication::styleHints(), &QStyleHints::useHoverEffectsChanged, this, &QQuickItem::setAcceptHoverEvents); } diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp index 92c85941..41980073 100644 --- a/src/quicktemplates2/qquicktextarea.cpp +++ b/src/quicktemplates2/qquicktextarea.cpp @@ -131,7 +131,8 @@ QT_BEGIN_NAMESPACE */ QQuickTextAreaPrivate::QQuickTextAreaPrivate() - : hovered(false), background(nullptr), focusReason(Qt::OtherFocusReason), accessibleAttached(nullptr), flickable(nullptr) + : hovered(false), explicitHoverEnabled(false), background(nullptr), + focusReason(Qt::OtherFocusReason), accessibleAttached(nullptr), flickable(nullptr) { #ifndef QT_NO_ACCESSIBILITY QAccessible::installActivationObserver(this); @@ -355,6 +356,21 @@ void QQuickTextAreaPrivate::inheritFont(const QFont &f) emit q->fontChanged(); } +void QQuickTextAreaPrivate::updateHoverEnabled(bool enabled, bool xplicit) +{ + Q_Q(QQuickTextArea); + if (!xplicit && explicitHoverEnabled) + return; + + bool wasEnabled = q->isHoverEnabled(); + explicitHoverEnabled = xplicit; + if (wasEnabled != enabled) { + q->setAcceptHoverEvents(enabled); + QQuickControlPrivate::updateHoverEnabledRecur(q, enabled); + emit q->hoverEnabledChanged(); + } +} + void QQuickTextAreaPrivate::_q_readOnlyChanged(bool isReadOnly) { #ifndef QT_NO_ACCESSIBILITY @@ -549,11 +565,20 @@ bool QQuickTextArea::isHoverEnabled() const void QQuickTextArea::setHoverEnabled(bool enabled) { Q_D(QQuickTextArea); - if (enabled == d->hoverEnabled) + if (d->explicitHoverEnabled && enabled == d->hoverEnabled) return; - setAcceptHoverEvents(enabled); - emit hoverEnabledChanged(); + d->updateHoverEnabled(enabled, true); // explicit=true +} + +void QQuickTextArea::resetHoverEnabled() +{ + Q_D(QQuickTextArea); + if (!d->explicitHoverEnabled) + return; + + d->explicitHoverEnabled = false; + d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false } bool QQuickTextArea::contains(const QPointF &point) const @@ -575,6 +600,8 @@ void QQuickTextArea::componentComplete() { Q_D(QQuickTextArea); QQuickTextEdit::componentComplete(); + if (!d->explicitHoverEnabled) + setAcceptHoverEvents(QQuickControlPrivate::calcHoverEnabled(d->parentItem)); #ifndef QT_NO_ACCESSIBILITY if (!d->accessibleAttached && QAccessible::isActive()) d->accessibilityActiveChanged(true); @@ -588,8 +615,11 @@ void QQuickTextArea::itemChange(QQuickItem::ItemChange change, const QQuickItem: { Q_D(QQuickTextArea); QQuickTextEdit::itemChange(change, value); - if (change == ItemParentHasChanged && value.item) + if (change == ItemParentHasChanged && value.item) { d->resolveFont(); + if (!d->explicitHoverEnabled) + d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false + } } void QQuickTextArea::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) diff --git a/src/quicktemplates2/qquicktextarea_p.h b/src/quicktemplates2/qquicktextarea_p.h index 20500ee6..35bddba0 100644 --- a/src/quicktemplates2/qquicktextarea_p.h +++ b/src/quicktemplates2/qquicktextarea_p.h @@ -68,7 +68,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTextArea : public QQuickTextEdit Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText NOTIFY placeholderTextChanged FINAL) Q_PROPERTY(Qt::FocusReason focusReason READ focusReason WRITE setFocusReason NOTIFY focusReasonChanged FINAL) Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged FINAL REVISION 1) - Q_PROPERTY(bool hoverEnabled READ isHoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged FINAL REVISION 1) + Q_PROPERTY(bool hoverEnabled READ isHoverEnabled WRITE setHoverEnabled RESET resetHoverEnabled NOTIFY hoverEnabledChanged FINAL REVISION 1) public: explicit QQuickTextArea(QQuickItem *parent = nullptr); @@ -93,6 +93,7 @@ public: bool isHoverEnabled() const; void setHoverEnabled(bool enabled); + void resetHoverEnabled(); bool contains(const QPointF &point) const override; diff --git a/src/quicktemplates2/qquicktextarea_p_p.h b/src/quicktemplates2/qquicktextarea_p_p.h index 3ffa29bc..ed74ac9a 100644 --- a/src/quicktemplates2/qquicktextarea_p_p.h +++ b/src/quicktemplates2/qquicktextarea_p_p.h @@ -81,6 +81,8 @@ public: void resolveFont(); void inheritFont(const QFont &f); + void updateHoverEnabled(bool h, bool e); + void attachFlickable(QQuickFlickable *flickable); void detachFlickable(); void ensureCursorVisible(); @@ -105,6 +107,7 @@ public: void deleteDelegate(QObject *object); bool hovered; + bool explicitHoverEnabled; QFont font; QQuickItem *background; QString placeholder; diff --git a/src/quicktemplates2/qquicktextfield.cpp b/src/quicktemplates2/qquicktextfield.cpp index 0ca0c6ce..8bdbe3cb 100644 --- a/src/quicktemplates2/qquicktextfield.cpp +++ b/src/quicktemplates2/qquicktextfield.cpp @@ -115,6 +115,7 @@ QT_BEGIN_NAMESPACE QQuickTextFieldPrivate::QQuickTextFieldPrivate() : hovered(false) + , explicitHoverEnabled(false) , background(nullptr) , focusReason(Qt::OtherFocusReason) , accessibleAttached(nullptr) @@ -221,6 +222,21 @@ void QQuickTextFieldPrivate::inheritFont(const QFont &f) emit q->fontChanged(); } +void QQuickTextFieldPrivate::updateHoverEnabled(bool enabled, bool xplicit) +{ + Q_Q(QQuickTextField); + if (!xplicit && explicitHoverEnabled) + return; + + bool wasEnabled = q->isHoverEnabled(); + explicitHoverEnabled = xplicit; + if (wasEnabled != enabled) { + q->setAcceptHoverEvents(enabled); + QQuickControlPrivate::updateHoverEnabledRecur(q, enabled); + emit q->hoverEnabledChanged(); + } +} + void QQuickTextFieldPrivate::_q_readOnlyChanged(bool isReadOnly) { #ifndef QT_NO_ACCESSIBILITY @@ -430,11 +446,20 @@ bool QQuickTextField::isHoverEnabled() const void QQuickTextField::setHoverEnabled(bool enabled) { Q_D(QQuickTextField); - if (enabled == d->hoverEnabled) + if (d->explicitHoverEnabled && enabled == d->hoverEnabled) return; - setAcceptHoverEvents(enabled); - emit hoverEnabledChanged(); + d->updateHoverEnabled(enabled, true); // explicit=true +} + +void QQuickTextField::resetHoverEnabled() +{ + Q_D(QQuickTextField); + if (!d->explicitHoverEnabled) + return; + + d->explicitHoverEnabled = false; + d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false } void QQuickTextField::classBegin() @@ -448,6 +473,8 @@ void QQuickTextField::componentComplete() { Q_D(QQuickTextField); QQuickTextInput::componentComplete(); + if (!d->explicitHoverEnabled) + setAcceptHoverEvents(QQuickControlPrivate::calcHoverEnabled(d->parentItem)); #ifndef QT_NO_ACCESSIBILITY if (!d->accessibleAttached && QAccessible::isActive()) d->accessibilityActiveChanged(true); @@ -461,8 +488,11 @@ void QQuickTextField::itemChange(QQuickItem::ItemChange change, const QQuickItem { Q_D(QQuickTextField); QQuickTextInput::itemChange(change, value); - if (change == ItemParentHasChanged && value.item) + if (change == ItemParentHasChanged && value.item) { d->resolveFont(); + if (!d->explicitHoverEnabled) + d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false + } } void QQuickTextField::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) diff --git a/src/quicktemplates2/qquicktextfield_p.h b/src/quicktemplates2/qquicktextfield_p.h index 5ef7a02d..57521592 100644 --- a/src/quicktemplates2/qquicktextfield_p.h +++ b/src/quicktemplates2/qquicktextfield_p.h @@ -67,7 +67,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTextField : public QQuickTextInput Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText NOTIFY placeholderTextChanged FINAL) Q_PROPERTY(Qt::FocusReason focusReason READ focusReason WRITE setFocusReason NOTIFY focusReasonChanged FINAL) Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged FINAL REVISION 1) - Q_PROPERTY(bool hoverEnabled READ isHoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged FINAL REVISION 1) + Q_PROPERTY(bool hoverEnabled READ isHoverEnabled WRITE setHoverEnabled RESET resetHoverEnabled NOTIFY hoverEnabledChanged FINAL REVISION 1) public: explicit QQuickTextField(QQuickItem *parent = nullptr); @@ -90,6 +90,7 @@ public: bool isHoverEnabled() const; void setHoverEnabled(bool enabled); + void resetHoverEnabled(); Q_SIGNALS: void fontChanged(); diff --git a/src/quicktemplates2/qquicktextfield_p_p.h b/src/quicktemplates2/qquicktextfield_p_p.h index 99e1c48c..fb973ad4 100644 --- a/src/quicktemplates2/qquicktextfield_p_p.h +++ b/src/quicktemplates2/qquicktextfield_p_p.h @@ -79,6 +79,8 @@ public: void resolveFont(); void inheritFont(const QFont &f); + void updateHoverEnabled(bool h, bool e); + qreal getImplicitWidth() const override; qreal getImplicitHeight() const override; @@ -96,6 +98,7 @@ public: void deleteDelegate(QObject *object); bool hovered; + bool explicitHoverEnabled; QFont font; QQuickItem *background; QString placeholder; diff --git a/tests/auto/controls/data/tst_control.qml b/tests/auto/controls/data/tst_control.qml index 77f23fa5..f07f6051 100644 --- a/tests/auto/controls/data/tst_control.qml +++ b/tests/auto/controls/data/tst_control.qml @@ -852,7 +852,9 @@ TestCase { verify(control) compare(control.hovered, false) - compare(control.hoverEnabled, false) + compare(control.hoverEnabled, Qt.styleHints.useHoverEffects) + + control.hoverEnabled = false mouseMove(control, control.width / 2, control.height / 2) compare(control.hovered, false) @@ -874,6 +876,42 @@ TestCase { control.destroy() } + function test_hoverEnabled() { + var control = component.createObject(testCase) + compare(control.hoverEnabled, Qt.styleHints.useHoverEffects) + + var child = component.createObject(control) + var grandChild = component.createObject(child) + + var childExplicitHoverEnabled = component.createObject(control, {hoverEnabled: true}) + var grandChildExplicitHoverDisabled = component.createObject(childExplicitHoverEnabled, {hoverEnabled: false}) + + var childExplicitHoverDisabled = component.createObject(control, {hoverEnabled: false}) + var grandChildExplicitHoverEnabled = component.createObject(childExplicitHoverDisabled, {hoverEnabled: true}) + + control.hoverEnabled = false + compare(control.hoverEnabled, false) + compare(grandChild.hoverEnabled, false) + + compare(childExplicitHoverEnabled.hoverEnabled, true) + compare(grandChildExplicitHoverDisabled.hoverEnabled, false) + + compare(childExplicitHoverDisabled.hoverEnabled, false) + compare(grandChildExplicitHoverEnabled.hoverEnabled, true) + + control.hoverEnabled = true + compare(control.hoverEnabled, true) + compare(grandChild.hoverEnabled, true) + + compare(childExplicitHoverEnabled.hoverEnabled, true) + compare(grandChildExplicitHoverDisabled.hoverEnabled, false) + + compare(childExplicitHoverDisabled.hoverEnabled, false) + compare(grandChildExplicitHoverEnabled.hoverEnabled, true) + + control.destroy() + } + function test_implicitSize() { var control = component.createObject(testCase) verify(control) diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp index 4e9e1e67..58a5ba3c 100644 --- a/tests/auto/drawer/tst_drawer.cpp +++ b/tests/auto/drawer/tst_drawer.cpp @@ -452,6 +452,10 @@ void tst_Drawer::hover() QVERIFY(drawer); drawer->setModal(modal); + QQuickControl *drawerItem = qobject_cast<QQuickControl *>(drawer->popupItem()); + QVERIFY(drawerItem); + QVERIFY(drawerItem->isHoverEnabled()); + QQuickButton *backgroundButton = window->property("backgroundButton").value<QQuickButton*>(); QVERIFY(backgroundButton); backgroundButton->setHoverEnabled(true); @@ -469,16 +473,19 @@ void tst_Drawer::hover() QTest::mouseMove(window, QPoint(window->width() - 1, window->height() - 1)); QCOMPARE(backgroundButton->isHovered(), !modal); QVERIFY(!drawerButton->isHovered()); + QVERIFY(!drawerItem->isHovered()); // hover the drawer background QTest::mouseMove(window, QPoint(1, 1)); QVERIFY(!backgroundButton->isHovered()); QVERIFY(!drawerButton->isHovered()); + QVERIFY(drawerItem->isHovered()); // hover the button in a drawer QTest::mouseMove(window, QPoint(2, 2)); QVERIFY(!backgroundButton->isHovered()); QVERIFY(drawerButton->isHovered()); + QVERIFY(drawerItem->isHovered()); QSignalSpy closedSpy(drawer, SIGNAL(closed())); QVERIFY(closedSpy.isValid()); @@ -488,6 +495,8 @@ void tst_Drawer::hover() // hover the background button after closing the drawer QTest::mouseMove(window, QPoint(window->width() / 2, window->height() / 2)); QVERIFY(backgroundButton->isHovered()); + QVERIFY(!drawerButton->isHovered()); + QVERIFY(!drawerItem->isHovered()); } void tst_Drawer::wheel_data() |