Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickfiledialog_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKFILEDIALOG_P_H
5#define QQUICKFILEDIALOG_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qurl.h>
19#include <QtQml/qqml.h>
20
22
24
26
27class Q_QUICKDIALOGS2_EXPORT QQuickFileDialog : public QQuickAbstractDialog
28{
30 Q_PROPERTY(FileMode fileMode READ fileMode WRITE setFileMode NOTIFY fileModeChanged FINAL)
31 Q_PROPERTY(QUrl selectedFile READ selectedFile WRITE setSelectedFile NOTIFY selectedFileChanged FINAL)
32 Q_PROPERTY(QList<QUrl> selectedFiles READ selectedFiles NOTIFY selectedFilesChanged FINAL)
33 Q_PROPERTY(QUrl currentFile READ currentFile WRITE setCurrentFile NOTIFY currentFileChanged FINAL)
34 Q_PROPERTY(QList<QUrl> currentFiles READ currentFiles WRITE setCurrentFiles NOTIFY currentFilesChanged FINAL)
35 Q_PROPERTY(QUrl currentFolder READ currentFolder WRITE setCurrentFolder NOTIFY currentFolderChanged FINAL)
36 Q_PROPERTY(QFileDialogOptions::FileDialogOptions options READ options WRITE setOptions RESET resetOptions NOTIFY optionsChanged FINAL)
37 Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters RESET resetNameFilters NOTIFY nameFiltersChanged FINAL)
38 Q_PROPERTY(QQuickFileNameFilter *selectedNameFilter READ selectedNameFilter CONSTANT)
39 Q_PROPERTY(QString defaultSuffix READ defaultSuffix WRITE setDefaultSuffix RESET resetDefaultSuffix NOTIFY defaultSuffixChanged FINAL)
40 Q_PROPERTY(QString acceptLabel READ acceptLabel WRITE setAcceptLabel RESET resetAcceptLabel NOTIFY acceptLabelChanged FINAL)
41 Q_PROPERTY(QString rejectLabel READ rejectLabel WRITE setRejectLabel RESET resetRejectLabel NOTIFY rejectLabelChanged FINAL)
42 Q_FLAGS(QFileDialogOptions::FileDialogOptions)
45 Q_MOC_INCLUDE(<QtQuickDialogs2Utils/private/qquickfilenamefilter_p.h>)
46
47public:
48 explicit QQuickFileDialog(QObject *parent = nullptr);
49
50 enum FileMode {
53 SaveFile
54 };
55 Q_ENUM(FileMode)
56
57 FileMode fileMode() const;
58 void setFileMode(FileMode fileMode);
59
60 QUrl selectedFile() const;
61 void setSelectedFile(const QUrl &selectedFile);
62
63 QList<QUrl> selectedFiles() const;
64
65 QUrl currentFile() const;
66 void setCurrentFile(const QUrl &file);
67
68 QList<QUrl> currentFiles() const;
69 void setCurrentFiles(const QList<QUrl> &currentFiles);
70
71 QUrl currentFolder() const;
72 void setCurrentFolder(const QUrl &currentFolder);
73
74 QFileDialogOptions::FileDialogOptions options() const;
75 void setOptions(QFileDialogOptions::FileDialogOptions options);
76 void resetOptions();
77
78 QStringList nameFilters() const;
80 void resetNameFilters();
81
82 QQuickFileNameFilter *selectedNameFilter() const;
83
84 QString defaultSuffix() const;
85 void setDefaultSuffix(const QString &suffix);
86 void resetDefaultSuffix();
87
88 QString acceptLabel() const;
89 void setAcceptLabel(const QString &label);
90 void resetAcceptLabel();
91
92 QString rejectLabel() const;
93 void setRejectLabel(const QString &label);
94 void resetRejectLabel();
95
108
109protected:
110 bool useNativeDialog() const override;
111 void onCreate(QPlatformDialogHelper *dialog) override;
112 void onShow(QPlatformDialogHelper *dialog) override;
113 void onHide(QPlatformDialogHelper *dialog) override;
114 void accept() override;
115
116private:
117 QUrl addDefaultSuffix(const QUrl &file) const;
118 QList<QUrl> addDefaultSuffixes(const QList<QUrl> &files) const;
119
120 void setSelectedFiles(const QList<QUrl> &selectedFiles);
121
122 FileMode m_fileMode;
123 QList<QUrl> m_selectedFiles;
124 QSharedPointer<QFileDialogOptions> m_options;
126};
127
129
130#endif // QQUICKFILEDIALOG_P_H
Definition qlist.h:75
\inmodule QtCore
Definition qobject.h:103
The QPlatformDialogHelper class allows for platform-specific customization of dialogs.
void defaultSuffixChanged()
void currentFolderChanged()
void fileModeChanged()
void selectedFilesChanged()
void rejectLabelChanged()
void nameFiltersChanged()
void currentFileChanged()
void acceptLabelChanged()
void currentFilesChanged()
void selectedFileChanged()
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
Combined button and popup list for selecting options.
QStringList m_selectedNameFilter
SharedPointerFileDialogOptions m_options
GLuint GLsizei const GLchar * label
[43]
GLfloat GLfloat GLfloat GLfloat h
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_FLAGS(x)
#define Q_MOC_INCLUDE(...)
#define Q_SIGNALS
#define explicit
QFile file
[0]
dialog setNameFilters(filters)
QFileDialog dialog(this)
[1]
QStringList files
[8]
dialog setFileMode(QFileDialog::AnyFile)
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]