File indexing completed on 2024-05-12 03:55:45
0001 /* 0002 SPDX-FileCopyrightText: 2015 Kai Uwe Broulik <kde@privat.broulik.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef ICONDIALOG_H 0008 #define ICONDIALOG_H 0009 0010 #include <QObject> 0011 #include <QString> 0012 0013 class KIconDialog; 0014 0015 class IconDialog : public QObject 0016 { 0017 Q_OBJECT 0018 0019 /** 0020 * The name or path of the icon the user has selected 0021 */ 0022 Q_PROPERTY(QString iconName READ iconName NOTIFY iconNameChanged) 0023 /** 0024 * The desired size of icons 0025 */ 0026 Q_PROPERTY(int iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged) 0027 /** 0028 * The title to use for the dialog 0029 */ 0030 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) 0031 /** 0032 * Begin with the "user icons" instead of "system icons" 0033 */ 0034 Q_PROPERTY(bool user READ user WRITE setUser NOTIFY userChanged) 0035 /** 0036 * Use a custom location, only local directory paths are allowed 0037 */ 0038 Q_PROPERTY(QString customLocation READ customLocation WRITE setCustomLocation NOTIFY customLocationChanged) 0039 /** 0040 * Window modality, default is Qt.NonModal 0041 */ 0042 Q_PROPERTY(Qt::WindowModality modality READ modality WRITE setModality NOTIFY modalityChanged) 0043 /** 0044 * Whether the dialog is currently visible, setting this property to true 0045 * is the same as calling show() 0046 */ 0047 Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged) 0048 0049 public: 0050 explicit IconDialog(QObject *parent = nullptr); 0051 ~IconDialog() override; 0052 0053 QString iconName() const; 0054 0055 int iconSize() const; 0056 void setIconSize(int iconSize); 0057 0058 QString title() const; 0059 void setTitle(const QString &title); 0060 0061 bool user() const; 0062 void setUser(bool user); 0063 0064 QString customLocation() const; 0065 void setCustomLocation(const QString &customLocation); 0066 0067 Qt::WindowModality modality() const; 0068 void setModality(Qt::WindowModality modality); 0069 0070 bool visible() const; 0071 void setVisible(bool visible); 0072 0073 Q_INVOKABLE void open(); 0074 Q_INVOKABLE void close(); 0075 0076 Q_SIGNALS: 0077 void iconNameChanged(const QString &iconName); 0078 void iconSizeChanged(int iconSize); 0079 void titleChanged(const QString &title); 0080 void userChanged(bool user); 0081 void customLocationChanged(const QString &customLocation); 0082 void modalityChanged(Qt::WindowModality modality); 0083 void visibleChanged(); 0084 0085 private: 0086 bool eventFilter(QObject *watched, QEvent *event) override; 0087 0088 QScopedPointer<KIconDialog> m_dialog; 0089 0090 QString m_iconName; 0091 int m_iconSize; 0092 bool m_user; 0093 QString m_customLocation; 0094 Qt::WindowModality m_modality; 0095 bool m_visible; 0096 }; 0097 0098 #endif // ICONDIALOG_H