File indexing completed on 2023-12-03 07:46:05

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2000 Wilco Greven <greven@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef KURLREQUESTERDIALOG_H
0009 #define KURLREQUESTERDIALOG_H
0010 
0011 #include "kiowidgets_export.h"
0012 #include <QDialog>
0013 #include <QUrl>
0014 
0015 #include <memory>
0016 
0017 class KUrlRequester;
0018 class QFileDialog;
0019 class KUrlRequesterDialogPrivate;
0020 
0021 /**
0022  * @class KUrlRequesterDialog kurlrequesterdialog.h <KUrlRequesterDialog>
0023  *
0024  * Dialog in which a user can enter a filename or url. It is a dialog
0025  * encapsulating KUrlRequester.
0026  *
0027  * @short Simple dialog to enter a filename/url.
0028  * @author Wilco Greven <greven@kde.org>
0029  */
0030 class KIOWIDGETS_EXPORT KUrlRequesterDialog : public QDialog
0031 {
0032     Q_OBJECT
0033 
0034 public:
0035     /**
0036      * Constructs a KUrlRequesterDialog.
0037      *
0038      * @param url    The url of the directory to start in. Use QString()
0039      *               to start in the current working directory, or the last
0040      *               directory where a file has been selected.
0041      * @param parent The parent object of this widget.
0042      */
0043     explicit KUrlRequesterDialog(const QUrl &url, QWidget *parent = nullptr);
0044 
0045     /**
0046      * Constructs a KUrlRequesterDialog.
0047      *
0048      * @param url    The url of the directory to start in. Use QString()
0049      *               to start in the current working directory, or the last
0050      *               directory where a file has been selected.
0051      * @param text   Text of the label
0052      * @param parent The parent object of this widget.
0053      */
0054     KUrlRequesterDialog(const QUrl &url, const QString &text, QWidget *parent);
0055     /**
0056      * Destructs the dialog.
0057      */
0058     ~KUrlRequesterDialog() override;
0059 
0060     /**
0061      * Returns the fully qualified filename.
0062      */
0063     QUrl selectedUrl() const;
0064 
0065     /**
0066      * Creates a modal dialog, executes it and returns the selected URL.
0067      *
0068      * @param url This specifies the initial path of the input line.
0069      * @param parent The widget the dialog will be centered on initially.
0070      * @param title The title to use for the dialog.
0071      */
0072     static QUrl getUrl(const QUrl &url = QUrl(), QWidget *parent = nullptr, const QString &title = QString());
0073 
0074 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 0)
0075     /**
0076      * Returns a pointer to the file dialog used by the KUrlRequester.
0077      * @deprecated since 5.0, use urlRequester() methods instead.
0078      */
0079     KIOWIDGETS_DEPRECATED_VERSION(5, 0, "Use KUrlRequesterDialog::urlRequester() and methods on it")
0080     QFileDialog *fileDialog();
0081 #endif
0082 
0083     /**
0084      * Returns a pointer to the KUrlRequester.
0085      */
0086     KUrlRequester *urlRequester();
0087 
0088 private:
0089     friend class KUrlRequesterDialogPrivate;
0090     std::unique_ptr<KUrlRequesterDialogPrivate> const d;
0091 
0092     Q_DISABLE_COPY(KUrlRequesterDialog)
0093 };
0094 
0095 #endif // KURLREQUESTERDIALOG_H