1 | /* |
2 | This file is part of the KDE libraries |
3 | SPDX-FileCopyrightText: 2017 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com> |
4 | Work sponsored by the LiMux project of the city of Munich |
5 | |
6 | SPDX-License-Identifier: LGPL-2.0-only |
7 | */ |
8 | |
9 | #ifndef KFILECUSTOMDIALOG_H |
10 | #define KFILECUSTOMDIALOG_H |
11 | |
12 | #include "kfilewidget.h" |
13 | #include "kiofilewidgets_export.h" |
14 | #include <QDialog> |
15 | |
16 | #include <memory> |
17 | |
18 | class KFileWidget; |
19 | class KFileCustomDialogPrivate; |
20 | |
21 | /** |
22 | * This class implement a custom file dialog. |
23 | * It uses a KFileWidget and allows the application to provide a custom widget. |
24 | * @since 5.42 |
25 | */ |
26 | class KIOFILEWIDGETS_EXPORT KFileCustomDialog : public QDialog |
27 | { |
28 | Q_OBJECT |
29 | public: |
30 | /** |
31 | * Constructs a custom file dialog |
32 | */ |
33 | explicit KFileCustomDialog(QWidget *parent = nullptr); |
34 | |
35 | /** |
36 | * Constructs a custom file dialog |
37 | * @param startDir see the KFileWidget constructor for documentation |
38 | * @since 5.67 |
39 | */ |
40 | explicit KFileCustomDialog(const QUrl &startDir, QWidget *parent = nullptr); |
41 | |
42 | ~KFileCustomDialog() override; |
43 | |
44 | /** |
45 | * Sets the directory to view. |
46 | * |
47 | * @param url URL to show. |
48 | */ |
49 | void setUrl(const QUrl &url); |
50 | |
51 | /** |
52 | * Set a custom widget that should be added to the file dialog. |
53 | * @param widget A widget, or a widget of widgets, for displaying custom |
54 | * data in the file widget. This can be used, for example, to |
55 | * display a check box with the title "Open as read-only". |
56 | * When creating this widget, you don't need to specify a parent, |
57 | * since the widget's parent will be set automatically by KFileWidget. |
58 | */ |
59 | void setCustomWidget(QWidget *widget); |
60 | |
61 | /** |
62 | * @brief fileWidget |
63 | * @return the filewidget used inside this dialog |
64 | */ |
65 | KFileWidget *fileWidget() const; |
66 | |
67 | /** |
68 | * Sets the operational mode of the filedialog to @p Saving, @p Opening |
69 | * or @p Other. This will set some flags that are specific to loading |
70 | * or saving files. E.g. setKeepLocation() makes mostly sense for |
71 | * a save-as dialog. So setOperationMode( KFileWidget::Saving ); sets |
72 | * setKeepLocation for example. |
73 | * |
74 | * The mode @p Saving, together with a default filter set via |
75 | * setMimeFilter() will make the filter combobox read-only. |
76 | * |
77 | * The default mode is @p Opening. |
78 | * |
79 | * Call this method right after instantiating KFileWidget. |
80 | * |
81 | * @see operationMode |
82 | * @see KFileWidget::OperationMode |
83 | */ |
84 | void setOperationMode(KFileWidget::OperationMode op); |
85 | |
86 | public Q_SLOTS: |
87 | void accept() override; |
88 | |
89 | private: |
90 | std::unique_ptr<KFileCustomDialogPrivate> const d; |
91 | }; |
92 | |
93 | #endif // KFILECUSTOMDIALOG_H |
94 | |