| 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 | |
| 4 | #ifndef QPLATFORMTHEME_H |
| 5 | #define QPLATFORMTHEME_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is part of the QPA API and is not meant to be used |
| 12 | // in applications. Usage of this API may make your code |
| 13 | // source and binary incompatible with future versions of Qt. |
| 14 | // |
| 15 | |
| 16 | #include <QtGui/qtguiglobal.h> |
| 17 | #include <QtCore/QObject> |
| 18 | #include <QtCore/QScopedPointer> |
| 19 | #if QT_CONFIG(shortcut) |
| 20 | # include <QtGui/QKeySequence> |
| 21 | #endif |
| 22 | |
| 23 | QT_BEGIN_NAMESPACE |
| 24 | |
| 25 | class QIcon; |
| 26 | class QIconEngine; |
| 27 | class ; |
| 28 | class ; |
| 29 | class ; |
| 30 | class ; |
| 31 | class ; |
| 32 | class QPlatformDialogHelper; |
| 33 | class QPlatformSystemTrayIcon; |
| 34 | class QPlatformThemePrivate; |
| 35 | class QVariant; |
| 36 | class QPalette; |
| 37 | class QFont; |
| 38 | class QPixmap; |
| 39 | class QSizeF; |
| 40 | class QFileInfo; |
| 41 | |
| 42 | class Q_GUI_EXPORT QPlatformTheme |
| 43 | { |
| 44 | Q_GADGET |
| 45 | Q_DECLARE_PRIVATE(QPlatformTheme) |
| 46 | |
| 47 | public: |
| 48 | Q_DISABLE_COPY_MOVE(QPlatformTheme) |
| 49 | |
| 50 | enum ThemeHint { |
| 51 | CursorFlashTime, |
| 52 | KeyboardInputInterval, |
| 53 | MouseDoubleClickInterval, |
| 54 | StartDragDistance, |
| 55 | StartDragTime, |
| 56 | KeyboardAutoRepeatRate, |
| 57 | PasswordMaskDelay, |
| 58 | StartDragVelocity, |
| 59 | TextCursorWidth, |
| 60 | DropShadow, |
| 61 | MaximumScrollBarDragDistance, |
| 62 | ToolButtonStyle, |
| 63 | ToolBarIconSize, |
| 64 | ItemViewActivateItemOnSingleClick, |
| 65 | SystemIconThemeName, |
| 66 | SystemIconFallbackThemeName, |
| 67 | IconThemeSearchPaths, |
| 68 | StyleNames, |
| 69 | WindowAutoPlacement, |
| 70 | DialogButtonBoxLayout, |
| 71 | DialogButtonBoxButtonsHaveIcons, |
| 72 | , |
| 73 | KeyboardScheme, |
| 74 | UiEffects, |
| 75 | SpellCheckUnderlineStyle, |
| 76 | TabFocusBehavior, |
| 77 | IconPixmapSizes, |
| 78 | PasswordMaskCharacter, |
| 79 | DialogSnapToDefaultButton, |
| 80 | , |
| 81 | MousePressAndHoldInterval, |
| 82 | MouseDoubleClickDistance, |
| 83 | WheelScrollLines, |
| 84 | TouchDoubleTapDistance, |
| 85 | , |
| 86 | IconFallbackSearchPaths, |
| 87 | MouseQuickSelectionThreshold, |
| 88 | InteractiveResizeAcrossScreens, |
| 89 | ShowDirectoriesFirst, |
| 90 | PreselectFirstFileInDirectory, |
| 91 | ButtonPressKeys, |
| 92 | SetFocusOnTouchRelease, |
| 93 | FlickStartDistance, |
| 94 | FlickMaximumVelocity, |
| 95 | FlickDeceleration, |
| 96 | , |
| 97 | MouseCursorTheme, |
| 98 | MouseCursorSize, |
| 99 | UnderlineShortcut, |
| 100 | , |
| 101 | PreferFileIconFromTheme, |
| 102 | }; |
| 103 | Q_ENUM(ThemeHint) |
| 104 | |
| 105 | enum DialogType { |
| 106 | FileDialog, |
| 107 | ColorDialog, |
| 108 | FontDialog, |
| 109 | MessageDialog |
| 110 | }; |
| 111 | Q_ENUM(DialogType) |
| 112 | |
| 113 | enum Palette { |
| 114 | SystemPalette, |
| 115 | ToolTipPalette, |
| 116 | ToolButtonPalette, |
| 117 | ButtonPalette, |
| 118 | CheckBoxPalette, |
| 119 | RadioButtonPalette, |
| 120 | , |
| 121 | ComboBoxPalette, |
| 122 | ItemViewPalette, |
| 123 | MessageBoxLabelPelette, |
| 124 | MessageBoxLabelPalette = MessageBoxLabelPelette, |
| 125 | TabBarPalette, |
| 126 | LabelPalette, |
| 127 | GroupBoxPalette, |
| 128 | , |
| 129 | , |
| 130 | TextEditPalette, |
| 131 | TextLineEditPalette, |
| 132 | NPalettes |
| 133 | }; |
| 134 | Q_ENUM(Palette) |
| 135 | |
| 136 | enum Font { |
| 137 | SystemFont, |
| 138 | , |
| 139 | , |
| 140 | , |
| 141 | MessageBoxFont, |
| 142 | LabelFont, |
| 143 | TipLabelFont, |
| 144 | StatusBarFont, |
| 145 | TitleBarFont, |
| 146 | MdiSubWindowTitleFont, |
| 147 | DockWidgetTitleFont, |
| 148 | PushButtonFont, |
| 149 | CheckBoxFont, |
| 150 | RadioButtonFont, |
| 151 | ToolButtonFont, |
| 152 | ItemViewFont, |
| 153 | ListViewFont, |
| 154 | , |
| 155 | ListBoxFont, |
| 156 | , |
| 157 | ComboLineEditFont, |
| 158 | SmallFont, |
| 159 | MiniFont, |
| 160 | FixedFont, |
| 161 | GroupBoxTitleFont, |
| 162 | TabButtonFont, |
| 163 | EditorFont, |
| 164 | NFonts |
| 165 | }; |
| 166 | Q_ENUM(Font) |
| 167 | |
| 168 | enum StandardPixmap { // Keep in sync with QStyle::StandardPixmap |
| 169 | , |
| 170 | TitleBarMinButton, |
| 171 | TitleBarMaxButton, |
| 172 | TitleBarCloseButton, |
| 173 | TitleBarNormalButton, |
| 174 | TitleBarShadeButton, |
| 175 | TitleBarUnshadeButton, |
| 176 | TitleBarContextHelpButton, |
| 177 | DockWidgetCloseButton, |
| 178 | MessageBoxInformation, |
| 179 | MessageBoxWarning, |
| 180 | MessageBoxCritical, |
| 181 | MessageBoxQuestion, |
| 182 | DesktopIcon, |
| 183 | TrashIcon, |
| 184 | ComputerIcon, |
| 185 | DriveFDIcon, |
| 186 | DriveHDIcon, |
| 187 | DriveCDIcon, |
| 188 | DriveDVDIcon, |
| 189 | DriveNetIcon, |
| 190 | DirOpenIcon, |
| 191 | DirClosedIcon, |
| 192 | DirLinkIcon, |
| 193 | DirLinkOpenIcon, |
| 194 | FileIcon, |
| 195 | FileLinkIcon, |
| 196 | ToolBarHorizontalExtensionButton, |
| 197 | ToolBarVerticalExtensionButton, |
| 198 | FileDialogStart, |
| 199 | FileDialogEnd, |
| 200 | FileDialogToParent, |
| 201 | FileDialogNewFolder, |
| 202 | FileDialogDetailedView, |
| 203 | FileDialogInfoView, |
| 204 | FileDialogContentsView, |
| 205 | FileDialogListView, |
| 206 | FileDialogBack, |
| 207 | DirIcon, |
| 208 | DialogOkButton, |
| 209 | DialogCancelButton, |
| 210 | DialogHelpButton, |
| 211 | DialogOpenButton, |
| 212 | DialogSaveButton, |
| 213 | DialogCloseButton, |
| 214 | DialogApplyButton, |
| 215 | DialogResetButton, |
| 216 | DialogDiscardButton, |
| 217 | DialogYesButton, |
| 218 | DialogNoButton, |
| 219 | ArrowUp, |
| 220 | ArrowDown, |
| 221 | ArrowLeft, |
| 222 | ArrowRight, |
| 223 | ArrowBack, |
| 224 | ArrowForward, |
| 225 | DirHomeIcon, |
| 226 | CommandLink, |
| 227 | VistaShield, |
| 228 | BrowserReload, |
| 229 | BrowserStop, |
| 230 | MediaPlay, |
| 231 | MediaStop, |
| 232 | MediaPause, |
| 233 | MediaSkipForward, |
| 234 | MediaSkipBackward, |
| 235 | MediaSeekForward, |
| 236 | MediaSeekBackward, |
| 237 | MediaVolume, |
| 238 | MediaVolumeMuted, |
| 239 | LineEditClearButton, |
| 240 | DialogYesToAllButton, |
| 241 | DialogNoToAllButton, |
| 242 | DialogSaveAllButton, |
| 243 | DialogAbortButton, |
| 244 | DialogRetryButton, |
| 245 | DialogIgnoreButton, |
| 246 | RestoreDefaultsButton, |
| 247 | TabCloseButton, |
| 248 | NStandardPixmap, // assertion value for sync with QStyle::StandardPixmap |
| 249 | |
| 250 | // do not add any values below/greater than this |
| 251 | CustomBase = 0xf0000000 |
| 252 | }; |
| 253 | Q_ENUM(StandardPixmap) |
| 254 | |
| 255 | enum KeyboardSchemes |
| 256 | { |
| 257 | WindowsKeyboardScheme, |
| 258 | MacKeyboardScheme, |
| 259 | X11KeyboardScheme, |
| 260 | KdeKeyboardScheme, |
| 261 | GnomeKeyboardScheme, |
| 262 | CdeKeyboardScheme |
| 263 | }; |
| 264 | Q_ENUM(KeyboardSchemes) |
| 265 | |
| 266 | enum UiEffect |
| 267 | { |
| 268 | GeneralUiEffect = 0x1, |
| 269 | = 0x2, |
| 270 | = 0x4, |
| 271 | AnimateComboUiEffect = 0x8, |
| 272 | AnimateTooltipUiEffect = 0x10, |
| 273 | FadeTooltipUiEffect = 0x20, |
| 274 | AnimateToolBoxUiEffect = 0x40, |
| 275 | HoverEffect = 0x80 |
| 276 | }; |
| 277 | Q_ENUM(UiEffect) |
| 278 | |
| 279 | enum IconOption { |
| 280 | DontUseCustomDirectoryIcons = 0x01 |
| 281 | }; |
| 282 | Q_DECLARE_FLAGS(IconOptions, IconOption) |
| 283 | |
| 284 | explicit QPlatformTheme(); |
| 285 | virtual ~QPlatformTheme(); |
| 286 | |
| 287 | virtual QPlatformMenuItem* () const; |
| 288 | virtual QPlatformMenu* () const; |
| 289 | virtual QPlatformMenuBar* () const; |
| 290 | virtual void () {} |
| 291 | |
| 292 | virtual bool usePlatformNativeDialog(DialogType type) const; |
| 293 | virtual QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const; |
| 294 | |
| 295 | #ifndef QT_NO_SYSTEMTRAYICON |
| 296 | virtual QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const; |
| 297 | #endif |
| 298 | |
| 299 | virtual Qt::ColorScheme colorScheme() const; |
| 300 | |
| 301 | virtual const QPalette *palette(Palette type = SystemPalette) const; |
| 302 | |
| 303 | virtual const QFont *font(Font type = SystemFont) const; |
| 304 | |
| 305 | virtual QVariant themeHint(ThemeHint hint) const; |
| 306 | |
| 307 | virtual QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const; |
| 308 | virtual QIcon fileIcon(const QFileInfo &fileInfo, |
| 309 | QPlatformTheme::IconOptions iconOptions = { }) const; |
| 310 | virtual QIconEngine *createIconEngine(const QString &iconName) const; |
| 311 | |
| 312 | #if QT_CONFIG(shortcut) |
| 313 | virtual QList<QKeySequence> keyBindings(QKeySequence::StandardKey key) const; |
| 314 | #endif |
| 315 | |
| 316 | virtual QString standardButtonText(int button) const; |
| 317 | #if QT_CONFIG(shortcut) |
| 318 | virtual QKeySequence standardButtonShortcut(int button) const; |
| 319 | #endif |
| 320 | virtual void requestColorScheme(Qt::ColorScheme scheme); |
| 321 | |
| 322 | static QVariant defaultThemeHint(ThemeHint hint); |
| 323 | static QString defaultStandardButtonText(int button); |
| 324 | static QString removeMnemonics(const QString &original); |
| 325 | QString name() const; |
| 326 | |
| 327 | protected: |
| 328 | explicit QPlatformTheme(QPlatformThemePrivate *priv); |
| 329 | QScopedPointer<QPlatformThemePrivate> d_ptr; |
| 330 | |
| 331 | private: |
| 332 | friend class QPlatformThemeFactory; |
| 333 | }; |
| 334 | |
| 335 | QT_END_NAMESPACE |
| 336 | |
| 337 | #endif // QPLATFORMTHEME_H |
| 338 | |