| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt Designer of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
| 21 | ** included in the packaging of this file. Please review the following |
| 22 | ** information to ensure the GNU General Public License requirements will |
| 23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 24 | ** |
| 25 | ** $QT_END_LICENSE$ |
| 26 | ** |
| 27 | ****************************************************************************/ |
| 28 | |
| 29 | // |
| 30 | // W A R N I N G |
| 31 | // ------------- |
| 32 | // |
| 33 | // This file is not part of the Qt API. It exists for the convenience |
| 34 | // of Qt Designer. This header |
| 35 | // file may change from version to version without notice, or even be removed. |
| 36 | // |
| 37 | // We mean it. |
| 38 | // |
| 39 | |
| 40 | |
| 41 | #ifndef ICONSELECTOR_H |
| 42 | #define ICONSELECTOR_H |
| 43 | |
| 44 | #include "shared_global_p.h" |
| 45 | |
| 46 | #include <QtWidgets/qwidget.h> |
| 47 | #include <QtWidgets/qdialog.h> |
| 48 | |
| 49 | #include <QtCore/qscopedpointer.h> |
| 50 | |
| 51 | QT_BEGIN_NAMESPACE |
| 52 | |
| 53 | class QtResourceModel; |
| 54 | class QDesignerFormEditorInterface; |
| 55 | class QDesignerDialogGuiInterface; |
| 56 | class QDesignerResourceBrowserInterface; |
| 57 | |
| 58 | namespace qdesigner_internal { |
| 59 | |
| 60 | class DesignerIconCache; |
| 61 | class DesignerPixmapCache; |
| 62 | class PropertySheetIconValue; |
| 63 | struct IconThemeEditorPrivate; |
| 64 | |
| 65 | // Resource Dialog that embeds the language-dependent resource widget as returned by the language extension |
| 66 | class QDESIGNER_SHARED_EXPORT LanguageResourceDialog : public QDialog |
| 67 | { |
| 68 | Q_OBJECT |
| 69 | |
| 70 | explicit LanguageResourceDialog(QDesignerResourceBrowserInterface *rb, QWidget *parent = nullptr); |
| 71 | |
| 72 | public: |
| 73 | ~LanguageResourceDialog() override; |
| 74 | // Factory: Returns 0 if the language extension does not provide a resource browser. |
| 75 | static LanguageResourceDialog* create(QDesignerFormEditorInterface *core, QWidget *parent); |
| 76 | |
| 77 | void setCurrentPath(const QString &filePath); |
| 78 | QString currentPath() const; |
| 79 | |
| 80 | private: |
| 81 | QScopedPointer<class LanguageResourceDialogPrivate> d_ptr; |
| 82 | Q_DECLARE_PRIVATE(LanguageResourceDialog) |
| 83 | Q_DISABLE_COPY_MOVE(LanguageResourceDialog) |
| 84 | Q_PRIVATE_SLOT(d_func(), void slotAccepted()) |
| 85 | Q_PRIVATE_SLOT(d_func(), void slotPathChanged(QString)) |
| 86 | |
| 87 | }; |
| 88 | |
| 89 | class QDESIGNER_SHARED_EXPORT IconSelector: public QWidget |
| 90 | { |
| 91 | Q_OBJECT |
| 92 | public: |
| 93 | IconSelector(QWidget *parent = nullptr); |
| 94 | ~IconSelector() override; |
| 95 | |
| 96 | void setFormEditor(QDesignerFormEditorInterface *core); // required for dialog gui. |
| 97 | void setIconCache(DesignerIconCache *iconCache); |
| 98 | void setPixmapCache(DesignerPixmapCache *pixmapCache); |
| 99 | |
| 100 | void setIcon(const PropertySheetIconValue &icon); |
| 101 | PropertySheetIconValue icon() const; |
| 102 | |
| 103 | // Check whether a pixmap may be read |
| 104 | enum CheckMode { CheckFast, CheckFully }; |
| 105 | static bool checkPixmap(const QString &fileName, CheckMode cm = CheckFully, QString *errorMessage = nullptr); |
| 106 | // Choose a pixmap from file |
| 107 | static QString choosePixmapFile(const QString &directory, QDesignerDialogGuiInterface *dlgGui, QWidget *parent); |
| 108 | // Choose a pixmap from resource; use language-dependent resource browser if present |
| 109 | static QString choosePixmapResource(QDesignerFormEditorInterface *core, QtResourceModel *resourceModel, const QString &oldPath, QWidget *parent); |
| 110 | |
| 111 | signals: |
| 112 | void iconChanged(const PropertySheetIconValue &icon); |
| 113 | private: |
| 114 | QScopedPointer<class IconSelectorPrivate> d_ptr; |
| 115 | Q_DECLARE_PRIVATE(IconSelector) |
| 116 | Q_DISABLE_COPY_MOVE(IconSelector) |
| 117 | |
| 118 | Q_PRIVATE_SLOT(d_func(), void slotStateActivated()) |
| 119 | Q_PRIVATE_SLOT(d_func(), void slotSetActivated()) |
| 120 | Q_PRIVATE_SLOT(d_func(), void slotSetResourceActivated()) |
| 121 | Q_PRIVATE_SLOT(d_func(), void slotSetFileActivated()) |
| 122 | Q_PRIVATE_SLOT(d_func(), void slotResetActivated()) |
| 123 | Q_PRIVATE_SLOT(d_func(), void slotResetAllActivated()) |
| 124 | Q_PRIVATE_SLOT(d_func(), void slotUpdate()) |
| 125 | }; |
| 126 | |
| 127 | // IconThemeEditor: Let's the user input theme icon names and shows a preview label. |
| 128 | class QDESIGNER_SHARED_EXPORT IconThemeEditor : public QWidget |
| 129 | { |
| 130 | Q_OBJECT |
| 131 | Q_PROPERTY(QString theme READ theme WRITE setTheme DESIGNABLE true) |
| 132 | public: |
| 133 | explicit IconThemeEditor(QWidget *parent = nullptr, bool wantResetButton = true); |
| 134 | ~IconThemeEditor() override; |
| 135 | |
| 136 | QString theme() const; |
| 137 | void setTheme(const QString &theme); |
| 138 | |
| 139 | signals: |
| 140 | void edited(const QString &); |
| 141 | |
| 142 | public slots: |
| 143 | void reset(); |
| 144 | |
| 145 | private slots: |
| 146 | void slotChanged(const QString &); |
| 147 | |
| 148 | private: |
| 149 | void updatePreview(const QString &); |
| 150 | |
| 151 | QScopedPointer<IconThemeEditorPrivate> d; |
| 152 | }; |
| 153 | |
| 154 | } // namespace qdesigner_internal |
| 155 | |
| 156 | QT_END_NAMESPACE |
| 157 | |
| 158 | #endif // ICONSELECTOR_H |
| 159 | |
| 160 | |