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
18class KFileWidget;
19class KFileCustomDialogPrivate;
20
21/*!
22 * \class KFileCustomDialog
23 * \inmodule KIOFileWidgets
24 *
25 * \brief This class implement a custom file dialog.
26 *
27 * It uses a KFileWidget and allows the application to provide a custom widget.
28 * \since 5.42
29 */
30class KIOFILEWIDGETS_EXPORT KFileCustomDialog : public QDialog
31{
32 Q_OBJECT
33public:
34 /*!
35 * Constructs a custom file dialog
36 */
37 explicit KFileCustomDialog(QWidget *parent = nullptr);
38
39 /*!
40 * Constructs a custom file dialog
41 *
42 * \a startDir see the KFileWidget constructor for documentation
43 * \since 5.67
44 */
45 explicit KFileCustomDialog(const QUrl &startDir, QWidget *parent = nullptr);
46
47 ~KFileCustomDialog() override;
48
49 /*!
50 * Sets the directory to view.
51 *
52 * \a url URL to show.
53 */
54 void setUrl(const QUrl &url);
55
56 /*!
57 * Set a custom widget that should be added to the file dialog.
58 *
59 * \a widget A widget, or a widget of widgets, for displaying custom
60 * data in the file widget. This can be used, for example, to
61 * display a check box with the title "Open as read-only".
62 * When creating this widget, you don't need to specify a parent,
63 * since the widget's parent will be set automatically by KFileWidget.
64 */
65 void setCustomWidget(QWidget *widget);
66
67 /*!
68 * Returns the filewidget used inside this dialog
69 */
70 KFileWidget *fileWidget() const;
71
72 /*!
73 * Sets the operational mode of the filedialog to Saving, Opening
74 * or Other. This will set some flags that are specific to loading
75 * or saving files. E.g. setKeepLocation() makes mostly sense for
76 * a save-as dialog. So setOperationMode( KFileWidget::Saving ); sets
77 * setKeepLocation for example.
78 *
79 * The mode Saving, together with a default filter set via
80 * setMimeFilter() will make the filter combobox read-only.
81 *
82 * The default mode is Opening.
83 *
84 * Call this method right after instantiating KFileWidget.
85 *
86 * \sa KFileWidget::OperationMode
87 */
88 void setOperationMode(KFileWidget::OperationMode op);
89
90public Q_SLOTS:
91 void accept() override;
92
93private:
94 std::unique_ptr<KFileCustomDialogPrivate> const d;
95};
96
97#endif // KFILECUSTOMDIALOG_H
98

source code of kio/src/filewidgets/kfilecustomdialog.h