11#include "qml_material/export.hpp"
17class FileDialogBackend;
19class QML_MATERIAL_API FileDialogSelectedNameFilter :
public QObject {
22 Q_PROPERTY(
int index READ index WRITE setIndex NOTIFY indexChanged FINAL)
23 Q_PROPERTY(QString name READ name NOTIFY nameChanged FINAL)
25 explicit FileDialogSelectedNameFilter(FileDialog* parent);
31 Q_SIGNAL
void indexChanged();
32 Q_SIGNAL
void nameChanged();
35 friend class FileDialog;
40class QML_MATERIAL_API FileDialog :
public QObject {
42 QML_NAMED_ELEMENT(FileDialog)
44 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL)
46 QString acceptLabel READ acceptLabel WRITE setAcceptLabel NOTIFY acceptLabelChanged FINAL)
47 Q_PROPERTY(FileMode fileMode READ fileMode WRITE setFileMode NOTIFY fileModeChanged FINAL)
48 Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters NOTIFY
49 nameFiltersChanged FINAL)
51 FileDialogSelectedNameFilter* selectedNameFilter READ selectedNameFilter CONSTANT FINAL)
52 Q_PROPERTY(QUrl currentFolder READ currentFolder WRITE setCurrentFolder NOTIFY
53 currentFolderChanged FINAL)
54 Q_PROPERTY(QString defaultSuffix READ defaultSuffix WRITE setDefaultSuffix NOTIFY
55 defaultSuffixChanged FINAL)
56 Q_PROPERTY(QUrl selectedFile READ selectedFile NOTIFY selectedFilesChanged FINAL)
57 Q_PROPERTY(QList<QUrl> selectedFiles READ selectedFiles NOTIFY selectedFilesChanged FINAL)
58 Q_PROPERTY(QUrl currentFile READ selectedFile NOTIFY selectedFilesChanged FINAL)
59 Q_PROPERTY(QList<QUrl> currentFiles READ selectedFiles NOTIFY selectedFilesChanged FINAL)
61 QWindow* parentWindow READ parentWindow WRITE setParentWindow NOTIFY parentWindowChanged)
72 explicit FileDialog(QObject* parent =
nullptr);
73 ~FileDialog()
override;
75 QString title()
const;
76 void setTitle(
const QString&);
77 QString acceptLabel()
const;
78 void setAcceptLabel(
const QString&);
79 FileMode fileMode()
const;
80 void setFileMode(FileMode);
81 QStringList nameFilters()
const;
82 void setNameFilters(
const QStringList&);
83 FileDialogSelectedNameFilter* selectedNameFilter()
const;
84 QUrl currentFolder()
const;
85 void setCurrentFolder(
const QUrl&);
86 QString defaultSuffix()
const;
87 void setDefaultSuffix(
const QString&);
88 QUrl selectedFile()
const;
89 QList<QUrl> selectedFiles()
const;
90 QWindow* parentWindow()
const;
91 void setParentWindow(QWindow*);
93 Q_INVOKABLE
void open();
94 Q_INVOKABLE
void close();
96 Q_SIGNAL
void titleChanged();
97 Q_SIGNAL
void acceptLabelChanged();
98 Q_SIGNAL
void fileModeChanged();
99 Q_SIGNAL
void nameFiltersChanged();
100 Q_SIGNAL
void currentFolderChanged();
101 Q_SIGNAL
void defaultSuffixChanged();
102 Q_SIGNAL
void selectedFilesChanged();
103 Q_SIGNAL
void parentWindowChanged();
104 Q_SIGNAL
void accepted();
105 Q_SIGNAL
void rejected();
108 void ensureBackend();
109 void applyResult(
const QList<QUrl>& urls);
112 QString m_accept_label;
113 FileMode m_file_mode { OpenFile };
114 QStringList m_name_filters;
115 FileDialogSelectedNameFilter* m_selected_name_filter;
116 QUrl m_current_folder;
117 QString m_default_suffix;
118 QList<QUrl> m_selected_files;
119 QPointer<QWindow> m_parent_window;
120 FileDialogBackend* m_backend {
nullptr };
123class QML_MATERIAL_API FolderDialog :
public QObject {
125 QML_NAMED_ELEMENT(FolderDialog)
127 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL)
129 QString acceptLabel READ acceptLabel WRITE setAcceptLabel NOTIFY acceptLabelChanged FINAL)
130 Q_PROPERTY(QUrl currentFolder READ currentFolder WRITE setCurrentFolder NOTIFY
131 currentFolderChanged FINAL)
132 Q_PROPERTY(QUrl selectedFolder READ selectedFolder NOTIFY selectedFolderChanged FINAL)
134 QWindow* parentWindow READ parentWindow WRITE setParentWindow NOTIFY parentWindowChanged)
137 explicit FolderDialog(QObject* parent =
nullptr);
138 ~FolderDialog()
override;
140 QString title()
const;
141 void setTitle(
const QString&);
142 QString acceptLabel()
const;
143 void setAcceptLabel(
const QString&);
144 QUrl currentFolder()
const;
145 void setCurrentFolder(
const QUrl&);
146 QUrl selectedFolder()
const;
147 QWindow* parentWindow()
const;
148 void setParentWindow(QWindow*);
150 Q_INVOKABLE
void open();
151 Q_INVOKABLE
void close();
153 Q_SIGNAL
void titleChanged();
154 Q_SIGNAL
void acceptLabelChanged();
155 Q_SIGNAL
void currentFolderChanged();
156 Q_SIGNAL
void selectedFolderChanged();
157 Q_SIGNAL
void parentWindowChanged();
158 Q_SIGNAL
void accepted();
159 Q_SIGNAL
void rejected();
162 void ensureBackend();
165 QString m_accept_label;
166 QUrl m_current_folder;
167 QUrl m_selected_folder;
168 QPointer<QWindow> m_parent_window;
169 FileDialogBackend* m_backend {
nullptr };