Changeset View
Changeset View
Standalone View
Standalone View
src/controls/templates/ApplicationHeader.qml
Show All 15 Lines | |||||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.5 | 20 | import QtQuick 2.5 | ||
21 | import QtQuick.Layouts 1.2 | 21 | import QtQuick.Layouts 1.2 | ||
22 | import QtQuick.Controls.Private 1.0 | 22 | import QtQuick.Controls.Private 1.0 | ||
23 | import "private" | 23 | import "private" | ||
24 | import org.kde.kirigami 1.0 | 24 | import org.kde.kirigami 2.0 | ||
25 | 25 | | |||
26 | 26 | | |||
27 | /** | 27 | /** | ||
28 | * An item that can be used as a title for the application. | 28 | * An item that can be used as a title for the application. | ||
29 | * Scrolling the main page will make it taller or shorter (trough the point of going away) | 29 | * Scrolling the main page will make it taller or shorter (trough the point of going away) | ||
30 | * It's a behavior similar to the typical mobile web browser adressbar | 30 | * It's a behavior similar to the typical mobile web browser adressbar | ||
31 | * the minimum, preferred and maximum heights of the item can be controlled with | 31 | * the minimum, preferred and maximum heights of the item can be controlled with | ||
32 | * * minimumHeight: default is 0, i.e. hidden | 32 | * * minimumHeight: default is 0, i.e. hidden | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 74 | if (!titleList.isTabBar && (!Settings.isMobile || Qt.platform.os == "ios")) { | |||
75 | var component = Qt.createComponent(Qt.resolvedUrl("private/BackButton.qml")); | 75 | var component = Qt.createComponent(Qt.resolvedUrl("private/BackButton.qml")); | ||
76 | titleList.backButton = component.createObject(titleList.parent); | 76 | titleList.backButton = component.createObject(titleList.parent); | ||
77 | } | 77 | } | ||
78 | } | 78 | } | ||
79 | property Item backButton | 79 | property Item backButton | ||
80 | clip: true | 80 | clip: true | ||
81 | anchors { | 81 | anchors { | ||
82 | fill: parent | 82 | fill: parent | ||
83 | leftMargin: Math.max ((backButton ? backButton.width : (titleList.isTabBar ? 0 : Units.smallSpacing*2)), __appWindow.contentItem.x) | 83 | leftMargin: (backButton ? backButton.width : (titleList.isTabBar ? 0 : Units.smallSpacing*2)) | ||
84 | } | 84 | } | ||
85 | cacheBuffer: width ? Math.max(0, width * count) : 0 | 85 | cacheBuffer: width ? Math.max(0, width * count) : 0 | ||
86 | displayMarginBeginning: __appWindow.pageStack.width * count | 86 | displayMarginBeginning: __appWindow.pageStack.width * count | ||
87 | orientation: ListView.Horizontal | 87 | orientation: ListView.Horizontal | ||
88 | boundsBehavior: Flickable.StopAtBounds | 88 | boundsBehavior: Flickable.StopAtBounds | ||
89 | model: __appWindow.pageStack.depth | 89 | model: __appWindow.pageStack.depth | ||
90 | spacing: 0 | 90 | spacing: 0 | ||
91 | currentIndex: __appWindow.pageStack && __appWindow.pageStack.currentIndex !== undefined ? __appWindow.pageStack.currentIndex : 0 | 91 | currentIndex: __appWindow.pageStack && __appWindow.pageStack.currentIndex !== undefined ? __appWindow.pageStack.currentIndex : 0 | ||
Show All 21 Lines | 108 | NumberAnimation { | |||
113 | easing.type: Easing.InOutQuad | 113 | easing.type: Easing.InOutQuad | ||
114 | } | 114 | } | ||
115 | 115 | | |||
116 | onCurrentIndexChanged: gotoIndex(currentIndex); | 116 | onCurrentIndexChanged: gotoIndex(currentIndex); | ||
117 | onModelChanged: gotoIndex(currentIndex); | 117 | onModelChanged: gotoIndex(currentIndex); | ||
118 | onContentWidthChanged: gotoIndex(currentIndex); | 118 | onContentWidthChanged: gotoIndex(currentIndex); | ||
119 | 119 | | |||
120 | onContentXChanged: { | 120 | onContentXChanged: { | ||
121 | if (__appWindow.wideScreen && !__appWindow.pageStack.contentItem.moving) { | 121 | if (__appWindow.wideScreen && !__appWindow.pageStack.contentItem.moving && titleList.moving) { | ||
122 | //__appWindow.pageStack.contentItem.contentX = titleList.contentX | 122 | __appWindow.pageStack.contentItem.contentX = titleList.contentX | ||
123 | } | 123 | } | ||
124 | } | 124 | } | ||
125 | onHeightChanged: { | 125 | onHeightChanged: { | ||
126 | titleList.returnToBounds() | 126 | titleList.returnToBounds() | ||
127 | } | 127 | } | ||
128 | onMovementEnded: { | 128 | onMovementEnded: { | ||
129 | if (__appWindow.wideScreen) { | 129 | if (__appWindow.wideScreen) { | ||
130 | __appWindow.pageStack.contentItem.movementEnded(); | 130 | __appWindow.pageStack.contentItem.movementEnded(); | ||
Show All 16 Lines | 143 | delegate: MouseArea { | |||
147 | //currentIndex in some situations (since here we are using an int as a model, | 147 | //currentIndex in some situations (since here we are using an int as a model, | ||
148 | //even more often) so the property binding gets broken | 148 | //even more often) so the property binding gets broken | ||
149 | readonly property bool current: __appWindow.pageStack.currentIndex == index | 149 | readonly property bool current: __appWindow.pageStack.currentIndex == index | ||
150 | 150 | | |||
151 | width: { | 151 | width: { | ||
152 | //more columns shown? | 152 | //more columns shown? | ||
153 | if (__appWindow.wideScreen && page) { | 153 | if (__appWindow.wideScreen && page) { | ||
154 | if (modelData == 0 && titleList.backButton) { | 154 | if (modelData == 0 && titleList.backButton) { | ||
155 | return page.width - Math.max(0, titleList.backButton.width - __appWindow.contentItem.x); | 155 | return page.width - titleList.backButton.width; | ||
156 | } else { | 156 | } else { | ||
157 | return page.width; | 157 | return page.width; | ||
158 | } | 158 | } | ||
159 | } else { | 159 | } else { | ||
160 | return Math.min(titleList.width, delegateRoot.implicitWidth + Units.smallSpacing); | 160 | return Math.min(titleList.width, delegateRoot.implicitWidth + Units.smallSpacing); | ||
161 | } | 161 | } | ||
162 | } | 162 | } | ||
163 | height: titleList.height | 163 | height: titleList.height | ||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |