File indexing completed on 2024-05-12 16:02:01

0001 /*
0002  *  SPDX-FileCopyrightText: 2015 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef KIS_FILE_NAME_REQUESTER_H
0008 #define KIS_FILE_NAME_REQUESTER_H
0009 
0010 #include "kritawidgets_export.h"
0011 
0012 #include <QWidget>
0013 #include <QString>
0014 #include <QUrl>
0015 #include <KoFileDialog.h>
0016 
0017 
0018 namespace Ui {
0019     class WdgFileNameRequester;
0020 }
0021 
0022 /**
0023  * This represents an editable file name.
0024  * Visual it presents a QLineEdit + a button that pops up
0025  * a file chooser.
0026  *
0027  * Signals are fired when the user changes the text
0028  * or selects a new file via the button/file chooser.
0029  */
0030 class KRITAWIDGETS_EXPORT KisFileNameRequester : public QWidget
0031 {
0032     Q_OBJECT
0033 
0034 public:
0035     explicit KisFileNameRequester(QWidget *parent = 0);
0036     ~KisFileNameRequester() override;
0037 
0038     void setStartDir(const QString &path);
0039     /// Set the name used to store the last-used directory in the settings
0040     void setConfigurationName(const QString &name);
0041 
0042     QString fileName() const;
0043     void setFileName(const QString &path);
0044 
0045     void setMode(KoFileDialog::DialogType mode);
0046     KoFileDialog::DialogType mode() const;
0047     void setReadOnlyText(bool readonly);
0048 
0049     /**
0050      * Sets the mime type filters to use, same format as KoFileDialog::setMimeTypeFilters.
0051      * If this is not called, the default list is used, which simply selects all the image
0052      * file formats Krita can load.
0053      */
0054     void setMimeTypeFilters(const QStringList &filterList, QString defaultFilter = QString());
0055 
0056 public Q_SLOTS:
0057     void slotSelectFile();
0058 
0059 Q_SIGNALS:
0060     void textChanged(const QString &fileName);
0061     void fileSelected(const QString &fileName);
0062 
0063 private:
0064     QScopedPointer<Ui::WdgFileNameRequester> m_ui;
0065     QString m_basePath;
0066     KoFileDialog::DialogType m_mode;
0067     QStringList m_mime_filter_list;
0068     QString m_mime_default_filter;
0069     QString m_name;
0070 };
0071 
0072 #endif // KIS_FILE_NAME_REQUESTER_H