QtMvvm  1.0.0
A mvvm oriented library for Qt, to create Projects for Widgets and Quick in parallel
PopupPresenter.qml
1 import QtQuick 2.10
2 import QtQuick.Controls 2.3
3 
39 QtObject {
40  id: _popPresenter
41 
56  property Item rootItem: null
57 
59  property var _popups: []
60 
70  function presentPopup(popup) {
71  popup.parent = rootItem;
72  popup.closed.connect(function() {
73  var index = _popups.indexOf(popup);
74  if(index > -1) {
75  popup.destroy();
76  _popups.splice(index, 1);
77  }
78  });
79  _popups.push(popup);
80  popup.open();
81  return true;
82  }
83 
93  function closeAction() {
94  if(_popups.length > 0) {
95  _popups[_popups.length - 1].close();
96  return true;
97  } else
98  return false;
99  }
100 }