/src/qtbase/src/gui/image/qicon.h
Line | Count | Source |
1 | | // Copyright (C) 2016 The Qt Company Ltd. |
2 | | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | | // Qt-Security score:significant reason:default |
4 | | |
5 | | #ifndef QICON_H |
6 | | #define QICON_H |
7 | | |
8 | | #include <QtGui/qtguiglobal.h> |
9 | | #include <QtCore/qsize.h> |
10 | | #include <QtCore/qlist.h> |
11 | | #include <QtGui/qpixmap.h> |
12 | | |
13 | | QT_BEGIN_NAMESPACE |
14 | | |
15 | | |
16 | | class QIconPrivate; |
17 | | class QIconEngine; |
18 | | class QPainter; |
19 | | |
20 | | class Q_GUI_EXPORT QIcon |
21 | | { |
22 | | Q_GADGET |
23 | | Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") |
24 | | public: |
25 | | enum Mode { Normal, Disabled, Active, Selected }; |
26 | | Q_ENUM(Mode); |
27 | | enum State { On, Off }; |
28 | | Q_ENUM(State); |
29 | | |
30 | | enum class ThemeIcon { |
31 | | AddressBookNew, |
32 | | ApplicationExit, |
33 | | AppointmentNew, |
34 | | CallStart, |
35 | | CallStop, |
36 | | ContactNew, |
37 | | DocumentNew, |
38 | | DocumentOpen, |
39 | | DocumentOpenRecent, |
40 | | DocumentPageSetup, |
41 | | DocumentPrint, |
42 | | DocumentPrintPreview, |
43 | | DocumentProperties, |
44 | | DocumentRevert, |
45 | | DocumentSave, |
46 | | DocumentSaveAs, |
47 | | DocumentSend, |
48 | | EditClear, |
49 | | EditCopy, |
50 | | EditCut, |
51 | | EditDelete, |
52 | | EditFind, |
53 | | EditPaste, |
54 | | EditRedo, |
55 | | EditSelectAll, |
56 | | EditUndo, |
57 | | FolderNew, |
58 | | FormatIndentLess, |
59 | | FormatIndentMore, |
60 | | FormatJustifyCenter, |
61 | | FormatJustifyFill, |
62 | | FormatJustifyLeft, |
63 | | FormatJustifyRight, |
64 | | FormatTextDirectionLtr, |
65 | | FormatTextDirectionRtl, |
66 | | FormatTextBold, |
67 | | FormatTextItalic, |
68 | | FormatTextUnderline, |
69 | | FormatTextStrikethrough, |
70 | | GoDown, |
71 | | GoHome, |
72 | | GoNext, |
73 | | GoPrevious, |
74 | | GoUp, |
75 | | HelpAbout, |
76 | | HelpFaq, |
77 | | InsertImage, |
78 | | InsertLink, |
79 | | InsertText, |
80 | | ListAdd, |
81 | | ListRemove, |
82 | | MailForward, |
83 | | MailMarkImportant, |
84 | | MailMarkRead, |
85 | | MailMarkUnread, |
86 | | MailMessageNew, |
87 | | MailReplyAll, |
88 | | MailReplySender, |
89 | | MailSend, |
90 | | MediaEject, |
91 | | MediaPlaybackPause, |
92 | | MediaPlaybackStart, |
93 | | MediaPlaybackStop, |
94 | | MediaRecord, |
95 | | MediaSeekBackward, |
96 | | MediaSeekForward, |
97 | | MediaSkipBackward, |
98 | | MediaSkipForward, |
99 | | ObjectRotateLeft, |
100 | | ObjectRotateRight, |
101 | | ProcessStop, |
102 | | SystemLockScreen, |
103 | | SystemLogOut, |
104 | | SystemSearch, |
105 | | SystemReboot, |
106 | | SystemShutdown, |
107 | | ToolsCheckSpelling, |
108 | | ViewFullscreen, |
109 | | ViewRefresh, |
110 | | ViewRestore, |
111 | | WindowClose, |
112 | | WindowNew, |
113 | | ZoomFitBest, |
114 | | ZoomIn, |
115 | | ZoomOut, |
116 | | |
117 | | AudioCard, |
118 | | AudioInputMicrophone, |
119 | | Battery, |
120 | | CameraPhoto, |
121 | | CameraVideo, |
122 | | CameraWeb, |
123 | | Computer, |
124 | | DriveHarddisk, |
125 | | DriveOptical, |
126 | | InputGaming, |
127 | | InputKeyboard, |
128 | | InputMouse, |
129 | | InputTablet, |
130 | | MediaFlash, |
131 | | MediaOptical, |
132 | | MediaTape, |
133 | | MultimediaPlayer, |
134 | | NetworkWired, |
135 | | NetworkWireless, |
136 | | Phone, |
137 | | Printer, |
138 | | Scanner, |
139 | | VideoDisplay, |
140 | | |
141 | | AppointmentMissed, |
142 | | AppointmentSoon, |
143 | | AudioVolumeHigh, |
144 | | AudioVolumeLow, |
145 | | AudioVolumeMedium, |
146 | | AudioVolumeMuted, |
147 | | BatteryCaution, |
148 | | BatteryLow, |
149 | | DialogError, |
150 | | DialogInformation, |
151 | | DialogPassword, |
152 | | DialogQuestion, |
153 | | DialogWarning, |
154 | | FolderDragAccept, |
155 | | FolderOpen, |
156 | | FolderVisiting, |
157 | | ImageLoading, |
158 | | ImageMissing, |
159 | | MailAttachment, |
160 | | MailUnread, |
161 | | MailRead, |
162 | | MailReplied, |
163 | | MediaPlaylistRepeat, |
164 | | MediaPlaylistShuffle, |
165 | | NetworkOffline, |
166 | | PrinterPrinting, |
167 | | SecurityHigh, |
168 | | SecurityLow, |
169 | | SoftwareUpdateAvailable, |
170 | | SoftwareUpdateUrgent, |
171 | | SyncError, |
172 | | SyncSynchronizing, |
173 | | UserAvailable, |
174 | | UserOffline, |
175 | | WeatherClear, |
176 | | WeatherClearNight, |
177 | | WeatherFewClouds, |
178 | | WeatherFewCloudsNight, |
179 | | WeatherFog, |
180 | | WeatherShowers, |
181 | | WeatherSnow, |
182 | | WeatherStorm, |
183 | | |
184 | | NThemeIcons |
185 | | }; |
186 | | Q_ENUM(ThemeIcon); |
187 | | |
188 | | QIcon() noexcept; |
189 | | QIcon(const QPixmap &pixmap); |
190 | | QIcon(const QIcon &other); |
191 | | QIcon(QIcon &&other) noexcept |
192 | | : d(std::exchange(other.d, nullptr)) |
193 | 0 | {} |
194 | | explicit QIcon(const QString &fileName); // file or resource name |
195 | | explicit QIcon(QIconEngine *engine); |
196 | | ~QIcon(); |
197 | | QIcon &operator=(const QIcon &other); |
198 | | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QIcon) |
199 | | inline void swap(QIcon &other) noexcept |
200 | 0 | { qt_ptr_swap(d, other.d); } |
201 | | bool operator==(const QIcon &) const = delete; |
202 | | bool operator!=(const QIcon &) const = delete; |
203 | | |
204 | | operator QVariant() const; |
205 | | |
206 | | QPixmap pixmap(const QSize &size, Mode mode = Normal, State state = Off) const; |
207 | | inline QPixmap pixmap(int w, int h, Mode mode = Normal, State state = Off) const |
208 | 0 | { return pixmap(QSize(w, h), mode, state); } |
209 | | inline QPixmap pixmap(int extent, Mode mode = Normal, State state = Off) const |
210 | 0 | { return pixmap(QSize(extent, extent), mode, state); } |
211 | | QPixmap pixmap(const QSize &size, qreal devicePixelRatio, Mode mode = Normal, State state = Off) const; |
212 | | #if QT_DEPRECATED_SINCE(6, 0) |
213 | | QT_DEPRECATED_VERSION_X_6_0("Use pixmap(size, devicePixelRatio) instead") |
214 | | QPixmap pixmap(QWindow *window, const QSize &size, Mode mode = Normal, State state = Off) const; |
215 | | #endif |
216 | | |
217 | | QSize actualSize(const QSize &size, Mode mode = Normal, State state = Off) const; |
218 | | #if QT_DEPRECATED_SINCE(6, 0) |
219 | | QT_DEPRECATED_VERSION_X_6_0("Use actualSize(size) instead") |
220 | | QSize actualSize(QWindow *window, const QSize &size, Mode mode = Normal, State state = Off) const; |
221 | | #endif |
222 | | |
223 | | QString name() const; |
224 | | |
225 | | void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment = Qt::AlignCenter, Mode mode = Normal, State state = Off) const; |
226 | | inline void paint(QPainter *painter, int x, int y, int w, int h, Qt::Alignment alignment = Qt::AlignCenter, Mode mode = Normal, State state = Off) const |
227 | 0 | { paint(painter, QRect(x, y, w, h), alignment, mode, state); } |
228 | | |
229 | | bool isNull() const; |
230 | | bool isDetached() const; |
231 | | void detach(); |
232 | | |
233 | | qint64 cacheKey() const; |
234 | | |
235 | | void addPixmap(const QPixmap &pixmap, Mode mode = Normal, State state = Off); |
236 | | void addFile(const QString &fileName, const QSize &size = QSize(), Mode mode = Normal, State state = Off); |
237 | | |
238 | | QList<QSize> availableSizes(Mode mode = Normal, State state = Off) const; |
239 | | |
240 | | void setIsMask(bool isMask); |
241 | | bool isMask() const; |
242 | | |
243 | | static QIcon fromTheme(const QString &name); |
244 | | static QIcon fromTheme(const QString &name, const QIcon &fallback); |
245 | | static bool hasThemeIcon(const QString &name); |
246 | | |
247 | | static QIcon fromTheme(ThemeIcon icon); |
248 | | static QIcon fromTheme(ThemeIcon icon, const QIcon &fallback); |
249 | | static bool hasThemeIcon(ThemeIcon icon); |
250 | | |
251 | | static QStringList themeSearchPaths(); |
252 | | static void setThemeSearchPaths(const QStringList &searchpath); |
253 | | |
254 | | static QStringList fallbackSearchPaths(); |
255 | | static void setFallbackSearchPaths(const QStringList &paths); |
256 | | |
257 | | static QString themeName(); |
258 | | static void setThemeName(const QString &path); |
259 | | |
260 | | static QString fallbackThemeName(); |
261 | | static void setFallbackThemeName(const QString &name); |
262 | | |
263 | | private: |
264 | | QIconPrivate *d; |
265 | | #if !defined(QT_NO_DATASTREAM) |
266 | | friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QIcon &); |
267 | | friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &); |
268 | | #endif |
269 | | |
270 | | friend class QIconPrivate; |
271 | | |
272 | | public: |
273 | | typedef QIconPrivate * DataPtr; |
274 | 0 | inline DataPtr &data_ptr() { return d; } |
275 | | }; |
276 | | |
277 | | Q_DECLARE_SHARED(QIcon) |
278 | | |
279 | | #if !defined(QT_NO_DATASTREAM) |
280 | | Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QIcon &); |
281 | | Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &); |
282 | | #endif |
283 | | |
284 | | #ifndef QT_NO_DEBUG_STREAM |
285 | | Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QIcon &); |
286 | | #endif |
287 | | |
288 | | Q_GUI_EXPORT QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio, |
289 | | qreal *sourceDevicePixelRatio = nullptr); |
290 | | |
291 | | QT_END_NAMESPACE |
292 | | |
293 | | #endif // QICON_H |