|
16 | 16 |
|
17 | 17 | import QtQuick 2.11 |
18 | 18 | import QtQuick.Controls 2.4 |
19 | | -import QtQuick.Dialogs 1.2 |
20 | 19 |
|
21 | 20 | /*! |
22 | 21 | \qmltype PopupStackView |
@@ -193,10 +192,8 @@ Item { |
193 | 192 | */ |
194 | 193 | function show() { |
195 | 194 | currentIndex = 0; |
196 | | - popupStack.clear(); |
197 | 195 | if (popupManagers !== null && popupManagers.length > 0) { |
198 | 196 | popup1.popupManagerInternal = popupManagers[currentIndex] |
199 | | - popupStack.push(popup1); |
200 | 197 | } |
201 | 198 | visible = true; |
202 | 199 | } |
@@ -289,36 +286,42 @@ Item { |
289 | 286 |
|
290 | 287 | /*! internal */ |
291 | 288 | function nextPopup() { |
| 289 | + if (popupStack.busy) |
| 290 | + return; |
| 291 | + |
292 | 292 | if (currentIndex + 1 === popupManagers.length) |
293 | 293 | return; |
294 | 294 |
|
295 | 295 | currentIndex += 1; |
296 | 296 |
|
297 | 297 | if (popupStack.currentItem === popup1) { |
298 | | - popup2.popupManagerInternal = popupManagers[currentIndex] |
299 | | - popupStack.push(popup2); |
300 | | - } |
301 | | - else |
302 | | - { |
303 | | - popup1.popupManagerInternal = popupManagers[currentIndex] |
304 | | - popupStack.push(popup1); |
| 298 | + swapPopups(popup1, popup2); |
| 299 | + } else { |
| 300 | + swapPopups(popup2, popup1); |
305 | 301 | } |
306 | | - |
307 | 302 | } |
308 | 303 |
|
309 | 304 | /*! internal */ |
310 | 305 | function previousPopup() { |
| 306 | + if (popupStack.busy) |
| 307 | + return; |
| 308 | + |
311 | 309 | if (currentIndex === 0) |
312 | 310 | return; |
313 | 311 |
|
314 | 312 | currentIndex -= 1; |
315 | 313 |
|
316 | | - if (popupStack.currentItem === popup2) |
317 | | - popup1.popupManagerInternal = popupManagers[currentIndex]; |
318 | | - else |
319 | | - popup2.popupManagerInternal = popupManagers[currentIndex]; |
| 314 | + if (popupStack.currentItem === popup1) { |
| 315 | + swapPopups(popup1, popup2); |
| 316 | + } |
| 317 | + else { |
| 318 | + swapPopups(popup2, popup1); |
| 319 | + } |
| 320 | + } |
320 | 321 |
|
321 | | - popupStack.pop(); |
| 322 | + function swapPopups(frontPopup, backPopup) { |
| 323 | + backPopup.popupManagerInternal = popupManagers[currentIndex]; |
| 324 | + popupStack.replace(frontPopup, backPopup); |
322 | 325 | } |
323 | 326 |
|
324 | 327 | /*! internal */ |
@@ -477,6 +480,10 @@ Item { |
477 | 480 | StackView { |
478 | 481 | id: popupStack |
479 | 482 | anchors.fill: parent |
| 483 | + |
| 484 | + Component.onCompleted: { |
| 485 | + push(popup1); |
| 486 | + } |
480 | 487 | } |
481 | 488 |
|
482 | 489 | Rectangle { |
|
0 commit comments