File indexing completed on 2025-01-18 10:07:59
0001
0002
0003
0004 #ifndef QICON_H
0005 #define QICON_H
0006
0007 #include <QtGui/qtguiglobal.h>
0008 #include <QtCore/qsize.h>
0009 #include <QtCore/qlist.h>
0010 #include <QtGui/qpixmap.h>
0011
0012 QT_BEGIN_NAMESPACE
0013
0014
0015 class QIconPrivate;
0016 class QIconEngine;
0017 class QPainter;
0018
0019 class Q_GUI_EXPORT QIcon
0020 {
0021 public:
0022 enum Mode { Normal, Disabled, Active, Selected };
0023 enum State { On, Off };
0024
0025 enum class ThemeIcon {
0026 AddressBookNew,
0027 ApplicationExit,
0028 AppointmentNew,
0029 CallStart,
0030 CallStop,
0031 ContactNew,
0032 DocumentNew,
0033 DocumentOpen,
0034 DocumentOpenRecent,
0035 DocumentPageSetup,
0036 DocumentPrint,
0037 DocumentPrintPreview,
0038 DocumentProperties,
0039 DocumentRevert,
0040 DocumentSave,
0041 DocumentSaveAs,
0042 DocumentSend,
0043 EditClear,
0044 EditCopy,
0045 EditCut,
0046 EditDelete,
0047 EditFind,
0048 EditPaste,
0049 EditRedo,
0050 EditSelectAll,
0051 EditUndo,
0052 FolderNew,
0053 FormatIndentLess,
0054 FormatIndentMore,
0055 FormatJustifyCenter,
0056 FormatJustifyFill,
0057 FormatJustifyLeft,
0058 FormatJustifyRight,
0059 FormatTextDirectionLtr,
0060 FormatTextDirectionRtl,
0061 FormatTextBold,
0062 FormatTextItalic,
0063 FormatTextUnderline,
0064 FormatTextStrikethrough,
0065 GoDown,
0066 GoHome,
0067 GoNext,
0068 GoPrevious,
0069 GoUp,
0070 HelpAbout,
0071 HelpFaq,
0072 InsertImage,
0073 InsertLink,
0074 InsertText,
0075 ListAdd,
0076 ListRemove,
0077 MailForward,
0078 MailMarkImportant,
0079 MailMarkRead,
0080 MailMarkUnread,
0081 MailMessageNew,
0082 MailReplyAll,
0083 MailReplySender,
0084 MailSend,
0085 MediaEject,
0086 MediaPlaybackPause,
0087 MediaPlaybackStart,
0088 MediaPlaybackStop,
0089 MediaRecord,
0090 MediaSeekBackward,
0091 MediaSeekForward,
0092 MediaSkipBackward,
0093 MediaSkipForward,
0094 ObjectRotateLeft,
0095 ObjectRotateRight,
0096 ProcessStop,
0097 SystemLockScreen,
0098 SystemLogOut,
0099 SystemSearch,
0100 SystemReboot,
0101 SystemShutdown,
0102 ToolsCheckSpelling,
0103 ViewFullscreen,
0104 ViewRefresh,
0105 ViewRestore,
0106 WindowClose,
0107 WindowNew,
0108 ZoomFitBest,
0109 ZoomIn,
0110 ZoomOut,
0111
0112 AudioCard,
0113 AudioInputMicrophone,
0114 Battery,
0115 CameraPhoto,
0116 CameraVideo,
0117 CameraWeb,
0118 Computer,
0119 DriveHarddisk,
0120 DriveOptical,
0121 InputGaming,
0122 InputKeyboard,
0123 InputMouse,
0124 InputTablet,
0125 MediaFlash,
0126 MediaOptical,
0127 MediaTape,
0128 MultimediaPlayer,
0129 NetworkWired,
0130 NetworkWireless,
0131 Phone,
0132 Printer,
0133 Scanner,
0134 VideoDisplay,
0135
0136 AppointmentMissed,
0137 AppointmentSoon,
0138 AudioVolumeHigh,
0139 AudioVolumeLow,
0140 AudioVolumeMedium,
0141 AudioVolumeMuted,
0142 BatteryCaution,
0143 BatteryLow,
0144 DialogError,
0145 DialogInformation,
0146 DialogPassword,
0147 DialogQuestion,
0148 DialogWarning,
0149 FolderDragAccept,
0150 FolderOpen,
0151 FolderVisiting,
0152 ImageLoading,
0153 ImageMissing,
0154 MailAttachment,
0155 MailUnread,
0156 MailRead,
0157 MailReplied,
0158 MediaPlaylistRepeat,
0159 MediaPlaylistShuffle,
0160 NetworkOffline,
0161 PrinterPrinting,
0162 SecurityHigh,
0163 SecurityLow,
0164 SoftwareUpdateAvailable,
0165 SoftwareUpdateUrgent,
0166 SyncError,
0167 SyncSynchronizing,
0168 UserAvailable,
0169 UserOffline,
0170 WeatherClear,
0171 WeatherClearNight,
0172 WeatherFewClouds,
0173 WeatherFewCloudsNight,
0174 WeatherFog,
0175 WeatherShowers,
0176 WeatherSnow,
0177 WeatherStorm,
0178
0179 NThemeIcons
0180 };
0181
0182 QIcon() noexcept;
0183 QIcon(const QPixmap &pixmap);
0184 QIcon(const QIcon &other);
0185 QIcon(QIcon &&other) noexcept
0186 : d(std::exchange(other.d, nullptr))
0187 {}
0188 explicit QIcon(const QString &fileName);
0189 explicit QIcon(QIconEngine *engine);
0190 ~QIcon();
0191 QIcon &operator=(const QIcon &other);
0192 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QIcon)
0193 inline void swap(QIcon &other) noexcept
0194 { qt_ptr_swap(d, other.d); }
0195 bool operator==(const QIcon &) const = delete;
0196 bool operator!=(const QIcon &) const = delete;
0197
0198 operator QVariant() const;
0199
0200 QPixmap pixmap(const QSize &size, Mode mode = Normal, State state = Off) const;
0201 inline QPixmap pixmap(int w, int h, Mode mode = Normal, State state = Off) const
0202 { return pixmap(QSize(w, h), mode, state); }
0203 inline QPixmap pixmap(int extent, Mode mode = Normal, State state = Off) const
0204 { return pixmap(QSize(extent, extent), mode, state); }
0205 QPixmap pixmap(const QSize &size, qreal devicePixelRatio, Mode mode = Normal, State state = Off) const;
0206 #if QT_DEPRECATED_SINCE(6, 0)
0207 QT_DEPRECATED_VERSION_X_6_0("Use pixmap(size, devicePixelRatio) instead")
0208 QPixmap pixmap(QWindow *window, const QSize &size, Mode mode = Normal, State state = Off) const;
0209 #endif
0210
0211 QSize actualSize(const QSize &size, Mode mode = Normal, State state = Off) const;
0212 #if QT_DEPRECATED_SINCE(6, 0)
0213 QT_DEPRECATED_VERSION_X_6_0("Use actualSize(size) instead")
0214 QSize actualSize(QWindow *window, const QSize &size, Mode mode = Normal, State state = Off) const;
0215 #endif
0216
0217 QString name() const;
0218
0219 void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment = Qt::AlignCenter, Mode mode = Normal, State state = Off) const;
0220 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
0221 { paint(painter, QRect(x, y, w, h), alignment, mode, state); }
0222
0223 bool isNull() const;
0224 bool isDetached() const;
0225 void detach();
0226
0227 qint64 cacheKey() const;
0228
0229 void addPixmap(const QPixmap &pixmap, Mode mode = Normal, State state = Off);
0230 void addFile(const QString &fileName, const QSize &size = QSize(), Mode mode = Normal, State state = Off);
0231
0232 QList<QSize> availableSizes(Mode mode = Normal, State state = Off) const;
0233
0234 void setIsMask(bool isMask);
0235 bool isMask() const;
0236
0237 static QIcon fromTheme(const QString &name);
0238 static QIcon fromTheme(const QString &name, const QIcon &fallback);
0239 static bool hasThemeIcon(const QString &name);
0240
0241 static QIcon fromTheme(ThemeIcon icon);
0242 static QIcon fromTheme(ThemeIcon icon, const QIcon &fallback);
0243 static bool hasThemeIcon(ThemeIcon icon);
0244
0245 static QStringList themeSearchPaths();
0246 static void setThemeSearchPaths(const QStringList &searchpath);
0247
0248 static QStringList fallbackSearchPaths();
0249 static void setFallbackSearchPaths(const QStringList &paths);
0250
0251 static QString themeName();
0252 static void setThemeName(const QString &path);
0253
0254 static QString fallbackThemeName();
0255 static void setFallbackThemeName(const QString &name);
0256
0257 private:
0258 QIconPrivate *d;
0259 #if !defined(QT_NO_DATASTREAM)
0260 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QIcon &);
0261 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &);
0262 #endif
0263
0264 public:
0265 typedef QIconPrivate * DataPtr;
0266 inline DataPtr &data_ptr() { return d; }
0267 };
0268
0269 Q_DECLARE_SHARED(QIcon)
0270
0271 #if !defined(QT_NO_DATASTREAM)
0272 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QIcon &);
0273 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &);
0274 #endif
0275
0276 #ifndef QT_NO_DEBUG_STREAM
0277 Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QIcon &);
0278 #endif
0279
0280 Q_GUI_EXPORT QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio,
0281 qreal *sourceDevicePixelRatio = nullptr);
0282
0283 QT_END_NAMESPACE
0284
0285 #endif