QtMvvm  1.0.0
A mvvm oriented library for Qt, to create Projects for Widgets and Quick in parallel
FileDialog.qml
1 import QtQuick 2.10
2 import QtQuick.Controls 2.3
3 import Qt.labs.platform 1.0 as Labs
4 import de.skycoder42.QtMvvm.Core 1.0
5 import de.skycoder42.QtMvvm.Quick 1.0
6 
18 Labs.FileDialog {
19  id: _fileDialog
20 
34  property var msgConfig
48  property MessageResult msgResult
62  property var mimeTypes
63 
65  signal closed()
66 
67  title: msgConfig.title
68  modality: Qt.WindowModal
69  folder: msgConfig.defaultValue
70  fileMode: {
71  if(msgConfig.subType == "open")
72  return Labs.FileDialog.OpenFile;
73  else if(msgConfig.subType == "files")
74  return Labs.FileDialog.OpenFiles;
75  else if(msgConfig.subType == "save")
76  return Labs.FileDialog.SaveFile;
77  else {
78  return Labs.FileDialog.OpenFile; //fallback
79  }
80  }
81  nameFilters: QuickPresenter.mimeTypeFilters(mimeTypes ? mimeTypes : msgConfig.viewProperties["mimeTypes"])
82 
83  Component.onCompleted: {
84  if(msgResult)
85  msgResult.setCloseTarget(_fileDialog, "reject()");
86  }
87 
88  onAccepted: {
89  if(msgResult) {
90  if(msgConfig.subType == "files")
91  msgResult.result = _fileDialog.files;
92  else
93  msgResult.result = _fileDialog.file;
94  msgResult.complete(MessageConfig.Ok);
95  msgResult = null;
96  }
97  closed();
98  }
99 
100  onRejected: {
101  if(msgResult) {
102  msgResult.complete(MessageConfig.Cancel);
103  msgResult = null;
104  }
105  closed();
106  }
107 }
QString title
The activity title/description of the file chooser.
The QML import for the QtMvvmCore QML module.
static Q_INVOKABLE QStringList mimeTypeFilters(const QStringList &mimeTypes) const
Converts a list of mimetypes into a list of extension filters, for a file dialog. ...
The QML import for the QtMvvmQuick QML module.
Definition: ActionButton.qml:4
A QML singleton to access common presenter methods globally.
A file dialog implementation based on the labs file dialog.
Definition: FileDialog.qml:18