aboutsummaryrefslogtreecommitdiffstats
path: root/src/labs/stylekit
Commit message (Collapse)AuthorAgeFilesLines
* StyleKit: insert cached string into hash tableRichard Moe Gustavsen28 hours1-0/+1
| | | | | | | | | | | | | | Amending commit 9975c733be The previous commit introduced caching of path strings, as the same paths are typically used repeatedly. However, it failed to actually insert the generated strings into the cache. This patch amends that change by ensuring the cache is properly populated with the generated path strings. Pick-to: 6.11 Change-Id: I4222f083b722947b168f1dadfba265a9aa4be702 Reviewed-by: Doris Verria <doris.verria@qt.io>
* StyleKitStyle: Give a parent to palette pointer memberDoris Verria5 days1-1/+1
| | | | | | | | This ensures correct lifetime management of it. Pick-to: 6.11 Change-Id: I7fd183abf6ab83d8bdc39d9406d044891c14ed6f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* StyleKit: Move palettes from QQuickTheme to parent classDoris Verria5 days9-114/+155
| | | | | | | Task-number: QTBUG-130067 Pick-to: 6.11 Change-Id: Ie9c466591fbfbf54d9575d3684636b13c1061d64 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* StyleKit: Don't directly point to the reader's palette from the styleDoris Verria5 days2-5/+20
| | | | | | | | | | | | Add an own QQuikcPalette * member type to the style that should be synced with the style reader's palette, but don't directly point to it. This avoids changing the reader's palette from the style, or that the style palette changes outside of a property read which is problematic. Task-number: QTBUG-130067 Pick-to: 6.11 Change-Id: I3524c3472a5c250f1f943d2b1b6c66d6fcb93929 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* StyleKit: reimplement broken QQStyleKitDebug::propertyPath()Richard Moe Gustavsen8 days4-33/+58
| | | | | | | | | | | | | | | | | | | | | | | | QQStyleKitDebug previously printed property paths under the assumption that nested property groups followed the same parent–child hierarchy as they are written in the style. After a recent optimization in QQStyleKitPropertyGroup, this assumption is no longer valid. As part of that optimization, all property groups now have the root QQStyleKitControlProperties as their parent in order to avoid unnecessary hierarchy traversals. This change broke the logic used to reconstruct property paths for debugging. This patch introduces QQStyleKitPropertyGroup::pathToString(), which reconstructs a property path in the same order as it is written in the style. While this functionality may also enable future optimizations, it is currently used to restore correct and readable debug output. Task-number: QTBUG-130067 Pick-to: 6.11 Change-Id: I60e0aac3320c703b5b0995daa5a68a8ea1f015c5 Reviewed-by: Doris Verria <doris.verria@qt.io>
* StyleKit, optimization: track which properties a style/theme storesRichard Moe Gustavsen11 days4-19/+68
| | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces an optimization that allows the propagation engine to skip checking a style/theme/variation if it does not store a value for the property being queried. This significantly reduces the number of QHash lookups needed during property resolution. For example, when resolving all property values for a Button in the hovered state, the number of “failed” lookups dropped from 1632 to 168 when tested with the Haze style. The large improvement is likely due to the typical separation of concerns between styles and themes (at least in Haze): styles primarily define structural properties such as implicit size and corner radii, while themes define colors. Additionally, many properties in the Fallback style remain untouched by both style and theme. Under such conditions, which should be common, this optimization becomes highly effective. Task-number: QTBUG-130067 Pick-to: 6.11 Change-Id: I25d3e350a70243b8e5f96b08f9217a3404866572 Reviewed-by: Doris Verria <doris.verria@qt.io>
* StyleKit: use QHash instead of QMapRichard Moe Gustavsen11 days2-2/+2
| | | | | | | | | | | | | It's apparently not only faster, but also more memory efficient to use a QHash. QMap can be better if one needs to iterate over the keys in sorted order. But that is never the case for StyleKit. So switch to use QHash instead of QMap for the affected containers. Task-number: QTBUG-130067 Pick-to: 6.11 Change-Id: I6f430acbd32555cba85de8191aefa71140b07111 Reviewed-by: Doris Verria <doris.verria@qt.io>
* StyleKit: remove unused function declarationRichard Moe Gustavsen11 days1-2/+0
| | | | | | | | | Remove left-over and unused function declaration Task-number: QTBUG-130067 Pick-to: 6.11 Change-Id: I0f56b9f60905d3474f9804ef39b2541344d4a3d0 Reviewed-by: Doris Verria <doris.verria@qt.io>
* StyleKit: only emit signals globally for readers of the correct typeRichard Moe Gustavsen13 days11-76/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | When the application wrote a new value to a property in the style, we used to emit a property changed signal for that property from every StyleKitReader (control) in the application. We did this because we could not easily know which controls would be affected by such a write because of property propagation. This could therefore be very slow. But now that we have more functionallity in StyleKit available, such as being able to resolve a controls base types, we can now improve on this logic. Therefore, this patch will ensure that we instead only emit changes from the StyleKitReaders of the same type (or a base type) as the control written to in the style. The result is that a write from the app, such as: StyleKit.style.groupBox.background.radius = value will cause an update only for groupBoxes, skipping all other controls. This is clearly faster. Task-number: QTBUG-130067 Pick-to: 6.11 Change-Id: I6432db93f282b8155d9270a57206f0d558b801a8 Reviewed-by: Doris Verria <doris.verria@qt.io>
* StyleKit: ensure we hide delegates upon setting 'visible: false'Richard Moe Gustavsen13 days1-4/+7
| | | | | | | | | | | | | | | | | | | | | | | As it stood, if you e.g did: control.background.shadow.visible: true control.hovered.background.shadow.visible: false Then the shadow would stay visible also when the control was hovered. The reason was because the shadow was already created in the normal state, and toggling visiblity after that point had no effect. This patch will fix this, so that we hide the shadow if its visibility is set to false after first having been created. We refrain from destroying it again, since doing so has a higher cost, and most likely, the hiding of the shadow is just temporarily. Task-number: QTBUG-130067 Pick-to: 6.11 Change-Id: Ib107b11b7f7fa638d7ac439348b9ccb75bf1bb1a Reviewed-by: Doris Verria <doris.verria@qt.io>
* StyleKit: don't bind to the palette from the Fallback styleRichard Moe Gustavsen2025-12-091-137/+207
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We used to bind several of the colors in the Fallback style the palette. This turns out to be not such a good idea. The reason is that the palette differs across platforms, which means that a style created on e.g macOS can end up looking completly different when running on Ubuntu. While this might be wanted sometimes, more often it has the potential to come as a surprise at a late stage during development, and contributes to a "write once, debug everywhere" scenario. This patch will therefore change this. We now choose to follow the Basic style approach, and "hard-code" the colors in the Fallback style to be the same on all platforms. This gives developers a stable platform to build their own styles on top of. It's still fully possible to bind all colors in their own style to the palette, if they want a more dynamic style that respects the platform palette. Task-number: QTBUG-130067 Pick-to: 6.11 Change-Id: Ibeeedacb35b5a4c68c827b66baf0298a42b2948a Reviewed-by: Doris Verria <doris.verria@qt.io>
* StyleKit Example: improve the example after recent StyleKit fixesRichard Moe Gustavsen2025-12-061-1/+1
| | | | | Change-Id: I01bcdaea8a7014c3bd2f1c65b7d00a048700b91f Reviewed-by: Doris Verria <doris.verria@qt.io>
* StyleKit: Add ApplicationWindowDoris Verria2025-12-058-5/+44
| | | | | Change-Id: I9cc429c5a5e229983cb68648df239260903a0af4 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* StyleKit: Add ToolSeparatorDoris Verria2025-12-058-1/+59
| | | | | Change-Id: If1285165aa28fea401bbff061fcdfd4563bce334 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* StyleKit: respect theme paletteRichard Moe Gustavsen2025-12-051-0/+6
| | | | | | | | | | | | | | | | A Qt Quick Control will use StyleKitControl.text.color as its text color. But as it stood, it was not initialized to anything in the FallbackStyle. The result was that all controls got a black text color, regardless of what was set in the theme palette. It would also not respect any palette overrides done from the app. This patch will make sure that we, by default, bind text.color for the various control types to the matching color in the Qt Quick Control's palette. This color will, unless overriden by the app, be initialized to the color set by the theme. Change-Id: I6d4f67c81c57c9a30940a720816fa4ed2675b8bd Reviewed-by: Doris Verria <doris.verria@qt.io>
* StyleKit: add spacing to TooBar.qmlRichard Moe Gustavsen2025-12-051-0/+1
| | | | | | | | | | | | The ToolBar missed a binding to spacing. A ToolBar doesn't actually layout its items, the application is responsible for that. Still, it might want to query the spacing set from the style for doing the layout. Change-Id: I1613ba519e8edaeb58fe2b4cc6f7e5599dd02dff Reviewed-by: Doris Verria <doris.verria@qt.io>
* StyleKit: Implement ScrollView, ScrollBar and ScrollIndicatorRichard Moe Gustavsen2025-12-048-0/+210
| | | | | | | | | | This patch will implement support for styling ScrollBar and ScrollIndicator. It also includes ScrollView, since otherwise, if we inherited the one from the Basic style, it would also use the ScrollBars from the Basic style. Change-Id: I8163824aec61ce3c84303b6add3fdb1b7701532e Reviewed-by: Doris Verria <doris.verria@qt.io>
* StyleKit: implement ProgressBarRichard Moe Gustavsen2025-12-047-1/+120
| | | | | | | | This patch will implement support for styling ProgressBar. Change-Id: Ic6d48bbb61b068ff967289736236f2d21992dc0a Reviewed-by: Doris Verria <doris.verria@qt.io>
* StyleKit: implement TabBar and TabButtonRichard Moe Gustavsen2025-12-048-4/+143
| | | | | | | | This patch will implement support for styling TabBar and TabButton. Change-Id: I31658cf6cb923a06efa0cc4b02275a26c1968577 Reviewed-by: Doris Verria <doris.verria@qt.io>
* StyleKit: only store the nested states that are actually usedRichard Moe Gustavsen2025-12-043-100/+85
| | | | | | | | | | | | | | | | | | | | | | | It's wasteful to set off pointer space for all the possible states that can be nested. Usually a state will not use nested states at all. E.g the assignment 'button.pressed.spacing' would cause the 'pressed' state to also set off space for all the states that can be nested inside it, even if they are never used. In addition, the current implementation would, by accident, lazy create all the nested states while traversing up the parent chain of states. And as it turns out, by just storing the nested state flag inside the state, we don't need to do any traveral at all. This patch will make sure that we only allocate space for nested states if we encounter that at least one of them are being used, and store the nested state to avoid unnecessary traversal. Change-Id: Ied87f0c6b04057cb4c9f3e31f275a2d4b87c3efb Reviewed-by: Doris Verria <doris.verria@qt.io>
* StyleKit: Add TextArea controlDoris Verria2025-12-044-0/+79
| | | | | Change-Id: Ie23d3dfc1a93d052e9a19c9151c5ede4afee5ea9 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* StyleKit: Add padding properties to textDoris Verria2025-12-0412-10/+131
| | | | | Change-Id: I8a7fc86482e2083a24d1e7159737fd0ababc8e0b Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* StyleKit: Add GroupBox controlDoris Verria2025-12-048-1/+79
| | | | | Change-Id: I0177d20c381d83d2a816199a89b6fc9150fa4766 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* StyleKit: Add Label controlDoris Verria2025-12-048-2/+58
| | | | | Change-Id: I3594798dfb475118cad046948ccc4fe180bbd9a3 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQStyleKitFont: Drop extra "font" from property namesDoris Verria2025-12-043-147/+147
| | | | | | | | It's redundant as the class name is QQStyleKitPropertyFont. Also this makes it consistent with the palette API. Change-Id: Ic334c1febb1cdfb5cb09f898cb2f27ecb06c1c1f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* StyleKit: improve property id calculationRichard Moe Gustavsen2025-12-0314-315/+299
| | | | | | | | | | | | | | | | | | | | | | | | | A style property in StyleKit typically looks like this: 'indicator.foreground.border.color'. In this example, the property name is 'color', and its group path is 'indicator.foreground.border'. The styling engine assigns a unique ID to each property—based on both its group path and its name—so its value can be stored efficiently in a QMap. Previously, the engine recalculated this ID on every property read by traversing the group path from color back to indicator. This resulted in a large amount of repeated work, especially during state changes or theme changes, when many properties are read at once. This patch refactors that logic so the group ID is computed once, when each group is created. In the example above, the groups indicator, foreground, and border each receive a unique group ID at construction time. From that point onward, computing a property’s ID simply combines the cached group ID with the property’s local ID—no group path traversal required. Change-Id: Id07a0cb477038420a55c7850ea09db7f7b4d9978 Reviewed-by: Doris Verria <doris.verria@qt.io>
* StyleKit: implement ToolBar and ToolButtonRichard Moe Gustavsen2025-12-039-1/+116
| | | | | | | | This patch will implement support for styling ToolBar and ToolButton. Change-Id: Ie8cbda5a1ee361e8f2ee1a78ec5634e52811e0cd Reviewed-by: Doris Verria <doris.verria@qt.io>
* Add font override properties to "text" propertyDoris Verria2025-12-014-2/+78
| | | | | | | | | This allows to override certain font properties per control/state. So then the final font propagation logic becomes: Fallback Style -> Style -> Theme -> Control -> State Change-Id: Ifb451b156b0e4de7734ac7b31a002cd3fcb78dd0 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* StyleKit: Add style and theme fontsDoris Verria2025-12-0119-254/+312
| | | | | | | | | | | | | | | | | Add a fonts property to the style that allows you to set fonts per control, similarily to what we do in QQuickTheme. The fonts are propagated from the style to the theme, and from the fallback style to the style. That means that if a font is not set for a theme or style, it will be resolved against its fallback font. Since both the QQStyleKitTheme and QQStyleKitStyle should have a fonts property, introduce a common base class: QQStyleKitThemeProperties that contains the fonts property. Later, the palettes can be moved there as well. Also add a font property to the QQStyleKitReader that is suposed to return the font for the current control being read. Change-Id: I116c1ab9bc426570756476ee409513587c475a0d Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQStyleKitControl: add support for Instance VariationsRichard Moe Gustavsen2025-11-2827-165/+338
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch will add support for Instance Variations. Instance Variations allows you to define one or more style variations in a StyleKit style that can be activated from the application using an attached 'StyleKitControl.variations' object. Instance Variations will affects all descendant StyleKitReaders of the item that contains the attached object. For example, if you set "StyleKitControl.variations: ['mini']" on a GroupBox, all controls inside that GroupBox will be affected with the variation named "mini" in the style (if any). Inside a variation, you specify which controls should receive alternative styling when the variation is applied. Any properties defined in a Variation override those set in the Style or Theme. In order to support Instance Variations, this patch will also refactor how we implement Type Variations, which are variations that applies to _all_ controls of a specific type, rather than to individual instances. Change-Id: I6486979281997e69b65da0ed4866b264c91c592f Reviewed-by: Doris Verria <doris.verria@qt.io>
* StyleKit: add StyleKit to labsRichard Moe Gustavsen2025-11-2765-0/+8799
This patch introduces a new styling API for Controls called StyleKit. StyleKit provides a higher-level, key–value–based approach to styling applications, serving as an alternative to working directly with the lower-level Templates API. The primary goal of StyleKit is to offer a unified API for styling both Controls and Widgets. The current Templates-based approach relies heavily on JavaScript, which makes it unsuitable for use with Widgets. This initial version supports Controls only; support for Widgets will be added in a future update. StyleKit is designed to make it easier for designers and UI developers to: - Focus on visual styling rather than Template logic (such as geometry, delegate positioning, and handle placement). - Allow style properties to propagate, enabling you to factor out common styling into shared control types and override only what differs in the more specific control types. - Style controls independently in each of their states, without needing nested ternary expressions to check state. - Define and apply multiple themes with minimal effort. - Provide different style variations depending on context. For example, styling a Switch differently when it appears inside a ToolBar. [ChangeLog][Qt labs] Introduced new QML module 'StyleKit'. StyleKit provides a flexible styling framework for Qt Quick Controls, enabling developers to define reusable styles and themes using a simple key-value property format. Change-Id: Iae25324486aea7a7b9b2ce52135327ec7e9b6f59 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>