summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Bache-Wiig <jens.bache-wiig@digia.com>2013-06-05 09:54:28 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-06 09:37:14 +0200
commit420bb714a8c8ebc67ad958897939d7d96e11806c (patch)
treea01cca701a930cba8710fd4cb9a5bb9abaaf9054
parent0ad4925f94c86dbe75e01d890fdb9fce64ca52fe (diff)
Expose hovered to our controls and document it consistently
The current solution is messy and we only expose it partially to some of our styles. I think we should simply expose this to all. Change-Id: Ia546d5657ea416df99c9d9d92cc714b7f1c928fe Reviewed-by: Caroline Chao <caroline.chao@digia.com> Reviewed-by: Nico Vertriest <nico.vertriest@digia.com>
-rw-r--r--src/controls/Button.qml2
-rw-r--r--src/controls/ComboBox.qml13
-rw-r--r--src/controls/ProgressBar.qml12
-rw-r--r--src/controls/Slider.qml18
-rw-r--r--src/controls/SpinBox.qml11
-rw-r--r--src/controls/TextField.qml7
-rw-r--r--src/private/AbstractCheckable.qml17
-rw-r--r--src/private/BasicButton.qml12
-rw-r--r--src/styles/Base/ButtonStyle.qml22
-rw-r--r--src/styles/Base/CheckBoxStyle.qml18
-rw-r--r--src/styles/Base/ComboBoxStyle.qml22
-rw-r--r--src/styles/Base/RadioButtonStyle.qml18
-rw-r--r--src/styles/Desktop/ButtonStyle.qml2
-rw-r--r--src/styles/Desktop/CheckBoxStyle.qml2
-rw-r--r--src/styles/Desktop/ComboBoxStyle.qml2
-rw-r--r--src/styles/Desktop/RadioButtonStyle.qml2
-rw-r--r--src/styles/Desktop/SpinBoxStyle.qml2
-rw-r--r--src/styles/Desktop/TextFieldStyle.qml2
-rw-r--r--src/styles/Desktop/ToolButtonStyle.qml4
-rw-r--r--tests/auto/controls/data/tst_spinbox.qml4
20 files changed, 81 insertions, 111 deletions
diff --git a/src/controls/Button.qml b/src/controls/Button.qml
index 1f00dccbb..0a3cb1316 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 e5efb63cb..9282c58d8 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 6d9f8be13..e472e66e0 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 e7e491515..64dcfff1d 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,7 +160,7 @@ 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.
@@ -161,9 +168,6 @@ Control {
property bool tickmarksEnabled: false
/*! \internal */
- property bool __containsMouse: mouseArea.containsMouse
-
- /*! \internal */
property bool __horizontal: orientation === Qt.Horizontal
/*! \internal */
diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml
index 68f97e0a4..b1f87cec7 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 903a64624..32b2d4fb2 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 ba203e4dd..02348b717 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 a967f73f0..b5e9ab8f4 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 3144a1a68..519e4d672 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 aa24a94a4..6aa6f9b5b 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 241f35503..7984a329f 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 b42ac1bda..ef3f22299 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 3f0670bfb..53c4ef7fd 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 d85a2cb30..9b19300f6 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 78e52f531..953976413 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 c5a3c80de..b41b959a2 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 d43a26301..24f51427c 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 ee6779ebd..8f71a45c4 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 3dd22a533..54726962d 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 a00544b85..15ac98b93 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()