1 | /* |
2 | This file is part of the KDE libraries |
3 | SPDX-FileCopyrightText: 2000 Wilco Greven <greven@kde.org> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-or-later |
6 | */ |
7 | |
8 | #ifndef KURLREQUESTERDIALOG_H |
9 | #define KURLREQUESTERDIALOG_H |
10 | |
11 | #include "kiowidgets_export.h" |
12 | #include <QDialog> |
13 | #include <QUrl> |
14 | |
15 | #include <memory> |
16 | |
17 | class KUrlRequester; |
18 | class QFileDialog; |
19 | class KUrlRequesterDialogPrivate; |
20 | |
21 | /** |
22 | * @class KUrlRequesterDialog kurlrequesterdialog.h <KUrlRequesterDialog> |
23 | * |
24 | * Dialog in which a user can enter a filename or url. It is a dialog |
25 | * encapsulating KUrlRequester. |
26 | * |
27 | * @short Simple dialog to enter a filename/url. |
28 | * @author Wilco Greven <greven@kde.org> |
29 | */ |
30 | class KIOWIDGETS_EXPORT KUrlRequesterDialog : public QDialog |
31 | { |
32 | Q_OBJECT |
33 | |
34 | public: |
35 | /** |
36 | * Constructs a KUrlRequesterDialog. |
37 | * |
38 | * @param url The url of the directory to start in. Use QString() |
39 | * to start in the current working directory, or the last |
40 | * directory where a file has been selected. |
41 | * @param parent The parent object of this widget. |
42 | */ |
43 | explicit KUrlRequesterDialog(const QUrl &url, QWidget *parent = nullptr); |
44 | |
45 | /** |
46 | * Constructs a KUrlRequesterDialog. |
47 | * |
48 | * @param url The url of the directory to start in. Use QString() |
49 | * to start in the current working directory, or the last |
50 | * directory where a file has been selected. |
51 | * @param text Text of the label |
52 | * @param parent The parent object of this widget. |
53 | */ |
54 | KUrlRequesterDialog(const QUrl &url, const QString &text, QWidget *parent); |
55 | /** |
56 | * Destructs the dialog. |
57 | */ |
58 | ~KUrlRequesterDialog() override; |
59 | |
60 | /** |
61 | * Returns the fully qualified filename. |
62 | */ |
63 | QUrl selectedUrl() const; |
64 | |
65 | /** |
66 | * Creates a modal dialog, executes it and returns the selected URL. |
67 | * |
68 | * @param url This specifies the initial path of the input line. |
69 | * @param parent The widget the dialog will be centered on initially. |
70 | * @param title The title to use for the dialog. |
71 | */ |
72 | static QUrl getUrl(const QUrl &url = QUrl(), QWidget *parent = nullptr, const QString &title = QString()); |
73 | |
74 | /** |
75 | * Returns a pointer to the KUrlRequester. |
76 | */ |
77 | KUrlRequester *urlRequester(); |
78 | |
79 | private: |
80 | friend class KUrlRequesterDialogPrivate; |
81 | std::unique_ptr<KUrlRequesterDialogPrivate> const d; |
82 | |
83 | Q_DISABLE_COPY(KUrlRequesterDialog) |
84 | }; |
85 | |
86 | #endif // KURLREQUESTERDIALOG_H |
87 | |