29 Q_PROPERTY(Theme theme READ theme WRITE setTheme RESET resetTheme NOTIFY themeChanged FINAL)
30 Q_PROPERTY(QVariant primary READ primary WRITE setPrimary RESET resetPrimary NOTIFY primaryChanged FINAL)
31 Q_PROPERTY(QVariant accent READ accent WRITE setAccent RESET resetAccent NOTIFY accentChanged FINAL)
32 Q_PROPERTY(QVariant foreground READ foreground WRITE setForeground RESET resetForeground NOTIFY foregroundChanged FINAL)
33 Q_PROPERTY(QVariant background READ background WRITE setBackground RESET resetBackground NOTIFY backgroundChanged FINAL)
34 Q_PROPERTY(
int elevation READ elevation WRITE setElevation RESET resetElevation NOTIFY elevationChanged FINAL)
35 Q_PROPERTY(RoundedScale roundedScale READ roundedScale WRITE setRoundedScale RESET resetRoundedScale
36 NOTIFY roundedScaleChanged FINAL)
37 Q_PROPERTY(ContainerStyle containerStyle READ containerStyle WRITE setContainerStyle RESET resetContainerStyle
38 NOTIFY containerStyleChanged FINAL)
40 Q_PROPERTY(QColor primaryColor READ primaryColor NOTIFY primaryChanged FINAL)
41 Q_PROPERTY(QColor accentColor READ accentColor NOTIFY accentChanged FINAL)
42 Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY backgroundChanged FINAL)
43 Q_PROPERTY(QColor primaryTextColor READ primaryTextColor NOTIFY themeChanged FINAL)
44 Q_PROPERTY(QColor primaryHighlightedTextColor READ primaryHighlightedTextColor NOTIFY primaryHighlightedTextColorChanged FINAL)
45 Q_PROPERTY(QColor secondaryTextColor READ secondaryTextColor NOTIFY themeChanged FINAL)
46 Q_PROPERTY(QColor hintTextColor READ hintTextColor NOTIFY themeChanged FINAL)
47 Q_PROPERTY(QColor textSelectionColor READ textSelectionColor NOTIFY themeOrAccentChanged FINAL)
48 Q_PROPERTY(QColor dropShadowColor READ dropShadowColor CONSTANT FINAL)
49 Q_PROPERTY(QColor dividerColor READ dividerColor NOTIFY themeChanged FINAL)
50 Q_PROPERTY(QColor iconColor READ iconColor NOTIFY themeChanged FINAL)
51 Q_PROPERTY(QColor iconDisabledColor READ iconDisabledColor NOTIFY themeChanged FINAL)
52 Q_PROPERTY(QColor frameColor READ frameColor NOTIFY themeChanged FINAL)
53 Q_PROPERTY(QColor rippleColor READ rippleColor NOTIFY themeChanged FINAL)
54 Q_PROPERTY(QColor highlightedRippleColor READ highlightedRippleColor NOTIFY themeOrAccentChanged FINAL)
55 Q_PROPERTY(QColor switchUncheckedTrackColor READ switchUncheckedTrackColor NOTIFY themeChanged FINAL)
56 Q_PROPERTY(QColor switchCheckedTrackColor READ switchCheckedTrackColor NOTIFY themeOrAccentChanged FINAL)
57 Q_PROPERTY(QColor switchUncheckedHandleColor READ switchUncheckedHandleColor NOTIFY themeChanged FINAL)
58 Q_PROPERTY(QColor switchUncheckedHoveredHandleColor READ switchUncheckedHoveredHandleColor NOTIFY themeChanged FINAL)
59 Q_PROPERTY(QColor switchDisabledUncheckedTrackColor READ switchDisabledUncheckedTrackColor NOTIFY themeChanged FINAL)
60 Q_PROPERTY(QColor switchDisabledCheckedTrackColor READ switchDisabledCheckedTrackColor NOTIFY themeChanged FINAL)
61 Q_PROPERTY(QColor switchDisabledUncheckedTrackBorderColor READ switchDisabledUncheckedTrackBorderColor NOTIFY themeChanged FINAL)
62 Q_PROPERTY(QColor switchCheckedHandleColor READ switchCheckedHandleColor NOTIFY themeOrAccentChanged FINAL)
63 Q_PROPERTY(QColor switchDisabledUncheckedHandleColor READ switchDisabledUncheckedHandleColor NOTIFY themeChanged FINAL)
64 Q_PROPERTY(QColor switchDisabledCheckedHandleColor READ switchDisabledCheckedHandleColor NOTIFY themeChanged FINAL)
65 Q_PROPERTY(QColor switchDisabledCheckedIconColor READ switchDisabledCheckedIconColor NOTIFY themeChanged FINAL)
66 Q_PROPERTY(QColor switchDisabledUncheckedIconColor READ switchDisabledUncheckedIconColor NOTIFY themeChanged FINAL)
67 Q_PROPERTY(QColor scrollBarColor READ scrollBarColor NOTIFY themeChanged FINAL)
68 Q_PROPERTY(QColor scrollBarHoveredColor READ scrollBarHoveredColor NOTIFY themeChanged FINAL)
69 Q_PROPERTY(QColor scrollBarPressedColor READ scrollBarPressedColor NOTIFY themeChanged FINAL)
70 Q_PROPERTY(QColor dialogColor READ dialogColor NOTIFY dialogColorChanged FINAL)
71 Q_PROPERTY(QColor backgroundDimColor READ backgroundDimColor NOTIFY themeChanged FINAL)
72 Q_PROPERTY(QColor listHighlightColor READ listHighlightColor NOTIFY themeChanged FINAL)
73 Q_PROPERTY(QColor tooltipColor READ tooltipColor NOTIFY tooltipColorChanged FINAL)
74 Q_PROPERTY(QColor toolBarColor READ toolBarColor NOTIFY toolBarColorChanged FINAL)
75 Q_PROPERTY(QColor toolTextColor READ toolTextColor NOTIFY toolTextColorChanged FINAL)
76 Q_PROPERTY(QColor spinBoxDisabledIconColor READ spinBoxDisabledIconColor NOTIFY themeChanged FINAL)
77 Q_PROPERTY(QColor sliderDisabledColor READ sliderDisabledColor NOTIFY themeChanged FINAL REVISION(2, 15))
78 Q_PROPERTY(QColor textFieldFilledContainerColor READ textFieldFilledContainerColor NOTIFY themeChanged FINAL)
80 Q_PROPERTY(
int touchTarget READ touchTarget CONSTANT FINAL)
81 Q_PROPERTY(
int buttonVerticalPadding READ buttonVerticalPadding CONSTANT FINAL)
82 Q_PROPERTY(
int buttonHeight READ buttonHeight CONSTANT FINAL)
83 Q_PROPERTY(
int delegateHeight READ delegateHeight CONSTANT FINAL)
84 Q_PROPERTY(
int dialogButtonBoxHeight READ dialogButtonBoxHeight CONSTANT FINAL)
85 Q_PROPERTY(
int dialogTitleFontPixelSize READ dialogTitleFontPixelSize CONSTANT FINAL)
86 Q_PROPERTY(RoundedScale dialogRoundedScale READ dialogRoundedScale CONSTANT FINAL)
87 Q_PROPERTY(
int frameVerticalPadding READ frameVerticalPadding CONSTANT FINAL)
88 Q_PROPERTY(
int menuItemHeight READ menuItemHeight CONSTANT FINAL)
89 Q_PROPERTY(
int menuItemVerticalPadding READ menuItemVerticalPadding CONSTANT FINAL)
90 Q_PROPERTY(
int switchIndicatorWidth READ switchIndicatorWidth CONSTANT FINAL)
91 Q_PROPERTY(
int switchIndicatorHeight READ switchIndicatorHeight CONSTANT FINAL)
92 Q_PROPERTY(
int switchNormalHandleHeight READ switchNormalHandleHeight CONSTANT FINAL)
93 Q_PROPERTY(
int switchCheckedHandleHeight READ switchCheckedHandleHeight CONSTANT FINAL)
94 Q_PROPERTY(
int switchLargestHandleHeight READ switchLargestHandleHeight CONSTANT FINAL)
95 Q_PROPERTY(
int switchDelegateVerticalPadding READ switchDelegateVerticalPadding CONSTANT FINAL)
96 Q_PROPERTY(
int textFieldHeight READ textFieldHeight CONSTANT FINAL)
97 Q_PROPERTY(
int textFieldHorizontalPadding READ textFieldHorizontalPadding CONSTANT FINAL)
98 Q_PROPERTY(
int textFieldVerticalPadding READ textFieldVerticalPadding CONSTANT FINAL)
99 Q_PROPERTY(
int tooltipHeight READ tooltipHeight CONSTANT FINAL)
101 QML_NAMED_ELEMENT(Material)
102 QML_ATTACHED(QQuickMaterialStyle)
104 QML_ADDED_IN_VERSION(2, 0)
157 enum class RoundedScale {
163 ExtraLargeScale = 28,
167 enum class ContainerStyle {
177 Q_ENUM(ContainerStyle)
179 explicit QQuickMaterialStyle(QObject *parent =
nullptr);
181 static QQuickMaterialStyle *qmlAttachedProperties(QObject *object);
184 void setTheme(Theme theme);
185 void inheritTheme(Theme theme);
186 void propagateTheme();
190 QVariant primary()
const;
191 void setPrimary(
const QVariant &accent);
192 void inheritPrimary(uint primary,
bool custom);
193 void propagatePrimary();
195 void primaryChange();
197 QVariant accent()
const;
198 void setAccent(
const QVariant &accent);
199 void inheritAccent(uint accent,
bool custom);
200 void propagateAccent();
204 QVariant foreground()
const;
205 void setForeground(
const QVariant &foreground);
206 void inheritForeground(uint foreground,
bool custom,
bool has);
207 void propagateForeground();
208 void resetForeground();
209 void foregroundChange();
211 QVariant background()
const;
212 void setBackground(
const QVariant &background);
213 void inheritBackground(uint background,
bool custom,
bool has);
214 void propagateBackground();
215 void resetBackground();
216 void backgroundChange();
218 int elevation()
const;
219 void setElevation(
int elevation);
220 void resetElevation();
221 void elevationChange();
223 RoundedScale roundedScale()
const;
224 void setRoundedScale(RoundedScale roundedScale);
225 void resetRoundedScale();
227 ContainerStyle containerStyle()
const;
228 void setContainerStyle(ContainerStyle containerStyle);
229 void resetContainerStyle();
231 QColor primaryColor()
const;
232 QColor accentColor()
const;
233 QColor backgroundColor()
const;
234 QColor primaryTextColor()
const;
235 QColor primaryHighlightedTextColor()
const;
236 QColor secondaryTextColor()
const;
237 QColor hintTextColor()
const;
238 QColor textSelectionColor()
const;
239 QColor dropShadowColor()
const;
240 QColor dividerColor()
const;
241 QColor iconColor()
const;
242 QColor iconDisabledColor()
const;
243 Q_INVOKABLE QColor buttonColor(Theme theme,
const QVariant &background,
const QVariant &accent,
244 bool enabled,
bool flat,
bool highlighted,
bool checked)
const;
245 QColor frameColor()
const;
246 QColor rippleColor()
const;
247 QColor highlightedRippleColor()
const;
248 QColor switchUncheckedTrackColor()
const;
249 QColor switchCheckedTrackColor()
const;
250 QColor switchDisabledUncheckedTrackColor()
const;
251 QColor switchDisabledCheckedTrackColor()
const;
252 QColor switchDisabledUncheckedTrackBorderColor()
const;
253 QColor switchUncheckedHandleColor()
const;
254 QColor switchUncheckedHoveredHandleColor()
const;
255 QColor switchCheckedHandleColor()
const;
256 QColor switchDisabledUncheckedHandleColor()
const;
257 QColor switchDisabledCheckedHandleColor()
const;
258 QColor switchDisabledCheckedIconColor()
const;
259 QColor switchDisabledUncheckedIconColor()
const;
260 QColor scrollBarColor()
const;
261 QColor scrollBarHoveredColor()
const;
262 QColor scrollBarPressedColor()
const;
263 QColor dialogColor()
const;
264 QColor backgroundDimColor()
const;
265 QColor listHighlightColor()
const;
266 QColor tooltipColor()
const;
267 QColor toolBarColor()
const;
268 QColor toolTextColor()
const;
269 QColor spinBoxDisabledIconColor()
const;
270 QColor sliderDisabledColor()
const;
271 QColor textFieldFilledContainerColor()
const;
273 Q_INVOKABLE QColor color(Color color, Shade shade = Shade500)
const;
274 Q_INVOKABLE QColor shade(
const QColor &color, Shade shade)
const;
276 int touchTarget()
const;
277 int buttonVerticalPadding()
const;
278 Q_INVOKABLE
int buttonLeftPadding(
bool flat,
bool hasIcon)
const;
279 Q_INVOKABLE
int buttonRightPadding(
bool flat,
bool hasIcon,
bool hasText)
const;
280 int buttonHeight()
const;
281 int delegateHeight()
const;
282 int dialogButtonBoxHeight()
const;
283 int dialogTitleFontPixelSize()
const;
284 RoundedScale dialogRoundedScale()
const;
285 int frameVerticalPadding()
const;
286 int menuItemHeight()
const;
287 int menuItemVerticalPadding()
const;
288 int switchIndicatorWidth()
const;
289 int switchIndicatorHeight()
const;
290 int switchNormalHandleHeight()
const;
291 int switchCheckedHandleHeight()
const;
292 int switchLargestHandleHeight()
const;
293 int switchDelegateVerticalPadding()
const;
294 int textFieldHeight()
const;
295 int textFieldHorizontalPadding()
const;
296 int textFieldVerticalPadding()
const;
297 int tooltipHeight()
const;
299 static void initGlobals();
301 static Variant variant();
305 void primaryChanged();
306 void accentChanged();
307 void foregroundChanged();
308 void backgroundChanged();
309 void elevationChanged();
311 void themeOrAccentChanged();
313 void primaryHighlightedTextColorChanged();
314 void dialogColorChanged();
315 void tooltipColorChanged();
316 void toolBarColorChanged();
317 void toolTextColorChanged();
318 void roundedScaleChanged();
319 void containerStyleChanged();
322 void attachedParentChange(QQuickAttachedPropertyPropagator *newParent, QQuickAttachedPropertyPropagator *oldParent) override;
326 bool variantToRgba(
const QVariant &var,
const char *name, QRgb *rgba,
bool *custom)
const;
328 QColor backgroundColor(Shade shade)
const;
329 QColor accentColor(Shade shade)
const;
331 Shade themeShade()
const;
335 bool m_explicitTheme =
false;
336 bool m_explicitPrimary =
false;
337 bool m_explicitAccent =
false;
338 bool m_explicitForeground =
false;
339 bool m_explicitBackground =
false;
343 bool m_customPrimary =
false;
344 bool m_customAccent =
false;
345 bool m_customForeground =
false;
346 bool m_customBackground =
false;
351 bool m_hasForeground =
false;
352 bool m_hasBackground =
false;
354 bool m_systemTheme =
false;
355 Theme m_theme = Light;
358 uint m_foreground = 0;
359 uint m_background = 0;
361 RoundedScale m_roundedScale = RoundedScale::NotRounded;
362 ContainerStyle m_containerStyle = ContainerStyle::Filled;