1/*
2 SPDX-FileCopyrightText: 2015 Kai Uwe Broulik <kde@privat.broulik.de>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#ifndef ICONDIALOG_H
8#define ICONDIALOG_H
9
10#include <QObject>
11#include <QString>
12#include <qqmlregistration.h>
13
14class KIconDialog;
15
16/*!
17 * \qmltype IconDialog
18 * \inqmlmodule org.kde.iconthemes
19 */
20class IconDialog : public QObject
21{
22 Q_OBJECT
23 QML_ELEMENT
24
25 /*!
26 * \qmlproperty string IconDialog::iconName
27 * The name or path of the icon the user has selected
28 */
29 Q_PROPERTY(QString iconName READ iconName NOTIFY iconNameChanged)
30 /*!
31 * \qmlproperty int IconDialog::iconSize
32 * The desired size of icons
33 */
34 Q_PROPERTY(int iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged)
35 /*!
36 * \qmlproperty string IconDialog::title
37 * The title to use for the dialog
38 */
39 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
40 /*!
41 * \qmlproperty bool IconDialog::user
42 * Begin with the "user icons" instead of "system icons"
43 */
44 Q_PROPERTY(bool user READ user WRITE setUser NOTIFY userChanged)
45 /*!
46 * \qmlproperty string IconDialog::customLocation
47 * Use a custom location, only local directory paths are allowed
48 */
49 Q_PROPERTY(QString customLocation READ customLocation WRITE setCustomLocation NOTIFY customLocationChanged)
50 /*!
51 * \qmlproperty enumeration IconDialog::modality
52 * Window modality, default is Qt.NonModal
53 */
54 Q_PROPERTY(Qt::WindowModality modality READ modality WRITE setModality NOTIFY modalityChanged)
55 /*!
56 * \qmlproperty string IconDialog::visible
57 * Whether the dialog is currently visible, setting this property to true
58 * is the same as calling show()
59 */
60 Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged)
61
62public:
63 explicit IconDialog(QObject *parent = nullptr);
64 ~IconDialog() override;
65
66 QString iconName() const;
67
68 int iconSize() const;
69 void setIconSize(int iconSize);
70
71 QString title() const;
72 void setTitle(const QString &title);
73
74 bool user() const;
75 void setUser(bool user);
76
77 QString customLocation() const;
78 void setCustomLocation(const QString &customLocation);
79
80 Qt::WindowModality modality() const;
81 void setModality(Qt::WindowModality modality);
82
83 bool visible() const;
84 void setVisible(bool visible);
85
86 /*!
87 * \qmlmethod void IconDialog::open
88 */
89 Q_INVOKABLE void open();
90
91 /*!
92 * \qmlmethod void IconDialog::close
93 */
94 Q_INVOKABLE void close();
95
96Q_SIGNALS:
97 void iconNameChanged(const QString &iconName);
98 void iconSizeChanged(int iconSize);
99 void titleChanged(const QString &title);
100 void userChanged(bool user);
101 void customLocationChanged(const QString &customLocation);
102 void modalityChanged(Qt::WindowModality modality);
103 void visibleChanged();
104 void accepted();
105 void rejected();
106
107private:
108 bool eventFilter(QObject *watched, QEvent *event) override;
109
110 QScopedPointer<KIconDialog> m_dialog;
111
112 QString m_iconName;
113 int m_iconSize;
114 bool m_user;
115 QString m_customLocation;
116 Qt::WindowModality m_modality;
117};
118
119#endif // ICONDIALOG_H
120

source code of kiconthemes/src/qml/icondialog_p.h