File indexing completed on 2024-12-01 09:53:05
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2017 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com> 0004 Work sponsored by the LiMux project of the city of Munich 0005 0006 SPDX-License-Identifier: LGPL-2.0-only 0007 */ 0008 0009 #ifndef KFILECUSTOMDIALOG_H 0010 #define KFILECUSTOMDIALOG_H 0011 0012 #include "kfilewidget.h" 0013 #include "kiofilewidgets_export.h" 0014 #include <QDialog> 0015 0016 #include <memory> 0017 0018 class KFileWidget; 0019 class KFileCustomDialogPrivate; 0020 0021 /** 0022 * This class implement a custom file dialog. 0023 * It uses a KFileWidget and allows the application to provide a custom widget. 0024 * @since 5.42 0025 */ 0026 class KIOFILEWIDGETS_EXPORT KFileCustomDialog : public QDialog 0027 { 0028 Q_OBJECT 0029 public: 0030 /** 0031 * Constructs a custom file dialog 0032 */ 0033 explicit KFileCustomDialog(QWidget *parent = nullptr); 0034 0035 /** 0036 * Constructs a custom file dialog 0037 * @param startDir see the KFileWidget constructor for documentation 0038 * @since 5.67 0039 */ 0040 explicit KFileCustomDialog(const QUrl &startDir, QWidget *parent = nullptr); 0041 0042 ~KFileCustomDialog() override; 0043 0044 /** 0045 * Sets the directory to view. 0046 * 0047 * @param url URL to show. 0048 */ 0049 void setUrl(const QUrl &url); 0050 0051 /** 0052 * Set a custom widget that should be added to the file dialog. 0053 * @param widget A widget, or a widget of widgets, for displaying custom 0054 * data in the file widget. This can be used, for example, to 0055 * display a check box with the title "Open as read-only". 0056 * When creating this widget, you don't need to specify a parent, 0057 * since the widget's parent will be set automatically by KFileWidget. 0058 */ 0059 void setCustomWidget(QWidget *widget); 0060 0061 /** 0062 * @brief fileWidget 0063 * @return the filewidget used inside this dialog 0064 */ 0065 KFileWidget *fileWidget() const; 0066 0067 /** 0068 * Sets the operational mode of the filedialog to @p Saving, @p Opening 0069 * or @p Other. This will set some flags that are specific to loading 0070 * or saving files. E.g. setKeepLocation() makes mostly sense for 0071 * a save-as dialog. So setOperationMode( KFileWidget::Saving ); sets 0072 * setKeepLocation for example. 0073 * 0074 * The mode @p Saving, together with a default filter set via 0075 * setMimeFilter() will make the filter combobox read-only. 0076 * 0077 * The default mode is @p Opening. 0078 * 0079 * Call this method right after instantiating KFileWidget. 0080 * 0081 * @see operationMode 0082 * @see KFileWidget::OperationMode 0083 */ 0084 void setOperationMode(KFileWidget::OperationMode op); 0085 0086 public Q_SLOTS: 0087 void accept() override; 0088 0089 private: 0090 std::unique_ptr<KFileCustomDialogPrivate> const d; 0091 }; 0092 0093 #endif // KFILECUSTOMDIALOG_H