QtMvvm  1.0.0
A mvvm oriented library for Qt, to create Projects for Widgets and Quick in parallel
QtMvvmApp.qml
1 import QtQuick 2.10
2 import QtQuick.Controls 2.3
3 import de.skycoder42.QtMvvm.Quick 1.0
4 
16 ApplicationWindow {
17  id: _root
18  visible: true
19  width: 360
20  height: 520
21 
38  readonly property alias drawer: _drawerLoader.item
55  property bool rootOnlyDrawer: true
56 
58  id: _rootProgress
59  z: _rootStack.empty ? 10 : -10
60  }
61 
63  id: _rootStack
64  anchors.fill: parent
65  }
66 
67  Loader {
68  id: _drawerLoader
69  active: false
70  asynchronous: false
71  sourceComponent: PresentingDrawer {
72  id: _rootDrawer
73 
74  interactive: !_root.rootOnlyDrawer || _rootStack.depth == 1
75  }
76  }
77 
79  id: _rootPopup
80  rootItem: _root.contentItem
81  }
82 
84  id: _rootDialogs
85  rootItem: _root.contentItem
86  }
87 
98  function presentDrawerContent(item) {
99  if(!_drawerLoader.item)
100  _drawerLoader.active = true;
101  return _drawerLoader.item.presentDrawerContent(item);
102  }
103 
113  function presentItem(item) {
114  return _rootStack.presentItem(item);
115  }
116 
126  function presentPopup(popup) {
127  return _rootPopup.presentPopup(popup);
128  }
129 
140  function showDialog(config, result) {
141  return _rootDialogs.showDialog(config, result);
142  }
143 
145  function toggleDrawer() {
146  if(_drawerLoader.item)
147  _drawerLoader.item.toggle();
148  else
149  console.warn("No drawer like view active. Cannot toggle drawer");
150  }
151 
165  function closeAction() {
166  var closed = false;
167  if(!closed)
168  closed = _rootDialogs.closeAction();
169  if(!closed)
170  closed = _rootPopup.closeAction();
171  if(!closed && _drawerLoader.item)
172  closed = _drawerLoader.item.closeAction();
173  if(!closed)
174  closed = _rootStack.closeAction();
175  return closed;
176  }
177 
178  Component.onCompleted: QuickPresenter.qmlPresenter = _root
179 
180  onClosing: close.accepted = !closeAction();
181 }
A Drawer that can be used as a presenter for drawer views.
A ProgressBar with automatic bindings to the presenters view loading progress.
QObject qmlPresenter
The primary presenter QML object.
A presentation helper that can present standard mvvm views.
A presentation helper that can present generic mvvm dialogs.
bool showDialog(MessageConfig config, MessageResult result)
The primary presenting method to present a dialog.
The QML import for the QtMvvmQuick QML module.
Definition: ActionButton.qml:4
A presentation helper that can present mvvm views that extend the Popup type.
A QML singleton to access common presenter methods globally.