summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-02 16:41:42 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-02 16:41:42 +0200
commit8f6f5450e1da3df06061e8720e37f1b0aea790b7 (patch)
tree83ec541f40baa67968a98e10d4cc0f27d36aca3c /components
parent74ef34dd42c2a780fbb7577a43e67f2b780d1b2c (diff)
downloadkube-8f6f5450e1da3df06061e8720e37f1b0aea790b7.tar.gz
kube-8f6f5450e1da3df06061e8720e37f1b0aea790b7.zip
Use the StackView to dynamically create the views we need
... that way we don't have to do our own bookkeeping
Diffstat (limited to 'components')
-rw-r--r--components/kube/contents/ui/Kube.qml57
1 files changed, 25 insertions, 32 deletions
diff --git a/components/kube/contents/ui/Kube.qml b/components/kube/contents/ui/Kube.qml
index 54b18b7e..72e74d71 100644
--- a/components/kube/contents/ui/Kube.qml
+++ b/components/kube/contents/ui/Kube.qml
@@ -63,9 +63,7 @@ Controls2.ApplicationWindow {
63 63
64 Kube.Listener { 64 Kube.Listener {
65 filter: Kube.Messages.compose 65 filter: Kube.Messages.compose
66 onMessageReceived: { 66 onMessageReceived: kubeViews.openComposer()
67 kubeViews.currentIndex = 2
68 }
69 } 67 }
70 68
71 //BEGIN Shortcuts 69 //BEGIN Shortcuts
@@ -127,18 +125,12 @@ Controls2.ApplicationWindow {
127 125
128 Kube.IconButton { 126 Kube.IconButton {
129 iconName: Kube.Icons.mail_inverted 127 iconName: Kube.Icons.mail_inverted
130 128 onClicked: kubeViews.setMailView()
131 onClicked: {
132 kubeViews.currentIndex = 0
133 }
134 } 129 }
135 130
136 Kube.IconButton { 131 Kube.IconButton {
137 iconName: Kube.Icons.user_inverted 132 iconName: Kube.Icons.user_inverted
138 133 onClicked: kubeViews.setPeopleView()
139 onClicked: {
140 kubeViews.currentIndex = 1
141 }
142 } 134 }
143 } 135 }
144 Column { 136 Column {
@@ -157,41 +149,42 @@ Controls2.ApplicationWindow {
157 Kube.AccountSwitcher {} 149 Kube.AccountSwitcher {}
158 } 150 }
159 } 151 }
160 StackLayout { 152 StackView {
161 id: kubeViews 153 id: kubeViews
162 154
163 property var stack: [0]
164
165 function goToPreviousView()
166 {
167 //Pop off current view
168 stack.pop()
169 //Then go to the previous view
170 kubeViews.currentIndex = stack.pop()
171 }
172
173 currentIndex: 0
174 onCurrentIndexChanged: {
175 if (stack.length > 100) {
176 //Cut off the first 50 once we grow to 100 (so we don't grow forever)
177 stack = stack.slice(50);
178 }
179 stack.push(currentIndex)
180 }
181 anchors { 155 anchors {
182 top: mainContent.top 156 top: mainContent.top
183 bottom: mainContent.bottom 157 bottom: mainContent.bottom
184 } 158 }
185 Layout.fillWidth: true 159 Layout.fillWidth: true
160 initialItem: mailView
161
162 function setPeopleView() {
163 //TODO replacing here while a composer is open is destructive
164 kubeViews.push({item: peopleView, replace: true, immediate: true})
165 }
166 function setMailView() {
167 //TODO replacing here while a composer is open is destructive
168 kubeViews.push({item: mailView, replace: true, immediate: true})
169 }
170 function openComposer() {
171 kubeViews.push({item: composerView, immediate: true})
172 }
173
174
175 //Not components so we maintain state
186 MailView { 176 MailView {
187 id: mailView 177 id: mailView
188 } 178 }
189 PeopleView { 179 PeopleView {
190 id: peopleView 180 id: peopleView
191 } 181 }
192 ComposerView { 182 //A component so it's always destroyed when we're done
183 Component {
193 id: composerView 184 id: composerView
194 onDone: kubeViews.goToPreviousView() 185 ComposerView {
186 onDone: kubeViews.pop({immediate: true})
187 }
195 } 188 }
196 } 189 }
197 } 190 }