File indexing completed on 2024-06-16 06:56:58

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     /**
0075      * Returns a pointer to the KUrlRequester.
0076      */
0077     KUrlRequester *urlRequester();
0078 
0079 private:
0080     friend class KUrlRequesterDialogPrivate;
0081     std::unique_ptr<KUrlRequesterDialogPrivate> const d;
0082 
0083     Q_DISABLE_COPY(KUrlRequesterDialog)
0084 };
0085 
0086 #endif // KURLREQUESTERDIALOG_H