1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4//
5// W A R N I N G
6// -------------
7//
8// This file is not part of the Qt API. It exists for the convenience
9// of Qt Designer. This header
10// file may change from version to version without notice, or even be removed.
11//
12// We mean it.
13//
14
15
16#ifndef ICONSELECTOR_H
17#define ICONSELECTOR_H
18
19#include "shared_global_p.h"
20
21#include <QtWidgets/qwidget.h>
22#include <QtWidgets/qdialog.h>
23
24#include <QtCore/qscopedpointer.h>
25
26QT_BEGIN_NAMESPACE
27
28class QtResourceModel;
29class QDesignerFormEditorInterface;
30class QDesignerDialogGuiInterface;
31class QDesignerResourceBrowserInterface;
32
33namespace qdesigner_internal {
34
35class DesignerIconCache;
36class DesignerPixmapCache;
37class PropertySheetIconValue;
38struct IconThemeEditorPrivate;
39
40// Resource Dialog that embeds the language-dependent resource widget as returned by the language extension
41class QDESIGNER_SHARED_EXPORT LanguageResourceDialog : public QDialog
42{
43 Q_OBJECT
44
45 explicit LanguageResourceDialog(QDesignerResourceBrowserInterface *rb, QWidget *parent = nullptr);
46
47public:
48 ~LanguageResourceDialog() override;
49 // Factory: Returns 0 if the language extension does not provide a resource browser.
50 static LanguageResourceDialog* create(QDesignerFormEditorInterface *core, QWidget *parent);
51
52 void setCurrentPath(const QString &filePath);
53 QString currentPath() const;
54
55private:
56 QScopedPointer<class LanguageResourceDialogPrivate> d_ptr;
57 Q_DECLARE_PRIVATE(LanguageResourceDialog)
58 Q_DISABLE_COPY_MOVE(LanguageResourceDialog)
59
60};
61
62class QDESIGNER_SHARED_EXPORT IconSelector: public QWidget
63{
64 Q_OBJECT
65public:
66 IconSelector(QWidget *parent = nullptr);
67 ~IconSelector() override;
68
69 void setFormEditor(QDesignerFormEditorInterface *core); // required for dialog gui.
70 void setIconCache(DesignerIconCache *iconCache);
71 void setPixmapCache(DesignerPixmapCache *pixmapCache);
72
73 void setIcon(const PropertySheetIconValue &icon);
74 PropertySheetIconValue icon() const;
75
76 // Check whether a pixmap may be read
77 enum CheckMode { CheckFast, CheckFully };
78 static bool checkPixmap(const QString &fileName, CheckMode cm = CheckFully, QString *errorMessage = nullptr);
79 // Choose a pixmap from file
80 static QString choosePixmapFile(const QString &directory, QDesignerDialogGuiInterface *dlgGui, QWidget *parent);
81 // Choose a pixmap from resource; use language-dependent resource browser if present
82 static QString choosePixmapResource(QDesignerFormEditorInterface *core, QtResourceModel *resourceModel, const QString &oldPath, QWidget *parent);
83
84signals:
85 void iconChanged(const PropertySheetIconValue &icon);
86private:
87 QScopedPointer<class IconSelectorPrivate> d_ptr;
88 Q_DECLARE_PRIVATE(IconSelector)
89 Q_DISABLE_COPY_MOVE(IconSelector)
90};
91
92// IconThemeEditor: Let's the user input theme icon names and shows a preview label.
93class QDESIGNER_SHARED_EXPORT IconThemeEditor : public QWidget
94{
95 Q_OBJECT
96 Q_PROPERTY(QString theme READ theme WRITE setTheme DESIGNABLE true)
97public:
98 explicit IconThemeEditor(QWidget *parent = nullptr, bool wantResetButton = true);
99 ~IconThemeEditor() override;
100
101 QString theme() const;
102 void setTheme(const QString &theme);
103
104signals:
105 void edited(const QString &);
106
107public slots:
108 void reset();
109
110private:
111 QScopedPointer<IconThemeEditorPrivate> d;
112};
113
114} // namespace qdesigner_internal
115
116QT_END_NAMESPACE
117
118#endif // ICONSELECTOR_H
119
120

source code of qttools/src/designer/src/lib/shared/iconselector_p.h