Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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// Qt-Security score:significant reason:default
4
5#ifndef QQUICKFILEDIALOG_P_H
6#define QQUICKFILEDIALOG_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/qurl.h>
20#include <QtQml/qqml.h>
21
23
25
26class QQuickFileNameFilter;
27
28class Q_QUICKDIALOGS2_EXPORT QQuickFileDialog : public QQuickAbstractDialog
29{
30 Q_OBJECT
31 Q_PROPERTY(FileMode fileMode READ fileMode WRITE setFileMode NOTIFY fileModeChanged FINAL)
32 Q_PROPERTY(QUrl selectedFile READ selectedFile WRITE setSelectedFile NOTIFY selectedFileChanged FINAL)
33 Q_PROPERTY(QList<QUrl> selectedFiles READ selectedFiles NOTIFY selectedFilesChanged FINAL)
34 Q_PROPERTY(QUrl currentFile READ currentFile WRITE setCurrentFile NOTIFY currentFileChanged FINAL)
35 Q_PROPERTY(QList<QUrl> currentFiles READ currentFiles WRITE setCurrentFiles NOTIFY currentFilesChanged FINAL)
36 Q_PROPERTY(QUrl currentFolder READ currentFolder WRITE setCurrentFolder NOTIFY currentFolderChanged FINAL)
37 Q_PROPERTY(QFileDialogOptions::FileDialogOptions options READ options WRITE setOptions RESET resetOptions NOTIFY optionsChanged FINAL)
38 Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters RESET resetNameFilters NOTIFY nameFiltersChanged FINAL)
39 Q_PROPERTY(QQuickFileNameFilter *selectedNameFilter READ selectedNameFilter CONSTANT)
40 Q_PROPERTY(QString defaultSuffix READ defaultSuffix WRITE setDefaultSuffix RESET resetDefaultSuffix NOTIFY defaultSuffixChanged FINAL)
41 Q_PROPERTY(QString acceptLabel READ acceptLabel WRITE setAcceptLabel RESET resetAcceptLabel NOTIFY acceptLabelChanged FINAL)
42 Q_PROPERTY(QString rejectLabel READ rejectLabel WRITE setRejectLabel RESET resetRejectLabel NOTIFY rejectLabelChanged FINAL)
43 QML_NAMED_ELEMENT(FileDialog)
44 QML_EXTENDED_NAMESPACE(QFileDialogOptions)
45 QML_ADDED_IN_VERSION(6, 2)
46 Q_MOC_INCLUDE(<QtQuickDialogs2Utils/private/qquickfilenamefilter_p.h>)
47
48public:
49 explicit QQuickFileDialog(QObject *parent = nullptr);
50
51 enum FileMode {
52 OpenFile,
53 OpenFiles,
54 SaveFile
55 };
56 Q_ENUM(FileMode)
57
58 FileMode fileMode() const;
59 void setFileMode(FileMode fileMode);
60
61 QUrl selectedFile() const;
62 void setSelectedFile(const QUrl &selectedFile);
63
64 QList<QUrl> selectedFiles() const;
65
66 QUrl currentFile() const;
67 void setCurrentFile(const QUrl &file);
68
69 QList<QUrl> currentFiles() const;
70 void setCurrentFiles(const QList<QUrl> &currentFiles);
71
72 QUrl currentFolder() const;
73 void setCurrentFolder(const QUrl &currentFolder);
74
75 QFileDialogOptions::FileDialogOptions options() const;
76 void setOptions(QFileDialogOptions::FileDialogOptions options);
77 void resetOptions();
78
79 QStringList nameFilters() const;
80 void setNameFilters(const QStringList &filters);
81 void resetNameFilters();
82
83 QQuickFileNameFilter *selectedNameFilter() const;
84
85 QString defaultSuffix() const;
86 void setDefaultSuffix(const QString &suffix);
87 void resetDefaultSuffix();
88
89 QString acceptLabel() const;
90 void setAcceptLabel(const QString &label);
91 void resetAcceptLabel();
92
93 QString rejectLabel() const;
94 void setRejectLabel(const QString &label);
95 void resetRejectLabel();
96
97Q_SIGNALS:
98 void fileModeChanged();
99 void selectedFileChanged();
100 void selectedFilesChanged();
101 void currentFileChanged();
102 void currentFilesChanged();
103 void currentFolderChanged();
104 void optionsChanged();
105 void nameFiltersChanged();
106 void defaultSuffixChanged();
107 void acceptLabelChanged();
108 void rejectLabelChanged();
109
110protected:
111 bool useNativeDialog() const override;
112 void onCreate(QPlatformDialogHelper *dialog) override;
113 void onShow(QPlatformDialogHelper *dialog) override;
114 void onHide(QPlatformDialogHelper *dialog) override;
115 void accept() override;
116
117private:
118 QUrl addDefaultSuffix(const QUrl &file) const;
119 QList<QUrl> addDefaultSuffixes(const QList<QUrl> &files) const;
120
121 void setSelectedFiles(const QList<QUrl> &selectedFiles);
122
123 FileMode m_fileMode;
124 QList<QUrl> m_selectedFiles;
125 QSharedPointer<QFileDialogOptions> m_options;
126 mutable QQuickFileNameFilter *m_selectedNameFilter;
127};
128
129QT_END_NAMESPACE
130
131#endif // QQUICKFILEDIALOG_P_H
Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core")