aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-03-13 09:39:14 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2017-03-13 10:19:16 +0000
commit1360d0b093c65bffa06e2db1b5c0991167d6c38f (patch)
tree0b52716f2ff93d13fc77a7a378a4a4454e68bda5 /examples
parentc99397d75120095e7c91bd674e10c760eba64ad4 (diff)
Wearable: use AbstractButton for the PathView delegate
Move the app title outside the delegate. Its position is static, and its visible in one place only, so one instance is enough. Change-Id: If5a9f4cb7893980cef6a08fdc8adde929f187460 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/quickcontrols2/wearable/qml/LauncherPage.qml92
1 files changed, 39 insertions, 53 deletions
diff --git a/examples/quickcontrols2/wearable/qml/LauncherPage.qml b/examples/quickcontrols2/wearable/qml/LauncherPage.qml
index e867d63d..a542058c 100644
--- a/examples/quickcontrols2/wearable/qml/LauncherPage.qml
+++ b/examples/quickcontrols2/wearable/qml/LauncherPage.qml
@@ -49,6 +49,7 @@
****************************************************************************/
import QtQuick 2.7
+import QtQuick.Controls 2.0 as QQC2
import "WatchFace"
import "Fitness"
import "Navigation"
@@ -159,64 +160,49 @@ Item {
Component {
id: pathDelegate
- Item {
- id: wrapper
-
- width: childrenRect.width
- height: childrenRect.height
-
- Column {
- opacity: wrapper.PathView.itemOpacity
- Item {
- anchors.horizontalCenter: parent.horizontalCenter
- height: wrapper.PathView.view.objSize
- width: wrapper.PathView.view.objSize
-
- Image {
- anchors.fill: parent
- source: icon
- }
- Rectangle {
- anchors.fill: parent
- radius: width / 2
- color: "transparent"
-
- border.width: 3
- border.color: wrapper.PathView.isCurrentItem ?
- "transparent"
- : UIStyle.colorQtGray4
- }
- }
-
- Text {
- id: appTitle
-
- opacity: wrapper.PathView.isCurrentItem
- && (wrapper.PathView.itemOpacity === 1.0)
-
- anchors.horizontalCenter: parent.horizontalCenter
- font.bold: true
- font.pixelSize: UIStyle.fontSizeS
- font.letterSpacing: 1
- color: UIStyle.colorQtGray1
- text: title
- }
+ QQC2.AbstractButton {
+ text: model.title
+ opacity: PathView.itemOpacity
+
+ contentItem: Image {
+ source: model.icon
+ fillMode: Image.Pad
}
- MouseArea {
- id: pathItemMouseArea
- anchors.fill: parent
- onClicked: {
- if (circularView.currentIndex === index)
- loadPage()
- else
- circularView.currentIndex = index
- }
+ background: Rectangle {
+ radius: width / 2
+ color: "transparent"
+
+ border.width: 3
+ border.color: parent.PathView.isCurrentItem ?
+ "transparent"
+ : UIStyle.colorQtGray4
}
- function loadPage() {
- stackView.push(Qt.resolvedUrl(page))
+
+ onClicked: {
+ if (circularView.currentIndex === index)
+ stackView.push(Qt.resolvedUrl(page))
+ else
+ circularView.currentIndex = index
}
}
}
}
+
+ Text {
+ id: appTitle
+
+ property Item currentItem: circularView.currentItem
+
+ visible: currentItem ? currentItem.PathView.itemOpacity === 1.0 : 0
+
+ text: currentItem ? currentItem.text : ""
+ anchors.centerIn: parent
+ anchors.verticalCenterOffset: (circularView.objSize + height) / 2
+
+ font.bold: true
+ font.pixelSize: UIStyle.fontSizeS
+ font.letterSpacing: 1
+ color: UIStyle.colorQtGray1
+ }
}