KanoopGuiQt 1.3.0
Qt GUI utility library
Loading...
Searching...
No Matches
stylesheettypes.h
1#ifndef STYLESHEETTYPES_H
2#define STYLESHEETTYPES_H
3
4#include <Kanoop/kanoopcommon.h>
5
6/**
7 * @brief Qt stylesheet property identifiers.
8 *
9 * Each value corresponds to a CSS property supported by Qt's stylesheet engine.
10 * Pass these to StyleSheet::setProperty() or StyleSheetStrings::getPropertyString().
11 */
12enum StyleSheetProperty {
13 SP_AccentColor,
14 SP_AlternateBackgroundColor,
15 SP_Background,
16 SP_BackgroundColor,
17 SP_BackgroundImage,
18 SP_BackgroundRepeat,
19 SP_BackgroundPosition,
20 SP_BackgroundAttachment,
21 SP_BackgroundClip,
22 SP_BackgroundOrigin,
23 SP_Border,
24 SP_BorderTop,
25 SP_BorderRight,
26 SP_BorderBottom,
27 SP_BorderLeft,
28 SP_BorderColor,
29 SP_BorderTopColor,
30 SP_BorderRightColor,
31 SP_BorderBottomColor,
32 SP_BorderLeftColor,
33 SP_BorderImage,
34 SP_BorderRadius,
35 SP_BorderTopLeftRadius,
36 SP_BorderTopRightRadius,
37 SP_BorderBottomRightRadius,
38 SP_BorderBottomLeftRadius,
39 SP_BorderStyle,
40 SP_BorderTopStyle,
41 SP_BorderRightStyle,
42 SP_BorderBottomStyle,
43 SP_BorderLeftStyle,
44 SP_BorderWidth,
45 SP_BorderTopWidth,
46 SP_BorderRightWidth,
47 SP_BorderBottomWidth,
48 SP_BorderLeftWidth,
49 SP_Bottom,
50 SP_ButtonLayout,
51 SP_Color,
52 SP_DialogbuttonboxButtonsHaveIcons,
53 SP_Font,
54 SP_FontFamily,
55 SP_FontSize,
56 SP_FontStyle,
57 SP_FontWeight,
58 SP_GridlineColor,
59 SP_Height,
60 SP_Icon,
61 SP_IconSize,
62 SP_Image,
63 SP_ImagePosition,
64 SP_Left,
65 SP_LineeditPasswordCharacter,
66 SP_LineeditPasswordMaskDelay,
67 SP_Margin,
68 SP_MarginTop,
69 SP_MarginRight,
70 SP_MarginBottom,
71 SP_MarginLeft,
72 SP_MaxHeight,
73 SP_MaxWidth,
74 SP_MessageboxTextInteractionFlags,
75 SP_MinHeight,
76 SP_MinWidth,
77 SP_Opacity,
78 SP_Outline,
79 SP_OutlineColor,
80 SP_OutlineOffset,
81 SP_OutlineStyle,
82 SP_OutlineRadius,
83 SP_OutlineBottomLeftRadius,
84 SP_OutlineBottomRightRadius,
85 SP_OutlineTopLeftRadius,
86 SP_OutlineTopRightRadius,
87 SP_Padding,
88 SP_PaddingTop,
89 SP_PaddingRight,
90 SP_PaddingBottom,
91 SP_PaddingLeft,
92 SP_PaintAlternatingRowColorsForEmptyArea,
93 SP_PlaceholderTextColor,
94 SP_Position,
95 SP_Right,
96 SP_SelectionBackgroundColor,
97 SP_SelectionColor,
98 SP_ShowDecorationSelected,
99 SP_Spacing,
100 SP_SubcontrolOrigin,
101 SP_SubcontrolPosition,
102 SP_TitlebarShowTooltipsOnButtons,
103 SP_WidgetAnimationDuration,
104 SP_TextAlign,
105 SP_TextDecoration,
106 SP_Top,
107 SP_Width,
108 SP_QtBackgroundRole,
109 SP_QtStyleFeatures,
110};
111
112/**
113 * @brief Qt stylesheet pseudo-state identifiers.
114 *
115 * Each value corresponds to a CSS pseudo-state supported by Qt's stylesheet engine.
116 * Pass these to StyleSheet::setPseudoState() or StyleSheetStrings::getPseudoStateString().
117 */
118enum StyleSheetPseudoState {
119 PS_Invalid = 0,
120
121 PS_Active, // This state is set when the widget resides in an active window.
122 PS_AdjoinsItem, // This state is set when the ::branch of a QTreeView is adjacent to an item.
123 PS_Alternate, // This state is set for every alternate row whe painting the row of a QAbstractItemView when QAbstractItemView::alternatingRowColors() is set to true.
124 PS_Bottom, // The item is positioned at the bottom. For example, a QTabBar that has its tabs positioned at the bottom.
125 PS_Checked, // The item is checked. For example, the checked state of QAbstractButton.
126 PS_Closable, // The items can be closed. For example, the QDockWidget has the QDockWidget::DockWidgetClosable feature turned on.
127 PS_Closed, // The item is in the closed state. For example, an non-expanded item in a QTreeView
128 PS_Default, // The item is the default. For example, a default QPushButton or a default action in a QMenu.
129 PS_Disabled, // The item is disabled.
130 PS_Editable, // The QComboBox is editable.
131 PS_EditFocus, // The item has edit focus (See QStyle::State_HasEditFocus). This state is available only for Qt Extended applications.
132 PS_Enabled, // The item is enabled.
133 PS_Exclusive, // The item is part of an exclusive item group. For example, a menu item in a exclusive QActionGroup.
134 PS_First, // The item is the first (in a list). For example, the first tab in a QTabBar.
135 PS_Flat, // The item is flat. For example, a flat QPushButton.
136 PS_Floatable, // The items can be floated. For example, the QDockWidget has the QDockWidget::DockWidgetFloatable feature turned on.
137 PS_Focus, // The item has input focus.
138 PS_HasChildren, // The item has children. For example, an item in a QTreeView that has child items.
139 PS_HasSiblings, // The item has siblings. For example, an item in a QTreeView that siblings.
140 PS_Horizontal, // The item has horizontal orientation
141 PS_Hover, // The mouse is hovering over the item.
142 PS_Indeterminate, // The item has indeterminate state. For example, a QCheckBox or QRadioButton is partially checked.
143 PS_Last, // The item is the last (in a list). For example, the last tab in a QTabBar.
144 PS_Left, // The item is positioned at the left. For example, a QTabBar that has its tabs positioned at the left.
145 PS_Maximized, // The item is maximized. For example, a maximized QMdiSubWindow.
146 PS_Middle, // The item is in the middle (in a list). For example, a tab that is not in the beginning or the end in a QTabBar.
147 PS_Minimized, // The item is minimized. For example, a minimized QMdiSubWindow.
148 PS_Movable, // The item can be moved around. For example, the QDockWidget has the QDockWidget::DockWidgetMovable feature turned on.
149 PS_NoFrame, // The item has no frame. For example, a frameless QSpinBox or QLineEdit.
150 PS_NonExclusive, // The item is part of a non-exclusive item group. For example, a menu item in a non-exclusive QActionGroup.
151 PS_Off, // For items that can be toggled, this applies to items in the "off" state.
152 PS_On, // For items that can be toggled, this applies to widgets in the "on" state.
153 PS_OnlyOne, // The item is the only one (in a list). For example, a lone tab in a QTabBar.
154 PS_Open, // The item is in the open state. For example, an expanded item in a QTreeView, or a QComboBox or QPushButton with an open menu.
155 PS_NextSelected, // The next item (in a list) is selected. For example, the selected tab of a QTabBar is next to this item.
156 PS_Pressed, // The item is being pressed using the mouse.
157 PS_PreviousSelected, // The previous item (in a list) is selected. For example, a tab in a QTabBar that is next to the selected tab.
158 PS_ReadOnly, // The item is marked read only or non-editable. For example, a read only QLineEdit or a non-editable QComboBox.
159 PS_Right, // The item is positioned at the right. For example, a QTabBar that has its tabs positioned at the right.
160 PS_Selected, // The item is selected. For example, the selected tab in a QTabBar or the selected item in a QMenu.
161 PS_Top, // The item is positioned at the top. For example, a QTabBar that has its tabs positioned at the top.
162 PS_Unchecked, // The item is unchecked.
163 PS_Vertical, // The item has vertical orientation.
164 PS_Window, // The widget is a window (i.e top level widget)
165};
166
167/**
168 * @brief Utility class for converting stylesheet enums to their CSS string equivalents.
169 */
171{
172public:
173 /**
174 * @brief Return the CSS property name for a StyleSheetProperty value.
175 * @param property Property enum value
176 * @return CSS property name string (e.g., "background-color")
177 */
178 static QString getPropertyString(StyleSheetProperty property) { return _PropertyToStringMap.getString(property); }
179
180 /**
181 * @brief Return the CSS pseudo-state name for a StyleSheetPseudoState value.
182 * @param pseudoState Pseudo-state enum value
183 * @return CSS pseudo-state string (e.g., "hover")
184 */
185 static QString getPseudoStateString(StyleSheetPseudoState pseudoState) { return _PseudoStateToStringMap.getString(pseudoState); }
186
187private:
188 class PropertyToStringMap : public KANOOP::EnumToStringMap<StyleSheetProperty>
189 {
190 public:
191 PropertyToStringMap()
192 {
193 insert(SP_AccentColor, "accent-color");
194 insert(SP_AlternateBackgroundColor, "alternate-background-color");
195 insert(SP_Background, "background");
196 insert(SP_BackgroundColor, "background-color");
197 insert(SP_BackgroundImage, "background-image");
198 insert(SP_BackgroundRepeat, "background-repeat");
199 insert(SP_BackgroundPosition, "background-position");
200 insert(SP_BackgroundAttachment, "background-attachment");
201 insert(SP_BackgroundClip, "background-clip");
202 insert(SP_BackgroundOrigin, "background-origin");
203 insert(SP_Border, "border");
204 insert(SP_BorderTop, "border-top");
205 insert(SP_BorderRight, "border-right");
206 insert(SP_BorderBottom, "border-bottom");
207 insert(SP_BorderLeft, "border-left");
208 insert(SP_BorderColor, "border-color");
209 insert(SP_BorderTopColor, "border-top-color");
210 insert(SP_BorderRightColor, "border-right-color");
211 insert(SP_BorderBottomColor, "border-bottom-color");
212 insert(SP_BorderLeftColor, "border-left-color");
213 insert(SP_BorderImage, "border-image");
214 insert(SP_BorderRadius, "border-radius");
215 insert(SP_BorderTopLeftRadius, "border-top-left-radius");
216 insert(SP_BorderTopRightRadius, "border-top-right-radius");
217 insert(SP_BorderBottomRightRadius, "border-bottom-right-radius");
218 insert(SP_BorderBottomLeftRadius, "border-bottom-left-radius");
219 insert(SP_BorderStyle, "border-style");
220 insert(SP_BorderTopStyle, "border-top-style");
221 insert(SP_BorderRightStyle, "border-right-style");
222 insert(SP_BorderBottomStyle, "border-bottom-style");
223 insert(SP_BorderLeftStyle, "border-left-style");
224 insert(SP_BorderWidth, "border-width");
225 insert(SP_BorderTopWidth, "border-top-width");
226 insert(SP_BorderRightWidth, "border-right-width");
227 insert(SP_BorderBottomWidth, "border-bottom-width");
228 insert(SP_BorderLeftWidth, "border-left-width");
229 insert(SP_Bottom, "bottom");
230 insert(SP_ButtonLayout, "button-layout");
231 insert(SP_Color, "color");
232 insert(SP_DialogbuttonboxButtonsHaveIcons, "dialogbuttonbox-buttons-have-icons");
233 insert(SP_Font, "font");
234 insert(SP_FontFamily, "font-family");
235 insert(SP_FontSize, "font-size");
236 insert(SP_FontStyle, "font-style");
237 insert(SP_FontWeight, "font-weight");
238 insert(SP_GridlineColor, "gridline-color");
239 insert(SP_Height, "height");
240 insert(SP_Icon, "icon");
241 insert(SP_IconSize, "icon-size");
242 insert(SP_Image, "image");
243 insert(SP_ImagePosition, "image-position");
244 insert(SP_Left, "left");
245 insert(SP_LineeditPasswordCharacter, "lineedit-password-character");
246 insert(SP_LineeditPasswordMaskDelay, "lineedit-password-mask-delay");
247 insert(SP_Margin, "margin");
248 insert(SP_MarginTop, "margin-top");
249 insert(SP_MarginRight, "margin-right");
250 insert(SP_MarginBottom, "margin-bottom");
251 insert(SP_MarginLeft, "margin-left");
252 insert(SP_MaxHeight, "max-height");
253 insert(SP_MaxWidth, "max-width");
254 insert(SP_MessageboxTextInteractionFlags, "messagebox-text-interaction-flags");
255 insert(SP_MinHeight, "min-height");
256 insert(SP_MinWidth, "min-width");
257 insert(SP_Opacity, "opacity");
258 insert(SP_Outline, "outline");
259 insert(SP_OutlineColor, "outline-color");
260 insert(SP_OutlineOffset, "outline-offset");
261 insert(SP_OutlineStyle, "outline-style");
262 insert(SP_OutlineRadius, "outline-radius");
263 insert(SP_OutlineBottomLeftRadius, "outline-bottom-left-radius");
264 insert(SP_OutlineBottomRightRadius, "outline-bottom-right-radius");
265 insert(SP_OutlineTopLeftRadius, "outline-top-left-radius");
266 insert(SP_OutlineTopRightRadius, "outline-top-right-radius");
267 insert(SP_Padding, "padding");
268 insert(SP_PaddingTop, "padding-top");
269 insert(SP_PaddingRight, "padding-right");
270 insert(SP_PaddingBottom, "padding-bottom");
271 insert(SP_PaddingLeft, "padding-left");
272 insert(SP_PaintAlternatingRowColorsForEmptyArea, "paint-alternating-row-colors-for-empty-area");
273 insert(SP_PlaceholderTextColor, "placeholder-text-color");
274 insert(SP_Position, "position");
275 insert(SP_Right, "right");
276 insert(SP_SelectionBackgroundColor, "selection-background-color");
277 insert(SP_SelectionColor, "selection-color");
278 insert(SP_ShowDecorationSelected, "show-decoration-selected");
279 insert(SP_Spacing, "spacing");
280 insert(SP_SubcontrolOrigin, "subcontrol-origin");
281 insert(SP_SubcontrolPosition, "subcontrol-position");
282 insert(SP_TitlebarShowTooltipsOnButtons, "titlebar-show-tooltips-on-buttons");
283 insert(SP_WidgetAnimationDuration, "widget-animation-duration");
284 insert(SP_TextAlign, "text-align");
285 insert(SP_TextDecoration, "text-decoration");
286 insert(SP_Top, "top");
287 insert(SP_Width, "width");
288 insert(SP_QtBackgroundRole, "-qt-background-role");
289 insert(SP_QtStyleFeatures, "-qt-style-features");
290 }
291 };
292
293 class PseudoStateToStringMap : public KANOOP::EnumToStringMap<StyleSheetPseudoState>
294 {
295 public:
296 PseudoStateToStringMap()
297 {
298 insert(PS_Active, "active");
299 insert(PS_AdjoinsItem, "adjoins-item");
300 insert(PS_Alternate, "alternate");
301 insert(PS_Bottom, "bottom");
302 insert(PS_Checked, "checked");
303 insert(PS_Closable, "closable");
304 insert(PS_Closed, "closed");
305 insert(PS_Default, "default");
306 insert(PS_Disabled, "disabled");
307 insert(PS_Editable, "editable");
308 insert(PS_EditFocus, "edit-focus");
309 insert(PS_Enabled, "enabled");
310 insert(PS_Exclusive, "exclusive");
311 insert(PS_First, "first");
312 insert(PS_Flat, "flat");
313 insert(PS_Floatable, "floatable");
314 insert(PS_Focus, "focus");
315 insert(PS_HasChildren, "has-children");
316 insert(PS_HasSiblings, "has-siblings");
317 insert(PS_Horizontal, "horizontal");
318 insert(PS_Hover, "hover");
319 insert(PS_Indeterminate, "indeterminate");
320 insert(PS_Last, "last");
321 insert(PS_Left, "left");
322 insert(PS_Maximized, "maximized");
323 insert(PS_Middle, "middle");
324 insert(PS_Minimized, "minimized");
325 insert(PS_Movable, "movable");
326 insert(PS_NoFrame, "no-frame");
327 insert(PS_NonExclusive, "non-exclusive");
328 insert(PS_Off, "off");
329 insert(PS_On, "on");
330 insert(PS_OnlyOne, "only-one");
331 insert(PS_Open, "open");
332 insert(PS_NextSelected, "next-selected");
333 insert(PS_Pressed, "pressed");
334 insert(PS_PreviousSelected, "previous-selected");
335 insert(PS_ReadOnly, "read-only");
336 insert(PS_Right, "right");
337 insert(PS_Selected, "selected");
338 insert(PS_Top, "top");
339 insert(PS_Unchecked, "unchecked");
340 insert(PS_Vertical, "vertical");
341 insert(PS_Window, "window");
342 }
343 };
344
345 static const PropertyToStringMap _PropertyToStringMap;
346 static const PseudoStateToStringMap _PseudoStateToStringMap;
347};
348
349#endif // STYLESHEETTYPES_H
Utility class for converting stylesheet enums to their CSS string equivalents.
static QString getPropertyString(StyleSheetProperty property)
Return the CSS property name for a StyleSheetProperty value.
static QString getPseudoStateString(StyleSheetPseudoState pseudoState)
Return the CSS pseudo-state name for a StyleSheetPseudoState value.