diff --git a/src/controls/Button.qml b/src/controls/Button.qml index 1f00dccbb17767f1008236dbe11de6b124932715..0a3cb131620e03274b2950f6198206092396aef6 100644 --- a/src/controls/Button.qml +++ b/src/controls/Button.qml @@ -80,7 +80,7 @@ BasicButton { /*! \qmlproperty bool BasicButton::pressed - This property holds whether the button is pressed. */ + This property holds whether the button is being pressed. */ readonly property bool pressed: __behavior.effectivePressed || menu && menu.__popupVisible activeFocusOnTab: true diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml index e5efb63cb6eac2766753978581f315840c936304..9282c58d8cd6d8128f4827e683cae8f8de42bd2d 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -99,10 +99,17 @@ Control { The default value is \c false. */ property bool activeFocusOnPress: false - /*! \internal */ + /*! \qmlproperty bool ComboBox::pressed + + This property holds whether the button is being pressed. */ readonly property bool pressed: mouseArea.pressed && mouseArea.containsMouse || popup.__popupVisible - /*! \internal */ - property alias __containsMouse: mouseArea.containsMouse + + /*! \qmlproperty bool ComboBox::hovered + + This property indicates whether the control is being hovered. + */ + readonly property alias hovered: mouseArea.containsMouse + /*! \internal */ property var __popup: popup diff --git a/src/controls/ProgressBar.qml b/src/controls/ProgressBar.qml index 6d9f8be13363c0a759ab6cfab44c47414e8745fb..e472e66e0a44c3b43339706c177eeb5d61995994 100644 --- a/src/controls/ProgressBar.qml +++ b/src/controls/ProgressBar.qml @@ -98,6 +98,12 @@ Control { */ property int orientation: Qt.Horizontal + /*! \qmlproperty bool ProgressBar::hovered + + This property indicates whether the control is being hovered. + */ + readonly property alias hovered: hoverArea.containsMouse + /*! \internal */ style: Qt.createComponent(Settings.style + "/ProgressBarStyle.qml", progressbar) @@ -123,6 +129,12 @@ Control { implicitWidth:(__panel ? __panel.implicitWidth : 0) implicitHeight: (__panel ? __panel.implicitHeight: 0) + MouseArea { + id: hoverArea + anchors.fill: parent + hoverEnabled: true + } + /*! \internal */ function setValue(v) { var newval = parseFloat(v) diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml index e7e491515b2707a185c8f80d7ef73b71a5b66eaa..64dcfff1d4ad36c62bcccf7e5ccdcb0cdfefb970 100644 --- a/src/controls/Slider.qml +++ b/src/controls/Slider.qml @@ -108,9 +108,16 @@ Control { /*! \qmlproperty bool Slider::pressed - This property indicates if slider handle is currently being pressed. + This property indicates whether the slider handle is being pressed. */ - property alias pressed: mouseArea.pressed + readonly property alias pressed: mouseArea.pressed + + /*! + \qmlproperty bool Slider::hovered + + This property indicates whether the control is being hovered. + */ + readonly property alias hovered: mouseArea.containsMouse /*! \qmlproperty real Slider::stepSize @@ -145,7 +152,7 @@ Control { /*! \qmlproperty bool Slider::activeFocusOnPress - This property indicates if the Slider should receive active focus when + This property indicates whether the Slider should receive active focus when pressed. */ property bool activeFocusOnPress: false @@ -153,16 +160,13 @@ Control { /*! \qmlproperty bool Slider::tickmarksEnabled - This property indicates if the Slider should display tickmarks + This property indicates whether the Slider should display tickmarks at step intervals. The default value is \c false. */ property bool tickmarksEnabled: false - /*! \internal */ - property bool __containsMouse: mouseArea.containsMouse - /*! \internal */ property bool __horizontal: orientation === Qt.Horizontal diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml index 68f97e0a4ceb831e631a79b560b65f9aa3146e9e..b1f87cec7d0bbb1521afc7fa3a3af9e80ccca4a5 100644 --- a/src/controls/SpinBox.qml +++ b/src/controls/SpinBox.qml @@ -134,12 +134,19 @@ Control { */ property alias font: input.font - /*! This property indicates if the Spinbox should get active + /*! This property indicates whether the Spinbox should get active focus when pressed. The default value is \c true. */ property bool activeFocusOnPress: true + /*! + \qmlproperty bool SpinBox::hovered + + This property indicates whether the control is being hovered. + */ + readonly property alias hovered: mouseArea.containsMouse + style: Qt.createComponent(Settings.style + "/SpinBoxStyle.qml", spinbox) /*! \internal */ @@ -166,8 +173,6 @@ Control { readonly property alias downPressed: mouseDown.pressed readonly property alias downHovered: mouseDown.containsMouse - readonly property alias hovered: mouseArea.containsMouse - readonly property int contentHeight: Math.max(input.implicitHeight, 16) readonly property int contentWidth: Math.max(maxSizeHint.implicitWidth, minSizeHint.implicitWidth) } diff --git a/src/controls/TextField.qml b/src/controls/TextField.qml index 903a646243b183956c0ea82c8f0060142e822c91..32b2d4fb2c5c6dd6200a9a9dd17a33a3983a52ea 100644 --- a/src/controls/TextField.qml +++ b/src/controls/TextField.qml @@ -524,8 +524,11 @@ Control { textInput.undo(); } - /*! \internal */ - property alias __containsMouse: mouseArea.containsMouse + /*! \qmlproperty bool TextField::hovered + + This property holds whether the control is being hovered. + */ + readonly property alias hovered: mouseArea.containsMouse /*! \internal */ property alias __contentHeight: textInput.contentHeight diff --git a/src/private/AbstractCheckable.qml b/src/private/AbstractCheckable.qml index ba203e4dd6ec0b2109dd7f34d16b300a333a1212..02348b7173b58248094c7ca5199f737c59ca46e8 100644 --- a/src/private/AbstractCheckable.qml +++ b/src/private/AbstractCheckable.qml @@ -69,10 +69,16 @@ Control { /*! \qmlproperty bool AbstractCheckable::pressed - This property is \c true if the control is pressed. + This property is \c true if the control is being pressed. Set this property to manually invoke a mouse click. */ - readonly property alias pressed: mouseArea.effectivePressed + property alias pressed: mouseArea.effectivePressed + + /*! \qmlproperty bool AbstractCheckcable::hovered + + This property indicates whether the control is being hovered. + */ + readonly property alias hovered: mouseArea.containsMouse /*! This property is \c true if the control is checked. @@ -99,13 +105,6 @@ Control { /*! \internal */ property var __cycleStatesHandler: cycleRadioButtonStates - /*! \internal - - This property is \c true if the control currently contains the - mouse cursor. - */ - readonly property alias __containsMouse: mouseArea.containsMouse - activeFocusOnTab: true MouseArea { diff --git a/src/private/BasicButton.qml b/src/private/BasicButton.qml index a967f73f07f64eb5e42207136dbaace568168325..b5e9ab8f418a19cc31e1eaa040afdfbb33e1cdfe 100644 --- a/src/private/BasicButton.qml +++ b/src/private/BasicButton.qml @@ -59,8 +59,14 @@ Control { /*! \qmlproperty bool BasicButton::pressed - This property holds whether the button is pressed. */ - readonly property bool pressed: behavior.effectivePressed + This property holds whether the button is being pressed. */ + readonly property alias pressed: behavior.effectivePressed + + /*! \qmlproperty bool BasicButton::hovered + + This property indicates whether the control is being hovered. + */ + readonly property alias hovered: behavior.containsMouse /*! This property holds whether the button is checkable. @@ -123,8 +129,6 @@ Control { /*! \internal */ property string __position: "only" /*! \internal */ - property alias __containsMouse: behavior.containsMouse - /*! \internal */ readonly property bool __iconOverriden: button.action && (button.action.iconSource !== button.iconSource || button.action.iconName !== button.iconName) /*! \internal */ property Action __action: action || ownAction diff --git a/src/styles/Base/ButtonStyle.qml b/src/styles/Base/ButtonStyle.qml index 3144a1a686017c4ea35b688660955a7662dc4a5d..519e4d672496733686e272a1108b6070105ea430 100644 --- a/src/styles/Base/ButtonStyle.qml +++ b/src/styles/Base/ButtonStyle.qml @@ -93,13 +93,7 @@ Style { bottom: 4 } - /*! This defines the background of the button. In addition to the public - properties of \c control, the following state properties are available: - - \table - \row \li readonly property bool \b styleData.hovered \li The control is being hovered. - \endtable - */ + /*! This defines the background of the button. */ property Component background: Item { implicitWidth: 100 implicitHeight: 25 @@ -136,13 +130,7 @@ Style { } } - /*! This defines the label of the button. In addition to the public - properties of \c control, the following state properties are available: - - \table - \row \li readonly property bool \b styleData.hovered \li The control is being hovered. - \endtable - */ + /*! This defines the label of the button. */ property Component label: Text { renderType: Text.NativeRendering verticalAlignment: Text.AlignVCenter @@ -162,9 +150,6 @@ Style { id: backgroundLoader anchors.fill: parent sourceComponent: background - property QtObject styleData: QtObject { - readonly property bool hovered: control.__containsMouse - } } Loader { @@ -175,9 +160,6 @@ Style { anchors.topMargin: padding.top anchors.rightMargin: padding.right anchors.bottomMargin: padding.bottom - property QtObject styleData: QtObject { - readonly property bool hovered: control.__containsMouse - } } } } diff --git a/src/styles/Base/CheckBoxStyle.qml b/src/styles/Base/CheckBoxStyle.qml index aa24a94a4ecafd194eb3c9373e49125df15d03fa..6aa6f9b5b3e94790715d5025dc6691e3d3c0bd3a 100644 --- a/src/styles/Base/CheckBoxStyle.qml +++ b/src/styles/Base/CheckBoxStyle.qml @@ -83,13 +83,7 @@ Style { SystemPalette.Active : SystemPalette.Disabled } - /*! This defines the text label. In addition to the public - properties of \c control, the following state properties are available: - - \table - \row \li readonly property bool \b styleData.hovered \li The control is being hovered. - \endtable - */ + /*! This defines the text label. */ property Component label: Text { text: control.text color: __syspal.text @@ -108,13 +102,7 @@ Style { /*! The spacing between indicator and label. */ property int spacing: 4 - /*! This defines the indicator button. In addition to the public - properties of \c control, the following state properties are available: - - \table - \row \li readonly property bool \b styleData.hovered \li The control is being hovered. - \endtable - */ + /*! This defines the indicator button. */ property Component indicator: Item { implicitWidth: 18 implicitHeight: 18 @@ -175,14 +163,12 @@ Style { id: indicatorLoader sourceComponent: indicator anchors.verticalCenter: parent.verticalCenter - property QtObject styleData: QtObject { readonly property bool hovered: control.__containsMouse } } Loader { id: labelLoader sourceComponent: label anchors.top: parent.top anchors.bottom: parent.bottom - property QtObject styleData: QtObject { readonly property bool hovered: control.__containsMouse } } } } diff --git a/src/styles/Base/ComboBoxStyle.qml b/src/styles/Base/ComboBoxStyle.qml index 241f3550338dc72b453568a453f3da8732e76011..7984a329f315d3e9a3a67901c526d5fe4cb68bdb 100644 --- a/src/styles/Base/ComboBoxStyle.qml +++ b/src/styles/Base/ComboBoxStyle.qml @@ -63,13 +63,7 @@ Style { /*! The padding between the background and the label components. */ padding { top: 4 ; left: 6 ; right: 6 ; bottom:4 } - /*! This defines the background of the button. In addition to the public - properties of \c control, the following state properties are available: - - \table - \row \li readonly property bool \b styleData.hovered \li The control is being hovered. - \endtable - */ + /*! This defines the background of the button. */ property Component background: Item { implicitWidth: 100 implicitHeight: 25 @@ -105,13 +99,7 @@ Style { } } - /*! This defines the label of the button. In addition to the public - properties of \c control, the following state properties are available: - - \table - \row \li readonly property bool \b styleData.hovered \li The control is being hovered. - \endtable - */ + /*! This defines the label of the button. */ property Component label: Item { implicitWidth: textitem.implicitWidth + 20 Text { @@ -137,9 +125,6 @@ Style { id: backgroundLoader anchors.fill: parent sourceComponent: background - property QtObject styleData: QtObject { - readonly property bool hovered: control.__containsMouse - } } Loader { @@ -150,9 +135,6 @@ Style { anchors.topMargin: padding.top anchors.rightMargin: padding.right anchors.bottomMargin: padding.bottom - property QtObject styleData: QtObject { - readonly property bool hovered: control.__containsMouse - } } } diff --git a/src/styles/Base/RadioButtonStyle.qml b/src/styles/Base/RadioButtonStyle.qml index b42ac1bdac5cf01702899705a5c3b6e7e94ed907..ef3f22299c02e03d2da341556820c77bd283d20c 100644 --- a/src/styles/Base/RadioButtonStyle.qml +++ b/src/styles/Base/RadioButtonStyle.qml @@ -83,13 +83,7 @@ Style { /*! The \l RadioButton attached to this style. */ readonly property RadioButton control: __control - /*! This defines the text label. In addition to the public - properties of \c control, the following state properties are available: - - \table - \row \li readonly property bool \b styleData.hovered \li The control is being hovered. - \endtable - */ + /*! This defines the text label. */ property Component label: Text { text: control.text renderType: Text.NativeRendering @@ -103,13 +97,7 @@ Style { /*! The spacing between indicator and label. */ property int spacing: 4 - /*! This defines the indicator button. In addition to the public - properties of \c control, the following state properties are available: - - \table - \row \li readonly property bool \b styleData.hovered \li The control is being hovered. - \endtable - */ + /*! This defines the indicator button. */ property Component indicator: Rectangle { width: 17 height: 17 @@ -145,14 +133,12 @@ Style { id: indicatorLoader sourceComponent: indicator anchors.verticalCenter: parent.verticalCenter - property QtObject styleData: QtObject { readonly property bool hovered: control.__containsMouse } } Loader { id: labelLoader sourceComponent: label anchors.top: parent.top anchors.bottom: parent.bottom - property QtObject styleData: QtObject { readonly property bool hovered: control.__containsMouse } } } } diff --git a/src/styles/Desktop/ButtonStyle.qml b/src/styles/Desktop/ButtonStyle.qml index 3f0670bfb3cce2f15a796fbbf68591df96b22b39..53c4ef7fda28d25a920f2d90343ba49348a3b3bb 100644 --- a/src/styles/Desktop/ButtonStyle.qml +++ b/src/styles/Desktop/ButtonStyle.qml @@ -46,7 +46,7 @@ Style { elementType: "button" sunken: control.pressed || (control.checkable && control.checked) raised: !(control.pressed || (control.checkable && control.checked)) - hover: control.__containsMouse + hover: control.hovered text: control.iconSource === "" ? "" : control.text hasFocus: control.activeFocus hints: control.styleHints diff --git a/src/styles/Desktop/CheckBoxStyle.qml b/src/styles/Desktop/CheckBoxStyle.qml index d85a2cb308a3fd269a6aa560e02451c4aa621772..9b19300f68af44b83794f60254caad0897d9d10c 100644 --- a/src/styles/Desktop/CheckBoxStyle.qml +++ b/src/styles/Desktop/CheckBoxStyle.qml @@ -52,7 +52,7 @@ Style { elementType: "checkbox" sunken: control.pressed on: control.checked || control.pressed - hover: control.__containsMouse + hover: control.hovered enabled: control.enabled hasFocus: control.activeFocus && styleitem.style == "mac" hints: control.styleHints diff --git a/src/styles/Desktop/ComboBoxStyle.qml b/src/styles/Desktop/ComboBoxStyle.qml index 78e52f531e9ed217b811c7c5cea4f70758b7b477..953976413af50d2cd076dd091ced16b36a70c20e 100644 --- a/src/styles/Desktop/ComboBoxStyle.qml +++ b/src/styles/Desktop/ComboBoxStyle.qml @@ -58,7 +58,7 @@ Style { elementType: "combobox" sunken: control.pressed raised: !sunken - hover: control.__containsMouse + hover: control.hovered enabled: control.enabled // The style makes sure the text rendering won't overlap the decoration. // In that case, 35 pixels margin in this case looks good enough. Worst diff --git a/src/styles/Desktop/RadioButtonStyle.qml b/src/styles/Desktop/RadioButtonStyle.qml index c5a3c80de500a93575627d6e96a4e01abf27b2e2..b41b959a2cb3adabf71a63805681737e21412f05 100644 --- a/src/styles/Desktop/RadioButtonStyle.qml +++ b/src/styles/Desktop/RadioButtonStyle.qml @@ -56,7 +56,7 @@ Style { anchors.verticalCenterOffset: macStyle ? -1 : 0 sunken: control.pressed on: control.checked || control.pressed - hover: control.__containsMouse + hover: control.hovered enabled: control.enabled hasFocus: control.activeFocus && styleitem.style == "mac" hints: control.styleHints diff --git a/src/styles/Desktop/SpinBoxStyle.qml b/src/styles/Desktop/SpinBoxStyle.qml index d43a26301189f128482a9af3601338e90c6da28d..24f51427cba87a465015403b8bee6764affa9d48 100644 --- a/src/styles/Desktop/SpinBoxStyle.qml +++ b/src/styles/Desktop/SpinBoxStyle.qml @@ -116,7 +116,7 @@ Style { elementType: "spinbox" anchors.fill: parent sunken: (styleData.downEnabled && styleData.downPressed) || (styleData.upEnabled && styleData.upPressed) - hover: styleData.hovered + hover: control.hovered hints: control.styleHints hasFocus: control.activeFocus enabled: control.enabled diff --git a/src/styles/Desktop/TextFieldStyle.qml b/src/styles/Desktop/TextFieldStyle.qml index ee6779ebd05d53ef34fd6edd3174a3b5400e06a9..8f71a45c47c305c957f77fd92d3c585198553188 100644 --- a/src/styles/Desktop/TextFieldStyle.qml +++ b/src/styles/Desktop/TextFieldStyle.qml @@ -48,7 +48,7 @@ Style { sunken: true hasFocus: control.activeFocus - hover: __containsMouse + hover: hovered hints: control.styleHints SystemPalette { diff --git a/src/styles/Desktop/ToolButtonStyle.qml b/src/styles/Desktop/ToolButtonStyle.qml index 3dd22a53384cfc33086c90bf32802fe0e4385584..54726962ddc7b3beebc4190887bbb2fc5933b6c5 100644 --- a/src/styles/Desktop/ToolButtonStyle.qml +++ b/src/styles/Desktop/ToolButtonStyle.qml @@ -48,8 +48,8 @@ Style { elementType: "toolbutton" on: control.checkable && control.checked sunken: control.pressed - raised: !(control.checkable && control.checked) && control.__containsMouse - hover: control.__containsMouse + raised: !(control.checkable && control.checked) && control.hovered + hover: control.hovered hasFocus: control.activeFocus hints: control.styleHints text: control.text diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml index a00544b85d466f886e79878a08b879bb40b24e8f..15ac98b935acbcfd41701989b358f563c71538bb 100644 --- a/tests/auto/controls/data/tst_spinbox.qml +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -178,7 +178,7 @@ Item { setCoordinates(spinbox) mouseMove(spinbox, mainCoord.x, mainCoord.y) - compare(spinbox.__styleData.hovered, true) + compare(spinbox.hovered, true) compare(spinbox.__styleData.upHovered, false) compare(spinbox.__styleData.downHovered, false) @@ -191,7 +191,7 @@ Item { compare(spinbox.__styleData.downHovered, true) mouseMove(spinbox, mainCoord.x - 2, mainCoord.y - 2) - compare(spinbox.__styleData.hovered, false) + compare(spinbox.hovered, false) compare(spinbox.__styleData.upHovered, false) compare(spinbox.__styleData.downHovered, false) spinbox.destroy()