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
13class KIconDialog;
14
15class IconDialog : public QObject
16{
17 Q_OBJECT
18
19 /**
20 * The name or path of the icon the user has selected
21 */
22 Q_PROPERTY(QString iconName READ iconName NOTIFY iconNameChanged)
23 /**
24 * The desired size of icons
25 */
26 Q_PROPERTY(int iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged)
27 /**
28 * The title to use for the dialog
29 */
30 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
31 /**
32 * Begin with the "user icons" instead of "system icons"
33 */
34 Q_PROPERTY(bool user READ user WRITE setUser NOTIFY userChanged)
35 /**
36 * Use a custom location, only local directory paths are allowed
37 */
38 Q_PROPERTY(QString customLocation READ customLocation WRITE setCustomLocation NOTIFY customLocationChanged)
39 /**
40 * Window modality, default is Qt.NonModal
41 */
42 Q_PROPERTY(Qt::WindowModality modality READ modality WRITE setModality NOTIFY modalityChanged)
43 /**
44 * Whether the dialog is currently visible, setting this property to true
45 * is the same as calling show()
46 */
47 Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged)
48
49public:
50 explicit IconDialog(QObject *parent = nullptr);
51 ~IconDialog() override;
52
53 QString iconName() const;
54
55 int iconSize() const;
56 void setIconSize(int iconSize);
57
58 QString title() const;
59 void setTitle(const QString &title);
60
61 bool user() const;
62 void setUser(bool user);
63
64 QString customLocation() const;
65 void setCustomLocation(const QString &customLocation);
66
67 Qt::WindowModality modality() const;
68 void setModality(Qt::WindowModality modality);
69
70 bool visible() const;
71 void setVisible(bool visible);
72
73 Q_INVOKABLE void open();
74 Q_INVOKABLE void close();
75
76Q_SIGNALS:
77 void iconNameChanged(const QString &iconName);
78 void iconSizeChanged(int iconSize);
79 void titleChanged(const QString &title);
80 void userChanged(bool user);
81 void customLocationChanged(const QString &customLocation);
82 void modalityChanged(Qt::WindowModality modality);
83 void visibleChanged();
84
85private:
86 bool eventFilter(QObject *watched, QEvent *event) override;
87
88 QScopedPointer<KIconDialog> m_dialog;
89
90 QString m_iconName;
91 int m_iconSize;
92 bool m_user;
93 QString m_customLocation;
94 Qt::WindowModality m_modality;
95};
96
97#endif // ICONDIALOG_H
98

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