[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kirigami] /: Prefer aliased properties
From: Aleix Pol <aleixpol () kde ! org>
Date: 2016-07-28 18:44:24
Message-ID: E1bSqIC-0000ba-Fw () code ! kde ! org
[Download RAW message or body]
Git commit 47445f6e2167f8e5ba4ea7ae72d3ec9474231149 by Aleix Pol.
Committed on 28/07/2016 at 18:43.
Pushed by apol into branch 'master'.
Prefer aliased properties
We make sure there's no useless type conversions in the way
M +10 -0 examples/gallery/contents/ui/gallery/ListViewGallery.qml
M +2 -2 src/controls/BasicListItem.qml
M +30 -0 src/controls/ScrollablePage.qml
http://commits.kde.org/kirigami/47445f6e2167f8e5ba4ea7ae72d3ec9474231149
diff --git a/examples/gallery/contents/ui/gallery/ListViewGallery.qml \
b/examples/gallery/contents/ui/gallery/ListViewGallery.qml index d605cb9..e2543be \
100644
--- a/examples/gallery/contents/ui/gallery/ListViewGallery.qml
+++ b/examples/gallery/contents/ui/gallery/ListViewGallery.qml
@@ -39,14 +39,24 @@ ScrollablePage {
background: Rectangle {
color: Theme.viewBackgroundColor
}
+ header: Component {
+ Controls.Button {
+ text: "Important information on top"
+ onClicked: theList.positionViewAtBeginning()
+ }
+ }
ListView {
+ id: theList
Timer {
id: refreshRequestTimer
interval: 3000
onTriggered: page.refreshing = false
}
model: 200
+ header: Label {
+ text: "super important information"
+ }
delegate: BasicListItem {
label: "Item " + modelData
}
diff --git a/src/controls/BasicListItem.qml b/src/controls/BasicListItem.qml
index 06d880d..1e9ca10 100644
--- a/src/controls/BasicListItem.qml
+++ b/src/controls/BasicListItem.qml
@@ -44,7 +44,7 @@ AbstractListItem {
* be either a QIcon, a string name of a fdo compatible name,
* or any url accepted by the Image element.
*/
- property var icon
+ property alias icon: iconItem.source
RowLayout {
anchors {
@@ -52,10 +52,10 @@ AbstractListItem {
verticalCenter: parent.verticalCenter
}
Icon {
+ id: iconItem
Layout.minimumHeight: Units.iconSizes.smallMedium
Layout.maximumHeight: Layout.minimumHeight
Layout.minimumWidth: height
- source: listItem.icon
selected: listItem.checked || listItem.pressed
}
Label {
diff --git a/src/controls/ScrollablePage.qml b/src/controls/ScrollablePage.qml
index 9d036b9..cd50e15 100644
--- a/src/controls/ScrollablePage.qml
+++ b/src/controls/ScrollablePage.qml
@@ -115,6 +115,8 @@ Page {
*/
property alias bottomPadding: scrollView.bottomPadding
+ property alias pageHeader: pageHeaderLoader.sourceComponent
+
children: [
RefreshableScrollView {
id: scrollView
@@ -131,6 +133,34 @@ Page {
id: overlay
anchors.fill: parent
property Item oldContentItem
+
+ Loader {
+ id: pageHeaderLoader
+ anchors {
+ left: parent.left
+ right: parent.right
+ }
+
+ Behavior on y {
+ NumberAnimation {
+ duration: Units.longDuration
+ easing.type: Easing.InOutQuad
+ }
+ }
+
+ states: [
+ State {
+ name: "top"
+ when: root.flickable.contentY > 0
+ PropertyChanges { target: pageHeaderLoader; y: 0 }
+ },
+ State {
+ name: "scrolled"
+ when: root.flickable.contentY <= 0
+ PropertyChanges { target: pageHeaderLoader; y: -height }
+ }
+ ]
+ }
}
]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic