diff options
author | Jens Bache-Wiig <jens.bache-wiig@digia.com> | 2013-05-28 17:27:09 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-05-29 10:46:25 +0200 |
commit | 10851004e327f4ab798753c645ab987f10160100 (patch) | |
tree | 567be49d2527f0dd7a0f848556d4999cd78fca86 /src | |
parent | 5eb54a1a9fcb25790fa7e54c4c20f61b39368e8b (diff) | |
download | qtquickcontrols-10851004e327f4ab798753c645ab987f10160100.tar.gz |
Consistent use of "hovered" and style API conventions
We were still using "containsMouse" in a few places, and
we should consistently add "hovered" to all button types
for consistency. Also fixed the SplitView to follow the
new style conventions.
Change-Id: Iebc333c0cecc5bcde27e626b1a611c2f2edcf7dc
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Reviewed-by: Caroline Chao <caroline.chao@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/controls/ScrollView.qml | 2 | ||||
-rw-r--r-- | src/controls/SpinBox.qml | 2 | ||||
-rw-r--r-- | src/controls/SplitView.qml | 50 | ||||
-rw-r--r-- | src/private/TabBar.qml | 3 | ||||
-rw-r--r-- | src/styles/Base/ButtonStyle.qml | 4 | ||||
-rw-r--r-- | src/styles/Base/CheckBoxStyle.qml | 2 | ||||
-rw-r--r-- | src/styles/Base/ComboBoxStyle.qml | 22 | ||||
-rw-r--r-- | src/styles/Base/RadioButtonStyle.qml | 18 | ||||
-rw-r--r-- | src/styles/Base/TabViewStyle.qml | 2 | ||||
-rw-r--r-- | src/styles/Desktop/SpinBoxStyle.qml | 2 |
10 files changed, 73 insertions, 34 deletions
diff --git a/src/controls/ScrollView.qml b/src/controls/ScrollView.qml index 3262648e..efa6e631 100644 --- a/src/controls/ScrollView.qml +++ b/src/controls/ScrollView.qml @@ -146,7 +146,7 @@ FocusScope { /*! \internal */ property Component style: Qt.createComponent(Settings.style + "/ScrollViewStyle.qml", root) - /* \internal */ + /*! \internal */ property PaddedStyle __style: styleLoader.item activeFocusOnTab: true diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml index 4db67c8d..92f25fbc 100644 --- a/src/controls/SpinBox.qml +++ b/src/controls/SpinBox.qml @@ -157,7 +157,7 @@ Control { readonly property alias downPressed: mouseDown.pressed readonly property alias downHovered: mouseDown.containsMouse - readonly property alias containsMouse: mouseArea.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/SplitView.qml b/src/controls/SplitView.qml index fc43874e..0adb4282 100644 --- a/src/controls/SplitView.qml +++ b/src/controls/SplitView.qml @@ -117,14 +117,17 @@ Item { /*! This property holds the delegate that will be instantiated between each child item. Inside the delegate the following properties are available: - \list - \li int \c handleIndex - specifies the index of the splitter handle. The handle - between the first and the second item will get index 0, - the next handle index 1 etc. - \li bool \c pressed: the handle is being pressed. - \li bool \c resizing: the handle is being dragged. - \endlist - */ + + \table + \li readonly property bool styleData.index - Specifies the index of the splitter handle. The handle + between the first and the second item will get index 0, + the next handle index 1 etc. + \li readonly property bool styleData.hovered - The handle is being hovered. + \li readonly property bool styleData.pressed - The handle is being pressed. + \li readonly property bool styleData.resizing - The handle is being dragged. + \endtable + +*/ property Component handleDelegate: Rectangle { width: 1 height: 1 @@ -176,7 +179,7 @@ Item { continue if (splitterItems.children.length > 0) - handleLoader.createObject(splitterHandles, {"handleIndex":splitterItems.children.length - 1}) + handleLoader.createObject(splitterHandles, {"__handleIndex":splitterItems.children.length - 1}) item.parent = splitterItems i-- // item was removed from list item.widthChanged.connect(d.updateLayout) @@ -319,18 +322,21 @@ Item { id: handleLoader Loader { id: itemHandle - property int handleIndex: -1 - property alias containsMouse: mouseArea.containsMouse - property alias pressed: mouseArea.pressed - property bool resizing: mouseArea.drag.active - visible: __items[handleIndex + ((d.fillIndex >= handleIndex) ? 0 : 1)].visible + property int __handleIndex: -1 + property QtObject styleData: QtObject { + readonly property int index: __handleIndex + readonly property alias hovered: mouseArea.containsMouse + readonly property alias pressed: mouseArea.pressed + readonly property bool resizing: mouseArea.drag.active + onResizingChanged: root.resizing = resizing + } + visible: __items[__handleIndex + ((d.fillIndex >= __handleIndex) ? 0 : 1)].visible sourceComponent: handleDelegate onWidthChanged: d.updateLayout() onHeightChanged: d.updateLayout() onXChanged: moveHandle() onYChanged: moveHandle() - onResizingChanged: root.resizing = resizing MouseArea { id: mouseArea @@ -357,12 +363,12 @@ Item { var leftEdge, rightEdge, newWidth, leftStopX, rightStopX var i - if (d.fillIndex > handleIndex) { + if (d.fillIndex > __handleIndex) { // Resize item to the left. // Ensure that the handle is not crossing other handles. So // find the first visible handle to the left to determine the left edge: leftEdge = 0 - for (i=handleIndex-1; i>=0; --i) { + for (i=__handleIndex-1; i>=0; --i) { leftHandle = __handles[i] if (leftHandle.visible) { leftEdge = leftHandle[d.offset] + leftHandle[d.size] @@ -371,13 +377,13 @@ Item { } // Ensure: leftStopX >= itemHandle[d.offset] >= rightStopX - var min = d.accumulatedSize(handleIndex+1, __items.length, true) + var min = d.accumulatedSize(__handleIndex+1, __items.length, true) rightStopX = root[d.size] - min - itemHandle[d.size] leftStopX = Math.max(leftEdge, itemHandle[d.offset]) itemHandle[d.offset] = Math.min(rightStopX, Math.max(leftStopX, itemHandle[d.offset])) newWidth = itemHandle[d.offset] - leftEdge - leftItem = __items[handleIndex] + leftItem = __items[__handleIndex] // The next line will trigger 'updateLayout': leftItem[d.size] = newWidth } else { @@ -385,7 +391,7 @@ Item { // Ensure that the handle is not crossing other handles. So // find the first visible handle to the right to determine the right edge: rightEdge = root[d.size] - for (i=handleIndex+1; i<__handles.length; ++i) { + for (i=__handleIndex+1; i<__handles.length; ++i) { rightHandle = __handles[i] if (rightHandle.visible) { rightEdge = rightHandle[d.offset] @@ -394,13 +400,13 @@ Item { } // Ensure: leftStopX <= itemHandle[d.offset] <= rightStopX - min = d.accumulatedSize(0, handleIndex+1, true) + min = d.accumulatedSize(0, __handleIndex+1, true) leftStopX = min - itemHandle[d.size] rightStopX = Math.min((rightEdge - itemHandle[d.size]), itemHandle[d.offset]) itemHandle[d.offset] = Math.max(leftStopX, Math.min(itemHandle[d.offset], rightStopX)) newWidth = rightEdge - (itemHandle[d.offset] + itemHandle[d.size]) - rightItem = __items[handleIndex+1] + rightItem = __items[__handleIndex+1] // The next line will trigger 'updateLayout': rightItem[d.size] = newWidth } diff --git a/src/private/TabBar.qml b/src/private/TabBar.qml index aa1f919b..a856cedd 100644 --- a/src/private/TabBar.qml +++ b/src/private/TabBar.qml @@ -170,7 +170,6 @@ FocusScope { property int tabindex: index property bool selected : tabView.currentIndex === index - property bool hover: containsMouse property string title: modelData.title property bool nextSelected: tabView.currentIndex === index + 1 property bool previousSelected: tabView.currentIndex === index - 1 @@ -201,7 +200,7 @@ FocusScope { readonly property alias title: tabitem.title readonly property alias nextSelected: tabitem.nextSelected readonly property alias previsousSelected: tabitem.previousSelected - readonly property alias hovered: tabitem.hover + readonly property alias hovered: tabitem.containsMouse readonly property bool activeFocus: tabbar.activeFocus } diff --git a/src/styles/Base/ButtonStyle.qml b/src/styles/Base/ButtonStyle.qml index e668b042..5674c118 100644 --- a/src/styles/Base/ButtonStyle.qml +++ b/src/styles/Base/ButtonStyle.qml @@ -96,7 +96,7 @@ PaddedStyle { properties of \c control, the following state properties are available: \table - \li readonly property bool styleData.hovered - The button is currently hovered. + \li readonly property bool styleData.hovered - The control is being hovered. \endtable */ property Component background: Item { @@ -139,7 +139,7 @@ PaddedStyle { properties of \c control, the following state properties are available: \table - \li readonly property bool styleData.hovered - The button is currently hovered. + \li readonly property bool styleData.hovered - The control is being hovered. \endtable */ property Component label: Text { diff --git a/src/styles/Base/CheckBoxStyle.qml b/src/styles/Base/CheckBoxStyle.qml index 1323aa85..b10b2859 100644 --- a/src/styles/Base/CheckBoxStyle.qml +++ b/src/styles/Base/CheckBoxStyle.qml @@ -163,12 +163,14 @@ PaddedStyle { 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 9795d1a8..5643d50f 100644 --- a/src/styles/Base/ComboBoxStyle.qml +++ b/src/styles/Base/ComboBoxStyle.qml @@ -62,7 +62,13 @@ PaddedStyle { /*! The padding between the background and the label components. */ padding { top: 4 ; left: 6 ; right: 6 ; bottom:4 } - /*! The background of the button. */ + /*! This defines the background of the button. In addition to the public + properties of \c control, the following state properties are available: + + \table + \li readonly property bool styleData.hovered - The control is being hovered. + \endtable + */ property Component background: Item { implicitWidth: 100 implicitHeight: 25 @@ -98,7 +104,13 @@ PaddedStyle { } } - /*! The label of the button. */ + /*! This defines the label of the button. In addition to the public + properties of \c control, the following state properties are available: + + \table + \li readonly property bool styleData.hovered - The control is being hovered. + \endtable + */ property Component label: Item { implicitWidth: textitem.implicitWidth + 20 Text { @@ -124,6 +136,9 @@ PaddedStyle { id: backgroundLoader anchors.fill: parent sourceComponent: background + property QtObject styleData: QtObject { + readonly property bool hovered: control.__containsMouse + } } Loader { @@ -134,6 +149,9 @@ PaddedStyle { 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 49d15e3d..614a9537 100644 --- a/src/styles/Base/RadioButtonStyle.qml +++ b/src/styles/Base/RadioButtonStyle.qml @@ -83,7 +83,13 @@ PaddedStyle { /*! The \l RadioButton attached to this style. */ readonly property RadioButton control: __control - /*! The text label. */ + /*! This defines the text label. In addition to the public + properties of \c control, the following state properties are available: + + \table + \li readonly property bool styleData.hovered - The control is being hovered. + \endtable + */ property Component label: Text { text: control.text renderType: Text.NativeRendering @@ -97,7 +103,13 @@ PaddedStyle { /*! The spacing between indicator and label. */ property int spacing: 4 - /*! The indicator button. */ + /*! This defines the indicator button. In addition to the public + properties of \c control, the following state properties are available: + + \table + \li readonly property bool styleData.hovered - The control is being hovered. + \endtable + */ property Component indicator: Rectangle { width: 17 height: 17 @@ -133,12 +145,14 @@ PaddedStyle { 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/TabViewStyle.qml b/src/styles/Base/TabViewStyle.qml index 91750ba9..344412b6 100644 --- a/src/styles/Base/TabViewStyle.qml +++ b/src/styles/Base/TabViewStyle.qml @@ -127,7 +127,7 @@ Style { \li readonly property string styleData.title - Tab title text. \li readonly property bool styleData.nextSelected - The next tab is selected. \li readonly property bool styleData.previousSelected - The previous tab is selected. - \li readonly property bool styleData.hovered - The tab is currently under the mouse. + \li readonly property bool styleData.hovered - The tab is being hovered. \li readonly property bool styleData.activeFocus - The tab button has keyboard focus. \endtable */ diff --git a/src/styles/Desktop/SpinBoxStyle.qml b/src/styles/Desktop/SpinBoxStyle.qml index e8012a69..59c20f55 100644 --- a/src/styles/Desktop/SpinBoxStyle.qml +++ b/src/styles/Desktop/SpinBoxStyle.qml @@ -115,7 +115,7 @@ PaddedStyle { elementType: "spinbox" anchors.fill: parent sunken: (styleData.downEnabled && styleData.downPressed) || (styleData.upEnabled && styleData.upPressed) - hover: styleData.containsMouse + hover: styleData.hovered hints: control.styleHints hasFocus: control.activeFocus enabled: control.enabled |