Merge lp:~zsombi/ubuntu-ui-toolkit/07-theming-tutorial into lp:ubuntu-ui-toolkit/staging
- 07-theming-tutorial
- Merge into staging
Status: | Merged |
---|---|
Approved by: | Zoltan Balogh |
Approved revision: | 1489 |
Merged at revision: | 1483 |
Proposed branch: | lp:~zsombi/ubuntu-ui-toolkit/07-theming-tutorial |
Merge into: | lp:ubuntu-ui-toolkit/staging |
Prerequisite: | lp:~zsombi/ubuntu-ui-toolkit/06-one-styleditem |
Diff against target: |
766 lines (+502/-57) 12 files modified
documentation/overview.qdoc (+8/-0) documentation/ubuntu-theming.qdoc (+438/-0) documentation/ubuntu-ui-toolkit-common.qdocconf (+4/-1) examples/customtheme/customtheme.pro (+18/-0) examples/customtheme/main.qml (+12/-41) examples/customtheme/theme/Palette.qml (+5/-3) examples/examples.pro (+2/-1) modules/Ubuntu/Components/Styles/PullToRefreshStyle.qml (+2/-1) modules/Ubuntu/Components/Themes/Palette.qml (+2/-2) modules/Ubuntu/Components/Themes/PaletteValues.qml (+2/-2) modules/Ubuntu/Components/Themes/SuruDark/MainViewStyle.qml (+3/-2) modules/Ubuntu/Components/Themes/SuruDark/Palette.qml (+6/-4) |
To merge this branch: | bzr merge lp:~zsombi/ubuntu-ui-toolkit/07-theming-tutorial |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Zoltan Balogh | Approve | ||
Review via email: mp+256144@code.launchpad.net |
Commit message
Theming tutorial
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
- 1486. By Zsombor Egri
-
some words reformulated to be more understandable
- 1487. By Zsombor Egri
-
prereq sync
- 1488. By Zsombor Egri
-
revert unwanted change
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1488
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Zoltan Balogh (bzoltan) wrote : | # |
See inline comments. Otherwise OK
- 1489. By Zsombor Egri
-
typos fixed
Zoltan Balogh (bzoltan) wrote : | # |
Ok, the docs look good too
Tim Peeters (tpeeters) wrote : | # |
"Some components have fixed style API the component relies on, and yet some others do not have any restriction on hwat the style contains or does"
hwat
Tim Peeters (tpeeters) wrote : | # |
in Ubuntu.
*ans
Tim Peeters (tpeeters) wrote : | # |
No need to fix the typos above, I will just fix them in the branch as I encounter them and propose an MR.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1489
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === added file 'documentation/images/surudark-theme.png' |
2 | Binary files documentation/images/surudark-theme.png 1970-01-01 00:00:00 +0000 and documentation/images/surudark-theme.png 2015-04-17 10:18:01 +0000 differ |
3 | === modified file 'documentation/overview.qdoc' |
4 | --- documentation/overview.qdoc 2015-03-04 09:09:39 +0000 |
5 | +++ documentation/overview.qdoc 2015-04-17 10:18:01 +0000 |
6 | @@ -21,6 +21,7 @@ |
7 | \part General Topics |
8 | \list |
9 | \li \l{ubuntu-whatsnew.html}{What's new in version 1.2?} |
10 | + \li \l{ubuntu-theming.html}{Styling} components |
11 | \li \l{ubuntu-layouts.html}{Layouts} describes a flexible layouting engine |
12 | to ease the development of responsive user interfaces. |
13 | \li \l {Resolution Independence} describes the facilities that should be |
14 | @@ -84,6 +85,13 @@ |
15 | \endcode |
16 | \annotatedlist theming |
17 | |
18 | + \part Theme module |
19 | + Available through: |
20 | + \code |
21 | + import Ubuntu.Components.Themes 1.0 |
22 | + \endcode |
23 | + \annotatedlist theme-module |
24 | + |
25 | \part Style API |
26 | The Style API defines the interface components use to style the visuals. |
27 | Themes must make sure that these interfaces are all implemented. |
28 | |
29 | === added file 'documentation/ubuntu-theming.qdoc' |
30 | --- documentation/ubuntu-theming.qdoc 1970-01-01 00:00:00 +0000 |
31 | +++ documentation/ubuntu-theming.qdoc 2015-04-17 10:18:01 +0000 |
32 | @@ -0,0 +1,438 @@ |
33 | +/* |
34 | + * Copyright 2015 Canonical Ltd. |
35 | + * |
36 | + * This program is free software; you can redistribute it and/or modify |
37 | + * it under the terms of the GNU Lesser General Public License as published by |
38 | + * the Free Software Foundation; version 3. |
39 | + * |
40 | + * This program is distributed in the hope that it will be useful, |
41 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
42 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
43 | + * GNU Lesser General Public License for more details. |
44 | + * |
45 | + * You should have received a copy of the GNU Lesser General Public License |
46 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
47 | + */ |
48 | + |
49 | +/*! |
50 | + * \page ubuntu-theming.html |
51 | + * \title Styling - Introduction |
52 | + * \nextpage Component styles, Style API |
53 | + * |
54 | + * The style defines the visuals, the implicit size of the component and may provide |
55 | + * additional logic for a given component. Some components have fixed style API the |
56 | + * component relies on, and yet some others do not have any restriction on hwat the |
57 | + * style contains or does. Components relying on a well defined API provide these |
58 | + * interfaces through Ubuntu.Components.Styles module, and styles must implement these |
59 | + * interfaces. |
60 | + * |
61 | + * The implicit size of a component is driven by the style as well, but it is not |
62 | + * mandatory for a style to provide those values, and components can override these |
63 | + * values at any time. However each style component is anchor filled to the styled |
64 | + * component and positioned to be under child components declared within the component |
65 | + * itself. |
66 | + * |
67 | + * Styles can be declared as Components (like delegates), in a separate document |
68 | + * loaded dynamically using a Loader or Qt.createComponent(), or can be grouped |
69 | + * in themes. When declared in themes, with some exceptions, each component's style |
70 | + * document name is compound of the component name having the \e Style word as postfix, |
71 | + * followed by the typical QML file name extension. In this way the Button component's |
72 | + * style is ButtonStyle. In addition to styles, themes can also provide custom palette |
73 | + * values. There are two themes in Ubuntu, Ambiance and SuruDark themes, Ambiance |
74 | + * being the default theme. Both themes are declared in separate modules, in \c |
75 | + * Ubuntu.Components.Themes.Ambiance ans well as \c Ubuntu.Components.Themes.SuruDark. |
76 | + * Application should define the theme name using this dotted name format. |
77 | + * |
78 | + * Applications can decide which theme they want to use or they can provide their |
79 | + * own themes. Also, applications can use multiple themes or set custom palette values. |
80 | + * |
81 | + * \qml |
82 | + * import QtQuick 2.4 |
83 | + * import Ubuntu.Components 1.3 |
84 | + * |
85 | + * MainView { |
86 | + * width: units,gu(40) |
87 | + * height: units.gu(71) |
88 | + * |
89 | + * theme.name: "Ubuntu.Components.Themes.SuruDark" |
90 | + * } |
91 | + * \endqml |
92 | + */ |
93 | + |
94 | +/*! |
95 | + * \page ubuntu-theming-styles.html |
96 | + * \title Component styles, Style API |
97 | + * \nextpage Themes, theme types, theme structure |
98 | + * |
99 | + * \section2 Naming conventions |
100 | + * With few exception, each toolkit component is having StyledItem as its base |
101 | + * component. The component is aimed to be the base component for all styled |
102 | + * elements in the toolkit. Modules providing additional components to UI Toolkit |
103 | + * can also use this component as base, especially if they want to provide styling |
104 | + * capabilities. |
105 | + * |
106 | + * As mentioned, each styled component is having a style pair in a theme which is |
107 | + * implemented in a document named using the component name adding the \e Style word. |
108 | + * The \l {Button}'s style is implemented by \c ButtonStyle.qml document in the theme, and |
109 | + * \l Button is loading this style from the theme: |
110 | + * \qml |
111 | + * import QtQuick 2.4 |
112 | + * import Ubuntu.Components 1.3 |
113 | + * |
114 | + * AbstractButton { |
115 | + * id: button |
116 | + * // [...] |
117 | + * style: theme.createStyleComponent("ButtonStyle.qml", button) |
118 | + * } |
119 | + * \endqml |
120 | + * Developers can override the style in two ways, depending on how they want to style |
121 | + * the component: |
122 | + * \list |
123 | + * \li 1. by overriding the style using an other style component from the theme, or |
124 | + * \li 2. by overriding the style with a custom style component. |
125 | + * \endlist |
126 | + * But let's see first how the styles are implemented. |
127 | + * |
128 | + * \section2 Creating styles |
129 | + * As mentioned before, styles are not restricted to only provide visuals to a component or |
130 | + * set of components, but can have also logic which drives the component functionality. |
131 | + * These kind of styles must implement the given component's style API, listed in |
132 | + * \c Ubuntu.Components.Styles module. |
133 | + * |
134 | + * A good example of such a style is the ListItemStyle. The ListItem drives the style |
135 | + * animation through the \l ListItemStyle::animatePanels property, value being false when |
136 | + * the style is loaded during component creation, i.e. when the component requires some |
137 | + * visuals to be present at creation time. Also, ListItem informs the style when to |
138 | + * execute leading or trailing panel \l {ListItemStyle::rebound}{rebound}s and provides |
139 | + * the style the ability to overrule the \l {ListItemStyle::swipeEvent}{swipe} coordinates |
140 | + * calculated by the ListItem. On the other hand, the style must inform the component |
141 | + * about the position of the \l {ListItemStyle::dragPanel}{drag panel} so dragging |
142 | + * (reordering of list items in a ListView) hot spot can be detected. A style implementation |
143 | + * must use the API provided by ListItemStyle, otherwise ListItem will fail to function |
144 | + * properly. |
145 | + * |
146 | + * Other styles are requested to provide additional \e content elements, which are then |
147 | + * positioned by the styled component separately from the main visuals given by the style. |
148 | + * A typical example of such a style API is the PullToRefresh component's style: |
149 | + * \snippet Styles/PullToRefreshStyle.qml 0 |
150 | + * The default style implementation can be found under Ubuntu.Components.Themes.Ambiance |
151 | + * theme \l {http://bazaar.launchpad.net/~ubuntu-sdk-team/ubuntu-ui-toolkit/trunk/view/head:/modules/Ubuntu/Components/Themes/Ambiance/PullToRefreshStyle.qml} |
152 | + * {PullToRefreshStyle.qml}. |
153 | + * |
154 | + * Beside these, component styles may provide default values for colors, fonts, widths, |
155 | + * margins, thicknesses. |
156 | + * |
157 | + * Each style component has a \c styledItem context property defined by the StyledItem, |
158 | + * which points to the StyledItem instance that uses the style. Style implementations can |
159 | + * access the actual styled item through this property. |
160 | + * |
161 | + * \section2 Overriding the default component style |
162 | + * |
163 | + * \section3 Override with a different style from the theme |
164 | + * Returning back to the ways to override a component's style, overriding by using a different |
165 | + * style from the theme can simply be done by calling the theme's \l{Theme::createStyleComponent} |
166 | + * {createStyleComponent()} function with the alternative style document name as follows: |
167 | + * \qml |
168 | + * Button { |
169 | + * id: button |
170 | + * style: theme.createStyleComponent("SquaryButton.qml", button) |
171 | + * } |
172 | + * \endqml |
173 | + * \note This assumes that the \c SquaryButton.qml document is present in the theme. |
174 | + * This type of component styling makes sure the style will always have theme specific implementation |
175 | + * or coloring, however it also requires the style document to be present in all the themes |
176 | + * used by the application. |
177 | + * |
178 | + * \section3 Override with a custom component |
179 | + * The other way is to override the style with a local component not present in any theme. |
180 | + * The style component can be in-source (Component) or declared in a separate document, |
181 | + * loaded dynamically with Loader or Qt.createComponent(). This kind of override will make |
182 | + * sure the component will use the custom style no matter of the theme used. These styles |
183 | + * however can still use the theme palette to be in sync with the theme coloring. |
184 | + * \qml |
185 | + * Button { |
186 | + * id: button |
187 | + * style: Rectangle { |
188 | + * implicitWidth: units.gu(12) |
189 | + * implicitHeight: units.gu(5) |
190 | + * color: styledItem.color |
191 | + * border { |
192 | + * width: units.dp(1) |
193 | + * color: styledItem.strokeColor |
194 | + * } |
195 | + * Label { |
196 | + * text: styledItem.text |
197 | + * font: styledItem.font |
198 | + * } |
199 | + * } |
200 | + * } |
201 | + * \endqml |
202 | + */ |
203 | + |
204 | +/*! |
205 | + * \page ubuntu-theming-themes.html |
206 | + * \title Themes, theme types, theme structure |
207 | + * \nextpage Sub-theming |
208 | + * |
209 | + * A theme is a collection of style implementations. The style component names are |
210 | + * typically built using the component name and the Style word, exceptions being |
211 | + * documented per component. |
212 | + * |
213 | + * In addition to the styles the theme can provide palette values used by the style |
214 | + * and components. The palette values are defined in \c Palette.qml file, which must |
215 | + * either be derived from \l Palette component or from a parent theme's Palette. |
216 | + * |
217 | + * There are two types of themes, shared themes and application themes. These themes |
218 | + * do not differ in structure but in the way they are exposed. Shared themes are |
219 | + * located either under \b QML2_IMPORT_PATH or \b XDG_DATA_DIR. Application themes |
220 | + * are located under the application's private folder, therefore they are typically |
221 | + * serving the application styling needs, and cannot be shared. Shared themes are also |
222 | + * presented as QML extension modules, giving the possibility for application themes |
223 | + * to extend them. |
224 | + * |
225 | + * \note Yet there is no possibility to install shared themes into the system through |
226 | + * app store, only by providing them as part of the system image. |
227 | + * |
228 | + * The system provides two shared themes, \b Ambiance and \b SuruDark, the latest derived |
229 | + * from Ambiance theme. Both themes can be used as base theme in application themes, |
230 | + * by importing the modules defining them. If you decide to create a shared theme |
231 | + * that can be used also as base for custom or application themes, it is recommended |
232 | + * to do the same approach as the system themes do. |
233 | + * |
234 | + * \section2 Theme structure |
235 | + * \image surudark-theme.png |
236 | + * The theme structure is similar to a QML extension module structure, and this applies |
237 | + * to both shared and application themes. Contains component style documents, palette |
238 | + * description document, \c qmldir file and a special file called \c parent_theme. All |
239 | + * these files are optional in a theme depending on context. |
240 | + * |
241 | + * \c parent_theme is a special file which defines the theme the current one is derifed from. |
242 | + * The parent theme must be a shared theme and its name must be specified in dotted format. |
243 | + * For example SuruDark theme is located under \c{$QML2_IMPORT_PATH/Ubuntu/Components/Themes/SuruDark} |
244 | + * folder. This means that the theme name is identified by the \b Ubuntu.Components.Themes.SuruDark |
245 | + * dotted format. |
246 | + * |
247 | + * In addition to the files mentioned, themes can provide components supporting the styling |
248 | + * (i.e. components providing common visuals in the style implementations). Style implementations |
249 | + * can also provide additional APIs alongside the standard style API. These additional APIs are |
250 | + * typically there to configure the style itself, or to turn on/off features provided by styles |
251 | + * in derived themes. |
252 | + * |
253 | + * \section3 Standalone theme |
254 | + * A standalone theme is a theme which defines all style documents and theme palette, |
255 | + * and it is not derived from any theme. The only standalone theme UI Toolkit provides is |
256 | + * the Ambiance theme. Both shared and application themes can be standalone themes, however |
257 | + * Applications should make sure they implement all the styles used by the toolkit components |
258 | + * used in the application. \c qmldir file presence is mandatory only if the theme is |
259 | + * shared. |
260 | + * |
261 | + * \section3 Derived themes |
262 | + * As the name suggests derived themes are themes which use other themes (standalone or derived ones) |
263 | + * as base theme. These themes must have the \c parent_theme file to be present and to contain the |
264 | + * name of the theme they are derived from. These themes do not have to provide palette configuration |
265 | + * as long as they use the derived theme's palette values. |
266 | + * |
267 | + * Derived themes should only list those style components which overrule the derived style or |
268 | + * extend the derived style. The only requirement is to use the same document name as the paren theme |
269 | + * is having. |
270 | + * |
271 | + * Let's take SuruDark theme as en example. The theme is derived from Ambiance theme, and only |
272 | + * extends few style components. When theming engine loads the style components, it looks |
273 | + * after the styles starting from the current theme. If the style is not found there, it |
274 | + * tries to look after the style in the parent themes until it finds one. |
275 | + * |
276 | + * The extended (or even overridden) style component documents must follow the naming |
277 | + * convention, and must have the names implied by the components styled. |
278 | + * |
279 | + * SuruDark theme overrides the Ambiance theme's MainViewStyle, therefore declares the |
280 | + * MainViewStyle.qml document, with the following content: |
281 | + * \snippet Themes/SuruDark/MainViewStyle.qml 0 |
282 | + * |
283 | + * The style imports the Ambiance theme module, and extends the Ambiance MainViewStyle |
284 | + * component. The same is done in the other style components. However, Palette defines |
285 | + * own values, and does not resuse Ambiance palette values. |
286 | + * \snippet Themes/SuruDark/Palette.qml 0 |
287 | + * |
288 | + * The same is done with TabBarStyle and OptionSelectorStyle components. |
289 | + * |
290 | + * \note If a theme derived from SuruDark wants to override style components not present |
291 | + * in SuruDark, they must import the SuruDark's parent theme in the style component. |
292 | + * As example, if FancyTheme would want to override the SwitchStyle, it would need to |
293 | + * import Ambiance module in the component as SuruDark doesn't have that style component |
294 | + * defined. |
295 | + * \qml |
296 | + * import QtQuick 2.4 |
297 | + * import Ubuntu.Components 1.3 |
298 | + * import Ubuntu.Components.Themes.Ambiance 1.2 as Ambiance |
299 | + * Ambiance.SwitchStyle { |
300 | + * // [...] |
301 | + * } |
302 | + * \endqml |
303 | + * |
304 | + * \section2 Application themes |
305 | + * Application themes can also be standalone or derived themes. Usually applications |
306 | + * need slight differences on certain component styles, colors. These can be configured |
307 | + * in multiple ways, depending on the needs of the application. Applications can decide |
308 | + * to have their own theme, and override the palette value in the theme, or to use the |
309 | + * system themes and override few color values from the theme palette. |
310 | + * |
311 | + * Let's take an example of an application which changes some palette values of SuruDark |
312 | + * theme. |
313 | + * |
314 | + * First, the application has to define the theme, preferably in a separate folder (e.g. |
315 | + * theme). The folder should contain a \c parent_theme file with the content |
316 | + * \code |
317 | + * Ubuntu.Components.Themes.SuruDark |
318 | + * \endcode |
319 | + * This will make sure theme engine will look after the style components that are not |
320 | + * defined by the application theme inside the parent theme. Remember, the parent themes |
321 | + * can have parent themes (in SuruDark case it is) in which case the style components |
322 | + * will be looked up in all these themes. |
323 | + * |
324 | + * As next, the application can define the palette. |
325 | + * \snippet customtheme/theme/Palette.qml 0 |
326 | + * Note that the palette uses the SuruDark palette as base, and changes few colors from it. |
327 | + * |
328 | + * The application can use its own theme in the following way: |
329 | + * \snippet customtheme/main.qml 0 |
330 | + */ |
331 | + |
332 | +/*! |
333 | + * \page ubuntu-theming-subtheming.html |
334 | + * \title Sub-theming |
335 | + * |
336 | + * There can be situations when an application has a design which combines styles from different |
337 | + * themes, which would not be possible or would be hard to be combined in a theme. In these |
338 | + * situations developers can use different themes in the components and its child components. |
339 | + * This is called sub-theming, which was introduced in Ubuntu.Components v1.3. |
340 | + * The only thing the application has to do is to define a ThemeSettings instance for the |
341 | + * component which is desired to use a different theme. |
342 | + * \qml |
343 | + * import QtQuick 2.4 |
344 | + * import Ubuntu.Componenst 1.3 |
345 | + * MainView { |
346 | + * width: units.gu(40) |
347 | + * height: units.gu(71) |
348 | + * |
349 | + * applicationName: "subthemed" |
350 | + * |
351 | + * // make sure the main theme is Ambiance |
352 | + * theme.name: "Ubuntu.Components.Themes.Ambiance" |
353 | + * |
354 | + * Component { |
355 | + * id: dialogComponent |
356 | + * Dialog { |
357 | + * id: dialog |
358 | + * title: "Input dialog" |
359 | + * // the dialog and its children will use SuruDark |
360 | + * theme: ThemeSettings { |
361 | + * name: "Ubuntu.Components.Themes.SuruDark" |
362 | + * } |
363 | + * TextField { |
364 | + * placeholderText: "enter text" |
365 | + * } |
366 | + * Button { |
367 | + * text: "Close" |
368 | + * onClicked: PopupUtils.close(dialog) |
369 | + * } |
370 | + * } |
371 | + * } |
372 | + * |
373 | + * Button { |
374 | + * text: "Open dialog" |
375 | + * onClicked: PopupUtils.open(dialogComponent) |
376 | + * } |
377 | + * } |
378 | + * \endqml |
379 | + * |
380 | + * Another use-case is when a different palette set is needed in the application. |
381 | + * One way to achieve that is to define a custom theme for the application, however |
382 | + * that theme must be derived from one particular theme, so the application will be |
383 | + * nailed to one given theme. If we want to have the same palette values to be used |
384 | + * no matter of the component shape, we can override the palette values we want to |
385 | + * change, by setting the theme palette to a \l Palette instance where only the desired |
386 | + * palette values are changed. This can be combined with sub-theming, which will make |
387 | + * sure that the palette values are applied only on a certain component sub-tree. |
388 | + * |
389 | + * The following example makes sure the Dialog and is child components will use a given |
390 | + * palette value: |
391 | + * \qml |
392 | + * import QtQuick 2.4 |
393 | + * import Ubuntu.Components 1.3 |
394 | + * import Ubuntu.Components.Themes 1.0 |
395 | + * |
396 | + * MainView { |
397 | + * width: units.gu(40) |
398 | + * height: units.gu(71) |
399 | + * |
400 | + * applicationName: "subthemed" |
401 | + * |
402 | + * Component { |
403 | + * id: dialogComponent |
404 | + * Dialog { |
405 | + * id: dialog |
406 | + * title: "Input dialog" |
407 | + * // make sure the dialog and its children will use the same |
408 | + * // theme as the rest of the application |
409 | + * theme: ThemeSettings { |
410 | + * name: parentTheme.name |
411 | + * palette: Palette { |
412 | + * id: config |
413 | + * normal { |
414 | + * foregroundText: UbuntuColors.blue |
415 | + * overlayText: "#BAFEDC" |
416 | + * } |
417 | + * selected { |
418 | + * fieldText: "brown" |
419 | + * foregroundText: Qt.rgba(0, 0, 1, 1) |
420 | + * overlayText: config.normal.overlayText |
421 | + * foreground: UbuntuColors.green |
422 | + * } |
423 | + * } |
424 | + * } |
425 | + * TextField { |
426 | + * placeholderText: "enter text" |
427 | + * } |
428 | + * Button { |
429 | + * text: "Close" |
430 | + * onClicked: PopupUtils.close(dialog) |
431 | + * } |
432 | + * } |
433 | + * } |
434 | + * |
435 | + * Column { |
436 | + * spacing: units.gu(1) |
437 | + * Button { |
438 | + * text: "Set Ambiance theme" |
439 | + * onClicked: theme.name = "Ubuntu.Components.Themes.Ambiance" |
440 | + * } |
441 | + * Button { |
442 | + * text: "Set SuruDark theme" |
443 | + * onClicked: theme.name = "Ubuntu.Components.Themes.SuruDark" |
444 | + * } |
445 | + * Button { |
446 | + * text: "Open dialog" |
447 | + * onClicked: PopupUtils.open(dialogComponent) |
448 | + * } |
449 | + * } |
450 | + * } |
451 | + * \endqml |
452 | + * \note Note the way the theme is changed! The first two buttons actually change the |
453 | + * name of the theme they inherit, which is the application's theme. This means that |
454 | + * the theme will actually be changed on the entire application, not only on the Button |
455 | + * itself. |
456 | + * |
457 | + * The Dialog uses the \l {ThemeSettings::parentTheme}{parentTheme} property to load |
458 | + * the same theme as its parent styled item is using, meaning that the Dialog will |
459 | + * also load the same theme as the application does, and will change the loaded palette |
460 | + * values with the ones defined in the \c config Palette instance, namely the \c |
461 | + * foregroundText and \c overlayText of \c normal, as well as \c fieldText, \c foregroundText, |
462 | + * \c overlayText and \c foreground on \c selected groups. |
463 | + * |
464 | + * \section1 That's it |
465 | + * By now you should have learned what the styling means, what are the themes, what |
466 | + * kind of themes toolkit has, how can you create shared or application themes, where should |
467 | + * you store them, how to extend styles, how to use multiple themes in an application |
468 | + * and how to set custom palette values runtime. If you have questions or need guidance, |
469 | + * you can contact us on \b{#ubuntu-app-devel} IRC channel on freenode. |
470 | + */ |
471 | |
472 | === modified file 'documentation/ubuntu-ui-toolkit-common.qdocconf' |
473 | --- documentation/ubuntu-ui-toolkit-common.qdocconf 2015-03-03 13:47:48 +0000 |
474 | +++ documentation/ubuntu-ui-toolkit-common.qdocconf 2015-04-17 10:18:01 +0000 |
475 | @@ -11,7 +11,10 @@ |
476 | sourcedirs += ../modules/Ubuntu/Test |
477 | headerdirs += ../modules/Ubuntu/Test/plugin |
478 | exampledirs += snippets |
479 | -excludedirs = ../modules/Ubuntu/Components/Themes |
480 | +exampledirs += ../examples |
481 | +exampledirs += ../modules/Ubuntu/Components |
482 | +excludedirs += ../modules/Ubuntu/Components/Themes/Ambiance |
483 | +excludedirs += ../modules/Ubuntu/Components/Themes/SuruDark |
484 | imagedirs = images |
485 | sources.fileextensions = "*.qml *.qdoc *.cpp" |
486 | headers.fileextensions = "*.h" |
487 | |
488 | === added file 'examples/customtheme/customtheme.pro' |
489 | --- examples/customtheme/customtheme.pro 1970-01-01 00:00:00 +0000 |
490 | +++ examples/customtheme/customtheme.pro 2015-04-17 10:18:01 +0000 |
491 | @@ -0,0 +1,18 @@ |
492 | +TEMPLATE = aux |
493 | + |
494 | +filetypes = qml png svg js jpg qmlproject desktop |
495 | + |
496 | +OTHER_FILES = theme/parent_theme |
497 | + |
498 | +for(filetype, filetypes) { |
499 | + OTHER_FILES += *.$$filetype |
500 | + OTHER_FILES += theme/*.$$filetype |
501 | +} |
502 | + |
503 | +desktop_files.path = /usr/share/applications |
504 | +desktop_files.files = customtheme.desktop |
505 | + |
506 | +other_files.path = /usr/lib/ubuntu-ui-toolkit/examples/customtheme |
507 | +other_files.files = $$OTHER_FILES |
508 | + |
509 | +INSTALLS += other_files desktop_files |
510 | |
511 | === modified file 'examples/customtheme/main.qml' |
512 | --- examples/customtheme/main.qml 2015-03-03 13:47:48 +0000 |
513 | +++ examples/customtheme/main.qml 2015-04-17 10:18:01 +0000 |
514 | @@ -1,5 +1,5 @@ |
515 | /* |
516 | - * Copyright 2014 Canonical Ltd. |
517 | + * Copyright 2015 Canonical Ltd. |
518 | * |
519 | * This program is free software; you can redistribute it and/or modify |
520 | * it under the terms of the GNU Lesser General Public License as published by |
521 | @@ -13,32 +13,19 @@ |
522 | * You should have received a copy of the GNU Lesser General Public License |
523 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
524 | */ |
525 | - |
526 | -import QtQuick 2.0 |
527 | -import Ubuntu.Components 1.2 |
528 | - |
529 | -/*! |
530 | - \brief MainView with a Label and Button elements. |
531 | -*/ |
532 | +//![0] |
533 | +import QtQuick 2.4 |
534 | +import Ubuntu.Components 1.3 |
535 | |
536 | MainView { |
537 | id: mainView |
538 | - // objectName for functional testing purposes (autopilot-qt5) |
539 | objectName: "mainView" |
540 | - |
541 | - // Note! applicationName needs to match the "name" field of the click manifest |
542 | applicationName: "customtheme" |
543 | |
544 | - /* |
545 | - This property enables the application to change orientation |
546 | - when the device is rotated. The default is false. |
547 | - */ |
548 | - //automaticOrientation: true |
549 | - |
550 | width: units.gu(100) |
551 | height: units.gu(75) |
552 | |
553 | - Component.onCompleted: Theme.name = "theme" |
554 | + theme.name: "theme" |
555 | |
556 | Page { |
557 | title: i18n.tr("Theme sample") |
558 | @@ -51,31 +38,15 @@ |
559 | } |
560 | |
561 | Label { |
562 | - text: i18n.tr("Theme.name:") + " " + Theme.name |
563 | - } |
564 | - |
565 | - Button { |
566 | - width: parent.width |
567 | - text: i18n.tr("Light background") |
568 | - |
569 | - onClicked: { |
570 | - mainView.backgroundColor = "white"; |
571 | - } |
572 | - } |
573 | - Button { |
574 | - width: parent.width |
575 | - text: i18n.tr("Dark background") |
576 | - |
577 | - onClicked: { |
578 | - mainView.backgroundColor = "blue"; |
579 | - } |
580 | - } |
581 | + text: i18n.tr("Theme.name:") + " " + theme.name |
582 | + } |
583 | + |
584 | Button { |
585 | width: parent.width |
586 | text: i18n.tr("Set Ambiance theme") |
587 | |
588 | onClicked: { |
589 | - Theme.name = "Ubuntu.Components.Themes.Ambiance"; |
590 | + theme.name = "Ubuntu.Components.Themes.Ambiance"; |
591 | } |
592 | } |
593 | Button { |
594 | @@ -83,7 +54,7 @@ |
595 | text: i18n.tr("Set SuruDark theme") |
596 | |
597 | onClicked: { |
598 | - Theme.name = "Ubuntu.Components.Themes.SuruDark"; |
599 | + theme.name = "Ubuntu.Components.Themes.SuruDark"; |
600 | } |
601 | } |
602 | Button { |
603 | @@ -91,10 +62,10 @@ |
604 | text: i18n.tr("Application theme") |
605 | |
606 | onClicked: { |
607 | - Theme.name = "theme"; |
608 | + theme.name = "theme"; |
609 | } |
610 | } |
611 | } |
612 | } |
613 | } |
614 | - |
615 | +//![0] |
616 | |
617 | === modified file 'examples/customtheme/theme/Palette.qml' |
618 | --- examples/customtheme/theme/Palette.qml 2015-03-03 13:47:48 +0000 |
619 | +++ examples/customtheme/theme/Palette.qml 2015-04-17 10:18:01 +0000 |
620 | @@ -1,5 +1,5 @@ |
621 | /* |
622 | - * Copyright 2014 Canonical Ltd. |
623 | + * Copyright 2015 Canonical Ltd. |
624 | * |
625 | * This program is free software; you can redistribute it and/or modify |
626 | * it under the terms of the GNU Lesser General Public License as published by |
627 | @@ -14,11 +14,13 @@ |
628 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
629 | */ |
630 | |
631 | -import QtQuick 2.0 |
632 | -import Ubuntu.Components 1.2 |
633 | +//![0] |
634 | +import QtQuick 2.4 |
635 | +import Ubuntu.Components 1.3 |
636 | import Ubuntu.Components.Themes.SuruDark 1.1 as Suru |
637 | |
638 | Suru.Palette { |
639 | normal.background: "#A21E1C" |
640 | selected.backgroundText: "lightblue" |
641 | } |
642 | +//![0] |
643 | |
644 | === modified file 'examples/examples.pro' |
645 | --- examples/examples.pro 2013-09-12 06:14:08 +0000 |
646 | +++ examples/examples.pro 2015-04-17 10:18:01 +0000 |
647 | @@ -4,7 +4,8 @@ |
648 | ubuntu-ui-toolkit-gallery\ |
649 | locale \ |
650 | unit-converter \ |
651 | - calculator |
652 | + calculator \ |
653 | + customtheme |
654 | |
655 | |
656 | #examples = jokes unit-converter |
657 | |
658 | === modified file 'modules/Ubuntu/Components/Styles/PullToRefreshStyle.qml' |
659 | --- modules/Ubuntu/Components/Styles/PullToRefreshStyle.qml 2015-03-03 12:53:42 +0000 |
660 | +++ modules/Ubuntu/Components/Styles/PullToRefreshStyle.qml 2015-04-17 10:18:01 +0000 |
661 | @@ -24,7 +24,7 @@ |
662 | |
663 | The component defines the style API for the PullToRefresh component. |
664 | */ |
665 | - |
666 | +//![0] |
667 | Item { |
668 | /*! |
669 | The property holds the style provided default content component. The value |
670 | @@ -46,3 +46,4 @@ |
671 | */ |
672 | property bool releaseToRefresh: false |
673 | } |
674 | +//![0] |
675 | |
676 | === modified file 'modules/Ubuntu/Components/Themes/Palette.qml' |
677 | --- modules/Ubuntu/Components/Themes/Palette.qml 2015-04-09 12:03:24 +0000 |
678 | +++ modules/Ubuntu/Components/Themes/Palette.qml 2015-04-17 10:18:01 +0000 |
679 | @@ -19,8 +19,8 @@ |
680 | /*! |
681 | \qmltype Palette |
682 | \inqmlmodule Ubuntu.Components.Themes 1.0 |
683 | - \ingroup theming |
684 | - \brief Palette of colors from the theme that widgets use to draw themselves. |
685 | + \ingroup theme-module |
686 | + \brief Provides the palette of colors from the theme that widgets use to draw themselves. |
687 | |
688 | Palette provides access to colors defined by the current theme. The actual |
689 | color palette to use depends on the state of the widget being drawn. |
690 | |
691 | === modified file 'modules/Ubuntu/Components/Themes/PaletteValues.qml' |
692 | --- modules/Ubuntu/Components/Themes/PaletteValues.qml 2015-03-03 13:47:48 +0000 |
693 | +++ modules/Ubuntu/Components/Themes/PaletteValues.qml 2015-04-17 10:18:01 +0000 |
694 | @@ -18,8 +18,8 @@ |
695 | |
696 | /*! |
697 | \qmltype PaletteValues |
698 | - \inqmlmodule Ubuntu.Components.Themes 0.1 |
699 | - \ingroup theming |
700 | + \inqmlmodule Ubuntu.Components.Themes 1.0 |
701 | + \ingroup theme-module |
702 | \brief Color values used for a given widget state. |
703 | */ |
704 | QtObject { |
705 | |
706 | === modified file 'modules/Ubuntu/Components/Themes/SuruDark/MainViewStyle.qml' |
707 | --- modules/Ubuntu/Components/Themes/SuruDark/MainViewStyle.qml 2015-03-03 13:47:48 +0000 |
708 | +++ modules/Ubuntu/Components/Themes/SuruDark/MainViewStyle.qml 2015-04-17 10:18:01 +0000 |
709 | @@ -1,5 +1,5 @@ |
710 | /* |
711 | - * Copyright 2013 Canonical Ltd. |
712 | + * Copyright 2015 Canonical Ltd. |
713 | * |
714 | * This program is free software; you can redistribute it and/or modify |
715 | * it under the terms of the GNU Lesser General Public License as published by |
716 | @@ -13,10 +13,11 @@ |
717 | * You should have received a copy of the GNU Lesser General Public License |
718 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
719 | */ |
720 | - |
721 | +//![0] |
722 | import QtQuick 2.4 |
723 | import Ubuntu.Components.Themes.Ambiance 0.1 |
724 | |
725 | MainViewStyle { |
726 | backgroundSource: "" |
727 | } |
728 | +//![0] |
729 | |
730 | === modified file 'modules/Ubuntu/Components/Themes/SuruDark/Palette.qml' |
731 | --- modules/Ubuntu/Components/Themes/SuruDark/Palette.qml 2015-04-16 13:39:02 +0000 |
732 | +++ modules/Ubuntu/Components/Themes/SuruDark/Palette.qml 2015-04-17 10:18:01 +0000 |
733 | @@ -1,5 +1,5 @@ |
734 | /* |
735 | - * Copyright 2013 Canonical Ltd. |
736 | + * Copyright 2015 Canonical Ltd. |
737 | * |
738 | * This program is free software; you can redistribute it and/or modify |
739 | * it under the terms of the GNU Lesser General Public License as published by |
740 | @@ -14,9 +14,10 @@ |
741 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
742 | */ |
743 | |
744 | +//![0] |
745 | import QtQuick 2.4 |
746 | -import Ubuntu.Components 1.2 |
747 | -import Ubuntu.Components.Themes 0.1 |
748 | +import Ubuntu.Components 1.3 |
749 | +import Ubuntu.Components.Themes 1.0 |
750 | |
751 | Palette { |
752 | normal { |
753 | @@ -32,7 +33,7 @@ |
754 | fieldText: "#7F7F7F7F" |
755 | } |
756 | selected { |
757 | - background: "#88D6D6D6" // FIXME: not from design |
758 | + background: "#88D6D6D6" |
759 | backgroundText: "#FFFFFF" |
760 | selection: Qt.rgba(UbuntuColors.blue.r, UbuntuColors.blue.g, UbuntuColors.blue.b, 0.2) |
761 | foreground: UbuntuColors.orange |
762 | @@ -41,3 +42,4 @@ |
763 | fieldText: "#888888" |
764 | } |
765 | } |
766 | +//![0] |
FAILED: Continuous integration, rev:1485 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- ci/1672/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- vivid-touch/ 2243 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- vivid-amd64- ci/399 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- vivid-armhf- ci/402 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- vivid-armhf- ci/402/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- vivid-i386- ci/399 jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- runner- vivid-mako/ 1969 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 2241 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 2241/artifact/ work/output/ *zip*/output. zip s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 19648
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- sdk-team- ubuntu- ui-toolkit- staging- ci/1672/ rebuild
http://