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)
45 Q_PROPERTY(QString acceptLabel READ acceptLabel WRITE setAcceptLabel NOTIFY acceptLabelChanged
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)
50 Q_PROPERTY(FileDialogSelectedNameFilter* selectedNameFilter READ selectedNameFilter CONSTANT
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)
71 explicit FileDialog(QObject* parent =
nullptr);
72 ~FileDialog()
override;
74 QString title()
const;
75 void setTitle(
const QString&);
76 QString acceptLabel()
const;
77 void setAcceptLabel(
const QString&);
78 FileMode fileMode()
const;
79 void setFileMode(FileMode);
80 QStringList nameFilters()
const;
81 void setNameFilters(
const QStringList&);
82 FileDialogSelectedNameFilter* selectedNameFilter()
const;
83 QUrl currentFolder()
const;
84 void setCurrentFolder(
const QUrl&);
85 QString defaultSuffix()
const;
86 void setDefaultSuffix(
const QString&);
87 QUrl selectedFile()
const;
88 QList<QUrl> selectedFiles()
const;
89 QWindow* parentWindow()
const;
90 void setParentWindow(QWindow*);
92 Q_INVOKABLE
void open();
93 Q_INVOKABLE
void close();
95 Q_SIGNAL
void titleChanged();
96 Q_SIGNAL
void acceptLabelChanged();
97 Q_SIGNAL
void fileModeChanged();
98 Q_SIGNAL
void nameFiltersChanged();
99 Q_SIGNAL
void currentFolderChanged();
100 Q_SIGNAL
void defaultSuffixChanged();
101 Q_SIGNAL
void selectedFilesChanged();
102 Q_SIGNAL
void parentWindowChanged();
103 Q_SIGNAL
void accepted();
104 Q_SIGNAL
void rejected();
107 void ensureBackend();
108 void applyResult(
const QList<QUrl>& urls);
111 QString m_accept_label;
112 FileMode m_file_mode { OpenFile };
113 QStringList m_name_filters;
114 FileDialogSelectedNameFilter* m_selected_name_filter;
115 QUrl m_current_folder;
116 QString m_default_suffix;
117 QList<QUrl> m_selected_files;
118 QPointer<QWindow> m_parent_window;
119 FileDialogBackend* m_backend {
nullptr };
122class QML_MATERIAL_API FolderDialog :
public QObject {
124 QML_NAMED_ELEMENT(FolderDialog)
126 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL)
127 Q_PROPERTY(QString acceptLabel READ acceptLabel WRITE setAcceptLabel NOTIFY acceptLabelChanged
129 Q_PROPERTY(QUrl currentFolder READ currentFolder WRITE setCurrentFolder NOTIFY
130 currentFolderChanged FINAL)
131 Q_PROPERTY(QUrl selectedFolder READ selectedFolder NOTIFY selectedFolderChanged FINAL)
133 QWindow* parentWindow READ parentWindow WRITE setParentWindow NOTIFY parentWindowChanged)
136 explicit FolderDialog(QObject* parent =
nullptr);
137 ~FolderDialog()
override;
139 QString title()
const;
140 void setTitle(
const QString&);
141 QString acceptLabel()
const;
142 void setAcceptLabel(
const QString&);
143 QUrl currentFolder()
const;
144 void setCurrentFolder(
const QUrl&);
145 QUrl selectedFolder()
const;
146 QWindow* parentWindow()
const;
147 void setParentWindow(QWindow*);
149 Q_INVOKABLE
void open();
150 Q_INVOKABLE
void close();
152 Q_SIGNAL
void titleChanged();
153 Q_SIGNAL
void acceptLabelChanged();
154 Q_SIGNAL
void currentFolderChanged();
155 Q_SIGNAL
void selectedFolderChanged();
156 Q_SIGNAL
void parentWindowChanged();
157 Q_SIGNAL
void accepted();
158 Q_SIGNAL
void rejected();
161 void ensureBackend();
164 QString m_accept_label;
165 QUrl m_current_folder;
166 QUrl m_selected_folder;
167 QPointer<QWindow> m_parent_window;
168 FileDialogBackend* m_backend {
nullptr };