Changeset View
Changeset View
Standalone View
Standalone View
src/controls/ApplicationWindow.qml
Show All 14 Lines | |||||
15 | * License along with this program; if not, write to the | 15 | * License along with this program; if not, write to the | ||
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.Controls.Private 1.0 | 21 | import QtQuick.Controls.Private 1.0 | ||
22 | import "templates/private" | 22 | import "templates/private" | ||
23 | import org.kde.kirigami 1.0 as Kirigami | 23 | import org.kde.kirigami 2.0 as Kirigami | ||
24 | import QtGraphicalEffects 1.0 | 24 | import QtGraphicalEffects 1.0 | ||
25 | 25 | | |||
26 | /** | 26 | /** | ||
27 | * A window that provides some basic features needed for all apps | 27 | * A window that provides some basic features needed for all apps | ||
28 | * | 28 | * | ||
29 | * It's usually used as a root QML component for the application. | 29 | * It's usually used as a root QML component for the application. | ||
30 | * It's based around the PageRow component, the application will be | 30 | * It's based around the PageRow component, the application will be | ||
31 | * about pages adding and removal. | 31 | * about pages adding and removal. | ||
32 | * For most of the usages, this class should be used instead | 32 | * For most of the usages, this class should be used instead | ||
33 | * of AbstractApplicationWidnow | 33 | * of AbstractApplicationWidnow | ||
34 | * @see AbstractApplicationWidnow | 34 | * @see AbstractApplicationWidnow | ||
35 | * | 35 | * | ||
36 | * Example usage: | 36 | * Example usage: | ||
37 | * @code | 37 | * @code | ||
38 | * import org.kde.kirigami 1.0 as Kirigami | 38 | * import org.kde.kirigami 2.0 as Kirigami | ||
39 | * | 39 | * | ||
40 | * Kirigami.ApplicationWindow { | 40 | * Kirigami.ApplicationWindow { | ||
41 | * [...] | 41 | * [...] | ||
42 | * globalDrawer: Kirigami.GlobalDrawer { | 42 | * globalDrawer: Kirigami.GlobalDrawer { | ||
43 | * actions: [ | 43 | * actions: [ | ||
44 | * Kirigami.Action { | 44 | * Kirigami.Action { | ||
45 | * text: "View" | 45 | * text: "View" | ||
46 | * iconName: "view-list-icons" | 46 | * iconName: "view-list-icons" | ||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | 123 | if (bottomMargin > 0) { | |||
124 | root.reachableMode = false; | 124 | root.reachableMode = false; | ||
125 | } | 125 | } | ||
126 | } | 126 | } | ||
127 | } | 127 | } | ||
128 | //FIXME | 128 | //FIXME | ||
129 | onCurrentIndexChanged: root.reachableMode = false; | 129 | onCurrentIndexChanged: root.reachableMode = false; | ||
130 | 130 | | |||
131 | function goBack() { | 131 | function goBack() { | ||
132 | if (root.contextDrawer && root.contextDrawer.opened && root.contextDrawer.modal) { | 132 | if (root.contextDrawer && root.contextDrawer.drawerOpen && root.contextDrawer.modal) { | ||
133 | root.contextDrawer.close(); | 133 | root.contextDrawer.close(); | ||
134 | } else if (root.globalDrawer && root.globalDrawer.opened && root.globalDrawer.modal) { | 134 | } else if (root.globalDrawer && root.globalDrawer.drawerOpen && root.globalDrawer.modal) { | ||
135 | root.globalDrawer.close(); | 135 | root.globalDrawer.close(); | ||
136 | } else { | 136 | } else { | ||
137 | var backEvent = {accepted: false} | 137 | var backEvent = {accepted: false} | ||
138 | if (root.pageStack.currentIndex >= 1) { | 138 | if (root.pageStack.currentIndex >= 1) { | ||
139 | root.pageStack.currentItem.backRequested(backEvent); | 139 | root.pageStack.currentItem.backRequested(backEvent); | ||
140 | if (!backEvent.accepted) { | 140 | if (!backEvent.accepted) { | ||
141 | if (root.pageStack.depth > 1) { | 141 | if (root.pageStack.depth > 1) { | ||
142 | root.pageStack.currentIndex = Math.max(0, root.pageStack.currentIndex - 1); | 142 | root.pageStack.currentIndex = Math.max(0, root.pageStack.currentIndex - 1); | ||
Show All 17 Lines | |||||
160 | 160 | | |||
161 | Rectangle { | 161 | Rectangle { | ||
162 | z: -1 | 162 | z: -1 | ||
163 | anchors.fill: parent | 163 | anchors.fill: parent | ||
164 | color: Kirigami.Theme.backgroundColor | 164 | color: Kirigami.Theme.backgroundColor | ||
165 | } | 165 | } | ||
166 | focus: true | 166 | focus: true | ||
167 | } | 167 | } | ||
168 | | ||||
169 | Component.onCompleted: { | | |||
170 | if (root.header === undefined) { | | |||
171 | var component = Qt.createComponent(Qt.resolvedUrl("./ApplicationHeader.qml")); | | |||
172 | root.header = component.createObject(root.contentItem.parent); | | |||
173 | } | | |||
174 | } | | |||
175 | } | 168 | } |