QtMvvm  1.1.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.1
5 import de.skycoder42.QtMvvm.Quick 1.1
6 
19 Labs.FileDialog {
20  id: _fileDialog
21 
35  property var msgConfig
49  property MessageResult msgResult
63  property var mimeTypes
64 
66  signal closed()
67 
68  title: msgConfig.title
69  modality: Qt.WindowModal
70  folder: msgConfig.defaultValue
71  fileMode: {
72  if(msgConfig.subType === "open")
73  return Labs.FileDialog.OpenFile;
74  else if(msgConfig.subType === "files")
75  return Labs.FileDialog.OpenFiles;
76  else if(msgConfig.subType === "save")
77  return Labs.FileDialog.SaveFile;
78  else {
79  return Labs.FileDialog.OpenFile; //fallback
80  }
81  }
82  nameFilters: QuickPresenter.mimeTypeFilters(mimeTypes ? mimeTypes : msgConfig.viewProperties["mimeTypes"])
83 
84  Component.onCompleted: {
85  if(msgResult)
86  msgResult.setCloseTarget(_fileDialog, "reject()");
87  }
88 
89  onAccepted: {
90  if(msgResult) {
91  if(msgConfig.subType === "files")
92  msgResult.result = _fileDialog.files;
93  else
94  msgResult.result = _fileDialog.file;
95  msgResult.complete(MessageConfig.Ok);
96  msgResult = null;
97  }
98  closed();
99  }
100 
101  onRejected: {
102  if(msgResult) {
103  msgResult.complete(MessageConfig.Cancel);
104  msgResult = null;
105  }
106  closed();
107  }
108 }
QString title
The activity title/description of the file chooser.
The QML import for the QtMvvmCore QML module.
Definition: qqmlcoreapp.h:9
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:19