diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-04-26 12:42:10 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-04-26 13:31:18 +0000 |
commit | 345fb099aa08c72d380fed3330cc8b9d088a3cb4 (patch) | |
tree | 4cf28ead358bc333a27e6b794ca439ad27938289 | |
parent | 67f3da65d7d11af025a9bdd54d08ca0bf764c3ce (diff) |
Control: rename activeKeyFocus to visualFocus
This is a bit more flexible, because the name is not strictly coupled
with key focus. We can even add a (re)setter later if we want. This
change only renames the property.
Change-Id: I6707e44040f584480a8712df1af0915ae2829d57
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
28 files changed, 75 insertions, 75 deletions
diff --git a/src/imports/calendar/plugins.qmltypes b/src/imports/calendar/plugins.qmltypes index 5d546407..2ad527f7 100644 --- a/src/imports/calendar/plugins.qmltypes +++ b/src/imports/calendar/plugins.qmltypes @@ -80,7 +80,7 @@ Module { Property { name: "mirrored"; type: "bool"; isReadonly: true } Property { name: "focusPolicy"; type: "Qt::FocusPolicy" } Property { name: "focusReason"; type: "Qt::FocusReason" } - Property { name: "activeKeyFocus"; type: "bool"; isReadonly: true } + Property { name: "visualFocus"; type: "bool"; isReadonly: true } Property { name: "hovered"; type: "bool"; isReadonly: true } Property { name: "hoverEnabled"; type: "bool" } Property { name: "wheelEnabled"; type: "bool" } diff --git a/src/imports/controls/Button.qml b/src/imports/controls/Button.qml index c68fc1e8..d9ca2910 100644 --- a/src/imports/controls/Button.qml +++ b/src/imports/controls/Button.qml @@ -55,7 +55,7 @@ T.Button { text: control.text font: control.font opacity: enabled || highlighted ? 1 : 0.3 - color: control.checked || control.highlighted ? "#ffffff" : (control.activeKeyFocus ? "#0066ff" : (control.down ? "#26282a" : "#353637")) + color: control.checked || control.highlighted ? "#ffffff" : (control.visualFocus ? "#0066ff" : (control.down ? "#26282a" : "#353637")) horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter elide: Text.ElideRight @@ -68,10 +68,10 @@ T.Button { implicitHeight: 40 opacity: enabled ? 1 : (control.checked ? 0.2 : 0.3) color: control.checked || control.highlighted ? - (control.activeKeyFocus ? (control.down ? "#599bff" : "#0066ff") : (control.down ? "#585a5c" : "#353637")) : - (control.activeKeyFocus ? (control.down ? "#cce0ff" : "#f0f6ff") : (control.down ? "#d6d6d6" : "#f6f6f6")) - border.color: control.activeKeyFocus ? "#0066ff" : (control.down ? "#26282a" : "#353637") - border.width: control.checked || control.highlighted ? 0 : (control.activeKeyFocus ? 2 : 1) + (control.visualFocus ? (control.down ? "#599bff" : "#0066ff") : (control.down ? "#585a5c" : "#353637")) : + (control.visualFocus ? (control.down ? "#cce0ff" : "#f0f6ff") : (control.down ? "#d6d6d6" : "#f6f6f6")) + border.color: control.visualFocus ? "#0066ff" : (control.down ? "#26282a" : "#353637") + border.width: control.checked || control.highlighted ? 0 : (control.visualFocus ? 2 : 1) } //! [background] } diff --git a/src/imports/controls/CheckIndicator.qml b/src/imports/controls/CheckIndicator.qml index fbaf86af..5f75181e 100644 --- a/src/imports/controls/CheckIndicator.qml +++ b/src/imports/controls/CheckIndicator.qml @@ -44,14 +44,14 @@ Rectangle { implicitWidth: 28 implicitHeight: 28 - color: control.enabled ? (control.down ? (control.activeKeyFocus ? "#cce0ff" : "#e4e4e4") : "#f6f6f6") : "#353637" - border.width: control.activeKeyFocus ? 2 : 1 - border.color: control.enabled ? (control.activeKeyFocus ? "#0066ff" : (control.down ? "#26282a" : "#353637")) : "transparent" + color: control.enabled ? (control.down ? (control.visualFocus ? "#cce0ff" : "#e4e4e4") : "#f6f6f6") : "#353637" + border.width: control.visualFocus ? 2 : 1 + border.color: control.enabled ? (control.visualFocus ? "#0066ff" : (control.down ? "#26282a" : "#353637")) : "transparent" Image { x: (parent.width - width) / 2 y: (parent.height - height) / 2 - source: "image://default/check/" + (control.activeKeyFocus ? "#0066ff" : "#353637") + source: "image://default/check/" + (control.visualFocus ? "#0066ff" : "#353637") visible: control.checkState === Qt.Checked } @@ -60,7 +60,7 @@ Rectangle { y: (parent.height - height) / 2 width: 16 height: 3 - color: control.activeKeyFocus ? "#0066ff" : "#353637" + color: control.visualFocus ? "#0066ff" : "#353637" visible: control.checkState === Qt.PartiallyChecked } } diff --git a/src/imports/controls/ComboBox.qml b/src/imports/controls/ComboBox.qml index 66d27da4..0ab7bf24 100644 --- a/src/imports/controls/ComboBox.qml +++ b/src/imports/controls/ComboBox.qml @@ -66,7 +66,7 @@ T.ComboBox { contentItem: Text { text: control.displayText font: control.font - color: control.activeKeyFocus ? "#0066ff" : "#353637" + color: control.visualFocus ? "#0066ff" : "#353637" horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter elide: Text.ElideRight @@ -79,22 +79,22 @@ T.ComboBox { implicitWidth: 120 implicitHeight: 40 - color: control.activeKeyFocus ? (control.pressed ? "#cce0ff" : "#f0f6ff") : + color: control.visualFocus ? (control.pressed ? "#cce0ff" : "#f0f6ff") : (control.pressed || popup.visible ? "#d6d6d6" : "#f6f6f6") - border.color: control.activeKeyFocus ? "#0066ff" : "#353637" - border.width: control.activeKeyFocus ? 2 : 1 + border.color: control.visualFocus ? "#0066ff" : "#353637" + border.width: control.visualFocus ? 2 : 1 Image { x: parent.width - width - 4 y: (parent.height - height) / 2 - source: "image://default/double-arrow/" + (control.activeKeyFocus ? "#0066ff" : "#353637") + source: "image://default/double-arrow/" + (control.visualFocus ? "#0066ff" : "#353637") } } //! [background] //! [popup] popup: T.Popup { - y: control.height - (control.activeKeyFocus ? 0 : 1) + y: control.height - (control.visualFocus ? 0 : 1) implicitWidth: control.width implicitHeight: listview.contentHeight topMargin: 6 diff --git a/src/imports/controls/Dial.qml b/src/imports/controls/Dial.qml index 55fd7a4b..9db51384 100644 --- a/src/imports/controls/Dial.qml +++ b/src/imports/controls/Dial.qml @@ -49,7 +49,7 @@ T.Dial { background: DialRing { width: control.availableWidth height: control.availableHeight - color: control.activeKeyFocus ? "#0066ff" : "#353637" + color: control.visualFocus ? "#0066ff" : "#353637" progress: control.position opacity: control.enabled ? 1 : 0.3 } @@ -62,7 +62,7 @@ T.Dial { y: background.y + background.height / 2 - handle.height / 2 width: 14 height: 10 - source: "image://default/dial-indicator/" + (control.activeKeyFocus ? "#0066ff" : "#353637") + source: "image://default/dial-indicator/" + (control.visualFocus ? "#0066ff" : "#353637") antialiasing: true opacity: control.enabled ? 1 : 0.3 transform: [ diff --git a/src/imports/controls/ItemDelegate.qml b/src/imports/controls/ItemDelegate.qml index 42d207de..d884a328 100644 --- a/src/imports/controls/ItemDelegate.qml +++ b/src/imports/controls/ItemDelegate.qml @@ -69,8 +69,8 @@ T.ItemDelegate { background: Rectangle { implicitWidth: 100 implicitHeight: 40 - visible: control.down || control.highlighted || control.activeKeyFocus - color: control.activeKeyFocus ? (control.pressed ? "#cce0ff" : "#e5efff") : (control.down ? "#bdbebf" : "#eeeeee") + visible: control.down || control.highlighted || control.visualFocus + color: control.visualFocus ? (control.pressed ? "#cce0ff" : "#e5efff") : (control.down ? "#bdbebf" : "#eeeeee") } //! [background] } diff --git a/src/imports/controls/MenuItem.qml b/src/imports/controls/MenuItem.qml index 0e66c1cc..ead943b0 100644 --- a/src/imports/controls/MenuItem.qml +++ b/src/imports/controls/MenuItem.qml @@ -84,7 +84,7 @@ T.MenuItem { y: 1 width: parent.width - 2 height: parent.height - 2 - color: control.activeKeyFocus || control.down ? "#eeeeee" : "transparent" + color: control.visualFocus || control.down ? "#eeeeee" : "transparent" } } //! [background] diff --git a/src/imports/controls/RadioIndicator.qml b/src/imports/controls/RadioIndicator.qml index 68b283c0..2223cfe2 100644 --- a/src/imports/controls/RadioIndicator.qml +++ b/src/imports/controls/RadioIndicator.qml @@ -41,9 +41,9 @@ Rectangle { implicitHeight: 28 radius: width / 2 - color: control.down ? (control.activeKeyFocus ? "#cce0ff" : "#e4e4e4") : "#f6f6f6" - border.width: control.activeKeyFocus ? 2 : 1 - border.color: control.activeKeyFocus ? "#0066ff" : (control.down ? "#26282a" : "#353637") + color: control.down ? (control.visualFocus ? "#cce0ff" : "#e4e4e4") : "#f6f6f6" + border.width: control.visualFocus ? 2 : 1 + border.color: control.visualFocus ? "#0066ff" : (control.down ? "#26282a" : "#353637") property Item control diff --git a/src/imports/controls/SwitchIndicator.qml b/src/imports/controls/SwitchIndicator.qml index cd4e2c73..ead6b64c 100644 --- a/src/imports/controls/SwitchIndicator.qml +++ b/src/imports/controls/SwitchIndicator.qml @@ -47,9 +47,9 @@ Item { width: 56 height: 16 radius: 8 - color: control.checked ? (control.activeKeyFocus ? "#0066ff" : "#353637") : "#ffffff" - border.width: control.activeKeyFocus ? 2 : 1 - border.color: control.checked ? "transparent" : (control.activeKeyFocus ? "#0066ff" : "#353637") + color: control.checked ? (control.visualFocus ? "#0066ff" : "#353637") : "#ffffff" + border.width: control.visualFocus ? 2 : 1 + border.color: control.checked ? "transparent" : (control.visualFocus ? "#0066ff" : "#353637") } Rectangle { @@ -58,9 +58,9 @@ Item { width: 28 height: 28 radius: 16 - color: control.pressed ? (control.activeKeyFocus ? "#cce0ff" : "#e4e4e4") : (control.activeKeyFocus ? "#f0f6ff" : "#f6f6f6") - border.width: control.activeKeyFocus ? 2 : 1 - border.color: control.activeKeyFocus ? "#0066ff" : (control.pressed ? "#26282a" : "#353637") + color: control.pressed ? (control.visualFocus ? "#cce0ff" : "#e4e4e4") : (control.visualFocus ? "#f0f6ff" : "#f6f6f6") + border.width: control.visualFocus ? 2 : 1 + border.color: control.visualFocus ? "#0066ff" : (control.pressed ? "#26282a" : "#353637") Behavior on x { enabled: !control.pressed diff --git a/src/imports/controls/material/Button.qml b/src/imports/controls/material/Button.qml index 1be54234..6ef27a5a 100644 --- a/src/imports/controls/material/Button.qml +++ b/src/imports/controls/material/Button.qml @@ -77,7 +77,7 @@ T.Button { radius: 2 color: !control.enabled ? (control.highlighted ? control.Material.raisedHighlightedButtonDisabledColor : control.Material.raisedButtonDisabledColor) : (control.down ? (control.highlighted ? control.Material.raisedHighlightedButtonPressColor : control.Material.raisedButtonPressColor) : - (control.activeKeyFocus ? (control.highlighted ? control.Material.raisedHighlightedButtonHoverColor : control.Material.raisedButtonHoverColor) : + (control.visualFocus ? (control.highlighted ? control.Material.raisedHighlightedButtonHoverColor : control.Material.raisedButtonHoverColor) : (control.highlighted ? control.Material.raisedHighlightedButtonColor : control.Material.raisedButtonColor))) Behavior on color { @@ -90,7 +90,7 @@ T.Button { width: parent.width height: parent.height radius: parent.radius - visible: control.activeKeyFocus + visible: control.visualFocus color: control.Material.checkBoxUncheckedRippleColor } diff --git a/src/imports/controls/material/ComboBox.qml b/src/imports/controls/material/ComboBox.qml index 49f4554e..a46994bc 100644 --- a/src/imports/controls/material/ComboBox.qml +++ b/src/imports/controls/material/ComboBox.qml @@ -107,7 +107,7 @@ T.ComboBox { width: parent.width height: parent.height radius: parent.radius - visible: control.activeKeyFocus + visible: control.visualFocus color: control.Material.checkBoxUncheckedRippleColor } } diff --git a/src/imports/controls/material/RadioIndicator.qml b/src/imports/controls/material/RadioIndicator.qml index dbd950de..4090c732 100644 --- a/src/imports/controls/material/RadioIndicator.qml +++ b/src/imports/controls/material/RadioIndicator.qml @@ -54,7 +54,7 @@ Rectangle { height: width control: control colored: control.checked - opacity: control.down || control.activeKeyFocus ? 1 : 0 + opacity: control.down || control.visualFocus ? 1 : 0 } Rectangle { diff --git a/src/imports/controls/material/Slider.qml b/src/imports/controls/material/Slider.qml index 8401bea5..d6280b67 100644 --- a/src/imports/controls/material/Slider.qml +++ b/src/imports/controls/material/Slider.qml @@ -56,7 +56,7 @@ T.Slider { 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)) value: control.value - handleHasFocus: control.activeKeyFocus + handleHasFocus: control.visualFocus handlePressed: control.pressed } //! [handle] diff --git a/src/imports/controls/material/SwipeDelegate.qml b/src/imports/controls/material/SwipeDelegate.qml index 4dc666e7..858c914d 100644 --- a/src/imports/controls/material/SwipeDelegate.qml +++ b/src/imports/controls/material/SwipeDelegate.qml @@ -79,7 +79,7 @@ T.SwipeDelegate { background: Rectangle { color: !control.enabled ? control.Material.swipeDelegateDisabledColor : (control.down ? control.Material.swipeDelegatePressColor : - (control.activeKeyFocus || control.hovered ? control.Material.swipeDelegateHoverColor : control.Material.swipeDelegateColor)) + (control.visualFocus || control.hovered ? control.Material.swipeDelegateHoverColor : control.Material.swipeDelegateColor)) Behavior on x { enabled: !control.down diff --git a/src/imports/controls/material/SwitchIndicator.qml b/src/imports/controls/material/SwitchIndicator.qml index 403587b9..93b4c9f6 100644 --- a/src/imports/controls/material/SwitchIndicator.qml +++ b/src/imports/controls/material/SwitchIndicator.qml @@ -52,7 +52,7 @@ Item { width: handle.width height: width colored: control.checked - opacity: control.pressed || control.activeKeyFocus ? 1 : 0 + opacity: control.pressed || control.visualFocus ? 1 : 0 } Rectangle { diff --git a/src/imports/controls/material/ToolButton.qml b/src/imports/controls/material/ToolButton.qml index a02254c4..22a81c76 100644 --- a/src/imports/controls/material/ToolButton.qml +++ b/src/imports/controls/material/ToolButton.qml @@ -66,7 +66,7 @@ T.ToolButton { implicitHeight: 48 color: control.down ? control.Material.flatButtonPressColor : control.Material.flatButtonFocusColor - visible: control.enabled && (control.down || control.activeKeyFocus || control.checked || control.highlighted) + visible: control.enabled && (control.down || control.visualFocus || control.checked || control.highlighted) } //! [background] } diff --git a/src/imports/controls/universal/ApplicationWindow.qml b/src/imports/controls/universal/ApplicationWindow.qml index e0a0b351..664229a3 100644 --- a/src/imports/controls/universal/ApplicationWindow.qml +++ b/src/imports/controls/universal/ApplicationWindow.qml @@ -52,6 +52,6 @@ T.ApplicationWindow { parent: window.activeFocusControl width: parent ? parent.width : 0 height: parent ? parent.height : 0 - visible: parent && !!parent.useSystemFocusVisuals && !!parent.activeKeyFocus + visible: parent && !!parent.useSystemFocusVisuals && !!parent.visualFocus } } diff --git a/src/imports/controls/universal/CheckDelegate.qml b/src/imports/controls/universal/CheckDelegate.qml index da8fe326..d693ead1 100644 --- a/src/imports/controls/universal/CheckDelegate.qml +++ b/src/imports/controls/universal/CheckDelegate.qml @@ -82,12 +82,12 @@ T.CheckDelegate { //! [background] background: Rectangle { - visible: control.down || control.highlighted || control.activeKeyFocus + visible: control.down || control.highlighted || control.visualFocus color: control.down ? control.Universal.listMediumColor : control.Universal.altMediumLowColor Rectangle { width: parent.width height: parent.height - visible: control.activeKeyFocus || control.highlighted + visible: control.visualFocus || control.highlighted color: control.Universal.accent opacity: control.Universal.theme === Universal.Light ? 0.4 : 0.6 } diff --git a/src/imports/controls/universal/ComboBox.qml b/src/imports/controls/universal/ComboBox.qml index 07e92a0e..bfb202bc 100644 --- a/src/imports/controls/universal/ComboBox.qml +++ b/src/imports/controls/universal/ComboBox.qml @@ -94,7 +94,7 @@ T.ComboBox { width: parent.width - 4 height: parent.height - 4 - visible: control.activeKeyFocus + visible: control.visualFocus color: control.Universal.accent opacity: control.Universal.theme === Universal.Light ? 0.4 : 0.6 } diff --git a/src/imports/controls/universal/ItemDelegate.qml b/src/imports/controls/universal/ItemDelegate.qml index 1bdcd620..e02eac69 100644 --- a/src/imports/controls/universal/ItemDelegate.qml +++ b/src/imports/controls/universal/ItemDelegate.qml @@ -74,12 +74,12 @@ T.ItemDelegate { //! [background] background: Rectangle { - visible: control.down || control.highlighted || control.activeKeyFocus + visible: control.down || control.highlighted || control.visualFocus color: control.down ? control.Universal.listMediumColor : control.Universal.altMediumLowColor Rectangle { width: parent.width height: parent.height - visible: control.activeKeyFocus || control.highlighted + visible: control.visualFocus || control.highlighted color: control.Universal.accent opacity: control.Universal.theme === Universal.Light ? 0.4 : 0.6 } diff --git a/src/imports/controls/universal/MenuItem.qml b/src/imports/controls/universal/MenuItem.qml index e14884ef..c8561cbf 100644 --- a/src/imports/controls/universal/MenuItem.qml +++ b/src/imports/controls/universal/MenuItem.qml @@ -92,7 +92,7 @@ T.MenuItem { width: parent.width - 2 height: parent.height - 2 - visible: control.activeKeyFocus + visible: control.visualFocus color: control.Universal.accent opacity: control.Universal.theme === Universal.Light ? 0.4 : 0.6 } diff --git a/src/imports/controls/universal/RadioDelegate.qml b/src/imports/controls/universal/RadioDelegate.qml index 3b9214ae..9fe984bd 100644 --- a/src/imports/controls/universal/RadioDelegate.qml +++ b/src/imports/controls/universal/RadioDelegate.qml @@ -84,12 +84,12 @@ T.RadioDelegate { //! [background] background: Rectangle { - visible: control.down || control.highlighted || control.activeKeyFocus + visible: control.down || control.highlighted || control.visualFocus color: control.down ? control.Universal.listMediumColor : control.Universal.altMediumLowColor Rectangle { width: parent.width height: parent.height - visible: control.activeKeyFocus || control.highlighted + visible: control.visualFocus || control.highlighted color: control.Universal.accent opacity: control.Universal.theme === Universal.Light ? 0.4 : 0.6 } diff --git a/src/imports/controls/universal/SwipeDelegate.qml b/src/imports/controls/universal/SwipeDelegate.qml index c908e517..02a2fa65 100644 --- a/src/imports/controls/universal/SwipeDelegate.qml +++ b/src/imports/controls/universal/SwipeDelegate.qml @@ -85,12 +85,12 @@ T.SwipeDelegate { background: Rectangle { color: !control.enabled ? control.Universal.chromeDisabledHighColor : (control.down ? control.Universal.chromeHighColor : - (control.activeKeyFocus || control.hovered ? control.Universal.chromeLowColor : control.Universal.chromeMediumColor)) + (control.visualFocus || control.hovered ? control.Universal.chromeLowColor : control.Universal.chromeMediumColor)) Rectangle { width: parent.width height: parent.height - visible: control.activeKeyFocus || control.highlighted + visible: control.visualFocus || control.highlighted color: control.Universal.accent opacity: control.Universal.theme === Universal.Light ? 0.4 : 0.6 } diff --git a/src/imports/controls/universal/SwitchDelegate.qml b/src/imports/controls/universal/SwitchDelegate.qml index 0d58824e..25652f1b 100644 --- a/src/imports/controls/universal/SwitchDelegate.qml +++ b/src/imports/controls/universal/SwitchDelegate.qml @@ -82,12 +82,12 @@ T.SwitchDelegate { //! [background] background: Rectangle { - visible: control.down || control.highlighted || control.activeKeyFocus + visible: control.down || control.highlighted || control.visualFocus color: control.down ? control.Universal.listMediumColor : control.Universal.altMediumLowColor Rectangle { width: parent.width height: parent.height - visible: control.activeKeyFocus || control.highlighted + visible: control.visualFocus || control.highlighted color: control.Universal.accent opacity: control.Universal.theme === Universal.Light ? 0.4 : 0.6 } diff --git a/src/imports/templates/plugins.qmltypes b/src/imports/templates/plugins.qmltypes index cae452d4..af573750 100644 --- a/src/imports/templates/plugins.qmltypes +++ b/src/imports/templates/plugins.qmltypes @@ -194,7 +194,7 @@ Module { Property { name: "mirrored"; type: "bool"; isReadonly: true } Property { name: "focusPolicy"; type: "Qt::FocusPolicy" } Property { name: "focusReason"; type: "Qt::FocusReason" } - Property { name: "activeKeyFocus"; type: "bool"; isReadonly: true } + Property { name: "visualFocus"; type: "bool"; isReadonly: true } Property { name: "hovered"; type: "bool"; isReadonly: true } Property { name: "hoverEnabled"; type: "bool" } Property { name: "wheelEnabled"; type: "bool" } diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index 669f8923..c006fd3a 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -397,7 +397,7 @@ void QQuickControl::itemChange(QQuickItem::ItemChange change, const QQuickItem:: break; case ItemActiveFocusHasChanged: if (isKeyFocusReason(d->focusReason)) - emit activeKeyFocusChanged(); + emit visualFocusChanged(); break; default: break; @@ -804,7 +804,7 @@ void QQuickControl::setFocusPolicy(Qt::FocusPolicy policy) \value Qt.MenuBarFocusReason The menu bar took focus. \value Qt.OtherFocusReason Another reason, usually application-specific. - \sa activeKeyFocus, Item::activeFocus + \sa visualFocus, Item::activeFocus */ Qt::FocusReason QQuickControl::focusReason() const { @@ -822,16 +822,16 @@ void QQuickControl::setFocusReason(Qt::FocusReason reason) d->focusReason = reason; emit focusReasonChanged(); if (d->activeFocus && isKeyFocusReason(oldReason) != isKeyFocusReason(reason)) - emit activeKeyFocusChanged(); + emit visualFocusChanged(); } /*! - \qmlproperty bool QtQuick.Controls::Control::activeKeyFocus + \qmlproperty bool QtQuick.Controls::Control::visualFocus \readonly - This property holds whether the control has active focus and the focus - reason is either \c Qt.TabFocusReason, \c Qt.BacktabFocusReason, or - \c Qt.ShortcutFocusReason. + This property holds whether the control has visual focus. This property + is \c true when the control has active focus and the focus reason is either + \c Qt.TabFocusReason, \c Qt.BacktabFocusReason, or \c Qt.ShortcutFocusReason. In general, for visualizing key focus, this property is preferred over \l Item::activeFocus. This ensures that key focus is only visualized when @@ -839,7 +839,7 @@ void QQuickControl::setFocusReason(Qt::FocusReason reason) \sa focusReason, Item::activeFocus */ -bool QQuickControl::hasActiveKeyFocus() const +bool QQuickControl::hasVisualFocus() const { Q_D(const QQuickControl); return d->activeFocus && isKeyFocusReason(d->focusReason); diff --git a/src/quicktemplates2/qquickcontrol_p.h b/src/quicktemplates2/qquickcontrol_p.h index 1657fd63..ffff75b4 100644 --- a/src/quicktemplates2/qquickcontrol_p.h +++ b/src/quicktemplates2/qquickcontrol_p.h @@ -72,7 +72,7 @@ class Q_QUICKTEMPLATES2_EXPORT QQuickControl : public QQuickItem Q_PROPERTY(bool mirrored READ isMirrored NOTIFY mirroredChanged FINAL) Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy NOTIFY focusPolicyChanged FINAL) Q_PROPERTY(Qt::FocusReason focusReason READ focusReason WRITE setFocusReason NOTIFY focusReasonChanged FINAL) - Q_PROPERTY(bool activeKeyFocus READ hasActiveKeyFocus NOTIFY activeKeyFocusChanged 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 wheelEnabled READ isWheelEnabled WRITE setWheelEnabled NOTIFY wheelEnabledChanged FINAL) @@ -125,7 +125,7 @@ public: Qt::FocusReason focusReason() const; void setFocusReason(Qt::FocusReason reason); - bool hasActiveKeyFocus() const; + bool hasVisualFocus() const; bool isHovered() const; void setHovered(bool hovered); @@ -156,7 +156,7 @@ Q_SIGNALS: void mirroredChanged(); void focusPolicyChanged(); void focusReasonChanged(); - void activeKeyFocusChanged(); + void visualFocusChanged(); void hoveredChanged(); void hoverEnabledChanged(); void wheelEnabledChanged(); diff --git a/tests/auto/focus/tst_focus.cpp b/tests/auto/focus/tst_focus.cpp index 8f79d659..6c184851 100644 --- a/tests/auto/focus/tst_focus.cpp +++ b/tests/auto/focus/tst_focus.cpp @@ -133,7 +133,7 @@ void tst_focus::policy() QVERIFY(control); QVERIFY(!control->hasActiveFocus()); - QVERIFY(!control->hasActiveKeyFocus()); + QVERIFY(!control->hasVisualFocus()); window->show(); window->requestActivate(); @@ -153,7 +153,7 @@ void tst_focus::policy() QGuiApplication::styleHints()->setTabFocusBehavior(Qt::TabFocusAllControls); QTest::keyClick(window.data(), Qt::Key_Tab); QVERIFY(control->hasActiveFocus()); - QVERIFY(control->hasActiveKeyFocus()); + QVERIFY(control->hasVisualFocus()); QGuiApplication::styleHints()->setTabFocusBehavior(Qt::TabFocusBehavior(-1)); // reset @@ -164,13 +164,13 @@ void tst_focus::policy() control->setAcceptedMouseButtons(Qt::LeftButton); QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(control->width() / 2, control->height() / 2)); QVERIFY(!control->hasActiveFocus()); - QVERIFY(!control->hasActiveKeyFocus()); + QVERIFY(!control->hasVisualFocus()); control->setFocusPolicy(Qt::ClickFocus); QCOMPARE(control->focusPolicy(), Qt::ClickFocus); QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(control->width() / 2, control->height() / 2)); QVERIFY(control->hasActiveFocus()); - QVERIFY(!control->hasActiveKeyFocus()); + QVERIFY(!control->hasVisualFocus()); // reset control->setFocus(false); @@ -180,14 +180,14 @@ void tst_focus::policy() QWheelEvent wheelEvent(QPoint(control->width() / 2, control->height() / 2), 10, Qt::NoButton, Qt::NoModifier); QGuiApplication::sendEvent(control, &wheelEvent); QVERIFY(!control->hasActiveFocus()); - QVERIFY(!control->hasActiveKeyFocus()); + QVERIFY(!control->hasVisualFocus()); control->setFocusPolicy(Qt::WheelFocus); QCOMPARE(control->focusPolicy(), Qt::WheelFocus); QGuiApplication::sendEvent(control, &wheelEvent); QVERIFY(control->hasActiveFocus()); - QVERIFY(!control->hasActiveKeyFocus()); + QVERIFY(!control->hasVisualFocus()); } void tst_focus::reason_data() @@ -224,9 +224,9 @@ void tst_focus::reason() QVERIFY(control->hasActiveFocus()); QCOMPARE(control->property("focusReason").toInt(), int(Qt::MouseFocusReason)); - QEXPECT_FAIL("TextArea", "TODO: TextArea::activeKeyFocus?", Continue); - QEXPECT_FAIL("TextField", "TODO: TextField::activeKeyFocus?", Continue); - QCOMPARE(control->property("activeKeyFocus"), QVariant(false)); + QEXPECT_FAIL("TextArea", "TODO: TextArea::visualFocus?", Continue); + QEXPECT_FAIL("TextField", "TODO: TextField::visualFocus?", Continue); + QCOMPARE(control->property("visualFocus"), QVariant(false)); window->contentItem()->forceActiveFocus(Qt::TabFocusReason); QVERIFY(!control->hasActiveFocus()); @@ -234,7 +234,7 @@ void tst_focus::reason() QEXPECT_FAIL("TextArea", "", Continue); QEXPECT_FAIL("TextField", "", Continue); - QCOMPARE(control->property("activeKeyFocus"), QVariant(false)); + QCOMPARE(control->property("visualFocus"), QVariant(false)); control->forceActiveFocus(Qt::TabFocusReason); QVERIFY(control->hasActiveFocus()); @@ -242,7 +242,7 @@ void tst_focus::reason() QEXPECT_FAIL("TextArea", "", Continue); QEXPECT_FAIL("TextField", "", Continue); - QCOMPARE(control->property("activeKeyFocus"), QVariant(true)); + QCOMPARE(control->property("visualFocus"), QVariant(true)); } QTEST_MAIN(tst_focus) |