Merge lp:~fboucault/ubuntu-ui-toolkit/simple_theming into lp:ubuntu-ui-toolkit

Proposed by Florian Boucault
Status: Merged
Approved by: Zsombor Egri
Approved revision: 596
Merged at revision: 572
Proposed branch: lp:~fboucault/ubuntu-ui-toolkit/simple_theming
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 11905 lines (+945/-8385)
168 files modified
CHANGES (+2/-0)
components.api (+12/-19)
debian/qtdeclarative5-ubuntu-ui-toolkit-plugin.install (+9/-1)
debian/ubuntu-ui-toolkit-theme.install (+1/-1)
examples/examples.pro (+1/-1)
examples/jokes/jokes.pro (+1/-1)
examples/locale/locale.pro (+1/-1)
examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.pro (+1/-1)
examples/unit-converter/unit-converter.pro (+1/-1)
export_modules_dir.sh (+1/-1)
modules/Ubuntu/Components/ActionItem.qml (+1/-1)
modules/Ubuntu/Components/ActivityIndicator.qml (+1/-7)
modules/Ubuntu/Components/AnimatedItem.qml (+1/-1)
modules/Ubuntu/Components/Button.qml (+2/-7)
modules/Ubuntu/Components/CheckBox.qml (+2/-10)
modules/Ubuntu/Components/Components.pro (+1/-1)
modules/Ubuntu/Components/Header.qml (+6/-7)
modules/Ubuntu/Components/Label.qml (+1/-11)
modules/Ubuntu/Components/MainView.qml (+3/-8)
modules/Ubuntu/Components/PageTreeNode.qml (+1/-1)
modules/Ubuntu/Components/Panel.qml (+0/-1)
modules/Ubuntu/Components/Popups/ActionSelectionPopover.qml (+0/-1)
modules/Ubuntu/Components/Popups/Dialog.qml (+16/-18)
modules/Ubuntu/Components/Popups/Pointer.qml (+6/-9)
modules/Ubuntu/Components/Popups/Popover.qml (+9/-12)
modules/Ubuntu/Components/Popups/PopupBase.qml (+2/-7)
modules/Ubuntu/Components/Popups/SheetBase.qml (+5/-19)
modules/Ubuntu/Components/Scrollbar.qml (+4/-10)
modules/Ubuntu/Components/Slider.qml (+10/-15)
modules/Ubuntu/Components/StyledItem.qml (+70/-0)
modules/Ubuntu/Components/Switch.qml (+2/-7)
modules/Ubuntu/Components/Tabs.qml (+6/-11)
modules/Ubuntu/Components/TextArea.qml (+13/-26)
modules/Ubuntu/Components/TextCursor.qml (+5/-3)
modules/Ubuntu/Components/TextField.qml (+13/-12)
modules/Ubuntu/Components/Themes/Ambiance/ActivityIndicatorStyle.qml (+3/-2)
modules/Ubuntu/Components/Themes/Ambiance/Ambiance.pro (+23/-0)
modules/Ubuntu/Components/Themes/Ambiance/ButtonStyle.qml (+7/-7)
modules/Ubuntu/Components/Themes/Ambiance/CheckBoxStyle.qml (+10/-6)
modules/Ubuntu/Components/Themes/Ambiance/DialogForegroundStyle.qml (+3/-2)
modules/Ubuntu/Components/Themes/Ambiance/HeaderStyle.qml (+22/-33)
modules/Ubuntu/Components/Themes/Ambiance/MainViewStyle.qml (+5/-5)
modules/Ubuntu/Components/Themes/Ambiance/PointerStyle.qml (+5/-1)
modules/Ubuntu/Components/Themes/Ambiance/PointerStyleShader.qml (+3/-3)
modules/Ubuntu/Components/Themes/Ambiance/PopoverForegroundStyle.qml (+2/-2)
modules/Ubuntu/Components/Themes/Ambiance/ScrollbarStyle.qml (+40/-40)
modules/Ubuntu/Components/Themes/Ambiance/SelectionCursorStyle.qml (+8/-7)
modules/Ubuntu/Components/Themes/Ambiance/SheetForegroundStyle.qml (+13/-13)
modules/Ubuntu/Components/Themes/Ambiance/SliderStyle.qml (+13/-11)
modules/Ubuntu/Components/Themes/Ambiance/SwitchStyle.qml (+25/-18)
modules/Ubuntu/Components/Themes/Ambiance/TabsStyle.qml (+30/-31)
modules/Ubuntu/Components/Themes/Ambiance/TextAreaStyle.qml (+16/-20)
modules/Ubuntu/Components/Themes/Ambiance/TextCursorStyle.qml (+8/-8)
modules/Ubuntu/Components/Themes/Ambiance/TextFieldStyle.qml (+20/-0)
modules/Ubuntu/Components/Themes/Ambiance/ToolbarButtonStyle.qml (+8/-6)
modules/Ubuntu/Components/Themes/Ambiance/ToolbarStyle.qml (+3/-4)
modules/Ubuntu/Components/Themes/Ambiance/TransparentButtonStyle.qml (+8/-8)
modules/Ubuntu/Components/Themes/Ambiance/qmldir (+21/-31)
modules/Ubuntu/Components/Themes/Themes.pro (+1/-25)
modules/Ubuntu/Components/Toolbar.qml (+4/-8)
modules/Ubuntu/Components/ToolbarActions.qml (+1/-1)
modules/Ubuntu/Components/ToolbarButton.qml (+2/-6)
modules/Ubuntu/Components/ToolbarItems.qml (+0/-5)
modules/Ubuntu/Components/overview.qdoc (+0/-2)
modules/Ubuntu/Components/plugin/itemstyleattached.cpp (+0/-715)
modules/Ubuntu/Components/plugin/itemstyleattached.h (+0/-76)
modules/Ubuntu/Components/plugin/itemstyleattached_p.h (+0/-75)
modules/Ubuntu/Components/plugin/plugin.cpp (+3/-7)
modules/Ubuntu/Components/plugin/plugin.pro (+4/-17)
modules/Ubuntu/Components/plugin/qmlthemeloader.cpp (+0/-777)
modules/Ubuntu/Components/plugin/qmlthemeloader_p.h (+0/-95)
modules/Ubuntu/Components/plugin/selector.cpp (+0/-339)
modules/Ubuntu/Components/plugin/selector_p.h (+0/-107)
modules/Ubuntu/Components/plugin/stylecache.cpp (+0/-318)
modules/Ubuntu/Components/plugin/stylecache_p.h (+0/-80)
modules/Ubuntu/Components/plugin/themeengine_p.h (+0/-95)
modules/Ubuntu/Components/plugin/themeloader_p.h (+0/-34)
modules/Ubuntu/Components/plugin/ucstyle.cpp (+0/-268)
modules/Ubuntu/Components/plugin/ucstyle.h (+0/-111)
modules/Ubuntu/Components/plugin/uctheme.cpp (+174/-318)
modules/Ubuntu/Components/plugin/uctheme.h (+34/-39)
modules/Ubuntu/Components/plugin/ucthemesettings.cpp (+53/-90)
modules/Ubuntu/Components/plugin/ucthemesettings.h (+19/-16)
modules/Ubuntu/Components/qmldir (+1/-0)
modules/Ubuntu/Components/scrollbarUtils.js (+2/-2)
modules/Ubuntu/Components/ubuntu-components-theming.qdoc (+0/-638)
tests/resources/base.qmltheme (+0/-21)
tests/resources/benchmark.qmltheme (+0/-324)
tests/resources/block.qmltheme (+0/-3)
tests/resources/components.qmltheme (+0/-6)
tests/resources/inheritance.qmltheme (+0/-30)
tests/resources/test.qmltheme (+0/-28)
tests/resources/theme-engine-test.qrc (+0/-6)
tests/resources/toolbar/panels.qml (+0/-1)
tests/resources/urlmacro.qmltheme (+0/-21)
tests/unit/README (+1/-1)
tests/unit/add_makecheck.pri (+1/-1)
tests/unit/runtest.sh (+1/-1)
tests/unit/tst_components/tst_scrollbar.qml (+0/-3)
tests/unit/tst_inversemousearea/tst_inversemouseareatest.cpp (+1/-18)
tests/unit/tst_performance/ButtonGrid.qml (+1/-1)
tests/unit/tst_performance/ButtonStyleGrid.qml (+4/-2)
tests/unit/tst_performance/ButtonsWithStyledGrid.qml (+0/-32)
tests/unit/tst_performance/CheckBoxGrid.qml (+1/-1)
tests/unit/tst_performance/CheckBoxStyleGrid.qml (+4/-2)
tests/unit/tst_performance/CustomTheme.qmltheme (+0/-5)
tests/unit/tst_performance/SliderGrid.qml (+1/-1)
tests/unit/tst_performance/SliderStyleGrid.qml (+6/-4)
tests/unit/tst_performance/SwitchGrid.qml (+1/-1)
tests/unit/tst_performance/SwitchStyleGrid.qml (+4/-2)
tests/unit/tst_performance/tst_performance.cpp (+8/-19)
tests/unit/tst_performance/tst_performance.pro (+4/-6)
tests/unit/tst_theme_engine/BlockPropertyTest.qml (+0/-23)
tests/unit/tst_theme_engine/CustomStyles.qml (+0/-44)
tests/unit/tst_theme_engine/InheritanceTest.qml (+0/-45)
tests/unit/tst_theme_engine/MemoryCleanup.qml (+0/-26)
tests/unit/tst_theme_engine/Parent.qml (+20/-0)
tests/unit/tst_theme_engine/ReparentingTest.qml (+0/-34)
tests/unit/tst_theme_engine/SelectorTest.qml (+0/-37)
tests/unit/tst_theme_engine/StyleLookupCrash.qml (+0/-26)
tests/unit/tst_theme_engine/StyleLookupCrash.qmltheme (+0/-1)
tests/unit/tst_theme_engine/TestModule/TestTheme/TestStyle.qml (+20/-0)
tests/unit/tst_theme_engine/tst_theme_engine.pro (+3/-12)
tests/unit/tst_theme_engine/tst_theme_enginetest.cpp (+59/-356)
tests/unit/tst_theme_engine_private/tst_theme_engine_private.pro (+0/-5)
tests/unit/tst_theme_engine_private/tst_theme_engine_privatetest.cpp (+0/-393)
tests/unit/tst_theme_engine_selector/DescendantSelector.qml (+0/-28)
tests/unit/tst_theme_engine_selector/DescendantSelectorWithName.qml (+0/-29)
tests/unit/tst_theme_engine_selector/DescendantSelectorWithNamedParent.qml (+0/-29)
tests/unit/tst_theme_engine_selector/DirectChildSelector.qml (+0/-26)
tests/unit/tst_theme_engine_selector/DirectChildSelectorWithName.qml (+0/-27)
tests/unit/tst_theme_engine_selector/DirectChildSelectorWithNamedParent.qml (+0/-27)
tests/unit/tst_theme_engine_selector/SimpleSelector.qml (+0/-23)
tests/unit/tst_theme_engine_selector/SimpleSelectorWithName.qml (+0/-24)
tests/unit/tst_theme_engine_selector/TestTheme.qmltheme (+0/-7)
tests/unit/tst_theme_engine_selector/tst_theme_engine_selector.pro (+0/-14)
tests/unit/tst_theme_engine_selector/tst_theme_engine_selectortest.cpp (+0/-399)
tests/unit/tst_theme_engine_style/BindingTest.qml (+0/-37)
tests/unit/tst_theme_engine_style/CustomDelegateComponent.qml (+0/-30)
tests/unit/tst_theme_engine_style/CustomDelegateObject.qml (+0/-26)
tests/unit/tst_theme_engine_style/CustomStyleObject.qml (+0/-26)
tests/unit/tst_theme_engine_style/FontThemeDoNotOverrideUserValue.qml (+0/-23)
tests/unit/tst_theme_engine_style/FontThemeDoNotOverrideUserValue.qmltheme (+0/-3)
tests/unit/tst_theme_engine_style/FontThemeDoNotOverrideUserValueText.qml (+0/-23)
tests/unit/tst_theme_engine_style/FontThemeNoOverride.qml (+0/-22)
tests/unit/tst_theme_engine_style/FontThemeNoOverride.qmltheme (+0/-3)
tests/unit/tst_theme_engine_style/FontThemeNoOverrideText.qml (+0/-22)
tests/unit/tst_theme_engine_style/FontThemeNoOverrideUserBinding.qml (+0/-24)
tests/unit/tst_theme_engine_style/FontThemeNoOverrideUserBinding.qmltheme (+0/-3)
tests/unit/tst_theme_engine_style/FontThemeNoOverrideUserBindingText.qml (+0/-22)
tests/unit/tst_theme_engine_style/FontThemeNoOverrideWithBinding.qml (+0/-22)
tests/unit/tst_theme_engine_style/FontThemeNoOverrideWithBinding.qmltheme (+0/-3)
tests/unit/tst_theme_engine_style/FontThemeNoOverrideWithBindingText.qml (+0/-24)
tests/unit/tst_theme_engine_style/FontThemeOverrideDefaultValue.qml (+0/-22)
tests/unit/tst_theme_engine_style/FontThemeOverrideDefaultValue.qmltheme (+0/-3)
tests/unit/tst_theme_engine_style/FontThemeOverrideDefaultValueText.qml (+0/-23)
tests/unit/tst_theme_engine_style/FontThemeWithOtherDefaultValue.qml (+0/-22)
tests/unit/tst_theme_engine_style/FontThemeWithOtherDefaultValue.qmltheme (+0/-3)
tests/unit/tst_theme_engine_style/FontThemeWithOtherDefaultValueText.qml (+0/-23)
tests/unit/tst_theme_engine_style/StyledItem.qml (+0/-22)
tests/unit/tst_theme_engine_style/TestDocument.qml (+0/-35)
tests/unit/tst_theme_engine_style/tst_theme_engine_style.pro (+0/-13)
tests/unit/tst_theme_engine_style/tst_theme_engine_styletest.cpp (+0/-395)
tests/unit/tst_theme_engine_stylecache/tst_theme_engine_stylecache.pro (+0/-3)
tests/unit/tst_theme_engine_stylecache/tst_theme_engine_stylecachetest.cpp (+0/-220)
tests/unit/unit.pro (+0/-4)
themes/Ambiance/qmltheme/default.qmltheme (+0/-354)
ubuntu-sdk.pro (+1/-1)
To merge this branch: bzr merge lp:~fboucault/ubuntu-ui-toolkit/simple_theming
Reviewer Review Type Date Requested Status
Zsombor Egri Needs Fixing
PS Jenkins bot continuous-integration Approve
Florian Boucault (community) Needs Fixing
Review via email: mp+171645@code.launchpad.net

Commit message

Simplified theming infrastructure.

There are no stylesheets anymore (.qmltheme file), only delegates remain. A theme is a QML module containing delegates whose names are standardized.
The default theme is called 'Ambiance' and available from QML through 'import Ubuntu.Components.Themes.Ambiance 0.1'.
The name of the current theme is set in ~/.config/ubuntu-ui-toolkit/theme.ini

Writing a new theme is done by creating a QML module and adding it in the Ubuntu/Components/Themes folder.
A theme inherits from another theme by containing a text file name 'parent_theme' whose first and only line is the name of the parent theme.

* Moved themes/ directory to Ubuntu/Components/Themes so that themes are importable.
* Simplified ThemeEngine and ThemeSettings class, removed the rest of the theming infrastructure (ItemStyle, Style, QmlThemeLoader, Selector, StyleCache).
* Adapted all widgets to use the simplified theming technique:
 - new StyledItem class that has a 'style' Component property representing the delegate
 - all widgets that have delegates inherit from StyledItem
 - all widgets set the 'style' property to the corresponding delegate in the current theme by using Theme.createStyleComponent()
 - Ambiance's stylesheet property/values have been moved to where they are used (mostly to the delegates)
 - TextAreaDelegate: exposed background as Component property
 - Added a delegate specific to TextField: TextFieldDelegate
 - Renamed delegates so that they match their widget's name (e.g. EditorCursorDelegate.qml renamed to TextCursorDelegate.qml since it's the delegate of TextCursor.qml)
* Renamed UITK_THEME_PATH into UBUNTU_UI_TOOLKIT_THEMES_PATH.

To post a comment you must log in.
565. By Florian Boucault

Moved themes under Ubuntu/Components/Themes*

566. By Florian Boucault

Removed useless debug.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
567. By Florian Boucault

Removed references to qmltheme.

568. By Florian Boucault

Updated components.api and CHANGES

569. By Florian Boucault

Removed outdated theming documentation.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Florian Boucault (fboucault) wrote :

Before reviewing/merging, the following needs to be done:
- documenting ThemeEngine and StyledItem
- testing on the phone
- adding unit tests for ThemeEngine
- proposing merge requests to fix the following apps that are using ItemStyle:
  * camera-app
  * mediaplayer-app
  * ubuntu-calculator-app
  * phone-app
  * notes-app
  * ubuntu-facebook-app

Optionally we may also want to:
- rename all *Delegate.qml into *Style.qml
- find a better name for the property StyledItem.delegate

review: Needs Fixing
570. By Florian Boucault

tst_performance: set styledItem on delegates.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
571. By Florian Boucault

Documented StyledItem.

572. By Florian Boucault

StyledItem: renamed internal delegateLoader into styleLoader.

573. By Florian Boucault

Recommend the use of the Style suffix.

574. By Florian Boucault

Added documentation for ThemeEngine.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zsombor Egri (zsombi) wrote :

> - find a better name for the property StyledItem.delegate

QtQuick Controls call it as "panel", how about us calling in the same way? they have it as internal, perhaps we should also keep it as such...

Revision history for this message
Zsombor Egri (zsombi) wrote :

As we do a major rework of theming, perhaps we should also rename the class name from ThemeEngine to UCTheme

review: Needs Fixing
Revision history for this message
Zsombor Egri (zsombi) wrote :

901 + \qmlabstract StyledItem
902 + \inqmlmodule Ubuntu.Components 0.1
903 + \ingroup ubuntu

I think documentation wise StyledItem should belong to theming group.

review: Needs Fixing
Revision history for this message
Zsombor Egri (zsombi) wrote :

In StyledItem.qml

944 + Loader {
945 + id: styleLoader
946 + anchors.fill: parent
947 + sourceComponent: style
948 + property Item styledItem: styledItem
949 + }

Shouldn't we display error message if the style loading fails?

review: Needs Fixing
575. By Florian Boucault

Theme.setName should not override the system wide theme.

Revision history for this message
Zsombor Egri (zsombi) wrote :

QtQuick Controls style shave "panel" component in styles, so they separate style properties from visuals. In this way you can change the style properties separately from the visuals. What do you think, shouldn't we also have this feature?

On the other hand we have the delegates specifying the styling properties as public properties, so a theme which is based on an other one can simply override the previous theme delegate and change these properties only...

review: Needs Information
576. By Florian Boucault

Renamed StyledItem.delegate into StyledItem.__styleInstance

577. By Florian Boucault

Merged trunk

Revision history for this message
Zsombor Egri (zsombi) wrote :

Do we really need separate delegate for TextField and TextArea? Those should look the same.. or you wanted to have separate delegate for each styled item in case a theme wants to have different look?

review: Needs Information
Revision history for this message
Zsombor Egri (zsombi) wrote :

So far looks good :) Waiting for the rest...

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
578. By Florian Boucault

Renamed all theme Delegates into Styles

579. By Florian Boucault

Merged trunk

580. By Florian Boucault

Fixed components.api

581. By Florian Boucault

Renamed ThemeEngine into UCTheme.
Renamed ThemeSettings into UCThemeSettings.

582. By Florian Boucault

Moved StyledItem into theming documentation group.

Revision history for this message
Florian Boucault (fboucault) wrote :

> As we do a major rework of theming, perhaps we should also rename the class
> name from ThemeEngine to UCTheme

Done.

Revision history for this message
Florian Boucault (fboucault) wrote :

> 901 + \qmlabstract StyledItem
> 902 + \inqmlmodule Ubuntu.Components 0.1
> 903 + \ingroup ubuntu
>
> I think documentation wise StyledItem should belong to theming group.

Done.

Revision history for this message
Florian Boucault (fboucault) wrote :

> In StyledItem.qml
>
> 944 + Loader {
> 945 + id: styleLoader
> 946 + anchors.fill: parent
> 947 + sourceComponent: style
> 948 + property Item styledItem: styledItem
> 949 + }
>
> Shouldn't we display error message if the style loading fails?

I believe Loader does that already.

Revision history for this message
Florian Boucault (fboucault) wrote :

> QtQuick Controls style shave "panel" component in styles, so they separate
> style properties from visuals. In this way you can change the style properties
> separately from the visuals. What do you think, shouldn't we also have this
> feature?
>

I have not found that we need to do that to get the same benefits.

> On the other hand we have the delegates specifying the styling properties as
> public properties, so a theme which is based on an other one can simply
> override the previous theme delegate and change these properties only...

Exactly.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
583. By Florian Boucault

Merged trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
584. By Florian Boucault

qtdeclarative5-ubuntu-ui-toolkit-plugin should not install the Themes directory.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
585. By Florian Boucault

Missing backslash preventing sci files from being installed.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
586. By Florian Boucault

Header height is set by its delegate.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
587. By Florian Boucault

Merged trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
588. By Florian Boucault

UCTheme: renamed styleUrlForTheme to styleUrl and made it public in prevision for future use in the QQmlExtensionPlugin.

589. By Florian Boucault

Removed deprecated documentation.

590. By Florian Boucault

Made styleUrl private again. Moved UCTheme registration into the class itself.

591. By Florian Boucault

Only expose TextAreaStyle and TextFieldStyle as we are not ready to commit to the APIs of all the Styles.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
592. By Florian Boucault

Added failing test cases.

593. By Florian Boucault

Fixed failing tests.

594. By Florian Boucault

Removed rogue references to ItemStyle.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
595. By Florian Boucault

Merged from trunk.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
596. By Florian Boucault

Merged with trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Florian Boucault (fboucault) wrote :
Revision history for this message
Zsombor Egri (zsombi) wrote :

Two small things to be fixed still:
- UCTheme::setName(), ::createStyleComponent(), ::styleUrl() and ::parentThemeName() can take const QString& as parameter.
- because of common.pri removal we have two warnings in Layouts.pro and Layouts\plugin.pro. I think we should fix those, either here or in a separate MR.

review: Needs Fixing
Revision history for this message
Zsombor Egri (zsombi) wrote :

Not sure whether it has bee brought in by this MR, but we have these errors displayed when opening a Dialog or Popover:
> When launching the toolkit gallery and activating Dialog or Popover (not on
> the Sheet), the following error is printed:
> (kernel/qobject.cpp:2571, QObject::connect) - QObject::connect: Cannot connect
> QQuickShaderEffectSource:: to ShapeItem::onImagePropertiesChanged()
>
> Would this be an error in Shape?

review: Needs Fixing
Revision history for this message
Florian Boucault (fboucault) wrote :

> Not sure whether it has bee brought in by this MR, but we have these errors
> displayed when opening a Dialog or Popover:
> > When launching the toolkit gallery and activating Dialog or Popover (not on
> > the Sheet), the following error is printed:
> > (kernel/qobject.cpp:2571, QObject::connect) - QObject::connect: Cannot
> connect
> > QQuickShaderEffectSource:: to ShapeItem::onImagePropertiesChanged()
> >
> > Would this be an error in Shape?

Also happens in trunk.

Revision history for this message
Florian Boucault (fboucault) wrote :

> Two small things to be fixed still:
> - UCTheme::setName(), ::createStyleComponent(), ::styleUrl() and
> ::parentThemeName() can take const QString& as parameter.

We only have a short window to merge this and the 4 other apps so that the build does not break. Can we avoid this detail? (also note that QStrings are shared implicity therefore no copy is occuring when passing by value)

> - because of common.pri removal we have two warnings in Layouts.pro and
> Layouts\plugin.pro. I think we should fix those, either here or in a separate
> MR.

Why here? the removal of common.pri was done in trunk.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CHANGES'
2--- CHANGES 2013-06-21 11:35:19 +0000
3+++ CHANGES 2013-07-01 22:15:52 +0000
4@@ -9,6 +9,8 @@
5
6 API Changes
7 ***********
8+
9+* REMOVED IN ALL: attached property ItemStyle
10 * ADDED IN OrientationHelper: property alias rotating
11 * ADDED IN OrientationHelper: property alias __orientationHelper
12 * ADDED IN OrientationHelper: property bool transitionEnabled
13
14=== modified file 'components.api'
15--- components.api 2013-07-01 20:32:20 +0000
16+++ components.api 2013-07-01 22:15:52 +0000
17@@ -15,7 +15,7 @@
18 property bool enabled
19 property Component itemHint
20 modules/Ubuntu/Components/ActionItem.qml
21-Item
22+StyledItem
23 property Action action
24 property string text
25 property url iconSource
26@@ -28,7 +28,7 @@
27 AnimatedItem
28 property bool running
29 modules/Ubuntu/Components/AnimatedItem.qml
30-Item
31+StyledItem
32 property bool onScreen
33 modules/Ubuntu/Components/Button.qml
34 AbstractButton
35@@ -55,7 +55,7 @@
36 function getEventSpeed(currentTime, event)
37 function pushDragEvent(event)
38 modules/Ubuntu/Components/Header.qml
39-Item
40+StyledItem
41 function show()
42 function hide()
43 property string title
44@@ -108,7 +108,7 @@
45 function pop()
46 function clear()
47 modules/Ubuntu/Components/PageTreeNode.qml
48-Item
49+StyledItem
50 property bool __isPageTreeNode
51 property Header header
52 property Toolbar toolbar
53@@ -139,7 +139,7 @@
54 property real maximumValue
55 property real value
56 modules/Ubuntu/Components/Scrollbar.qml
57-Item
58+StyledItem
59 property Flickable flickableItem
60 property int align
61 property bool __interactive
62@@ -153,6 +153,10 @@
63 signal touched(bool onThumb)
64 function formatValue(v)
65 property alias __internals
66+modules/Ubuntu/Components/StyledItem.qml
67+FocusScope
68+ property Component style
69+ readonly property Item __styleInstance
70 modules/Ubuntu/Components/Switch.qml
71 CheckBox
72 modules/Ubuntu/Components/Tab.qml
73@@ -172,7 +176,7 @@
74 default property alias tabChildren
75 signal modelChanged()
76 modules/Ubuntu/Components/TextArea.qml
77-FocusScope
78+StyledItem
79 property bool highlighted
80 property alias placeholderText
81 readonly property alias displayText
82@@ -234,13 +238,13 @@
83 function forceActiveFocus()
84 property alias __internal
85 modules/Ubuntu/Components/TextCursor.qml
86-Item
87+StyledItem
88 property var editorItem
89 property string positionProperty
90 property var popover
91 function openPopover()
92 modules/Ubuntu/Components/TextField.qml
93-FocusScope
94+StyledItem
95 property bool highlighted
96 property alias placeholderText
97 property bool hasClearButton
98@@ -330,14 +334,6 @@
99 Method {
100 name: "contains"
101 Parameter { name: "point"; type: "QPointF" }
102- name: "ItemStyleAttached"
103- prototype: "QObject"
104- exports: ["ItemStyle 0.1"]
105- Property { name: "class"; type: "string" }
106- Property { name: "name"; type: "string" }
107- Property { name: "style"; type: "UCStyle"; isPointer: true }
108- Property { name: "delegate"; type: "QQuickItem"; isPointer: true }
109- Property { name: "path"; type: "string"; isReadonly: true }
110 name: "QQmlPropertyMap"
111 prototype: "QObject"
112 Signal {
113@@ -412,9 +408,6 @@
114 Signal {
115 name: "sourceChanged"
116 Parameter { type: "QUrl" }
117- name: "UCStyle"
118- prototype: "QObject"
119- exports: ["Style 0.1"]
120 name: "UCUbuntuAnimation"
121 prototype: "QObject"
122 exports: ["UbuntuAnimation 0.1"]
123
124=== modified file 'debian/qtdeclarative5-ubuntu-ui-toolkit-plugin.install'
125--- debian/qtdeclarative5-ubuntu-ui-toolkit-plugin.install 2013-02-15 11:52:44 +0000
126+++ debian/qtdeclarative5-ubuntu-ui-toolkit-plugin.install 2013-07-01 22:15:52 +0000
127@@ -1,1 +1,9 @@
128-usr/lib/*/qt5/qml/
129+usr/lib/*/qt5/qml/Ubuntu/Layouts
130+usr/lib/*/qt5/qml/Ubuntu/Components/*.qml
131+usr/lib/*/qt5/qml/Ubuntu/Components/*.js
132+usr/lib/*/qt5/qml/Ubuntu/Components/qmldir
133+usr/lib/*/qt5/qml/Ubuntu/Components/plugins.qmltypes
134+usr/lib/*/qt5/qml/Ubuntu/Components/libUbuntuComponents.so
135+usr/lib/*/qt5/qml/Ubuntu/Components/artwork
136+usr/lib/*/qt5/qml/Ubuntu/Components/ListItems
137+usr/lib/*/qt5/qml/Ubuntu/Components/Popups
138
139=== modified file 'debian/ubuntu-ui-toolkit-theme.install'
140--- debian/ubuntu-ui-toolkit-theme.install 2013-02-15 11:52:44 +0000
141+++ debian/ubuntu-ui-toolkit-theme.install 2013-07-01 22:15:52 +0000
142@@ -1,1 +1,1 @@
143-usr/share/themes/Ambiance
144+usr/lib/*/qt5/qml/Ubuntu/Components/Themes
145
146=== modified file 'examples/examples.pro'
147--- examples/examples.pro 2013-05-07 10:23:57 +0000
148+++ examples/examples.pro 2013-07-01 22:15:52 +0000
149@@ -8,7 +8,7 @@
150
151
152 #examples = jokes unit-converter
153-#filetypes = qml png svg js qmltheme jpg wav
154+#filetypes = qml png svg js jpg wav
155
156 #OTHER_FILES = ""
157
158
159=== modified file 'examples/jokes/jokes.pro'
160--- examples/jokes/jokes.pro 2013-05-07 10:23:57 +0000
161+++ examples/jokes/jokes.pro 2013-07-01 22:15:52 +0000
162@@ -1,6 +1,6 @@
163 TEMPLATE = subdirs
164
165-filetypes = qml png svg js qmltheme jpg qmlproject desktop wav
166+filetypes = qml png svg js jpg qmlproject desktop wav
167
168 OTHER_FILES = ""
169
170
171=== modified file 'examples/locale/locale.pro'
172--- examples/locale/locale.pro 2013-05-07 10:23:57 +0000
173+++ examples/locale/locale.pro 2013-07-01 22:15:52 +0000
174@@ -1,6 +1,6 @@
175 TEMPLATE = subdirs
176
177-filetypes = qml png svg js qmltheme jpg qmlproject desktop
178+filetypes = qml png svg js jpg qmlproject desktop
179
180 OTHER_FILES = ""
181
182
183=== modified file 'examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.pro'
184--- examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.pro 2013-05-06 16:24:50 +0000
185+++ examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.pro 2013-07-01 22:15:52 +0000
186@@ -2,7 +2,7 @@
187
188 SUBDIRS += po
189
190-filetypes = qml png svg js qmltheme jpg qmlproject desktop
191+filetypes = qml png svg js jpg qmlproject desktop
192
193 OTHER_FILES = ""
194
195
196=== modified file 'examples/unit-converter/unit-converter.pro'
197--- examples/unit-converter/unit-converter.pro 2013-05-07 10:23:57 +0000
198+++ examples/unit-converter/unit-converter.pro 2013-07-01 22:15:52 +0000
199@@ -1,6 +1,6 @@
200 TEMPLATE = subdirs
201
202-filetypes = qml png svg js qmltheme jpg qmlproject desktop
203+filetypes = qml png svg js jpg qmlproject desktop
204
205 OTHER_FILES = ""
206
207
208=== modified file 'export_modules_dir.sh'
209--- export_modules_dir.sh 2013-04-24 17:09:29 +0000
210+++ export_modules_dir.sh 2013-07-01 22:15:52 +0000
211@@ -17,4 +17,4 @@
212
213 export QML_IMPORT_PATH=$PWD/modules
214 export QML2_IMPORT_PATH=$PWD/modules
215-export UITK_THEME_PATH=.
216+export UBUNTU_UI_TOOLKIT_THEMES_PATH=$PWD/modules
217
218=== modified file 'modules/Ubuntu/Components/ActionItem.qml'
219--- modules/Ubuntu/Components/ActionItem.qml 2013-06-28 18:14:20 +0000
220+++ modules/Ubuntu/Components/ActionItem.qml 2013-07-01 22:15:52 +0000
221@@ -31,7 +31,7 @@
222 See \l ToolbarItems for examples of how to use \l ToolbarButton or other ActionItems
223 in a toolbar.
224 */
225-Item {
226+StyledItem {
227 id: actionItem
228
229 /*!
230
231=== modified file 'modules/Ubuntu/Components/ActivityIndicator.qml'
232--- modules/Ubuntu/Components/ActivityIndicator.qml 2013-02-27 07:15:35 +0000
233+++ modules/Ubuntu/Components/ActivityIndicator.qml 2013-07-01 22:15:52 +0000
234@@ -15,11 +15,6 @@
235 */
236
237 import QtQuick 2.0
238-// FIXME: When a module contains QML, C++ and JavaScript elements exported,
239-// we need to use named imports otherwise namespace collision is reported
240-// by the QML engine. As workaround, we use Theming named import.
241-// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
242-import "." 0.1 as Theming
243
244 /*!
245 \qmltype ActivityIndicator
246@@ -63,6 +58,5 @@
247 implicitWidth: units.gu(3)
248 implicitHeight: units.gu(3)
249
250- Theming.ItemStyle.class: "activityindicator"
251-
252+ style: Theme.createStyleComponent("ActivityIndicatorStyle.qml", indicator)
253 }
254
255=== modified file 'modules/Ubuntu/Components/AnimatedItem.qml'
256--- modules/Ubuntu/Components/AnimatedItem.qml 2012-10-29 17:14:42 +0000
257+++ modules/Ubuntu/Components/AnimatedItem.qml 2013-07-01 22:15:52 +0000
258@@ -26,7 +26,7 @@
259
260 import QtQuick 2.0
261
262-Item {
263+StyledItem {
264 id: root
265 /*!
266 \preliminary
267
268=== modified file 'modules/Ubuntu/Components/Button.qml'
269--- modules/Ubuntu/Components/Button.qml 2013-06-26 23:42:39 +0000
270+++ modules/Ubuntu/Components/Button.qml 2013-07-01 22:15:52 +0000
271@@ -15,11 +15,6 @@
272 */
273
274 import QtQuick 2.0
275-// FIXME: When a module contains QML, C++ and JavaScript elements exported,
276-// we need to use named imports otherwise namespace collision is reported
277-// by the QML engine. As workaround, we use Theming named import.
278-// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
279-import Ubuntu.Components 0.1 as Theming
280
281 /*!
282 \qmltype Button
283@@ -69,8 +64,6 @@
284 AbstractButton {
285 id: button
286
287- // FIXME: see FIXME above
288- Theming.ItemStyle.class: "button"
289 implicitWidth: units.gu(9)
290 implicitHeight: units.gu(4)
291
292@@ -107,4 +100,6 @@
293 https://bugreports.qt-project.org/browse/QTBUG-14861
294 */
295 property string iconPosition: "left"
296+
297+ style: Theme.createStyleComponent("ButtonStyle.qml", button)
298 }
299
300=== modified file 'modules/Ubuntu/Components/CheckBox.qml'
301--- modules/Ubuntu/Components/CheckBox.qml 2013-05-24 09:12:56 +0000
302+++ modules/Ubuntu/Components/CheckBox.qml 2013-07-01 22:15:52 +0000
303@@ -15,11 +15,6 @@
304 */
305
306 import QtQuick 2.0
307-// FIXME: When a module contains QML, C++ and JavaScript elements exported,
308-// we need to use named imports otherwise namespace collision is reported
309-// by the QML engine. As workaround, we use Theming named import.
310-// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
311-import Ubuntu.Components 0.1 as Theming
312
313 /*!
314 \qmltype CheckBox
315@@ -45,11 +40,6 @@
316 AbstractButton {
317 id: checkBox
318
319- // FIXME: see FIXME above
320- Theming.ItemStyle.class: "checkbox"
321- implicitWidth: units.gu(4)
322- implicitHeight: units.gu(4)
323-
324 /*!
325 \preliminary
326 Specifies whether the checkbox is checked or not. By default the property
327@@ -61,4 +51,6 @@
328 \internal
329 */
330 onClicked: checked = !checked
331+
332+ style: Theme.createStyleComponent("CheckBoxStyle.qml", checkBox)
333 }
334
335=== modified file 'modules/Ubuntu/Components/Components.pro'
336--- modules/Ubuntu/Components/Components.pro 2013-06-25 14:18:18 +0000
337+++ modules/Ubuntu/Components/Components.pro 2013-07-01 22:15:52 +0000
338@@ -1,5 +1,5 @@
339 TEMPLATE = subdirs
340
341-SUBDIRS += plugin
342+SUBDIRS += plugin Themes
343
344 include(deployment.pri)
345
346=== modified file 'modules/Ubuntu/Components/Header.qml'
347--- modules/Ubuntu/Components/Header.qml 2013-06-21 11:28:33 +0000
348+++ modules/Ubuntu/Components/Header.qml 2013-07-01 22:15:52 +0000
349@@ -17,9 +17,9 @@
350 import QtQuick 2.0
351 // FIXME: When a module contains QML, C++ and JavaScript elements exported,
352 // we need to use named imports otherwise namespace collision is reported
353-// by the QML engine. As workaround, we use Theming named import.
354+// by the QML engine. As workaround, we use Ubuntu named import.
355 // Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
356-import Ubuntu.Components 0.1 as Theming
357+import Ubuntu.Components 0.1 as Ubuntu
358
359 /*!
360 \internal
361@@ -27,10 +27,8 @@
362 \inqmlmodule Ubuntu.Components 0.1
363 \ingroup ubuntu
364 */
365-Item {
366+StyledItem {
367 id: header
368- // FIXME: see above
369- Theming.ItemStyle.class: "header"
370
371 anchors {
372 left: parent.left
373@@ -41,10 +39,9 @@
374 Behavior on y {
375 enabled: !(header.flickable && header.flickable.moving)
376 SmoothedAnimation {
377- duration: Theming.UbuntuAnimation.FastDuration
378+ duration: Ubuntu.UbuntuAnimation.FastDuration
379 }
380 }
381- height: units.gu(10)
382
383 /*! \internal */
384 onHeightChanged: internal.movementEnded()
385@@ -157,4 +154,6 @@
386 if (flickable && !flickable.interactive) header.show();
387 }
388 }
389+
390+ style: Theme.createStyleComponent("HeaderStyle.qml", header)
391 }
392
393=== modified file 'modules/Ubuntu/Components/Label.qml'
394--- modules/Ubuntu/Components/Label.qml 2013-05-20 08:34:52 +0000
395+++ modules/Ubuntu/Components/Label.qml 2013-07-01 22:15:52 +0000
396@@ -15,11 +15,6 @@
397 */
398
399 import QtQuick 2.0
400-// FIXME: When a module contains QML, C++ and JavaScript elements exported,
401-// we need to use named imports otherwise namespace collision is reported
402-// by the QML engine. As workaround, we use Theming named import.
403-// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
404-import Ubuntu.Components 0.1 as Theming
405
406 /*!
407 \qmltype Label
408@@ -45,8 +40,6 @@
409 Text {
410 id: label
411
412- Theming.ItemStyle.class: "label"
413-
414 /*!
415 The size of the text. One of the following strings (from smallest to largest):
416 \list
417@@ -63,8 +56,5 @@
418
419 font.pixelSize: FontUtils.sizeToPixels(fontSize)
420 font.family: "Ubuntu"
421- /* FIXME: do not set any font subproperties (e.g. font.family, font.italic, etc.)
422- as setting there default value here will prevent them from being overriden
423- by the theme.
424- */
425+ color: "#757373"
426 }
427
428=== modified file 'modules/Ubuntu/Components/MainView.qml'
429--- modules/Ubuntu/Components/MainView.qml 2013-06-14 16:28:04 +0000
430+++ modules/Ubuntu/Components/MainView.qml 2013-07-01 22:15:52 +0000
431@@ -15,11 +15,6 @@
432 */
433
434 import QtQuick 2.0
435-// FIXME: When a module contains QML, C++ and JavaScript elements exported,
436-// we need to use named imports otherwise namespace collision is reported
437-// by the QML engine. As workaround, we use Theming named import.
438-// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
439-import Ubuntu.Components 0.1 as Theming
440
441 /*!
442 \qmltype MainView
443@@ -140,13 +135,13 @@
444 */
445 property string applicationName
446
447- // FIXME: Make sure that the theming is only in the background, and the delegate
448+ // FIXME: Make sure that the theming is only in the background, and the style
449 // should not occlude contents of the MainView. When making changes here, make
450 // sure that bug https://bugs.launchpad.net/manhattan/+bug/1124076 does not come back.
451- Item {
452+ StyledItem {
453 id: background
454- Theming.ItemStyle.class: "mainview"
455 anchors.fill: parent
456+ style: Theme.createStyleComponent("MainViewStyle.qml", background)
457 }
458
459 /*!
460
461=== modified file 'modules/Ubuntu/Components/PageTreeNode.qml'
462--- modules/Ubuntu/Components/PageTreeNode.qml 2013-05-21 18:06:28 +0000
463+++ modules/Ubuntu/Components/PageTreeNode.qml 2013-07-01 22:15:52 +0000
464@@ -26,7 +26,7 @@
465 It is used to propagate properties such as \l header and \l toolbar from a
466 \l MainView (the root node) to each \l Page (leaf node) in the tree.
467 */
468-Item {
469+StyledItem {
470 id: node
471
472 /*!
473
474=== modified file 'modules/Ubuntu/Components/Panel.qml'
475--- modules/Ubuntu/Components/Panel.qml 2013-06-13 13:39:32 +0000
476+++ modules/Ubuntu/Components/Panel.qml 2013-07-01 22:15:52 +0000
477@@ -86,7 +86,6 @@
478
479 Item {
480 anchors.fill: parent
481- ItemStyle.class: "toolbar"
482
483 // two properties used by the toolbar delegate:
484 property bool opened: panel.opened
485
486=== modified file 'modules/Ubuntu/Components/Popups/ActionSelectionPopover.qml'
487--- modules/Ubuntu/Components/Popups/ActionSelectionPopover.qml 2013-06-12 18:52:01 +0000
488+++ modules/Ubuntu/Components/Popups/ActionSelectionPopover.qml 2013-07-01 22:15:52 +0000
489@@ -17,7 +17,6 @@
490 import QtQuick 2.0
491 import "../" 0.1
492 import "../ListItems" 0.1
493-import "../" 0.1 as Theming
494
495 /*!
496 \qmltype ActionSelectionPopover
497
498=== modified file 'modules/Ubuntu/Components/Popups/Dialog.qml'
499--- modules/Ubuntu/Components/Popups/Dialog.qml 2013-05-28 19:25:47 +0000
500+++ modules/Ubuntu/Components/Popups/Dialog.qml 2013-07-01 22:15:52 +0000
501@@ -16,11 +16,6 @@
502
503 import QtQuick 2.0
504 import Ubuntu.Components 0.1
505-// FIXME: When a module contains QML, C++ and JavaScript elements exported,
506-// we need to use named imports otherwise namespace collision is reported
507-// by the QML engine. As workaround, we use Theming named import.
508-// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
509-import Ubuntu.Components 0.1 as Theming
510 import "internalPopupUtils.js" as InternalPopupUtils
511
512 /*!
513@@ -120,13 +115,13 @@
514 The property holds the margins from the dialog's dismissArea. The property
515 is themed.
516 */
517- property real edgeMargins
518+ property real edgeMargins: units.gu(2)
519
520 /*!
521 The property holds the margin from the dialog's caller. The property
522 is themed.
523 */
524- property real callerMargin
525+ property real callerMargin: units.gu(1)
526
527 /*!
528 The property controls whether the dialog is modal or not. Modal dialogs block
529@@ -138,8 +133,6 @@
530 */
531 property bool modal: true
532
533- Theming.ItemStyle.class: "dialog"
534-
535 /*
536 QtObject {
537 id: internal
538@@ -157,22 +150,21 @@
539 __foreground: foreground
540 __eventGrabber.enabled: modal
541 __dimBackground: modal
542+ fadingAnimation: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
543
544- Item {
545+ StyledItem {
546 id: foreground
547- // FIXME: see above
548- Theming.ItemStyle.class: "foreground"
549 width: Math.min(minimumWidth, dialog.width)
550 anchors.centerIn: parent
551
552- // used in the delegate
553+ // used in the style
554 property string title
555 property string text
556- property real minimumWidth
557- property real minimumHeight
558+ property real minimumWidth: units.gu(38)
559+ property real minimumHeight: units.gu(32)
560 property real maxHeight: 3*dialog.height/4
561- property real margins
562- property real itemSpacing
563+ property real margins: units.gu(4)
564+ property real itemSpacing: units.gu(2)
565 property Item dismissArea: dialog.dismissArea
566
567 height: Math.min(childrenRect.height, dialog.height)
568@@ -190,14 +182,18 @@
569 onWidthChanged: updateChildrenWidths();
570
571 Label {
572- ItemStyle.class: "title"
573 horizontalAlignment: Text.AlignHCenter
574 text: dialog.title
575+ fontSize: "large"
576+ color: Qt.rgba(1, 1, 1, 0.9)
577 }
578
579 Label {
580 horizontalAlignment: Text.AlignHCenter
581 text: dialog.text
582+ fontSize: "medium"
583+ color: Qt.rgba(1, 1, 1, 0.6)
584+ wrapMode: Text.Wrap
585 }
586
587 onChildrenChanged: updateChildrenWidths()
588@@ -208,5 +204,7 @@
589 }
590 }
591 }
592+
593+ style: Theme.createStyleComponent("DialogForegroundStyle.qml", foreground)
594 }
595 }
596
597=== modified file 'modules/Ubuntu/Components/Popups/Pointer.qml'
598--- modules/Ubuntu/Components/Popups/Pointer.qml 2013-03-14 11:48:53 +0000
599+++ modules/Ubuntu/Components/Popups/Pointer.qml 2013-07-01 22:15:52 +0000
600@@ -15,21 +15,16 @@
601 */
602
603 import QtQuick 2.0
604-// FIXME: When a module contains QML, C++ and JavaScript elements exported,
605-// we need to use named imports otherwise namespace collision is reported
606-// by the QML engine. As workaround, we use Theming named import.
607-// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
608-import Ubuntu.Components 0.1 as Theming
609+import Ubuntu.Components 0.1
610
611 // internal class, used inside subclasses of PopupBase
612-Item {
613+StyledItem {
614 id: pointer
615- Theming.ItemStyle.class: "pointer"
616
617 // Using Item.Rotation does not play well with the
618 // translation that would be needed after rotating.
619- property real longAxis
620- property real shortAxis
621+ property real longAxis: units.gu(2)
622+ property real shortAxis: units.gu(1)
623
624 // up, down, left or right, or none to hide the pointer
625 property string direction: "down"
626@@ -39,4 +34,6 @@
627
628 width: rotate ? shortAxis : longAxis
629 height: rotate ? longAxis : shortAxis
630+
631+ style: Theme.createStyleComponent("PointerStyle.qml", pointer)
632 }
633
634=== modified file 'modules/Ubuntu/Components/Popups/Popover.qml'
635--- modules/Ubuntu/Components/Popups/Popover.qml 2013-05-24 09:12:56 +0000
636+++ modules/Ubuntu/Components/Popups/Popover.qml 2013-07-01 22:15:52 +0000
637@@ -16,11 +16,7 @@
638
639 import QtQuick 2.0
640 import "internalPopupUtils.js" as InternalPopupUtils
641-// FIXME: When a module contains QML, C++ and JavaScript elements exported,
642-// we need to use named imports otherwise namespace collision is reported
643-// by the QML engine. As workaround, we use Theming named import.
644-// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
645-import Ubuntu.Components 0.1 as Theming
646+import Ubuntu.Components 0.1
647
648 /*!
649 \qmltype Popover
650@@ -129,13 +125,13 @@
651 The property holds the margins from the popover's dismissArea. The property
652 is themed.
653 */
654- property real edgeMargins
655+ property real edgeMargins: units.gu(2)
656
657 /*!
658 The property holds the margin from the popover's caller. The property
659 is themed.
660 */
661- property real callerMargin
662+ property real callerMargin: units.gu(1)
663
664 /*!
665 The property drives the automatic closing of the Popover when user taps
666@@ -147,7 +143,7 @@
667 */
668 property bool autoClose: true
669
670- Theming.ItemStyle.class: "popover"
671+ fadingAnimation: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
672
673 QtObject {
674 id: internal
675@@ -164,13 +160,11 @@
676 __eventGrabber.enabled: autoClose
677 __closeOnDismissAreaPress: true
678
679- Item {
680+ StyledItem {
681 id: foreground
682
683- // FIXME: see above
684- Theming.ItemStyle.class: "foreground"
685 //styling properties
686- property real minimumWidth
687+ property real minimumWidth: units.gu(40)
688
689 property real maxWidth: dismissArea ? (internal.portrait ? dismissArea.width : dismissArea.width * 3/4) : 0.0
690 property real maxHeight: dismissArea ? (internal.portrait ? dismissArea.height * 3/4 : dismissArea.height) : 0.0
691@@ -179,6 +173,7 @@
692
693 Item {
694 id: containerItem
695+ parent: foreground.__styleInstance.contentItem
696 anchors {
697 left: parent.left
698 top: parent.top
699@@ -189,6 +184,8 @@
700
701 onWidthChanged: internal.updatePosition()
702 onHeightChanged: internal.updatePosition()
703+
704+ style: Theme.createStyleComponent("PopoverForegroundStyle.qml", foreground)
705 }
706
707 Pointer { id: pointer }
708
709=== modified file 'modules/Ubuntu/Components/Popups/PopupBase.qml'
710--- modules/Ubuntu/Components/Popups/PopupBase.qml 2013-05-24 10:07:44 +0000
711+++ modules/Ubuntu/Components/Popups/PopupBase.qml 2013-07-01 22:15:52 +0000
712@@ -15,11 +15,6 @@
713 */
714
715 import QtQuick 2.0
716-// FIXME: When a module contains QML, C++ and JavaScript elements exported,
717-// we need to use named imports otherwise namespace collision is reported
718-// by the QML engine. As workaround, we use Theming named import.
719-// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
720-import Ubuntu.Components 0.1 as Theming
721 import Ubuntu.Components 0.1
722
723 /*!
724@@ -134,14 +129,14 @@
725 // dimmer
726 Rectangle {
727 id: background
728- Theming.ItemStyle.class: "background"
729 // styling properties
730 property bool dim: false
731 anchors.fill: parent
732 visible: dim
733+ color: popupBase.width > units.gu(60) ? Qt.rgba(0, 0, 0, 0.6) : Qt.rgba(0, 0, 0, 0.9)
734 }
735
736- Theming.InverseMouseArea {
737+ InverseMouseArea {
738 id: eventGrabber
739 enabled: true
740 anchors.fill: __foreground
741
742=== modified file 'modules/Ubuntu/Components/Popups/SheetBase.qml'
743--- modules/Ubuntu/Components/Popups/SheetBase.qml 2013-05-19 19:03:44 +0000
744+++ modules/Ubuntu/Components/Popups/SheetBase.qml 2013-07-01 22:15:52 +0000
745@@ -16,11 +16,6 @@
746
747 import QtQuick 2.0
748 import Ubuntu.Components 0.1
749-// FIXME: When a module contains QML, C++ and JavaScript elements exported,
750-// we need to use named imports otherwise namespace collision is reported
751-// by the QML engine. As workaround, we use Theming named import.
752-// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
753-import Ubuntu.Components 0.1 as Theming
754
755 /*!
756 \qmltype SheetBase
757@@ -78,17 +73,14 @@
758 /*! \internal */
759 property alias __rightButton: foreground.rightButton
760
761- Theming.ItemStyle.class: "sheet"
762+ fadingAnimation: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
763
764 __foreground: foreground
765 __eventGrabber.enabled: modal
766
767- Item {
768+ StyledItem {
769 id: foreground
770
771- // FIXME: see above
772- Theming.ItemStyle.class: "foreground"
773-
774 property string title
775 property real contentsWidth: units.gu(64)
776 property real contentsHeight: units.gu(40)
777@@ -103,21 +95,15 @@
778 property real minHeight: Math.min(units.gu(40), sheet.height)
779 property real maxHeight: sheet.height
780
781- // childrenRect includes the delegate which may add decoration
782- // to the sheet (such as a header with title), and thus width and height
783- // can differ from contentsWidth and contentsHeight.
784- // Delegate makes use of minWidth/maxWidth/minHeight/maxHeight properties
785- // which are defined above. Those properties are not moved to the delegate
786- // because here we have easy access to sheet.width and sheet.height.
787- width: childrenRect.width
788- height: childrenRect.height
789-
790 Item {
791 id: containerItem
792+ parent: foreground.__styleInstance.contentItem
793 anchors {
794 fill: parent
795 margins: units.gu(1)
796 }
797 }
798+
799+ style: Theme.createStyleComponent("SheetForegroundStyle.qml", sheet)
800 }
801 }
802
803=== modified file 'modules/Ubuntu/Components/Scrollbar.qml'
804--- modules/Ubuntu/Components/Scrollbar.qml 2013-03-14 11:56:06 +0000
805+++ modules/Ubuntu/Components/Scrollbar.qml 2013-07-01 22:15:52 +0000
806@@ -15,11 +15,6 @@
807 */
808
809 import QtQuick 2.0
810-// FIXME: When a module contains QML, C++ and JavaScript elements exported,
811-// we need to use named imports otherwise namespace collision is reported
812-// by the QML engine. As workaround, we use Theming named import.
813-// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
814-import Ubuntu.Components 0.1 as Theming
815
816 /*!
817 \qmltype ScrollBar
818@@ -35,7 +30,7 @@
819 direction (RTL or LTR).
820
821 The content position is driven through the attached Flickable. Therefore every
822- delegate implementation should drive the position through contentX/contentY
823+ style implementation should drive the position through contentX/contentY
824 properties, depending on whether the orientation is vertical or horizontal.
825
826 Example:
827@@ -63,7 +58,7 @@
828 \endqml
829 */
830
831-Item {
832+StyledItem {
833 id: scrollbar
834
835 /*!
836@@ -94,9 +89,6 @@
837 */
838 property bool __interactive: false
839
840- // styling
841- Theming.ItemStyle.class: "scrollbar"
842-
843 implicitWidth: internals.vertical ? units.gu(4) : flickableItem.width
844 implicitHeight: !internals.vertical ? units.gu(4) : flickableItem.height
845
846@@ -154,4 +146,6 @@
847 return undefined;
848 }
849 }
850+
851+ style: Theme.createStyleComponent("ScrollbarStyle.qml", scrollbar)
852 }
853
854=== modified file 'modules/Ubuntu/Components/Slider.qml'
855--- modules/Ubuntu/Components/Slider.qml 2013-05-24 09:12:56 +0000
856+++ modules/Ubuntu/Components/Slider.qml 2013-07-01 22:15:52 +0000
857@@ -33,11 +33,6 @@
858 import QtQuick 2.0
859 import "mathUtils.js" as MathUtils
860 import "sliderUtils.js" as SliderFuncs
861-// FIXME: When a module contains QML, C++ and JavaScript elements exported,
862-// we need to use named imports otherwise namespace collision is reported
863-// by the QML engine. As workaround, we use Theming named import.
864-// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
865-import "." 0.1 as Theming
866
867 /*!
868 \qmltype Slider
869@@ -47,7 +42,7 @@
870 values.
871
872 The slider's sensing area is defined by the width and height, therefore
873- delegates should take this into account when defining the visuals, and
874+ styles should take this into account when defining the visuals, and
875 alter these values to align the graphics' sizes.
876
877 \l {http://design.ubuntu.com/apps/building-blocks/slider}{See also the Design Guidelines on Sliders}.
878@@ -68,16 +63,16 @@
879 \section2 Theming
880
881 The slider's default style class is \b slider and style properties depend on
882- the actual delegate defined by the theme, except of one property which defines
883+ the actual style defined by the theme, except of one property which defines
884 the spacing units between the slider's bar and thumb, called \b thumbSpacing.
885 The slider uses one single touch sensing area to position the thumb within the
886- bar. Therefore However delegates must define the following properties:
887+ bar. Therefore However styles must define the following properties:
888 \list
889 \li * \b bar - the slider's bar object
890 \li * \b thumb - the slider's thumb object
891 \endlist
892
893- Beside these, the library provies functions for delegates to update liveValue and
894+ Beside these, the library provies functions for styles to update liveValue and
895 normalizedValue in SliderUtils module.
896
897 \b{This component is under heavy development.}
898@@ -88,8 +83,6 @@
899 width: units.gu(38)
900 height: units.gu(5)
901
902- Theming.ItemStyle.class: "slider"
903-
904 // FIXME(loicm) Add Support for the inverted property. There's an ongoing
905 // debate on whether we should use that property (like every other
906 // toolkits) or add new enumerations to the orientation property and
907@@ -157,7 +150,7 @@
908 default, the value v is rounded to the nearest interger value.
909
910 \b Note: this function will be deprecated, and will be solved with particular
911- delegates for the thumb.
912+ styles for the thumb.
913 */
914 function formatValue(v) {
915 return v.toFixed(0)
916@@ -179,9 +172,9 @@
917 QtObject {
918 id: internals
919
920- property real thumbSpacing: slider.Theming.ItemStyle.delegate ? slider.Theming.ItemStyle.delegate.thumbSpacing : 0
921- property Item bar: slider.Theming.ItemStyle.delegate ? slider.Theming.ItemStyle.delegate.bar : null
922- property Item thumb: slider.Theming.ItemStyle.delegate ? slider.Theming.ItemStyle.delegate.thumb : null
923+ property real thumbSpacing: slider.__styleInstance ? slider.__styleInstance.thumbSpacing : 0
924+ property Item bar: slider.__styleInstance ? slider.__styleInstance.bar : null
925+ property Item thumb: slider.__styleInstance ? slider.__styleInstance.thumb : null
926
927 property real liveValue: 0.0
928 property real normalizedValue: MathUtils.clamp((liveValue - slider.minimumValue) /
929@@ -244,4 +237,6 @@
930 }
931 }
932 }
933+
934+ style: Theme.createStyleComponent("SliderStyle.qml", slider)
935 }
936
937=== added file 'modules/Ubuntu/Components/StyledItem.qml'
938--- modules/Ubuntu/Components/StyledItem.qml 1970-01-01 00:00:00 +0000
939+++ modules/Ubuntu/Components/StyledItem.qml 2013-07-01 22:15:52 +0000
940@@ -0,0 +1,70 @@
941+/*
942+ * Copyright 2013 Canonical Ltd.
943+ *
944+ * This program is free software; you can redistribute it and/or modify
945+ * it under the terms of the GNU Lesser General Public License as published by
946+ * the Free Software Foundation; version 3.
947+ *
948+ * This program is distributed in the hope that it will be useful,
949+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
950+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
951+ * GNU Lesser General Public License for more details.
952+ *
953+ * You should have received a copy of the GNU Lesser General Public License
954+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
955+ */
956+
957+import QtQuick 2.0
958+
959+/*!
960+ \qmlabstract StyledItem
961+ \inqmlmodule Ubuntu.Components 0.1
962+ \ingroup theming
963+ \brief The StyledItem class allows items to be styled by the theme.
964+
965+ StyledItem provides facilities for making an Item stylable by the theme.
966+
967+ In order to make an Item stylable by the theme, it is enough to make the Item
968+ inherit from StyledItem and set its \l style property to be the result of the
969+ appropriate call to Theme.createStyleComponent().
970+
971+ Example definition of a custom Item MyItem.qml:
972+ \qml
973+ StyledItem {
974+ id: myItem
975+ style: Theme.createStyleComponent("MyItemStyle.qml", myItem)
976+ }
977+ \endqml
978+
979+ The Component set on \l style is instantiated and placed below everything else
980+ that the Item contains.
981+
982+ A reference to the Item being styled is accessible from the style and named
983+ 'styledItem'.
984+
985+ \sa {Theme}
986+*/
987+FocusScope {
988+ id: styledItem
989+
990+ /*!
991+ Component instantiated immediately and placed below everything else.
992+ */
993+ property Component style
994+
995+ /*!
996+ \internal
997+ Instance of the \l style.
998+ */
999+ readonly property Item __styleInstance: styleLoader.status == Loader.Ready ? styleLoader.item : null
1000+
1001+ implicitWidth: __styleInstance ? __styleInstance.implicitWidth : 0
1002+ implicitHeight: __styleInstance ? __styleInstance.implicitHeight : 0
1003+
1004+ Loader {
1005+ id: styleLoader
1006+ anchors.fill: parent
1007+ sourceComponent: style
1008+ property Item styledItem: styledItem
1009+ }
1010+}
1011
1012=== modified file 'modules/Ubuntu/Components/Switch.qml'
1013--- modules/Ubuntu/Components/Switch.qml 2013-05-24 09:12:56 +0000
1014+++ modules/Ubuntu/Components/Switch.qml 2013-07-01 22:15:52 +0000
1015@@ -19,12 +19,6 @@
1016
1017 import QtQuick 2.0
1018
1019-// FIXME: When a module contains QML, C++ and JavaScript elements exported,
1020-// we need to use named imports otherwise namespace collision is reported
1021-// by the QML engine. As workaround, we use Theming named import.
1022-// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
1023-import Ubuntu.Components 0.1 as Theming
1024-
1025 /*!
1026 \qmltype Switch
1027 \inqmlmodule Ubuntu.Components 0.1
1028@@ -47,5 +41,6 @@
1029 \endqml
1030 */
1031 CheckBox {
1032- Theming.ItemStyle.class: "switch"
1033+ id: switchItem
1034+ style: Theme.createStyleComponent("SwitchStyle.qml", switchItem)
1035 }
1036
1037=== modified file 'modules/Ubuntu/Components/Tabs.qml'
1038--- modules/Ubuntu/Components/Tabs.qml 2013-05-24 19:47:47 +0000
1039+++ modules/Ubuntu/Components/Tabs.qml 2013-07-01 22:15:52 +0000
1040@@ -15,11 +15,6 @@
1041 */
1042
1043 import QtQuick 2.0
1044-// FIXME: When a module contains QML, C++ and JavaScript elements exported,
1045-// we need to use named imports otherwise namespace collision is reported
1046-// by the QML engine. As workaround, we use Theming named import.
1047-// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
1048-import Ubuntu.Components 0.1 as Theming
1049
1050 /*!
1051 \qmltype Tabs
1052@@ -100,8 +95,6 @@
1053
1054 PageTreeNode {
1055 id: tabs
1056- // FIXME: see above
1057- Theming.ItemStyle.class: "new-tabs"
1058 anchors.fill: parent
1059
1060 /*!
1061@@ -128,7 +121,7 @@
1062 \internal
1063 Header contents that will be used to override the default title inside the header,
1064 and provides scrollable tab buttons.
1065- FIXME: headerContents may be specified here directly, not taken from the delegate.
1066+ FIXME: headerContents may be specified here directly, not taken from the style.
1067 */
1068 property Component __headerContents
1069
1070@@ -147,7 +140,7 @@
1071
1072 /*!
1073 \internal
1074- Used by the delegate to create the tabs header.
1075+ Used by the style to create the tabs header.
1076 */
1077 property alias __tabs: tabsModel.tabList
1078
1079@@ -158,7 +151,7 @@
1080 default property alias tabChildren: tabsModel.children
1081
1082 /*!
1083- Used by the tabs delegate to update the tabs header with the titles of all the tabs.
1084+ Used by the tabs style to update the tabs header with the titles of all the tabs.
1085 This signal is used in an intermediate step in transitioning the tabs to a new
1086 implementation and may be removed in the future.
1087 */
1088@@ -166,7 +159,7 @@
1089
1090 /*!
1091 \internal
1092- required by NewTabsDelegate
1093+ required by TabsStyle
1094 */
1095 Item {
1096 anchors.fill: parent
1097@@ -218,4 +211,6 @@
1098 }
1099 }
1100 }
1101+
1102+ style: Theme.createStyleComponent("TabsStyle.qml", tabs)
1103 }
1104
1105=== modified file 'modules/Ubuntu/Components/TextArea.qml'
1106--- modules/Ubuntu/Components/TextArea.qml 2013-05-19 19:23:40 +0000
1107+++ modules/Ubuntu/Components/TextArea.qml 2013-07-01 22:15:52 +0000
1108@@ -15,11 +15,6 @@
1109 */
1110
1111 import QtQuick 2.0
1112-// FIXME: When a module contains QML, C++ and JavaScript elements exported,
1113-// we need to use named imports otherwise namespace collision is reported
1114-// by the QML engine. As workaround, we use Theming named import.
1115-// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
1116-import "." 0.1 as Theming
1117
1118 /*!
1119 \qmltype TextArea
1120@@ -76,12 +71,10 @@
1121 character or word. The editor leaves the selection mode by pressing/tapping again on it
1122 or by losing focus.
1123
1124- The default styling uses \b textarea selector.
1125-
1126 \b{This component is under heavy development.}
1127 */
1128
1129-FocusScope {
1130+StyledItem {
1131 id: control
1132 implicitWidth: units.gu(30)
1133 implicitHeight: (autoSize) ? internal.minimumSize : internal.linesHeight(4)
1134@@ -96,19 +89,7 @@
1135 property bool highlighted: focus
1136 /*!
1137 Text that appears when there is no focus and no content in the component
1138- (hint text). The hint style can be customized by defining a style selector which
1139- styles a label. For example the default styling defines the hint styling using
1140- \b{.textarea .label} selector.
1141-
1142- \code
1143- .textarea .label {
1144- italic: true;
1145- color: "#B6B6B6";
1146- fontSize: "small";
1147- elide: Text.ElideRight;
1148- wrapMode: Text.WordWrap;
1149- }
1150- \endcode
1151+ (hint text).
1152
1153 \qmlproperty string placeholderText
1154 */
1155@@ -740,8 +721,6 @@
1156 // the editor activates automatically when pressed in the editor control,
1157 // however that one can be slightly spaced to the main control area
1158
1159- // styling
1160- Theming.ItemStyle.class: "textarea"
1161 //internals
1162
1163 /*!\internal */
1164@@ -766,7 +745,7 @@
1165 // public property locals enabling aliasing
1166 property string displayText: editor.getText(0, editor.length)
1167 property real lineSpacing: units.dp(3)
1168- property real frameSpacing: 0
1169+ property real frameSpacing: control.__styleInstance.frameSpacing
1170 property real lineSize: editor.font.pixelSize + lineSpacing
1171 property real minimumSize: units.gu(4)
1172 property real inputAreaWidth: control.width - 2 * frameSpacing
1173@@ -892,7 +871,6 @@
1174 id: leftCursorLoader
1175 onStatusChanged: {
1176 if (status == Loader.Ready && item) {
1177- item.Theming.ItemStyle.class = "left-pin";
1178 item.positionProperty = "selectionStart";
1179 item.parent = editor;
1180 }
1181@@ -902,7 +880,6 @@
1182 id: rightCursorLoader
1183 onStatusChanged: {
1184 if (status == Loader.Ready && item) {
1185- item.Theming.ItemStyle.class = "right-pin";
1186 item.positionProperty = "selectionEnd";
1187 item.parent = editor;
1188 }
1189@@ -922,6 +899,10 @@
1190 }
1191 // hint is shown till user types something in the field
1192 visible: (editor.getText(0, editor.length) == "") && !editor.inputMethodComposing
1193+ color: Qt.rgba(0.5, 0.5, 0.5, 0.5)
1194+ fontSize: "medium"
1195+ elide: Text.ElideRight
1196+ wrapMode: Text.WordWrap
1197 }
1198
1199 //scrollbars and flickable
1200@@ -976,6 +957,10 @@
1201 mouseSelectionMode: TextEdit.SelectWords
1202 selectByMouse: false
1203 cursorDelegate: cursor
1204+ color: control.__styleInstance.color
1205+ selectedTextColor: "#F3F3E7"
1206+ selectionColor: "#19B6EE"
1207+ font.pixelSize: FontUtils.sizeToPixels("medium")
1208 // forward keys to the root element so it can be captured outside of it
1209 Keys.forwardTo: [control]
1210
1211@@ -1034,4 +1019,6 @@
1212 }
1213 }
1214 }
1215+
1216+ style: Theme.createStyleComponent("TextAreaStyle.qml", control)
1217 }
1218
1219=== modified file 'modules/Ubuntu/Components/TextCursor.qml'
1220--- modules/Ubuntu/Components/TextCursor.qml 2013-02-13 09:36:45 +0000
1221+++ modules/Ubuntu/Components/TextCursor.qml 2013-07-01 22:15:52 +0000
1222@@ -15,12 +15,12 @@
1223 */
1224
1225 import QtQuick 2.0
1226-import "." 0.1 as Theming
1227 import "Popups" 0.1
1228
1229-Item {
1230+StyledItem {
1231 id: cursorItem
1232- Theming.ItemStyle.class: "cursor"
1233+
1234+ width: units.dp(1)
1235
1236 /*
1237 Property holding the text input item instance.
1238@@ -57,4 +57,6 @@
1239 })
1240 }
1241 }
1242+
1243+ style: Theme.createStyleComponent("TextCursorStyle.qml", cursorItem)
1244 }
1245
1246=== modified file 'modules/Ubuntu/Components/TextField.qml'
1247--- modules/Ubuntu/Components/TextField.qml 2013-06-03 13:51:10 +0000
1248+++ modules/Ubuntu/Components/TextField.qml 2013-07-01 22:15:52 +0000
1249@@ -15,11 +15,6 @@
1250 */
1251
1252 import QtQuick 2.0
1253-// FIXME: When a module contains QML, C++ and JavaScript elements exported,
1254-// we need to use named imports otherwise namespace collision is reported
1255-// by the QML engine. As workaround, we use Theming named import.
1256-// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
1257-import "." 0.1 as Theming
1258
1259 /*!
1260 \qmltype TextField
1261@@ -59,14 +54,12 @@
1262 }
1263 secondaryItem: Row {
1264 Button {
1265- ItemStyle.class: "transparent-button"
1266 height: parent.height
1267 width: height
1268 iconSource: "caps-lock.png"
1269 onClicked: doSomething()
1270 }
1271 Button {
1272- ItemStyle.class: "transparent-button"
1273 height: parent.height
1274 width: height
1275 iconSource: "num-lock.png"
1276@@ -78,7 +71,7 @@
1277 \endqml
1278 */
1279
1280-FocusScope {
1281+StyledItem {
1282 id: control
1283
1284 implicitWidth: units.gu(25)
1285@@ -519,7 +512,6 @@
1286 }
1287
1288 // internals
1289- Theming.ItemStyle.class: "textfield"
1290
1291 /*! internal */
1292 onVisibleChanged: {
1293@@ -545,7 +537,7 @@
1294 id: internal
1295 // array of borders in left, top, right, bottom order
1296 property bool textChanged: false
1297- property real spacing: 0
1298+ property real spacing: control.__styleInstance.overlaySpacing
1299 property real lineSpacing: units.dp(3)
1300 property real lineSize: editor.font.pixelSize + lineSpacing
1301 //selection properties
1302@@ -656,8 +648,7 @@
1303
1304 AbstractButton {
1305 id: clearButton
1306- Theming.ItemStyle.class: "clear-button"
1307- property url iconSource
1308+ property url iconSource: control.__styleInstance.iconSource
1309 anchors {
1310 top: parent.top
1311 right: rightPane.left
1312@@ -695,6 +686,9 @@
1313 }
1314 // hint is shown till user types something in the field
1315 visible: (editor.text == "") && !editor.inputMethodComposing
1316+ color: Qt.rgba(0.5, 0.5, 0.5, 0.5)
1317+ fontSize: "medium"
1318+ elide: Text.ElideRight
1319 }
1320
1321
1322@@ -713,6 +707,11 @@
1323 clip: true
1324 onTextChanged: internal.textChanged = true
1325 cursorDelegate: cursor
1326+ color: control.__styleInstance.color
1327+ selectedTextColor: "#F3F3E7"
1328+ selectionColor: "#19B6EE"
1329+ font.pixelSize: FontUtils.sizeToPixels("medium")
1330+ passwordCharacter: "\u2022"
1331 // forward keys to the root element so it can be captured outside of it
1332 Keys.forwardTo: [control]
1333
1334@@ -778,4 +777,6 @@
1335 editor.accepted.connect(control.accepted);
1336 cursorPosition = 0;
1337 }
1338+
1339+ style: Theme.createStyleComponent("TextFieldStyle.qml", control)
1340 }
1341
1342=== renamed directory 'themes' => 'modules/Ubuntu/Components/Themes'
1343=== renamed file 'themes/Ambiance/qmltheme/ActivityIndicatorDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/ActivityIndicatorStyle.qml'
1344--- themes/Ambiance/qmltheme/ActivityIndicatorDelegate.qml 2013-05-14 13:33:39 +0000
1345+++ modules/Ubuntu/Components/Themes/Ambiance/ActivityIndicatorStyle.qml 2013-07-01 22:15:52 +0000
1346@@ -22,13 +22,14 @@
1347
1348 anchors.fill: parent
1349 smooth: true
1350- visible: item.running
1351+ visible: styledItem.running
1352 fillMode: Image.PreserveAspectFit
1353 horizontalAlignment: Image.AlignHCenter
1354 verticalAlignment: Image.AlignVCenter
1355+ source: "artwork/spinner.png"
1356
1357 NumberAnimation on rotation {
1358- running: item.running
1359+ running: styledItem.running
1360 from: 0
1361 to: 360
1362 loops: Animation.Infinite
1363
1364=== added file 'modules/Ubuntu/Components/Themes/Ambiance/Ambiance.pro'
1365--- modules/Ubuntu/Components/Themes/Ambiance/Ambiance.pro 1970-01-01 00:00:00 +0000
1366+++ modules/Ubuntu/Components/Themes/Ambiance/Ambiance.pro 2013-07-01 22:15:52 +0000
1367@@ -0,0 +1,23 @@
1368+TEMPLATE = subdirs
1369+
1370+uri = Ubuntu.Components.Themes.Ambiance
1371+installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /)
1372+
1373+QMLDIR_FILE = qmldir
1374+QML_FILES = *.qml
1375+ARTWORK_FILES += artwork/*.png \
1376+ artwork/*.svg \
1377+ artwork/*.sci
1378+
1379+qmldir_file.path = $$installPath
1380+qmldir_file.files = $$QMLDIR_FILE
1381+
1382+qml_files.path = $$installPath
1383+qml_files.files = $$QML_FILES
1384+
1385+artwork_files.path = $$installPath/artwork
1386+artwork_files.files = $$ARTWORK_FILES
1387+
1388+
1389+INSTALLS += qmldir_file qml_files artwork_files
1390+OTHER_FILES += $$QMLDIR_FILE $$QML_FILES $$ARTWORK_FILES
1391
1392=== renamed file 'themes/Ambiance/qmltheme/ButtonDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/ButtonStyle.qml'
1393--- themes/Ambiance/qmltheme/ButtonDelegate.qml 2013-06-26 23:42:39 +0000
1394+++ modules/Ubuntu/Components/Themes/Ambiance/ButtonStyle.qml 2013-07-01 22:15:52 +0000
1395@@ -22,8 +22,8 @@
1396 anchors.fill: parent
1397
1398 // styling properties
1399- property url borderSource
1400- property url borderPressed
1401+ property url borderSource: "artwork/ubuntushape_small_radius_idle.sci"
1402+ property url borderPressed: "artwork/ubuntushape_small_radius_pressed.sci"
1403
1404 // pick either a clear or dark text color depending on the luminance of the
1405 // background color to maintain good contrast (works in most cases)
1406@@ -39,7 +39,7 @@
1407 id: border
1408
1409 anchors.fill: parent
1410- color: item.color
1411+ color: styledItem.color
1412 borderSource: visuals.borderSource
1413 opacity: 1.0 - borderPressed.opacity
1414 visible: color.a != 0.0
1415@@ -49,14 +49,14 @@
1416 id: borderPressed
1417
1418 anchors.fill: parent
1419- color: item.color
1420+ color: styledItem.color
1421 borderSource: visuals.borderPressed
1422- opacity: item.pressed ? 1.0 : 0.0
1423+ opacity: styledItem.pressed ? 1.0 : 0.0
1424 Behavior on opacity { UbuntuNumberAnimation {} }
1425 visible: color.a != 0.0
1426 }
1427
1428- TransparentButtonDelegate {
1429- textColor: __luminance(item.color) <= 0.72 ? Qt.rgba(0.95, 0.95, 0.91, 1.0) : Qt.rgba(0.2, 0.2, 0.2, 0.8)//"#333333"
1430+ TransparentButtonStyle {
1431+ textColor: __luminance(styledItem.color) <= 0.72 ? Qt.rgba(0.95, 0.95, 0.91, 1.0) : Qt.rgba(0.2, 0.2, 0.2, 0.8)//"#333333"
1432 }
1433 }
1434
1435=== renamed file 'themes/Ambiance/qmltheme/CheckBoxDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/CheckBoxStyle.qml'
1436--- themes/Ambiance/qmltheme/CheckBoxDelegate.qml 2013-07-01 12:50:42 +0000
1437+++ modules/Ubuntu/Components/Themes/Ambiance/CheckBoxStyle.qml 2013-07-01 22:15:52 +0000
1438@@ -20,24 +20,28 @@
1439 Item {
1440 id: visuals
1441 // styling properties
1442- property color checkedColor
1443- property color uncheckedColor
1444+ property color checkedColor: "#DD4814"
1445+ property color uncheckedColor: Qt.rgba(0.0, 0.0, 0.0, 0.1)
1446+
1447 /*!
1448 The image to show inside the checkbox when it is checked.
1449 */
1450- property url checkMarkSource
1451+ property url checkMarkSource: "artwork/CheckMark.png"
1452 /*!
1453 The animation to fade the color from checkedColor to uncheckedColor and vice versa.
1454 */
1455- property PropertyAnimation backgroundColorAnimation: PropertyAnimation{duration: 0}
1456+ property PropertyAnimation backgroundColorAnimation: ColorAnimation { duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing }
1457
1458 // code
1459 anchors.fill: parent
1460 opacity: enabled ? 1.0 : 0.5
1461
1462+ implicitWidth: units.gu(4)
1463+ implicitHeight: units.gu(4)
1464+
1465 UbuntuShape {
1466 anchors.fill: parent
1467- color: item.checked ? checkedColor : uncheckedColor
1468+ color: styledItem.checked ? checkedColor : uncheckedColor
1469 Behavior on color {
1470 ColorAnimation {
1471 duration: backgroundColorAnimation.duration
1472@@ -51,7 +55,7 @@
1473 anchors.centerIn: parent
1474 smooth: true
1475 source: checkMarkSource
1476- opacity: item.checked ? 1.0 : 0.0
1477+ opacity: styledItem.checked ? 1.0 : 0.0
1478 Behavior on opacity {
1479 UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
1480 }
1481
1482=== renamed file 'themes/Ambiance/qmltheme/DialogForegroundDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/DialogForegroundStyle.qml'
1483--- themes/Ambiance/qmltheme/DialogForegroundDelegate.qml 2013-06-28 13:56:45 +0000
1484+++ modules/Ubuntu/Components/Themes/Ambiance/DialogForegroundStyle.qml 2013-07-01 22:15:52 +0000
1485@@ -20,8 +20,9 @@
1486 Item {
1487 id: visuals
1488 // styling properties
1489- property color color
1490- property string radius
1491+ visible: styledItem.dismissArea.width > units.gu(60)
1492+ property color color: visible ? Qt.rgba(0, 0, 0, 0.7) : "transparent"
1493+ property string radius: "medium"
1494
1495 anchors.fill: parent
1496 z: -1
1497
1498=== renamed file 'themes/Ambiance/qmltheme/HeaderDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/HeaderStyle.qml'
1499--- themes/Ambiance/qmltheme/HeaderDelegate.qml 2013-05-06 11:18:06 +0000
1500+++ modules/Ubuntu/Components/Themes/Ambiance/HeaderStyle.qml 2013-07-01 22:15:52 +0000
1501@@ -17,7 +17,7 @@
1502 import Ubuntu.Components 0.1
1503
1504 Item {
1505- id: headerDelegate
1506+ id: headerStyle
1507 /*!
1508 The height of the headercontents, which is the full height of
1509 the header minus the separators shown at the bottom of it.
1510@@ -27,43 +27,33 @@
1511 /*!
1512 The background color of the header.
1513 */
1514- property color backgroundColor: "transparent"
1515+ property color backgroundColor: "#ededf0"
1516
1517 /*!
1518 The source of the background image of the header. If the image is has (semi-)transparent
1519 pixels, \l backgroundColor can be set to specify the color behind those (semi-)transparent
1520 pixels.
1521 */
1522- property url backgroundSource: ""
1523+ property url backgroundSource: "artwork/background_paper.png"
1524
1525 /*!
1526 The source of the image that separates the header from the contents of a \l MainView.
1527 The separator will be drawn over the contents.
1528 */
1529- property url separatorSource: ""
1530+ property url separatorSource: "artwork/PageHeaderBaseDividerLight.sci"
1531
1532 /*!
1533 The source of an additional image attached to the bottom of the separator. The contents
1534 of the \l MainView will be drawn on top of the separator bottom image.
1535 */
1536- property url separatorBottomSource: ""
1537+ property url separatorBottomSource: "artwork/PageHeaderBaseDividerBottom.png"
1538
1539- property int fontWeight
1540+ property int fontWeight: Font.Light
1541 property string fontSize: "x-large"
1542- property color textColor: "black"
1543- property real textLeftMargin
1544+ property color textColor: Qt.rgba(0.51, 0.51, 0.51, 0.9)
1545+ property real textLeftMargin: units.gu(2)
1546
1547- anchors {
1548- left: parent ? parent.left : undefined
1549- right: parent ? parent.right : undefined
1550- top: parent ? parent.top : undefined
1551- }
1552- height: headerDelegate.contentHeight + separator.height + separatorBottom.height
1553- Binding {
1554- target: item
1555- property: "height"
1556- value: height
1557- }
1558+ implicitHeight: headerStyle.contentHeight + separator.height + separatorBottom.height
1559
1560 Rectangle {
1561 id: backgroundColor
1562@@ -72,9 +62,9 @@
1563 right: parent.right
1564 top: parent.top
1565 }
1566- color: headerDelegate.backgroundColor
1567+ color: headerStyle.backgroundColor
1568 visible: color != "transparent"
1569- height: headerDelegate.contentHeight + separator.height
1570+ height: headerStyle.contentHeight + separator.height
1571 }
1572 Image {
1573 id: background
1574@@ -83,10 +73,10 @@
1575 right: parent.right
1576 top: parent.top
1577 }
1578- source: headerDelegate.backgroundSource
1579+ source: headerStyle.backgroundSource
1580 visible: source != ""
1581 fillMode: Image.Tile
1582- height: headerDelegate.contentHeight + separator.height
1583+ height: headerStyle.contentHeight + separator.height
1584 }
1585 BorderImage {
1586 id: separator
1587@@ -95,7 +85,7 @@
1588 left: parent.left
1589 right: parent.right
1590 }
1591- source: headerDelegate.separatorSource
1592+ source: headerStyle.separatorSource
1593 }
1594 Image {
1595 id: separatorBottom
1596@@ -104,7 +94,7 @@
1597 left: parent.left
1598 right: parent.right
1599 }
1600- source: headerDelegate.separatorBottomSource
1601+ source: headerStyle.separatorBottomSource
1602 }
1603
1604 Item {
1605@@ -114,23 +104,22 @@
1606 right: parent.right
1607 top: parent.top
1608 }
1609- height: headerDelegate.contentHeight
1610+ height: headerStyle.contentHeight
1611
1612 Label {
1613 anchors {
1614 left: parent.left
1615 verticalCenter: parent.verticalCenter
1616- leftMargin: headerDelegate.textLeftMargin
1617+ leftMargin: headerStyle.textLeftMargin
1618 }
1619- text: item.title
1620- font.weight: headerDelegate.fontWeight
1621+ text: styledItem.title
1622+ font.weight: headerStyle.fontWeight
1623 visible: contentsLoader.status != Loader.Ready
1624- fontSize: headerDelegate.fontSize
1625- color: headerDelegate.textColor
1626+ fontSize: headerStyle.fontSize
1627+ color: headerStyle.textColor
1628 }
1629
1630- // Link to item here, because Loader has its own item property
1631- property Header header: item
1632+ property Header header: styledItem
1633 Loader {
1634 id: contentsLoader
1635 sourceComponent: foreground.header.contents
1636
1637=== renamed file 'themes/Ambiance/qmltheme/MainViewDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/MainViewStyle.qml'
1638--- themes/Ambiance/qmltheme/MainViewDelegate.qml 2013-03-14 12:52:13 +0000
1639+++ modules/Ubuntu/Components/Themes/Ambiance/MainViewStyle.qml 2013-07-01 22:15:52 +0000
1640@@ -20,29 +20,29 @@
1641 // styling properties
1642 anchors.fill: parent
1643 z: -1
1644- id: mainViewDelegate
1645+ id: mainViewStyle
1646
1647 /*!
1648 The background color of the main view.
1649 */
1650- property color backgroundColor
1651+ property color backgroundColor: "#ededf0"
1652
1653 /*!
1654 The background texture of the main view. The image will be drawn over the background color,
1655 so if it has (semi-)transparent pixels, in those pixels the background color will be visible.
1656 */
1657- property url backgroundSource: ""
1658+ property url backgroundSource: "artwork/background_paper.png"
1659
1660 Rectangle {
1661 id: backgroundColor
1662 anchors.fill: parent
1663- color: mainViewDelegate.backgroundColor
1664+ color: mainViewStyle.backgroundColor
1665 }
1666
1667 Image {
1668 id: backgroundTexture
1669 anchors.fill: parent
1670- source: mainViewDelegate.backgroundSource
1671+ source: mainViewStyle.backgroundSource
1672 fillMode: Image.Tile
1673 }
1674 }
1675
1676=== renamed file 'themes/Ambiance/qmltheme/NewTabBar.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/NewTabBar.qml'
1677=== renamed file 'themes/Ambiance/qmltheme/PointerDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/PointerStyle.qml'
1678--- themes/Ambiance/qmltheme/PointerDelegate.qml 2013-03-14 12:01:42 +0000
1679+++ modules/Ubuntu/Components/Themes/Ambiance/PointerStyle.qml 2013-07-01 22:15:52 +0000
1680@@ -23,7 +23,11 @@
1681 id: image
1682 anchors.fill: parent
1683
1684- visible: (item.direction !== "none")
1685+ visible: (styledItem.direction !== "none")
1686+ source: (styledItem.direction === "left") ? "artwork/LeftArrow.png" :
1687+ (styledItem.direction === "right") ? "artwork/RightArrow.png" :
1688+ (styledItem.direction === "up") ? "artwork/UpArrow.png" :
1689+ "artwork/DownArrow.png"
1690
1691 smooth: true
1692 }
1693
1694=== renamed file 'themes/Ambiance/qmltheme/PointerDelegateShader.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/PointerStyleShader.qml'
1695--- themes/Ambiance/qmltheme/PointerDelegateShader.qml 2012-12-14 18:19:26 +0000
1696+++ modules/Ubuntu/Components/Themes/Ambiance/PointerStyleShader.qml 2013-07-01 22:15:52 +0000
1697@@ -29,12 +29,12 @@
1698 // but I did not manage to get a 3x3 matrix from QML into the shader.
1699
1700 // rotate pointer 90 degrees
1701- property bool rotate: (item.direction === "left" || item.direction === "right")
1702+ property bool rotate: (styledItem.direction === "left" || styledItem.direction === "right")
1703
1704 // flip the direction of the pointer
1705- property bool flip: (item.direction === "left" || item.direction === "up")
1706+ property bool flip: (styledItem.direction === "left" || styledItem.direction === "up")
1707
1708- visible: (item.direction !== "none")
1709+ visible: (styledItem.direction !== "none")
1710
1711 vertexShader: "
1712 uniform highp mat4 qt_Matrix;
1713
1714=== renamed file 'themes/Ambiance/qmltheme/PopoverForegroundDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/PopoverForegroundStyle.qml'
1715--- themes/Ambiance/qmltheme/PopoverForegroundDelegate.qml 2013-06-28 13:56:45 +0000
1716+++ modules/Ubuntu/Components/Themes/Ambiance/PopoverForegroundStyle.qml 2013-07-01 22:15:52 +0000
1717@@ -21,8 +21,8 @@
1718 Item {
1719 id: frame
1720 // styling properties
1721- property string radius: "small"
1722- property color color
1723+ property string radius: "medium"
1724+ property color color: "white"
1725
1726 property alias contentItem: body
1727
1728
1729=== renamed file 'themes/Ambiance/qmltheme/ScrollbarDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/ScrollbarStyle.qml'
1730--- themes/Ambiance/qmltheme/ScrollbarDelegate.qml 2013-03-13 12:26:20 +0000
1731+++ modules/Ubuntu/Components/Themes/Ambiance/ScrollbarStyle.qml 2013-07-01 22:15:52 +0000
1732@@ -19,7 +19,7 @@
1733
1734 /*
1735 The visuals handle both active and passive modes. This behavior is driven yet by
1736- the item's __inactive property, however should be detected upon runtime based on
1737+ the styledItem's __inactive property, however should be detected upon runtime based on
1738 the device type.
1739 On active scrollbars, positioning is handled so that the logic updates the flickable's
1740 X/Y content positions, which is then synched with the contentPosition by the main
1741@@ -63,36 +63,36 @@
1742 property real overlayOpacityWhenShown: 0.6
1743 property real overlayOpacityWhenHidden: 0.0
1744
1745- property PropertyAnimation scrollbarFadeInAnimation: PropertyAnimation{duration: 100}
1746- property PropertyAnimation scrollbarFadeOutAnimation: PropertyAnimation{duration: 100}
1747- property int scrollbarFadeOutPause: 100
1748- property PropertyAnimation sliderAnimation: PropertyAnimation{duration: 100}
1749- property PropertyAnimation thumbConnectorFading: PropertyAnimation{duration: 100}
1750- property PropertyAnimation thumbFading: PropertyAnimation{duration: 100}
1751-
1752- property color sliderColor
1753- property real sliderRadius
1754- property color thumbConnectorColor
1755- property url forwardThumbReleased
1756- property url forwardThumbPressed
1757- property url backwardThumbReleased
1758- property url backwardThumbPressed
1759-
1760- property real scrollAreaThickness
1761- property real thumbConnectorMargin
1762+ property PropertyAnimation scrollbarFadeInAnimation: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
1763+ property PropertyAnimation scrollbarFadeOutAnimation: UbuntuNumberAnimation { duration: UbuntuAnimation.SlowDuration }
1764+ property int scrollbarFadeOutPause: 300
1765+ property PropertyAnimation sliderAnimation: UbuntuNumberAnimation {}
1766+ property PropertyAnimation thumbConnectorFading: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
1767+ property PropertyAnimation thumbFading: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
1768+
1769+ property color sliderColor: Qt.rgba(0.5, 0.5, 0.5, 0.7)
1770+ property real sliderRadius: units.gu(0.5)
1771+ property color thumbConnectorColor: "white"
1772+ property url forwardThumbReleased: (styledItem.align === Qt.AlignLeading || styledItem.align === Qt.AlignTrailing) ? "artwork/ScrollbarBottomIdle.png" : "artwork/ScrollbarRightIdle.png"
1773+ property url forwardThumbPressed: (styledItem.align === Qt.AlignLeading || styledItem.align === Qt.AlignTrailing) ? "artwork/ScrollbarBottomPressed.png" : "artwork/ScrollbarRightPressed.png"
1774+ property url backwardThumbReleased: (styledItem.align === Qt.AlignLeading || styledItem.align === Qt.AlignTrailing) ? "artwork/ScrollbarTopIdle.png" : "artwork/ScrollbarLeftIdle.png"
1775+ property url backwardThumbPressed: (styledItem.align === Qt.AlignLeading || styledItem.align === Qt.AlignTrailing) ? "artwork/ScrollbarTopPressed.png" : "artwork/ScrollbarLeftPressed.png"
1776+
1777+ property real scrollAreaThickness: units.gu(0.5)
1778+ property real thumbConnectorMargin: units.dp(3)
1779
1780 // helper properties to ease code readability
1781- property Flickable flickableItem: item.flickableItem
1782- property bool isScrollable: item.__private.scrollable && pageSize > 0.0
1783+ property Flickable flickableItem: styledItem.flickableItem
1784+ property bool isScrollable: styledItem.__private.scrollable && pageSize > 0.0
1785 && contentSize > 0.0 && contentSize > pageSize
1786- property bool isVertical: ScrollbarUtils.isVertical(item)
1787- property bool frontAligned: (item.align === Qt.AlignLeading)
1788- property bool rearAligned: (item.align === Qt.AlignTrailing)
1789- property bool topAligned: (item.align === Qt.AlignTop)
1790- property bool bottomAligned: (item.align === Qt.AlignBottom)
1791+ property bool isVertical: ScrollbarUtils.isVertical(styledItem)
1792+ property bool frontAligned: (styledItem.align === Qt.AlignLeading)
1793+ property bool rearAligned: (styledItem.align === Qt.AlignTrailing)
1794+ property bool topAligned: (styledItem.align === Qt.AlignTop)
1795+ property bool bottomAligned: (styledItem.align === Qt.AlignBottom)
1796
1797- property real pageSize: (isVertical) ? item.height : item.width
1798- property real contentSize: (isVertical) ? item.flickableItem.contentHeight : item.flickableItem.contentWidth
1799+ property real pageSize: (isVertical) ? styledItem.height : styledItem.width
1800+ property real contentSize: (isVertical) ? styledItem.flickableItem.contentHeight : styledItem.flickableItem.contentWidth
1801
1802 /*****************************************
1803 Visuals
1804@@ -184,7 +184,7 @@
1805
1806 duration: 200
1807 easing.type: Easing.InOutQuad
1808- target: item.flickableItem
1809+ target: styledItem.flickableItem
1810 property: (isVertical) ? "contentY" : "contentX"
1811 }
1812
1813@@ -193,7 +193,7 @@
1814 id: scrollbarArea
1815
1816 property real thickness: scrollAreaThickness
1817- property real proximityThickness: (isVertical) ? item.width - thickness : item.height - thickness
1818+ property real proximityThickness: (isVertical) ? styledItem.width - thickness : styledItem.height - thickness
1819 anchors {
1820 fill: parent
1821 leftMargin: (!isVertical || frontAligned) ? 0 : proximityThickness
1822@@ -230,13 +230,13 @@
1823 // total size of the flickable.
1824 Item {
1825 id: scrollCursor
1826- x: (isVertical) ? 0 : ScrollbarUtils.sliderPos(item, 0.0, item.width - scrollCursor.width)
1827- y: (!isVertical) ? 0 : ScrollbarUtils.sliderPos(item, 0.0, item.height - scrollCursor.height)
1828- width: (isVertical) ? scrollbarArea.thickness : ScrollbarUtils.sliderSize(item, 0.0, flickableItem.width)
1829- height: (!isVertical) ? scrollbarArea.thickness : ScrollbarUtils.sliderSize(item, 0.0, flickableItem.height)
1830+ x: (isVertical) ? 0 : ScrollbarUtils.sliderPos(styledItem, 0.0, styledItem.width - scrollCursor.width)
1831+ y: (!isVertical) ? 0 : ScrollbarUtils.sliderPos(styledItem, 0.0, styledItem.height - scrollCursor.height)
1832+ width: (isVertical) ? scrollbarArea.thickness : ScrollbarUtils.sliderSize(styledItem, 0.0, flickableItem.width)
1833+ height: (!isVertical) ? scrollbarArea.thickness : ScrollbarUtils.sliderSize(styledItem, 0.0, flickableItem.height)
1834
1835 function drag() {
1836- ScrollbarUtils.dragAndClamp(item, scrollCursor, contentSize, pageSize);
1837+ ScrollbarUtils.dragAndClamp(styledItem, scrollCursor, contentSize, pageSize);
1838 }
1839 }
1840
1841@@ -252,10 +252,10 @@
1842 bottom: (!isVertical) ? scrollbarArea.bottom : undefined
1843 }
1844
1845- x: (isVertical) ? 0 : ScrollbarUtils.sliderPos(item, 0.0, item.width - slider.width)
1846- y: (!isVertical) ? 0 : ScrollbarUtils.sliderPos(item, 0.0, item.height - slider.height)
1847- width: (isVertical) ? scrollbarArea.thickness : ScrollbarUtils.sliderSize(item, minimumSliderSize, flickableItem.width)
1848- height: (!isVertical) ? scrollbarArea.thickness : ScrollbarUtils.sliderSize(item, minimumSliderSize, flickableItem.height)
1849+ x: (isVertical) ? 0 : ScrollbarUtils.sliderPos(styledItem, 0.0, styledItem.width - slider.width)
1850+ y: (!isVertical) ? 0 : ScrollbarUtils.sliderPos(styledItem, 0.0, styledItem.height - slider.height)
1851+ width: (isVertical) ? scrollbarArea.thickness : ScrollbarUtils.sliderSize(styledItem, minimumSliderSize, flickableItem.width)
1852+ height: (!isVertical) ? scrollbarArea.thickness : ScrollbarUtils.sliderSize(styledItem, minimumSliderSize, flickableItem.height)
1853 radius: visuals.sliderRadius
1854
1855 Behavior on width {
1856@@ -274,7 +274,7 @@
1857 }
1858
1859 function scroll(amount) {
1860- scrollAnimation.to = ScrollbarUtils.scrollAndClamp(item, amount, 0.0, contentSize - pageSize);
1861+ scrollAnimation.to = ScrollbarUtils.scrollAndClamp(styledItem, amount, 0.0, contentSize - pageSize);
1862 scrollAnimation.restart();
1863 }
1864 }
1865@@ -417,7 +417,7 @@
1866 height: childrenRect.height
1867
1868 property bool shown
1869- property int maximumPos: (isVertical) ? item.height - thumb.height : item.width - thumb.width
1870+ property int maximumPos: (isVertical) ? styledItem.height - thumb.height : styledItem.width - thumb.width
1871
1872 /* Show the thumb as close as possible to the mouse pointer */
1873 onShownChanged: {
1874
1875=== renamed file 'themes/Ambiance/qmltheme/SelectionCursorDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/SelectionCursorStyle.qml'
1876--- themes/Ambiance/qmltheme/SelectionCursorDelegate.qml 2013-03-13 15:22:23 +0000
1877+++ modules/Ubuntu/Components/Themes/Ambiance/SelectionCursorStyle.qml 2013-07-01 22:15:52 +0000
1878@@ -17,11 +17,12 @@
1879 import QtQuick 2.0
1880 import Ubuntu.Components 0.1
1881
1882-EditorCursorDelegate {
1883+EditorCursorStyle {
1884 id: cursor
1885
1886- property bool startPin: (item.positionProperty === "selectionStart")
1887- property int cursorPosition: item.editorItem[item.positionProperty]
1888+ blinking: false
1889+ property bool startPin: (styledItem.positionProperty === "selectionStart")
1890+ property int cursorPosition: styledItem.editorItem[styledItem.positionProperty]
1891
1892 visible: true
1893
1894@@ -29,7 +30,7 @@
1895 {
1896 if (undefined === pos)
1897 return;
1898- var rect = item.editorItem.positionToRectangle(pos);
1899+ var rect = styledItem.editorItem.positionToRectangle(pos);
1900 x = rect.x;
1901 y = rect.y;
1902 }
1903@@ -78,13 +79,13 @@
1904
1905 function updateEditorCursorPosition()
1906 {
1907- var pos = item.editorItem.mapFromItem(item, cursor.x, cursor.y + cursor.height / 2);
1908+ var pos = styledItem.editorItem.mapFromItem(styledItem, cursor.x, cursor.y + cursor.height / 2);
1909 var dx = dragArea.cursorStartX + dragDX;
1910 var dy = dragArea.cursorStartY + dragDY;
1911 if (startPin)
1912- item.editorItem.select(item.editorItem.positionAt(dx, dy), item.editorItem.selectionEnd);
1913+ styledItem.editorItem.select(styledItem.editorItem.positionAt(dx, dy), styledItem.editorItem.selectionEnd);
1914 else
1915- item.editorItem.select(item.editorItem.selectionStart, item.editorItem.positionAt(dx, dy));
1916+ styledItem.editorItem.select(styledItem.editorItem.selectionStart, styledItem.editorItem.positionAt(dx, dy));
1917 }
1918 }
1919 }
1920
1921=== renamed file 'themes/Ambiance/qmltheme/SheetForegroundDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/SheetForegroundStyle.qml'
1922--- themes/Ambiance/qmltheme/SheetForegroundDelegate.qml 2013-04-08 13:30:17 +0000
1923+++ modules/Ubuntu/Components/Themes/Ambiance/SheetForegroundStyle.qml 2013-07-01 22:15:52 +0000
1924@@ -20,13 +20,13 @@
1925 Item {
1926 id: visuals
1927 // styling properties
1928- property color backgroundColor
1929- property color headerColor
1930- property real headerHeight
1931- property real buttonContainerWidth
1932+ property color backgroundColor: "lightgray"
1933+ property color headerColor: "darkgray"
1934+ property real headerHeight: units.gu(8)
1935+ property real buttonContainerWidth: units.gu(14)
1936
1937- width: MathUtils.clamp(item.contentsWidth, item.minWidth, item.maxWidth)
1938- height: header.height + containerItem.height
1939+ implicitWidth: MathUtils.clamp(styledItem.contentsWidth, styledItem.minWidth, styledItem.maxWidth)
1940+ implicitHeight: header.height + containerItem.height
1941
1942 property alias contentItem: containerItem
1943
1944@@ -50,7 +50,7 @@
1945 width: headerText.implicitWidth + units.gu(4)
1946 elide: Text.ElideRight
1947 horizontalAlignment: Text.AlignHCenter
1948- text: item.title
1949+ text: styledItem.title
1950 }
1951
1952 Item {
1953@@ -61,7 +61,7 @@
1954 bottom: parent.bottom
1955 }
1956 width: visuals.buttonContainerWidth
1957- Component.onCompleted: header.updateButton(item.leftButton, leftButtonContainer)
1958+ Component.onCompleted: header.updateButton(styledItem.leftButton, leftButtonContainer)
1959 }
1960
1961 Item {
1962@@ -72,7 +72,7 @@
1963 bottom: parent.bottom
1964 }
1965 width: visuals.buttonContainerWidth
1966- Component.onCompleted: header.updateButton(item.rightButton, rightButtonContainer)
1967+ Component.onCompleted: header.updateButton(styledItem.rightButton, rightButtonContainer)
1968 }
1969
1970 function updateButton(button, container) {
1971@@ -85,16 +85,16 @@
1972 }
1973
1974 Connections {
1975- target: item
1976- onLeftButtonChanged: header.updateButton(item.leftButton, leftButtonContainer)
1977- onRightButtonChanged: header.updateButton(item.rightButton, rightButtonContainer)
1978+ target: styledItem
1979+ onLeftButtonChanged: header.updateButton(styledItem.leftButton, leftButtonContainer)
1980+ onRightButtonChanged: header.updateButton(styledItem.rightButton, rightButtonContainer)
1981 }
1982 }
1983
1984 Rectangle {
1985 id: containerItem
1986 color: visuals.backgroundColor
1987- height: MathUtils.clamp(item.contentsHeight, item.minHeight - header.height, item.maxHeight - header.height)
1988+ height: MathUtils.clamp(styledItem.contentsHeight, styledItem.minHeight - header.height, styledItem.maxHeight - header.height)
1989 anchors {
1990 top: header.bottom
1991 left: parent.left
1992
1993=== renamed file 'themes/Ambiance/qmltheme/SliderDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/SliderStyle.qml'
1994--- themes/Ambiance/qmltheme/SliderDelegate.qml 2013-03-25 14:55:38 +0000
1995+++ modules/Ubuntu/Components/Themes/Ambiance/SliderStyle.qml 2013-07-01 22:15:52 +0000
1996@@ -19,10 +19,9 @@
1997
1998 /*
1999 The default slider style consists of a bar and a thumb shape, where the thumb
2000- is having a label showing the actual value. This label can be styled using
2001- \b{.slider .label} selector.
2002+ is having a label showing the actual value.
2003
2004- This delegate is styled using the following properties:
2005+ This style is styled using the following properties:
2006 - backgroundColor: color for the slider bar
2007 - thumbColor: color for the thumb
2008 - thumbSpacing: spacing between the thumb and the bar
2009@@ -34,10 +33,10 @@
2010 id: main
2011 // styling properties
2012
2013- property color backgroundColor: "white"
2014- property color thumbColor: "darkgray"
2015- property real thumbSpacing: 0
2016- property real backgroundOpacity: 1.0
2017+ property color backgroundColor: "#c0c0c0"
2018+ property color thumbColor: "#bbbbbb"
2019+ property real thumbSpacing: units.dp(2)
2020+ property real backgroundOpacity: 0.1
2021 property real thumbOpacity: 1.0
2022
2023 // visuals
2024@@ -49,10 +48,10 @@
2025
2026 // private properties
2027
2028- property real liveValue: SliderUtils.liveValue(item)
2029- property real normalizedValue: SliderUtils.normalizedValue(item)
2030+ property real liveValue: SliderUtils.liveValue(styledItem)
2031+ property real normalizedValue: SliderUtils.normalizedValue(styledItem)
2032 property real thumbSpace: backgroundShape.width - (2.0 * thumbSpacing + thumbWidth)
2033- property real thumbWidth: item.height - thumbSpacing
2034+ property real thumbWidth: styledItem.height - thumbSpacing
2035
2036 UbuntuShape {
2037 id: backgroundShape
2038@@ -81,6 +80,9 @@
2039 right: thumbShape.right
2040 }
2041 horizontalAlignment: Text.AlignHCenter
2042- text: item.formatValue(MathUtils.clamp(liveValue, item.minimumValue, item.maximumValue))
2043+ text: styledItem.formatValue(MathUtils.clamp(liveValue, styledItem.minimumValue, styledItem.maximumValue))
2044+ fontSize: "medium"
2045+ color: "white"
2046+ font.weight: Font.Bold
2047 }
2048 }
2049
2050=== renamed file 'themes/Ambiance/qmltheme/SwitchDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/SwitchStyle.qml'
2051--- themes/Ambiance/qmltheme/SwitchDelegate.qml 2013-07-01 12:50:42 +0000
2052+++ modules/Ubuntu/Components/Themes/Ambiance/SwitchStyle.qml 2013-07-01 22:15:52 +0000
2053@@ -19,8 +19,8 @@
2054 Item {
2055 id: visuals
2056 // style properties
2057- property url crossSource
2058- property url checkMarkSource
2059+ property url crossSource: "artwork/Cross.png"
2060+ property url checkMarkSource: "artwork/CheckMark.png"
2061 /*!
2062 The opacity of the "cross" image when the switch is not checked,
2063 and opacity of the "checkMark" image when the switch is checked.
2064@@ -30,29 +30,29 @@
2065 The opacity of the "cross" image when the switch is checked,
2066 and the opacity of the "checkMark" image when the switch is not checked.
2067 */
2068- property real unselectedImageOpacity: 1.0
2069+ property real unselectedImageOpacity: 0.4
2070 /*!
2071 Spacing around the thumb.
2072 */
2073- property real thumbSpacing: units.dp(1)
2074+ property real thumbSpacing: units.dp(2)
2075 /*!
2076 Color of the thumb when the switch is checked.
2077 */
2078- property color checkedThumbColor
2079+ property color checkedThumbColor: "#DD4814"
2080 /*!
2081 Color of the thumb when the switch is not checked.
2082 */
2083- property color uncheckedThumbColor
2084+ property color uncheckedThumbColor: "#bbbbbb"
2085 /*!
2086 The animation to fade the color from checkedColor to uncheckedColor and vice versa.
2087 */
2088- property ColorAnimation thumbColorAnimation: ColorAnimation{duration: 0}
2089+ property ColorAnimation thumbColorAnimation: ColorAnimation { duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing }
2090 /*!
2091 The animation on x to move the thumb.
2092 */
2093- property NumberAnimation moveThumbAnimation: NumberAnimation{duration: 0}
2094+ property NumberAnimation moveThumbAnimation: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
2095
2096- property color backgroundColor: Qt.rgba(0.5, 0.5, 0.5, 0.5)
2097+ property color backgroundColor: Qt.rgba(0.78, 0.78, 0.78, 0.1)
2098 property real thumbWidth: units.gu(4)
2099 property real thumbHeight: units.gu(4)
2100
2101@@ -60,11 +60,18 @@
2102 anchors.fill: parent
2103 implicitWidth: 2*thumb.width + 3*thumb.spacing
2104 implicitHeight: thumb.height + 2*thumb.spacing
2105- opacity: item.enabled ? 1.0 : 0.5
2106-
2107- Component.onCompleted: {
2108- item.implicitWidth = implicitWidth;
2109- item.implicitHeight = implicitHeight;
2110+ opacity: styledItem.enabled ? 1.0 : 0.5
2111+
2112+ Binding {
2113+ target: styledItem
2114+ property: "implicitWidth"
2115+ value: implicitWidth
2116+ }
2117+
2118+ Binding {
2119+ target: styledItem
2120+ property: "implicitHeight"
2121+ value: implicitHeight
2122 }
2123
2124 UbuntuShape {
2125@@ -80,10 +87,10 @@
2126
2127 width: visuals.thumbHeight
2128 height: visuals.thumbWidth
2129- x: item.checked ? rightThumbPosition.x : leftThumbPosition.x
2130+ x: styledItem.checked ? rightThumbPosition.x : leftThumbPosition.x
2131 y: leftThumbPosition.y
2132
2133- color: item.checked ? visuals.checkedThumbColor
2134+ color: styledItem.checked ? visuals.checkedThumbColor
2135 : visuals.uncheckedThumbColor
2136
2137 Behavior on x {
2138@@ -113,7 +120,7 @@
2139
2140 Image {
2141 anchors.centerIn: parent
2142- opacity: item.checked ? visuals.unselectedImageOpacity
2143+ opacity: styledItem.checked ? visuals.unselectedImageOpacity
2144 : visuals.selectedImageOpacity
2145 source: visuals.crossSource
2146 }
2147@@ -132,7 +139,7 @@
2148
2149 Image {
2150 anchors.centerIn: parent
2151- opacity: item.checked ? visuals.selectedImageOpacity
2152+ opacity: styledItem.checked ? visuals.selectedImageOpacity
2153 : visuals.unselectedImageOpacity
2154 source: visuals.checkMarkSource
2155 }
2156
2157=== renamed file 'themes/Ambiance/qmltheme/NewTabsDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/TabsStyle.qml'
2158--- themes/Ambiance/qmltheme/NewTabsDelegate.qml 2013-05-03 21:07:40 +0000
2159+++ modules/Ubuntu/Components/Themes/Ambiance/TabsStyle.qml 2013-07-01 22:15:52 +0000
2160@@ -38,35 +38,34 @@
2161 */
2162 onSwipeToSwitchTabsChanged: print("swipeToSwitchTabs property is DEPRECATED.")
2163
2164- property color headerTextColor
2165- property color headerTextSelectedColor
2166- property real headerTextOpacity
2167- property real headerTextSelectedOpacity
2168- property int headerTextFadeDuration
2169- property string headerFontSize
2170- property int headerFontWeight
2171- property real headerTextLeftMargin
2172- property real headerTextRightMargin
2173- property real headerTextBottomMargin
2174- property url indicatorImageSource
2175- property real tabBarHeight
2176+ property color headerTextColor: "#333333"
2177+ property color headerTextSelectedColor: "#333333"
2178+ property real headerTextOpacity: 0.4
2179+ property real headerTextSelectedOpacity: 0.9
2180+ property int headerTextFadeDuration: 350
2181+ property string headerFontSize: "x-large"
2182+ property int headerFontWeight: Font.Light
2183+ property real headerTextLeftMargin: units.gu(2)
2184+ property real headerTextRightMargin: units.gu(2)
2185+ property real headerTextBottomMargin: units.gu(2)
2186+ property url indicatorImageSource: "artwork/chevron.png"
2187+ property real tabBarHeight: units.gu(7.5)
2188
2189 /*!
2190 The time of inactivity in ms before the tab bar is automatically deactivated
2191 */
2192- property int deactivateTime: 1000
2193+ property int deactivateTime: 3000
2194
2195 /*!
2196 The velocity at which buttons are repositioned when a new tab gets selected.
2197 */
2198- property real buttonPositioningVelocity
2199+ property real buttonPositioningVelocity: 1.0
2200
2201 // visuals
2202- id: tabsDelegate
2203+ id: tabsStyle
2204 anchors.fill: parent
2205
2206- // use theTabs property because item gives problems in the loader
2207- property Tabs theTabs: item
2208+ property Tabs theTabs: styledItem
2209 property Component headerContents: Component {
2210 NewTabBar {
2211 id: tabBar
2212@@ -77,23 +76,23 @@
2213 right: parent ? parent.right : undefined
2214 }
2215 //height: tabBarHeight
2216- headerTextColor: tabsDelegate.headerTextColor
2217- headerTextSelectedColor: tabsDelegate.headerTextSelectedColor
2218- headerTextOpacity: tabsDelegate.headerTextOpacity
2219- headerTextSelectedOpacity: tabsDelegate.headerTextSelectedOpacity
2220- headerTextFadeDuration: tabsDelegate.headerTextFadeDuration
2221- indicatorImageSource: tabsDelegate.indicatorImageSource
2222- headerFontSize: tabsDelegate.headerFontSize
2223- headerFontWeight: tabsDelegate.headerFontWeight
2224- headerTextLeftMargin: tabsDelegate.headerTextLeftMargin
2225- headerTextRightMargin: tabsDelegate.headerTextRightMargin
2226- headerTextBottomMargin: tabsDelegate.headerTextBottomMargin
2227- buttonPositioningVelocity: tabsDelegate.buttonPositioningVelocity
2228- deactivateTime: tabsDelegate.deactivateTime
2229+ headerTextColor: tabsStyle.headerTextColor
2230+ headerTextSelectedColor: tabsStyle.headerTextSelectedColor
2231+ headerTextOpacity: tabsStyle.headerTextOpacity
2232+ headerTextSelectedOpacity: tabsStyle.headerTextSelectedOpacity
2233+ headerTextFadeDuration: tabsStyle.headerTextFadeDuration
2234+ indicatorImageSource: tabsStyle.indicatorImageSource
2235+ headerFontSize: tabsStyle.headerFontSize
2236+ headerFontWeight: tabsStyle.headerFontWeight
2237+ headerTextLeftMargin: tabsStyle.headerTextLeftMargin
2238+ headerTextRightMargin: tabsStyle.headerTextRightMargin
2239+ headerTextBottomMargin: tabsStyle.headerTextBottomMargin
2240+ buttonPositioningVelocity: tabsStyle.buttonPositioningVelocity
2241+ deactivateTime: tabsStyle.deactivateTime
2242 }
2243 }
2244
2245 Component.onCompleted: {
2246- item.__headerContents = headerContents;
2247+ styledItem.__headerContents = headerContents;
2248 }
2249 }
2250
2251=== renamed file 'themes/Ambiance/qmltheme/TextAreaDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/TextAreaStyle.qml'
2252--- themes/Ambiance/qmltheme/TextAreaDelegate.qml 2013-04-18 05:42:22 +0000
2253+++ modules/Ubuntu/Components/Themes/Ambiance/TextAreaStyle.qml 2013-07-01 22:15:52 +0000
2254@@ -21,40 +21,30 @@
2255 Item {
2256 id: visuals
2257 // style properties
2258+ property url iconSource: "artwork/clear.svg"
2259 // FIXME: needs type checking in themes to define the proper type to be used
2260 // if color type is used, alpha value gets lost
2261
2262- property color color
2263+ property color color: (styledItem.enabled) ? "#757373" : "darkgray"
2264 /*!
2265 Background fill color
2266 */
2267- property color backgroundColor: Qt.rgba(0, 0, 0, 0.1)
2268+ property color backgroundColor: (styledItem.focus || styledItem.highlighted) ? "white" : Qt.rgba(0, 0, 0, 0.1)
2269 property color errorColor: "red"
2270- property real backgroundOpacity
2271+ property real backgroundOpacity: styledItem.enabled ? 1.0 : 0.1
2272
2273 /*!
2274 Spacing between the frame and the text editor area
2275 */
2276- property var frameSpacing
2277- property real overlaySpacing
2278+ property real frameSpacing: units.gu(1)
2279+ property real overlaySpacing: units.gu(0.5)
2280
2281 anchors.fill: parent
2282
2283- Binding {
2284- target: item.__internal
2285- property: "frameSpacing"
2286- value: visuals.frameSpacing
2287- }
2288- Binding {
2289- target: item.__internal
2290- property: "spacing"
2291- value: visuals.overlaySpacing
2292- }
2293-
2294 z: -1
2295- UbuntuShape {
2296- id: shape
2297- property bool error: (item.hasOwnProperty("errorHighlight") && item.errorHighlight && !item.acceptableInput)
2298+
2299+ property Component background: UbuntuShape {
2300+ property bool error: (styledItem.hasOwnProperty("errorHighlight") && styledItem.errorHighlight && !styledItem.acceptableInput)
2301 onErrorChanged: (error) ? visuals.errorColor : visuals.backgroundColor;
2302 color: visuals.backgroundColor;
2303 anchors.fill: parent
2304@@ -62,7 +52,13 @@
2305
2306 MouseArea {
2307 anchors.fill: parent
2308- onPressed: if (!item.activeFocus && item.activeFocusOnPress) item.forceActiveFocus()
2309+ onPressed: if (!styledItem.activeFocus && styledItem.activeFocusOnPress) styledItem.forceActiveFocus()
2310 }
2311 }
2312+
2313+ Loader {
2314+ id: backgroundLoader
2315+ sourceComponent: background
2316+ anchors.fill: parent
2317+ }
2318 }
2319
2320=== renamed file 'themes/Ambiance/qmltheme/EditorCursorDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/TextCursorStyle.qml'
2321--- themes/Ambiance/qmltheme/EditorCursorDelegate.qml 2013-05-20 09:06:47 +0000
2322+++ modules/Ubuntu/Components/Themes/Ambiance/TextCursorStyle.qml 2013-07-01 22:15:52 +0000
2323@@ -21,28 +21,28 @@
2324 /*!
2325 Cursor color
2326 */
2327- property color color
2328+ property color color: Qt.rgba(0.4, 0.4, 0.4, 1.0)
2329
2330 /*!
2331 Properties driving cursor blinking. If either of these values are 0, no
2332 blinking is provided.
2333 */
2334- property bool blinking
2335- property int blinkTimeoutShown
2336- property int blinkTimeoutHidden
2337+ property bool blinking: true
2338+ property int blinkTimeoutShown: 800
2339+ property int blinkTimeoutHidden: 400
2340
2341 /*!
2342 Selection mode pin styles
2343 */
2344- property var pinSize
2345- property var pinSensingOffset
2346- property color pinColor
2347+ property var pinSize: units.gu(1.2)
2348+ property var pinSensingOffset: units.dp(4)
2349+ property color pinColor: "blue"
2350
2351 anchors.fill: parent
2352 Rectangle {
2353 id: cursor
2354
2355- property bool showCursor: item.visible
2356+ property bool showCursor: styledItem.visible
2357 property bool timerShowCursor: true
2358
2359 visible: showCursor && timerShowCursor
2360
2361=== added file 'modules/Ubuntu/Components/Themes/Ambiance/TextFieldStyle.qml'
2362--- modules/Ubuntu/Components/Themes/Ambiance/TextFieldStyle.qml 1970-01-01 00:00:00 +0000
2363+++ modules/Ubuntu/Components/Themes/Ambiance/TextFieldStyle.qml 2013-07-01 22:15:52 +0000
2364@@ -0,0 +1,20 @@
2365+/*
2366+ * Copyright 2013 Canonical Ltd.
2367+ *
2368+ * This program is free software; you can redistribute it and/or modify
2369+ * it under the terms of the GNU Lesser General Public License as published by
2370+ * the Free Software Foundation; version 3.
2371+ *
2372+ * This program is distributed in the hope that it will be useful,
2373+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2374+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2375+ * GNU Lesser General Public License for more details.
2376+ *
2377+ * You should have received a copy of the GNU Lesser General Public License
2378+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2379+ */
2380+
2381+import QtQuick 2.0
2382+
2383+TextAreaStyle {
2384+}
2385
2386=== renamed file 'themes/Ambiance/qmltheme/ToolbarButtonDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/ToolbarButtonStyle.qml'
2387--- themes/Ambiance/qmltheme/ToolbarButtonDelegate.qml 2013-04-29 18:36:03 +0000
2388+++ modules/Ubuntu/Components/Themes/Ambiance/ToolbarButtonStyle.qml 2013-07-01 22:15:52 +0000
2389@@ -20,15 +20,15 @@
2390 Item {
2391 id: visuals
2392 // styling properties
2393- property int iconWidth: 0
2394- property int iconHeight: 0
2395+ property int iconWidth: units.gu(2)
2396+ property int iconHeight: units.gu(2)
2397
2398 anchors.fill: parent
2399
2400 Item {
2401 anchors.centerIn: parent
2402 height: icon.height + label.height + label.anchors.topMargin
2403- opacity: item.enabled ? 1.0 : 0.3
2404+ opacity: styledItem.enabled ? 1.0 : 0.3
2405
2406 Image {
2407 id: icon
2408@@ -38,7 +38,7 @@
2409 }
2410 width: iconWidth
2411 height: iconWidth
2412- source: item.iconSource
2413+ source: styledItem.iconSource
2414 }
2415
2416 Label {
2417@@ -49,9 +49,11 @@
2418 topMargin: units.gu(1)
2419 }
2420 width: paintedWidth
2421- text: item.text
2422+ text: styledItem.text
2423+ fontSize: "x-small"
2424+ color: "#888888"
2425 }
2426 }
2427
2428- Component.onCompleted: item.implicitWidth = implicitWidth
2429+ Component.onCompleted: styledItem.implicitWidth = implicitWidth
2430 }
2431
2432=== renamed file 'themes/Ambiance/qmltheme/ToolbarDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/ToolbarStyle.qml'
2433--- themes/Ambiance/qmltheme/ToolbarDelegate.qml 2013-05-14 13:33:39 +0000
2434+++ modules/Ubuntu/Components/Themes/Ambiance/ToolbarStyle.qml 2013-07-01 22:15:52 +0000
2435@@ -19,11 +19,10 @@
2436 Item {
2437 id: visuals
2438 // styling properties
2439- property color color
2440- property real barOpacity
2441+ property color color: "white"
2442+ property real barOpacity: 0.9
2443
2444 anchors.fill: parent
2445- property alias contentItem: background
2446
2447 Rectangle {
2448 id: background
2449@@ -40,7 +39,7 @@
2450 bottom: background.top
2451 }
2452 source: Qt.resolvedUrl("artwork/toolbar_dropshadow.png")
2453- opacity: item.opened || item.animating ? 0.5 : 0.0
2454+ opacity: styledItem.opened || styledItem.animating ? 0.5 : 0.0
2455 Behavior on opacity {
2456 UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
2457 }
2458
2459=== renamed file 'themes/Ambiance/qmltheme/TransparentButtonDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/TransparentButtonStyle.qml'
2460--- themes/Ambiance/qmltheme/TransparentButtonDelegate.qml 2013-01-28 16:40:37 +0000
2461+++ modules/Ubuntu/Components/Themes/Ambiance/TransparentButtonStyle.qml 2013-07-01 22:15:52 +0000
2462@@ -28,31 +28,31 @@
2463 The padding on the left and right side of the button foreground.
2464 */
2465 property real horizontalPadding: units.gu(2)
2466- property real maximumWidth: item.width - 2*foreground.horizontalPadding
2467- property real spacing: (item.text == "" || item.iconSource == "") ? 0 : units.gu(1)
2468+ property real maximumWidth: styledItem.width - 2*foreground.horizontalPadding
2469+ property real spacing: (styledItem.text == "" || styledItem.iconSource == "") ? 0 : units.gu(1)
2470 property real verticalPadding: units.gu(0.5)
2471
2472 width: icon.width + label.width + foreground.spacing
2473- height: item.height - 2*foreground.verticalPadding
2474+ height: styledItem.height - 2*foreground.verticalPadding
2475 implicitWidth: icon.width + label.implicitWidth + foreground.spacing
2476
2477 Image {
2478 id: icon
2479- source: item.iconSource
2480+ source: styledItem.iconSource
2481 fillMode: Image.PreserveAspectFit
2482 anchors.verticalCenter: foreground.verticalCenter
2483- opacity: item.enabled ? 1.0 : 0.5
2484+ opacity: styledItem.enabled ? 1.0 : 0.5
2485 }
2486
2487 Label {
2488 id: label
2489- text: item.text
2490+ text: styledItem.text
2491 anchors {
2492 verticalCenter: foreground.verticalCenter
2493 verticalCenterOffset: units.dp(-1)
2494 }
2495 fontSize: "medium"
2496- opacity: item.enabled ? 1.0 : 0.5
2497+ opacity: styledItem.enabled ? 1.0 : 0.5
2498 elide: Text.ElideRight
2499
2500 property real availableWidth: foreground.maximumWidth - icon.width - foreground.spacing
2501@@ -97,6 +97,6 @@
2502 }
2503 }
2504 ]
2505- state: (item.iconSource == "" || item.text == "") ? "center" : item.iconPosition
2506+ state: (styledItem.iconSource == "" || styledItem.text == "") ? "center" : styledItem.iconPosition
2507 }
2508 }
2509
2510=== renamed directory 'themes/Ambiance/qmltheme/artwork' => 'modules/Ubuntu/Components/Themes/Ambiance/artwork'
2511=== renamed file 'themes/Ambiance/qmltheme/qmldir' => 'modules/Ubuntu/Components/Themes/Ambiance/qmldir'
2512--- themes/Ambiance/qmltheme/qmldir 2013-06-29 19:10:44 +0000
2513+++ modules/Ubuntu/Components/Themes/Ambiance/qmldir 2013-07-01 22:15:52 +0000
2514@@ -1,32 +1,22 @@
2515-module qmltheme
2516-ButtonStyle 0.1 ButtonStyle.qml
2517-ButtonDelegate 0.1 ButtonDelegate.qml
2518-ToolbarDelegate 0.1 ToolbarDelegate.qml
2519-ToolbarButtonDelegate 0.1 ToolbarButtonDelegate.qml
2520-HeaderDelegate 0.1 HeaderDelegate.qml
2521-MainViewDelegate 0.1 MainViewDelegate.qml
2522-CheckBoxStyle 0.1 CheckBoxStyle.qml
2523-CheckBoxDelegate 0.1 CheckBoxDelegate.qml
2524-SwitchStyle 0.1 SwitchStyle.qml
2525-SwitchDelegate 0.1 SwitchDelegate.qml
2526-NewTabBar 0.1 NewTabBar.qml
2527-NewTabsDelegate 0.1 NewTabsDelegate.qml
2528-NewTabsStyle 0.1 NewTabsStyle.qml
2529-TransparentButtonDelegate 0.1 TransparentButtonDelegate.qml
2530-UbuntuShapeStyle 0.1 UbuntuShapeStyle.qml
2531-DialogForegroundDelegate 0.1 DialogForegroundDelegate.qml
2532-PopoverForegroundDelegate 0.1 PopoverForegroundDelegate.qml
2533-SheetForegroundDelegate 0.1 SheetForegroundDelegate.qml
2534-PointerDelegate 0.1 PointerDelegate.qml
2535-ScrollbarStyle 0.1 ScrollbarStyle.qml
2536-ScrollbarDelegate 0.1 ScrollbarDelegate.qml
2537-ScrollSliderSizer 0.1 ScrollSliderSizer.qml
2538+module Ubuntu.Components.Themes.Ambiance
2539+internal ActivityIndicatorStyle ActivityIndicatorStyle.qml
2540+internal ButtonStyle ButtonStyle.qml
2541+internal CheckBoxStyle CheckBoxStyle.qml
2542+internal DialogForegroundStyle DialogForegroundStyle.qml
2543+internal HeaderStyle HeaderStyle.qml
2544+internal MainViewStyle MainViewStyle.qml
2545+internal PointerStyle PointerStyle.qml
2546+internal PointerStyleShader PointerStyleShader.qml
2547+internal PopoverForegroundStyle PopoverForegroundStyle.qml
2548+internal ScrollbarStyle ScrollbarStyle.qml
2549+internal SelectionCursorStyle SelectionCursorStyle.qml
2550+internal SheetForegroundStyle SheetForegroundStyle.qml
2551+internal SliderStyle SliderStyle.qml
2552+internal SwitchStyle SwitchStyle.qml
2553+TextAreaStyle 0.1 TextAreaStyle.qml
2554+internal TextCursorStyle TextCursorStyle.qml
2555 TextFieldStyle 0.1 TextFieldStyle.qml
2556-TextFieldDelegate 0.1 TextFieldDelegate.qml
2557-EditorCursorStyle 0.1 EditorCursorStyle.qml
2558-EditorCursorDelegate 0.1 EditorCursorDelegate.qml
2559-SelectionCursorDelegate 0.1 SelectionCursorDelegate.qml
2560-TextAreaStyle 0.1 TextAreaStyle.qml
2561-TextAreaDelegate 0.1 TextAreaDelegate.qml
2562-SliderDelegate 0.1 SliderDelegate.qml
2563-ActivityIndicatorDelegate 0.1 ActivityIndicatorDelegate.qml
2564+internal ToolbarButtonStyle ToolbarButtonStyle.qml
2565+internal ToolbarStyle ToolbarStyle.qml
2566+internal TransparentButtonStyle TransparentButtonStyle.qml
2567+
2568
2569=== renamed file 'themes/themes.pro' => 'modules/Ubuntu/Components/Themes/Themes.pro'
2570--- themes/themes.pro 2013-06-28 16:33:57 +0000
2571+++ modules/Ubuntu/Components/Themes/Themes.pro 2013-07-01 22:15:52 +0000
2572@@ -1,26 +1,2 @@
2573 TEMPLATE = subdirs
2574-
2575-THEME_FILES = Ambiance/qmltheme/*.qmltheme
2576-QML_FILES = $$system(ls Ambiance/qmltheme/*.qml)
2577-QML_FILES += $$system(ls Ambiance/qmltheme/*.js)
2578-QMLDIR_FILE = Ambiance/qmltheme/qmldir
2579-
2580-OTHER_FILES += $$THEME_FILES $$QML_FILES $$QMLDIR_FILE
2581-
2582-theme_files.path = /usr/share/themes/Ambiance/qmltheme
2583-theme_files.files = $$THEME_FILES
2584-
2585-ARTWORK_FILES += \
2586- Ambiance/qmltheme/artwork/*.png \
2587- Ambiance/qmltheme/artwork/*.svg \
2588- Ambiance/qmltheme/artwork/*.sci
2589-theme_artworks.path = /usr/share/themes/Ambiance/qmltheme/artwork
2590-theme_artworks.files = $$ARTWORK_FILES
2591-
2592-qmldir_file.path = /usr/share/themes/Ambiance/qmltheme
2593-qmldir_file.files = $$QMLDIR_FILE
2594-
2595-qml_files.path = /usr/share/themes/Ambiance/qmltheme
2596-qml_files.files = $$QML_FILES
2597-
2598-INSTALLS += theme_files theme_artworks qmldir_file qml_files
2599+SUBDIRS += Ambiance
2600
2601=== modified file 'modules/Ubuntu/Components/Toolbar.qml'
2602--- modules/Ubuntu/Components/Toolbar.qml 2013-06-19 10:17:28 +0000
2603+++ modules/Ubuntu/Components/Toolbar.qml 2013-07-01 22:15:52 +0000
2604@@ -15,11 +15,6 @@
2605 */
2606
2607 import QtQuick 2.0
2608-// FIXME: When a module contains QML, C++ and JavaScript elements exported,
2609-// we need to use named imports otherwise namespace collision is reported
2610-// by the QML engine. As workaround, we use Theming named import.
2611-// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
2612-import Ubuntu.Components 0.1 as Theming
2613
2614 /*!
2615 \internal
2616@@ -111,7 +106,7 @@
2617 }
2618 }
2619
2620- Item {
2621+ StyledItem {
2622 // FIXME:
2623 // All theming items go into the background because only the children
2624 // of the Panel are being shown/hidden while the toolbar
2625@@ -124,10 +119,11 @@
2626 }
2627 height: units.gu(8)
2628
2629- Theming.ItemStyle.class: "toolbar"
2630- // The values of opened and animated properties are used in the delegate
2631+ // The values of opened and animated properties are used in the style
2632 property bool opened: toolbar.opened
2633 property bool animating: toolbar.animating
2634+
2635+ style: Theme.createStyleComponent("ToolbarStyle.qml", background)
2636 }
2637
2638 Item {
2639
2640=== modified file 'modules/Ubuntu/Components/ToolbarActions.qml'
2641--- modules/Ubuntu/Components/ToolbarActions.qml 2013-06-17 17:34:41 +0000
2642+++ modules/Ubuntu/Components/ToolbarActions.qml 2013-07-01 22:15:52 +0000
2643@@ -246,7 +246,7 @@
2644 // Disable the mouse area so swipes on the button will not be blocked
2645 // from going to the toolbar. The panel will take care calling the button's clicked().
2646 __mouseArea.visible: false
2647- Theming.ItemStyle.class: "toolbar-button"
2648+ style: Theme.createStyleComponent("ToolbarButtonStyle.qml", toolButton)
2649 width: visible ? units.gu(5) : 0
2650 height: toolbarActions.height
2651 }
2652
2653=== modified file 'modules/Ubuntu/Components/ToolbarButton.qml'
2654--- modules/Ubuntu/Components/ToolbarButton.qml 2013-06-14 16:28:04 +0000
2655+++ modules/Ubuntu/Components/ToolbarButton.qml 2013-07-01 22:15:52 +0000
2656@@ -15,11 +15,6 @@
2657 */
2658
2659 import QtQuick 2.0
2660-// FIXME: When a module contains QML, C++ and JavaScript elements exported,
2661-// we need to use named imports otherwise namespace collision is reported
2662-// by the QML engine. As workaround, we use Theming named import.
2663-// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
2664-import Ubuntu.Components 0.1 as Theming
2665
2666 /*!
2667 \qmltype ToolbarButton
2668@@ -85,7 +80,8 @@
2669 */
2670 ActionItem {
2671 id: toolbarButton
2672- Theming.ItemStyle.class: "toolbar-button"
2673 height: parent ? parent.height : undefined
2674 width: units.gu(5)
2675+
2676+ style: Theme.createStyleComponent("ToolbarButtonStyle.qml", toolbarButton)
2677 }
2678
2679=== modified file 'modules/Ubuntu/Components/ToolbarItems.qml'
2680--- modules/Ubuntu/Components/ToolbarItems.qml 2013-06-17 12:36:11 +0000
2681+++ modules/Ubuntu/Components/ToolbarItems.qml 2013-07-01 22:15:52 +0000
2682@@ -15,11 +15,6 @@
2683 */
2684
2685 import QtQuick 2.0
2686-// FIXME: When a module contains QML, C++ and JavaScript elements exported,
2687-// we need to use named imports otherwise namespace collision is reported
2688-// by the QML engine. As workaround, we use Theming named import.
2689-// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
2690-import Ubuntu.Components 0.1 as Theming
2691
2692 /*!
2693 \qmltype ToolbarItems
2694
2695=== modified file 'modules/Ubuntu/Components/overview.qdoc'
2696--- modules/Ubuntu/Components/overview.qdoc 2013-06-27 12:54:26 +0000
2697+++ modules/Ubuntu/Components/overview.qdoc 2013-07-01 22:15:52 +0000
2698@@ -20,8 +20,6 @@
2699
2700 \part General Topics
2701 \list
2702- \li \l{theming-components.html}{Theming} describes the styling capabilities
2703- provided by the toolkit.
2704 \li \l{ubuntu-layouts.html}{Layouts} describes a flexible layouting engine
2705 to ease the development of responsive user interfaces.
2706 \li \l {Resolution Independence} describes the facilities that should be
2707
2708=== removed file 'modules/Ubuntu/Components/plugin/itemstyleattached.cpp'
2709--- modules/Ubuntu/Components/plugin/itemstyleattached.cpp 2013-05-20 09:06:47 +0000
2710+++ modules/Ubuntu/Components/plugin/itemstyleattached.cpp 1970-01-01 00:00:00 +0000
2711@@ -1,715 +0,0 @@
2712-/*
2713- * Copyright 2012 Canonical Ltd.
2714- *
2715- * This program is free software; you can redistribute it and/or modify
2716- * it under the terms of the GNU Lesser General Public License as published by
2717- * the Free Software Foundation; version 3.
2718- *
2719- * This program is distributed in the hope that it will be useful,
2720- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2721- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2722- * GNU Lesser General Public License for more details.
2723- *
2724- * You should have received a copy of the GNU Lesser General Public License
2725- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2726- *
2727- * Author: Zsombor Egri <zsombor.egri@canonical.com>
2728- */
2729-
2730-#include <QtQml/QQmlComponent>
2731-#include <QtQml/QQmlContext>
2732-#include <QtQml/QQmlEngine>
2733-#include <QtQml/QQmlInfo>
2734-#include <QtQuick/QQuickItem>
2735-
2736-#include "itemstyleattached.h"
2737-#include "itemstyleattached_p.h"
2738-#include "themeengine.h"
2739-#include "themeengine_p.h"
2740-#include "quickutils.h"
2741-
2742-#include <private/qqmlproperty_p.h>
2743-#include <private/qqmlcomponentattached_p.h>
2744-
2745-const char *itemProperty = "item";
2746-
2747-/*!
2748- \qmltype ItemStyle
2749- \inqmlmodule Ubuntu.Components 0.1
2750- \ingroup theming
2751- \brief The ItemStyle attached property contains styling properties for a
2752- particular UI element.
2753-
2754- The element provides styling support to any element derived from Item
2755- (QQuickItem).
2756- The style is selected based on the \a class and \a name properties. If neither
2757- of these is defined, the framework will use the meta class name to identify the
2758- style rule to be used. However this can happen only if the document defining the
2759- item refers to the styling attached property.
2760-
2761- The following items will use styling as they declare and refer to styling
2762- attached properties, and styling Text can be done by defining the ".Text"
2763- selector.
2764-
2765- \qml
2766- Item {
2767- ItemStyle.class: "button"
2768- }
2769- \endqml
2770- \qml
2771- Text {
2772- ItemStyle.class: "text"
2773- }
2774- \endqml
2775-
2776- An item can use private styling by setting the style and/or the delegate property
2777- locally. In this case the item won't use the theme defined style/delegate but will
2778- use the styling elements defined locally. Switching back to theme defined styles
2779- can be achieved by clearing the style/delegate property. It is also possible to
2780- set only one of the styling elements locally and use the theme defined one for
2781- the other.
2782-
2783- \qml
2784- // Button.qml
2785- Item {
2786- id: root
2787- property bool pressed: false
2788- property bool hovered: false
2789- property color color: "lightgray"
2790-
2791- signal clicked
2792-
2793- MouseArea {
2794- anchors.fill: parent
2795- onClicked: control.clicked()
2796- }
2797- }
2798- \endqml
2799- In the example above the Button document refers to the style property of the attached
2800- styling, therefore the element by default will use the style defined using
2801- the ".button" selector.
2802-
2803- The following example shows a Button item that uses a private delegate but the
2804- styles from the themes.
2805-
2806- \qml
2807- Button {
2808- id: control
2809- ItemStyle.delegate: Rectangle {
2810- anchors.fill: parent
2811- color: ItemStyle.style.color
2812- radius: 15
2813- border {
2814- width: 2
2815- color: Qt.darker(color, 1.4)
2816- }
2817- }
2818- }
2819- \endqml
2820-
2821- Attached styling defines a context property which can be used from delegates and
2822- also in style declaration to access the item properties. This property is called
2823- \b item.
2824-*/
2825-
2826-
2827-ItemStyleAttachedPrivate::ItemStyleAttachedPrivate(ItemStyleAttached *qq, QObject *attached):
2828- q_ptr(qq),
2829- attachee(qobject_cast<QQuickItem*>(attached)),
2830- style(0),
2831- delegate(0),
2832- styleRule(0),
2833- completed(false),
2834- customStyle(false),
2835- customDelegate(false),
2836- connectedToEngine(false)
2837-{
2838- styleClass = QuickUtils::instance().className(attachee).toLower();
2839- // refresh style upon reparenting!
2840- // there is no reason to do styling till the parent is not set and this applies
2841- // to the root objects too as even those have an internal parent
2842- QObject::connect(attachee, SIGNAL(parentChanged(QQuickItem*)), q_ptr, SLOT(_q_reapplyStyling(QQuickItem*)));
2843-
2844- // connect to one of the attached components to receive completion
2845- QQmlComponentAttached *component = QQmlComponent::qmlAttachedProperties(attachee);
2846- if (component) {
2847- QObject::connect(component, SIGNAL(completed()), q_ptr, SLOT(_q_refreshStyle()));
2848- } else {
2849- qmlInfo(q_ptr) << "WARNING: no attached component found for " << styleClass;
2850- }
2851-
2852- listenThemeEngine();
2853-
2854- //enum attachee properties and watch them
2855- watchAttacheeProperties();
2856-}
2857-
2858-ItemStyleAttachedPrivate::~ItemStyleAttachedPrivate()
2859-{
2860- // remove name from the theming engine
2861- if (!styleId.isEmpty())
2862- ThemeEnginePrivate::registerName(attachee, QString());
2863- resetDelegate();
2864- resetStyle();
2865-}
2866-
2867-/*!
2868- * \internal
2869- * Enumerates attachee properties and marks them all candidates for styling. Connects
2870- * each property's notify signal so we get notified when those are binded in QML, so we
2871- * won't alter their value.
2872- */
2873-void ItemStyleAttachedPrivate::watchAttacheeProperties()
2874-{
2875- Q_Q(ItemStyleAttached);
2876- // enumerate properties and figure out which one has binding
2877- const QMetaObject *mo = attachee->metaObject();
2878- QMetaMethod onAttacheePropertyChanged = q->metaObject()->method(q->metaObject()->indexOfSlot("_q_attacheePropertyChanged()"));
2879- for (int i = 0; i < mo->propertyCount(); i++) {
2880- const QMetaProperty prop = mo->property(i);
2881-
2882- if (!prop.hasNotifySignal() || UCStyle::omitProperty(prop.name())) {
2883- continue;
2884- }
2885-
2886- QQmlProperty qmlProp(attachee, prop.name(), QQmlEngine::contextForObject(attachee));
2887- QQmlAbstractBinding *binding = QQmlPropertyPrivate::binding(qmlProp);
2888- if (binding) {
2889- // mark as first time bound, so further styling can unbind it and do styling
2890- watchedProperties.mark(i, StyledPropertyMap::Bound, binding);
2891- } else {
2892- watchedProperties.mark(i, StyledPropertyMap::Enabled);
2893- }
2894-
2895- if (QLatin1String(prop.name()) == QLatin1String("font")) {
2896- // never ban the font property from being styled
2897- continue;
2898- }
2899-
2900- // connect property's notify signal to watch when it gets changed so we can stop watching it
2901- QObject::connect(attachee, prop.notifySignal(), q, onAttacheePropertyChanged);
2902- }
2903-}
2904-
2905-/*!
2906- * \internal
2907- * Captures attachee property changes which are to be removed from stylable ones.
2908- */
2909-void ItemStyleAttachedPrivate::_q_attacheePropertyChanged()
2910-{
2911- Q_Q(ItemStyleAttached);
2912-
2913- const QMetaObject *mo = attachee->metaObject();
2914- QMetaMethod signal = mo->method(q->senderSignalIndex());
2915- QString property = QString(signal.name()).remove("Changed");
2916-
2917- // was the property change invoked by the style update, exit
2918- if (style && style->isUpdating(property))
2919- return;
2920-
2921- int index = mo->indexOfProperty(property.toLatin1());
2922- if (watchedProperties.isBanned(index))
2923- return;
2924-
2925- // ban property from being styled
2926- watchedProperties.mark(index, StyledPropertyMap::Banned);
2927-
2928- // unbind style from attachee
2929- if (style)
2930- style->unbindProperty(property);
2931-}
2932-
2933-bool ItemStyleAttachedPrivate::updateStyle()
2934-{
2935- bool result = false;
2936- // do not do anything till the component gets complete?
2937- if (!completed)
2938- return result;
2939-
2940- if (!customStyle) {
2941- // make sure we have a theme
2942- if (styleRule && styleRule->style) {
2943- QQmlContext *context = new QQmlContext(qmlContext(attachee));
2944- context->setContextProperty(itemProperty, attachee);
2945- QObject *obj = styleRule->style->create(context);
2946- style = qobject_cast<UCStyle*>(obj);
2947- if (!style) {
2948- delete obj;
2949- delete context;
2950- } else {
2951- // set style as parent for the context so it gets deleted together with the style
2952- context->setParent(style);
2953- // set owner so we know that the style object has been created by theming
2954- style->setOwner(attachee);
2955- }
2956- result = (style != 0);
2957- }
2958- } else
2959- result = true;
2960-
2961- // reparent also custom styles!
2962- if (result && style) {
2963- style->bindItem(attachee, watchedProperties, true);
2964- style->bindItem(delegate, watchedProperties, false);
2965- }
2966- return result;
2967-}
2968-
2969-bool ItemStyleAttachedPrivate::updateDelegate()
2970-{
2971- bool result = false;
2972- // do not do anything till the component gets complete?
2973- if (!completed)
2974- return result;
2975-
2976- if (!customDelegate) {
2977- // make sure we have a theme
2978- if (styleRule && styleRule->delegate) {
2979- QQmlContext * context = new QQmlContext(qmlContext(attachee));
2980- context->setContextProperty(itemProperty, attachee);
2981- delegate = qobject_cast<QQuickItem*>(styleRule->delegate->create(context));
2982- if (delegate) {
2983- // set delegate as parent for the context so it gets deleted together with the style
2984- context->setParent(delegate);
2985- // set delegate's parent to attachee
2986- delegate->setParent(attachee);
2987- } else {
2988- delete context;
2989- }
2990- result = (delegate != 0);
2991- }
2992- } else
2993- result = true;
2994-
2995- if (delegate && ((delegate->parent() != attachee) || (delegate->parentItem() != attachee))) {
2996- delegate->setParentItem(attachee);
2997- // If style item contains a property "contentItem" that points
2998- // to an item, reparent all children into it:
2999- QVariant contentVariant = delegate->property("contentItem");
3000- QQuickItem *contentItem = qvariant_cast<QQuickItem *>(contentVariant);
3001- if (contentItem) {
3002- Q_FOREACH (QObject *child, attachee->children()) {
3003- QQuickItem *childItem = qobject_cast<QQuickItem *>(child);
3004- if (childItem && (childItem != delegate))
3005- childItem->setParentItem(contentItem);
3006- }
3007- }
3008- // setup property "bindings" towards delegate properties
3009- if (style)
3010- style->bindItem(delegate, watchedProperties, false);
3011- }
3012- return result;
3013-}
3014-
3015-/*!
3016- \internal
3017- Updates the style and delegate variables. The style update is forced
3018- when the item changes the style lookup from private to theme.
3019-*/
3020-int ItemStyleAttachedPrivate::updateTheme()
3021-{
3022- int result = NoUpdate;
3023- // check if the new rule differs from the previous one
3024- StyleCache::StyleData *newRule = ThemeEnginePrivate::styleRuleForPath(styleSelector);
3025- if (newRule && (styleRule != newRule)) {
3026- // check what has been changed
3027- bool styleChanged = (!styleRule || (styleRule && (styleRule->style != newRule->style)));
3028- bool delegateChanged = (!styleRule || (styleRule && (styleRule->delegate != newRule->delegate)));
3029- styleRule = newRule;
3030-
3031- // the order is: clean up delegate then style, then create style and then delegate
3032- // so that when delegate is built we already have the styles ready for that
3033- if (delegateChanged) {
3034- resetDelegate();
3035- }
3036- if (styleChanged) {
3037- resetStyle();
3038- styleChanged = updateStyle();
3039- }
3040- if (delegateChanged) {
3041- delegateChanged = updateDelegate();
3042- } else if (style) {
3043- style->bindItem(delegate, watchedProperties, false);
3044- }
3045- if (styleChanged || delegateChanged) {
3046- if (styleChanged) {
3047- result |= StyleUpdated;
3048- }
3049- if (delegateChanged) {
3050- result |= DelegateUpdated;
3051- }
3052- Q_Q(ItemStyleAttached);
3053- Q_EMIT q->styleChanged();
3054- }
3055- }
3056- return result;
3057-}
3058-
3059-void ItemStyleAttachedPrivate::resetStyle()
3060-{
3061- if (!style)
3062- return;
3063- // clear bindings, disconnect as properties may change before the style
3064- // is deleted
3065- style->unbindItem(delegate);
3066- style->unbindItem(attachee);
3067-
3068- // delete style also if there is an owner set to it
3069- if (!customStyle || style->owner()) {
3070- // reset style object before we delete it, themed animations may get changed
3071- // during the style deletion which will cause invalid pointer operations
3072- // in style bindings cleanup
3073- // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1175394
3074- QObject *object = style;
3075- style = 0;
3076- delete object;
3077- }
3078-}
3079-
3080-void ItemStyleAttachedPrivate::resetDelegate()
3081-{
3082- if (!delegate)
3083- return;
3084- // remove all bindings between style and delegate
3085- if (style)
3086- style->unbindItem(delegate);
3087-
3088- // delete delegate also if there is an owner set to it
3089- if (!customDelegate || (delegate->parent() == attachee)) {
3090- delegate->setParent(0);
3091- delegate->setParentItem(0);
3092- delete delegate;
3093- delegate = 0;
3094- }
3095-}
3096-
3097-/*!
3098- * \internal
3099- * Applies styling on children recoursively.
3100- */
3101-void ItemStyleAttachedPrivate::applyStyleOnChildren(QQuickItem *item)
3102-{
3103- QList<QQuickItem*> children = item->childItems();
3104- Q_FOREACH(QQuickItem *child, children) {
3105- ItemStyleAttached *style = ThemeEnginePrivate::attachedStyle(child);
3106- if (style)
3107- style->d_ptr->_q_reapplyStyling(child->parentItem());
3108- else
3109- applyStyleOnChildren(child);
3110- }
3111-}
3112-
3113-/*!
3114- \internal
3115- Registers the element with the given instance \a id. Returns true on
3116- successful registration. On error, the theme engine's error string is set.
3117- */
3118-bool ItemStyleAttachedPrivate::registerName(const QString &id)
3119-{
3120- bool result = true;
3121- if (ThemeEnginePrivate::registerName(attachee, id)) {
3122- styleId = id;
3123- attachee->setProperty("name", styleId);
3124- } else {
3125- ThemeEnginePrivate::setError(QString("Instance %1 already registered. Resetting instance for %2.")
3126- .arg(styleId)
3127- .arg(styleClass));
3128- styleId = QString();
3129- result = false;
3130- }
3131- return result;
3132-}
3133-
3134-/*!
3135- \internal
3136- Checks if the item needs to receive updates from theme engine or not. Connects to
3137- or disconnects from the engine.
3138- */
3139-void ItemStyleAttachedPrivate::listenThemeEngine()
3140-{
3141- Q_Q(ItemStyleAttached);
3142- if (!customStyle || !customDelegate) {
3143- if (!connectedToEngine) {
3144- connectedToEngine = (bool)QObject::connect(ThemeEngine::instance(), SIGNAL(themeChanged()), q, SLOT(_q_refreshStyle()));
3145- }
3146- } else {
3147- if (connectedToEngine)
3148- connectedToEngine = !QObject::disconnect(ThemeEngine::instance(), SIGNAL(themeChanged()), q, SLOT(_q_refreshStyle()));
3149- if (!connectedToEngine) {
3150- styleRule = 0;
3151- styleSelector.clear();
3152- }
3153- }
3154-}
3155-
3156-/*!
3157- * \internal
3158- * Transfers the ownership of the style object (style or delegate) to teh current item.
3159- */
3160-void ItemStyleAttachedPrivate::gainOwnershipOverStyleObject(QObject *styleObject, bool style)
3161-{
3162- if (!styleObject)
3163- return;
3164-
3165- if (style) {
3166- UCStyle *style = qobject_cast<UCStyle*>(styleObject);
3167- if (!style)
3168- return;
3169- ItemStyleAttached *attached = ThemeEnginePrivate::attachedStyle(style->owner());
3170- if (attached) {
3171- attached->d_ptr->style = 0;
3172- style->setOwner(attachee);
3173- }
3174- } else {
3175- QQuickItem *delegate = qobject_cast<QQuickItem*>(styleObject);
3176- if (!delegate)
3177- return;
3178- // return if the delegate has no parent item set - case ItemStyle.delegate: Item{}
3179- if (!delegate->parentItem())
3180- return;
3181- ItemStyleAttached *attached = ThemeEnginePrivate::attachedStyle(delegate->parentItem());
3182- // check if the object is set as parent's delegate
3183- if (attached && (attached->d_ptr->delegate == delegate)) {
3184- // need to take ownership
3185- attached->d_ptr->delegate = 0;
3186- // set the new parent of the delegate
3187- delegate->setParent(attachee);
3188- }
3189- }
3190-}
3191-
3192-
3193-/*!
3194- \internal
3195- Internal slot to update the style of an item when the theme is changed. The slot
3196- is connected to the engine's themeChanged() signal. The slot should not be used
3197- from other methods as it will cause performance problems.
3198- */
3199-void ItemStyleAttachedPrivate::_q_refreshStyle()
3200-{
3201- // no need to delay style applying any longer
3202- bool applyOnChildren = !completed;
3203- if (!completed) {
3204- styleSelector = Selector(attachee);
3205- }
3206- completed = true;
3207-
3208- // ... but style refresh is needed as the old styles are dead
3209- styleRule = 0;
3210-
3211- int update = updateTheme();
3212- if (applyOnChildren) {
3213- // theme applied first time, style on custom style objects
3214- if (((update & StyleUpdated) != StyleUpdated) && customStyle) {
3215- updateStyle();
3216- }
3217- if (((update & DelegateUpdated) != DelegateUpdated) && customDelegate) {
3218- updateDelegate();
3219- }
3220- // this will happen only upon the styled item gets completed
3221- applyStyleOnChildren(attachee);
3222- }
3223-}
3224-
3225-/*!
3226- * \internal
3227- * Reapply styling on parent change.
3228- */
3229-void ItemStyleAttachedPrivate::_q_reapplyStyling(QQuickItem *parentItem)
3230-{
3231- if (!parentItem || !completed)
3232- // the component is most likely used in a delegate, is being deleted
3233- // or not yet complete
3234- return;
3235-
3236- Selector newSelector(attachee);
3237- if (newSelector != styleSelector) {
3238- styleSelector = newSelector;
3239- updateTheme();
3240- }
3241- // need to reapply styling on each child of the attachee!
3242- // this will cause performance issues!
3243- applyStyleOnChildren(attachee);
3244-}
3245-
3246-/*==============================================================================
3247- */
3248-
3249-ItemStyleAttached::ItemStyleAttached(QObject *parent) :
3250- QObject(parent),
3251- d_ptr(new ItemStyleAttachedPrivate(this, parent))
3252-{
3253- d_ptr->styleSelector = Selector(d_ptr->attachee);
3254-}
3255-
3256-ItemStyleAttached::~ItemStyleAttached()
3257-{}
3258-
3259-ItemStyleAttached *ItemStyleAttached::qmlAttachedProperties(QObject *obj)
3260-{
3261- ItemStyleAttached *ret = 0;
3262- if (qobject_cast<QQuickItem*>(obj)) {
3263- ret = new ItemStyleAttached(obj);
3264- }
3265- return ret;
3266-}
3267-
3268-/*!
3269- \qmlproperty string ItemStyle::name
3270- This property holds the item unique identifier used in styling.
3271- */
3272-/*!
3273- name property.
3274- */
3275-QString ItemStyleAttached::name() const
3276-{
3277- Q_D(const ItemStyleAttached);
3278- return d->styleId;
3279-}
3280-/*!
3281- Updates the name property.
3282- */
3283-void ItemStyleAttached::setName(const QString &name)
3284-{
3285- Q_D(ItemStyleAttached);
3286- if (d->styleId.compare(name, Qt::CaseInsensitive)) {
3287- if (d->registerName(name.toLower())) {
3288- d->styleSelector.update();
3289- if (!d->completed)
3290- return;
3291- d->updateTheme();
3292- // refresh children theme
3293- d->applyStyleOnChildren(d->attachee);
3294- }
3295- }
3296-}
3297-
3298-/*!
3299- \qmlproperty string ItemStyle::class
3300- This property holds the style class identifier used by the item.
3301- When the engine locates the style rule to be applied on the item, it takes
3302- the class and name properties. If none is specified, the meta class
3303- name will be used to search for the style. This must be taken into account both
3304- when defining themes and designing items and applications.
3305- */
3306-/*!
3307- class property.
3308- */
3309-QString ItemStyleAttached::styleClass()
3310-{
3311- Q_D(ItemStyleAttached);
3312- return d->styleClass.replace('.', ' ');
3313-}
3314-/*!
3315- Sets the class property value.
3316- */
3317-void ItemStyleAttached::setStyleClass(const QString &styleClass)
3318-{
3319- Q_D(ItemStyleAttached);
3320- if (d->styleClass.compare(styleClass.trimmed(), Qt::CaseInsensitive)) {
3321- // replace spaces with dots
3322- d->styleClass = styleClass.toLower().trimmed().replace(' ', '.');
3323- d->styleSelector.update();
3324- if (!d->completed)
3325- return;
3326- d->updateTheme();
3327- // refresh children theme
3328- d->applyStyleOnChildren(d->attachee);
3329- }
3330-}
3331-
3332-/*!
3333- *\qmlproperty string ItemStyle::path
3334- * This property holds the style path applied on the attachee item.
3335- */
3336-QString ItemStyleAttached::path() const
3337-{
3338- Q_D(const ItemStyleAttached);
3339- return d->styleRule ?
3340- d->styleRule->selector().toString() :
3341- QString("(null)");
3342-}
3343-
3344-/*!
3345- \qmlproperty Style ItemStyle::style
3346- The property holds the object containing the style configuration properties. This can
3347- either be defined by a theme style rule or the private style. When set, the item will
3348- no longer use the theme defined style properties but the ones set. The property must be
3349- reset (set to null object) in order to use the theme defined styles.
3350-
3351- Modifying the property alone will only affect the styling. The delegate will be used
3352- from the theme unless specified explicitly. Therefore items can be used with custom
3353- styling and theme defined delegate, theme style and custom delegate or both theme defined/
3354- custom.
3355- */
3356-/*!
3357- \internal
3358- Returns the object created out of the style used.
3359- */
3360-UCStyle *ItemStyleAttached::style() const
3361-{
3362- Q_D(const ItemStyleAttached);
3363- return d->style;
3364-}
3365-
3366-
3367-/*!
3368- \internal
3369- Sets/resets the style object for the item.
3370- */
3371-void ItemStyleAttached::setStyle(UCStyle *style)
3372-{
3373- Q_D(ItemStyleAttached);
3374- if (d->style != style) {
3375- // clear the previous style
3376- d->resetStyle();
3377- // check if style belongs to a styled item, if it does, detach it
3378- d->customStyle = (style != 0);
3379- d->gainOwnershipOverStyleObject(style, true);
3380- d->style = style;
3381- d->listenThemeEngine();
3382- if (d->updateStyle())
3383- Q_EMIT styleChanged();
3384- }
3385-}
3386-
3387-/*!
3388- \qmlproperty Item ItemStyle::delegate
3389- The property holds the Item containing the visuals. This can either be defined
3390- by a theme or can be a private element. When set, the item will no longer use
3391- the theme defined visuals but the ones set. The property must be reset (set to
3392- null object) in order to use the theme defined visuals.
3393-
3394- Modifying the property alone will only affect the visuals. Styles can be still
3395- used from the theme, unless specified explicitly. Therefore custom visuals can
3396- be made so that are aware of the styling properties.
3397- */
3398-/*!
3399- Returns the delegate Item created out of the style.
3400- */
3401-QQuickItem *ItemStyleAttached::delegate() const
3402-{
3403- Q_D(const ItemStyleAttached);
3404- return d->delegate;
3405-}
3406-
3407-/*!
3408- \internal
3409- Sets/resets the delegate item for the item.
3410- */
3411-void ItemStyleAttached::setDelegate(QQuickItem *delegate)
3412-{
3413- Q_D(ItemStyleAttached);
3414- if (d->delegate != delegate) {
3415- // clear the previous theme delegate
3416- d->resetDelegate();
3417- d->customDelegate = (delegate != 0);
3418- d->gainOwnershipOverStyleObject(delegate, false);
3419- d->delegate = delegate;
3420- d->listenThemeEngine();
3421- if (d->updateDelegate())
3422- Q_EMIT styleChanged();
3423- }
3424-}
3425-
3426-#include "moc_itemstyleattached.cpp"
3427
3428=== removed file 'modules/Ubuntu/Components/plugin/itemstyleattached.h'
3429--- modules/Ubuntu/Components/plugin/itemstyleattached.h 2013-04-26 07:23:32 +0000
3430+++ modules/Ubuntu/Components/plugin/itemstyleattached.h 1970-01-01 00:00:00 +0000
3431@@ -1,76 +0,0 @@
3432-/*
3433- * Copyright 2012 Canonical Ltd.
3434- *
3435- * This program is free software; you can redistribute it and/or modify
3436- * it under the terms of the GNU Lesser General Public License as published by
3437- * the Free Software Foundation; version 3.
3438- *
3439- * This program is distributed in the hope that it will be useful,
3440- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3441- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3442- * GNU Lesser General Public License for more details.
3443- *
3444- * You should have received a copy of the GNU Lesser General Public License
3445- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3446- *
3447- * Author: Zsombor Egri <zsombor.egri@canonical.com>
3448- */
3449-
3450-#ifndef ITEMSTYLEATTACHED_H
3451-#define ITEMSTYLEATTACHED_H
3452-
3453-#include <QtCore/QObject>
3454-#include <QtQml>
3455-
3456-class QQuickItem;
3457-class UCStyle;
3458-class ItemStyleAttachedPrivate;
3459-class ItemStyleAttached : public QObject
3460-{
3461- Q_OBJECT
3462-
3463- Q_PROPERTY(QString class READ styleClass WRITE setStyleClass NOTIFY styleChanged)
3464- Q_PROPERTY(QString name READ name WRITE setName NOTIFY styleChanged)
3465- Q_PROPERTY(UCStyle *style READ style WRITE setStyle NOTIFY styleChanged)
3466- Q_PROPERTY(QQuickItem *delegate READ delegate WRITE setDelegate NOTIFY styleChanged)
3467-
3468- Q_PROPERTY(QString path READ path NOTIFY styleChanged)
3469-
3470-public:
3471- explicit ItemStyleAttached(QObject *parent = 0);
3472- ~ItemStyleAttached();
3473- static ItemStyleAttached *qmlAttachedProperties(QObject *obj);
3474-
3475-Q_SIGNALS:
3476- void styleChanged();
3477-
3478-public Q_SLOTS:
3479-
3480-public: //getters
3481- QString name() const;
3482- QString styleClass();
3483- QString path() const;
3484-
3485-private:
3486- void setName(const QString &name);
3487- void setStyleClass(const QString &styleClass);
3488- UCStyle *style() const;
3489- void setStyle(UCStyle *style);
3490- QQuickItem *delegate() const;
3491- void setDelegate(QQuickItem *delegate);
3492-
3493-private:
3494- Q_DISABLE_COPY(ItemStyleAttached)
3495- Q_DECLARE_PRIVATE(ItemStyleAttached)
3496- QScopedPointer<ItemStyleAttachedPrivate> d_ptr;
3497- friend class ThemeEnginePrivate;
3498- friend class SelectorNode;
3499-
3500- Q_PRIVATE_SLOT(d_func(), void _q_attacheePropertyChanged())
3501- Q_PRIVATE_SLOT(d_func(), void _q_reapplyStyling(QQuickItem *))
3502- Q_PRIVATE_SLOT(d_func(), void _q_refreshStyle())
3503-};
3504-
3505-QML_DECLARE_TYPEINFO(ItemStyleAttached, QML_HAS_ATTACHED_PROPERTIES)
3506-
3507-#endif // ITEMSTYLEATTACHED_H
3508
3509=== removed file 'modules/Ubuntu/Components/plugin/itemstyleattached_p.h'
3510--- modules/Ubuntu/Components/plugin/itemstyleattached_p.h 2013-05-07 10:55:24 +0000
3511+++ modules/Ubuntu/Components/plugin/itemstyleattached_p.h 1970-01-01 00:00:00 +0000
3512@@ -1,75 +0,0 @@
3513-/*
3514- * Copyright 2012 Canonical Ltd.
3515- *
3516- * This program is free software; you can redistribute it and/or modify
3517- * it under the terms of the GNU Lesser General Public License as published by
3518- * the Free Software Foundation; version 3.
3519- *
3520- * This program is distributed in the hope that it will be useful,
3521- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3522- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3523- * GNU Lesser General Public License for more details.
3524- *
3525- * You should have received a copy of the GNU Lesser General Public License
3526- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3527- *
3528- * Author: Zsombor Egri <zsombor.egri@canonical.com>
3529- */
3530-
3531-#ifndef ITEMSTYLEATTACHED_P_H
3532-#define ITEMSTYLEATTACHED_P_H
3533-
3534-#include "itemstyleattached.h"
3535-#include "stylecache_p.h"
3536-#include "ucstyle.h"
3537-
3538-class QQmlContext;
3539-class ItemStyleAttachedPrivate {
3540- Q_DECLARE_PUBLIC(ItemStyleAttached)
3541-
3542-public:
3543- enum UpdateThemeResult {
3544- NoUpdate = 0,
3545- StyleUpdated = 0x01,
3546- DelegateUpdated = 0x02
3547- };
3548- ItemStyleAttachedPrivate(ItemStyleAttached *qq, QObject *attached);
3549- ~ItemStyleAttachedPrivate();
3550-
3551- ItemStyleAttached *q_ptr;
3552- QQuickItem *attachee;
3553- UCStyle *style;
3554- QQuickItem *delegate;
3555- QString styleClass;
3556- QString styleId;
3557- Selector styleSelector;
3558-
3559- // internal members
3560- StyleCache::StyleData *styleRule;
3561- // hash of attachee property indexes as key, containing enabled/disabled value
3562- StyledPropertyMap watchedProperties;
3563- bool completed;
3564- bool customStyle;
3565- bool customDelegate;
3566- bool connectedToEngine;
3567-
3568- void watchAttacheeProperties();
3569- bool updateStyle();
3570- bool updateDelegate();
3571- int updateTheme();
3572- void resetStyle();
3573- void resetDelegate();
3574- void applyStyleOnChildren(QQuickItem *item);
3575- bool registerName(const QString &id);
3576- void listenThemeEngine();
3577- void gainOwnershipOverStyleObject(QObject *styleObject, bool style);
3578- void _q_attacheePropertyChanged();
3579- void _q_refreshStyle();
3580- void _q_reapplyStyling(QQuickItem *);
3581-
3582-#ifdef QT_TESTLIB_LIB
3583- friend class tst_ThemeEngineStyle;
3584-#endif
3585-};
3586-
3587-#endif // ITEMSTYLEATTACHED_P_H
3588
3589=== modified file 'modules/Ubuntu/Components/plugin/plugin.cpp'
3590--- modules/Ubuntu/Components/plugin/plugin.cpp 2013-06-28 13:56:45 +0000
3591+++ modules/Ubuntu/Components/plugin/plugin.cpp 2013-07-01 22:15:52 +0000
3592@@ -23,8 +23,7 @@
3593 #include <QtGui/QScreen>
3594
3595 #include "plugin.h"
3596-#include "themeengine.h"
3597-#include "itemstyleattached.h"
3598+#include "uctheme.h"
3599
3600 #include <QtQml/QQmlContext>
3601 #include "i18n.h"
3602@@ -39,7 +38,6 @@
3603 #include "qquickclipboard.h"
3604 #include "qquickmimedata.h"
3605 #include "bottombarvisibilitycommunicator.h"
3606-#include "ucstyle.h"
3607 #include "ucubuntuanimation.h"
3608 #include "ucfontutils.h"
3609 #include "ucarguments.h"
3610@@ -64,7 +62,6 @@
3611 {
3612 Q_ASSERT(uri == QLatin1String("Ubuntu.Components"));
3613
3614- qmlRegisterUncreatableType<ItemStyleAttached>(uri, 0, 1, "ItemStyle", "Type is not instantiable.");
3615 qmlRegisterUncreatableType<UbuntuI18n>(uri, 0, 1, "i18n", "Singleton object");
3616 qmlRegisterExtendedType<QQuickImageBase, UCQQuickImageExtension>(uri, 0, 1, "QQuickImageBase");
3617 qmlRegisterUncreatableType<UCUnits>(uri, 0, 1, "UCUnits", "Not instantiable");
3618@@ -74,7 +71,6 @@
3619 qmlRegisterType<InverseMouseAreaType>(uri, 0, 1, "InverseMouseArea");
3620 qmlRegisterType<QQuickMimeData>(uri, 0, 1, "MimeData");
3621 qmlRegisterSingletonType<QQuickClipboard>(uri, 0, 1, "Clipboard", registerClipboard);
3622- qmlRegisterType<UCStyle>(uri, 0, 1, "Style");
3623 qmlRegisterSingletonType<UCUbuntuAnimation>(uri, 0, 1, "UbuntuAnimation", registerUCUbuntuAnimation);
3624 qmlRegisterType<UCArguments>(uri, 0, 1, "Arguments");
3625 qmlRegisterType<UCArgument>(uri, 0, 1, "Argument");
3626@@ -84,14 +80,14 @@
3627 void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
3628 {
3629 QQmlExtensionPlugin::initializeEngine(engine, uri);
3630- // call engine registration method to load the theme
3631 QQmlContext* context = engine->rootContext();
3632
3633 // register root object watcher that sets a global property with the root object
3634 // that can be accessed from any object
3635 context->setContextProperty("QuickUtils", &QuickUtils::instance());
3636
3637- context->setContextProperty("Theme", ThemeEngine::initializeEngine(engine));
3638+ UCTheme::instance().registerToContext(context);
3639+
3640 context->setContextProperty("i18n", &UbuntuI18n::instance());
3641 static ContextPropertyChangeListener i18nChangeListener(context, "i18n");
3642 QObject::connect(&UbuntuI18n::instance(), SIGNAL(domainChanged()),
3643
3644=== modified file 'modules/Ubuntu/Components/plugin/plugin.pro'
3645--- modules/Ubuntu/Components/plugin/plugin.pro 2013-06-25 14:18:18 +0000
3646+++ modules/Ubuntu/Components/plugin/plugin.pro 2013-07-01 22:15:52 +0000
3647@@ -18,14 +18,8 @@
3648 uri = Ubuntu.Components
3649
3650 HEADERS += plugin.h \
3651- themeengine.h \
3652- themeengine_p.h \
3653- themeloader_p.h \
3654- themesettings_p.h \
3655- stylecache_p.h \
3656- itemstyleattached.h \
3657- itemstyleattached_p.h \
3658- qmlthemeloader_p.h \
3659+ uctheme.h \
3660+ ucthemesettings.h \
3661 i18n.h \
3662 listener.h \
3663 ucscalingimageprovider.h \
3664@@ -40,19 +34,14 @@
3665 qquickclipboard.h \
3666 qquickmimedata.h \
3667 qquickclipboard_p.h \
3668- selector_p.h \
3669- ucstyle.h \
3670 ucubuntuanimation.h \
3671 ucfontutils.h \
3672 ucarguments.h \
3673 ucargument.h
3674
3675 SOURCES += plugin.cpp \
3676- themeengine.cpp \
3677- stylecache.cpp \
3678- themesettings.cpp \
3679- itemstyleattached.cpp \
3680- qmlthemeloader.cpp \
3681+ uctheme.cpp \
3682+ ucthemesettings.cpp \
3683 i18n.cpp \
3684 listener.cpp \
3685 ucscalingimageprovider.cpp \
3686@@ -65,8 +54,6 @@
3687 bottombarvisibilitycommunicator.cpp \
3688 qquickclipboard.cpp \
3689 qquickmimedata.cpp \
3690- selector.cpp \
3691- ucstyle.cpp \
3692 ucubuntuanimation.cpp \
3693 ucfontutils.cpp \
3694 ucarguments.cpp \
3695
3696=== removed file 'modules/Ubuntu/Components/plugin/qmlthemeloader.cpp'
3697--- modules/Ubuntu/Components/plugin/qmlthemeloader.cpp 2013-05-02 00:54:44 +0000
3698+++ modules/Ubuntu/Components/plugin/qmlthemeloader.cpp 1970-01-01 00:00:00 +0000
3699@@ -1,777 +0,0 @@
3700-/*
3701- * Copyright 2012 Canonical Ltd.
3702- *
3703- * This program is free software; you can redistribute it and/or modify
3704- * it under the terms of the GNU Lesser General Public License as published by
3705- * the Free Software Foundation; version 3.
3706- *
3707- * This program is distributed in the hope that it will be useful,
3708- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3709- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3710- * GNU Lesser General Public License for more details.
3711- *
3712- * You should have received a copy of the GNU Lesser General Public License
3713- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3714- *
3715- * Author: Zsombor Egri <zsombor.egri@canonical.com>
3716- */
3717-
3718-#include "themeengine.h"
3719-#include "themeengine_p.h"
3720-#include "qmlthemeloader_p.h"
3721-#include <QtQml/QQmlEngine>
3722-#include <QtQml/QQmlContext>
3723-#include <QtQml/QQmlComponent>
3724-#include <QtCore/QFileInfo>
3725-#include <QtCore/QDir>
3726-#include <QtCore/QCoreApplication>
3727-#include <QtQml/QQmlInfo>
3728-#include <QtCore/QRegularExpression>
3729-#include <QDebug>
3730-
3731-/*
3732- QmlTheme file parser
3733-
3734- The parsing steps are:
3735- 1. load file and build up selectorTable
3736- 2. normalize selectorTable by updating each selector with the non-overridden
3737- properties from the base selector
3738- 3. build ThemeEngine's styleCache by creating Rule elements using the styles,
3739- mappings and imports specified.
3740-
3741- TODOs:
3742- - optimization
3743- - merge steps 1 and 2
3744- - export into QML theme file for comparison in between CSS-like and QML theme
3745- loading
3746-*/
3747-
3748-const char *styleRuleComponent = \
3749- "import QtQuick 2.0\n"
3750- "%1\n"
3751- "%2\n";
3752-
3753-const char *stylePropertyFormat = \
3754- "%1 {\n"
3755- "%2"
3756- " }";
3757-
3758-/*!
3759- * \internal
3760- * The function lists the folders the listed import modules can be found.
3761- */
3762-QStringList importFolders(QQmlEngine *engine, QString imports)
3763-{
3764- QStringList importPaths = engine->importPathList();
3765- imports.remove("import ");
3766- imports.remove(QRegularExpression(" \\d.\\d"));
3767- imports.replace(QChar('.'), QDir::separator());
3768- QStringList importList = imports.split('\n');
3769-
3770- QStringList result;
3771- Q_FOREACH(const QString &import, importList) {
3772- Q_FOREACH(const QString &path, importPaths) {
3773- QDir dir(path + QDir::separator() + import);
3774- if (dir.exists())
3775- result << dir.path();
3776- }
3777- }
3778- return result;
3779-}
3780-
3781-/*!
3782- \internal
3783- Returns a subset from the given selector and configures it to ignore relation
3784- and name.
3785- */
3786-Selector selectorSubset(const Selector &path, int elements, int ignoreFlags = SelectorNode::IgnoreAll)
3787-{
3788- Selector result;
3789- while (elements > 0) {
3790- result << SelectorNode(path[path.length() - elements], ignoreFlags);
3791- elements--;
3792- }
3793- return result;
3794-}
3795-
3796-/*!
3797- * \internal
3798- * Create a QQmlComponent from a given QML string using the given engine
3799- */
3800-QQmlComponent *createComponent(QQmlEngine *engine, const QString &qmlCode)
3801-{
3802- if (qmlCode.isEmpty())
3803- return 0;
3804-
3805- QQmlComponent *ret = new QQmlComponent(engine);
3806- ret->setData(qmlCode.toLatin1(), QUrl());
3807- if (ret->isError() || !ret->isReady()) {
3808- QString errorString = ret->isError() ? ret->errorString() : "Component not ready";
3809- ThemeEnginePrivate::setError(QString("Error on creating style rule: \n%2\n%3")
3810- .arg(qmlCode)
3811- .arg(errorString));
3812- delete ret;
3813- ret = 0;
3814- }
3815- return ret;
3816-}
3817-
3818-/*!
3819- * \internal
3820- * Create a QQmlComponent delegate from a given file. The file is searched in the folders
3821- * specified in folderList parameter.
3822- */
3823-QQmlComponent *createDelegate(QQmlEngine *engine, const QString &qmlType, const QStringList &folderList)
3824-{
3825- if (qmlType.isEmpty() || folderList.isEmpty())
3826- return 0;
3827-
3828- QFile f;
3829- Q_FOREACH(const QString &folder, folderList) {
3830- f.setFileName(folder + QDir::separator() + qmlType + ".qml");
3831- if (f.exists()) {
3832- QQmlComponent *ret = new QQmlComponent(engine, f.fileName());
3833- if (ret->isError() || !ret->isReady()) {
3834- QString errorString = ret->isError() ? ret->errorString() : "Component not ready";
3835- ThemeEnginePrivate::setError(QString("Error on creating delegate: \n%2\n%3")
3836- .arg(qmlType)
3837- .arg(errorString));
3838- delete ret;
3839- ret = 0;
3840- }
3841- return ret;
3842- }
3843- }
3844- // the QML type wasn't found in the folders, try to create a component
3845- // using inline QML document
3846- return createComponent(engine, QString("import QtQuick 2.0; %1{}").arg(qmlType));
3847-}
3848-
3849-/*!
3850- * \brief QmlThemeLoader::urlMacro resolves the QmlTheme url() macro.
3851- */
3852-QString QmlThemeLoader::urlMacro(const QString &param, const QTextStream &stream)
3853-{
3854- QString path(param);
3855- path.remove('\"');
3856-
3857- if (!path.startsWith('/') && !path.startsWith("qrc:/") &&
3858- !path.startsWith("image:/") && !path.startsWith(":/")) {
3859- // check if we have one of the location tags: current, system, application
3860- if (path.startsWith("current:")) {
3861- path.remove("current:");
3862- if (!path.startsWith('/'))
3863- path.prepend('/');
3864- path.prepend(QDir::currentPath());
3865- } else if (path.startsWith("application:")) {
3866- path.remove("application:");
3867- if (!path.startsWith('/'))
3868- path.prepend('/');
3869- path.prepend(QCoreApplication::applicationDirPath());
3870- } else if (path.startsWith("system:")) {
3871- path.remove("system:");
3872- if (!path.startsWith('/'))
3873- path.prepend('/');
3874- path.prepend(themeFolder());
3875- } else {
3876- QFile *file = qobject_cast<QFile*>(stream.device());
3877- QFileInfo fi(*file);
3878- //create the path so that returns the absolute path to the URL given
3879- path = QFileInfo(fi.absoluteDir().path() + '/' + path).absoluteFilePath();
3880- }
3881- }
3882- return path;
3883-}
3884-
3885-/*!
3886- \internal
3887- Reads the stream character by character skipping characters specified in \a bypassTokens
3888- parameter and comments. Returns a string which in the most cases contains a single character
3889- except when a '/' chracter was followed by a valid one, when returns two chars.
3890- */
3891-QString QmlThemeLoader::readChar(QTextStream &stream, const QRegExp &bypassTokens)
3892-{
3893- QString data;
3894- while (!stream.atEnd()) {
3895-
3896- data += stream.read(1);
3897-
3898- // skip comments by default; as we read character by character, it's easier to
3899- // implement by checking the comment limitators than using QRegExp, which would
3900- // ease our life if we'd work with strings.
3901- if (data[0] == '/') {
3902- if (data == "/*") {
3903- // read till we get the comment's end mark
3904- QChar charData;
3905- // consume comment
3906- while ((charData = stream.read(1)[0]) != '/') {
3907- while (charData != '*')
3908- charData = stream.read(1)[0];
3909- }
3910- data.clear();
3911- continue;
3912- } else if (data.length() <= 1)
3913- // we don't know yet the next character, so stay in
3914- continue;
3915- else
3916- // we have the next one and that's not a comment marker, so return it
3917- return data;
3918- }
3919-
3920- // check if we have something to skip
3921- if (!data.contains(bypassTokens))
3922- return data;
3923- else
3924- data.clear();
3925- }
3926- return QString();
3927-}
3928-
3929-/*!
3930- \internal
3931- Reads the stream content till one of the \a tokens is reached. The characters
3932- specified in \a bypassTokens will be skipped. \a excludeToken specifies whether
3933- the limiting token reached should be included in the data read or not (default
3934- is not to include).
3935- */
3936-QString QmlThemeLoader::readTillToken(QTextStream &stream, const QRegExp &tokens, const QRegExp &bypassTokens, bool excludeToken)
3937-{
3938- QString ret;
3939- while (!stream.atEnd() && !ret.contains(tokens)) {
3940- ret += readChar(stream, bypassTokens);
3941- }
3942- if (excludeToken)
3943- // remove the last character as that is the token
3944- ret.remove(ret.length() - 1, 1);
3945- return ret;
3946-}
3947-
3948-/*!
3949- \internal
3950- Special read function for reading declaration block where we may have objects
3951- defined and we need to count the opened and closed parenthesis.
3952- Example of such a declaration block:
3953- \code
3954- .button {
3955- pressedAnimation: NumberAnimation {duration: 300; easing.type: Easing.OutQuad};
3956- }
3957- \endcode
3958- */
3959-QString QmlThemeLoader::readDeclarationBlock(QTextStream &stream)
3960-{
3961- // read till the close brace count is zero
3962- // the first opened brace is consumed, therefore start from 1
3963- int braceCount = 1;
3964- QString chunk, data;
3965-
3966- while (!stream.atEnd() && (braceCount > 0)) {
3967- chunk = readChar(stream, QRegExp("[\r\n]"));
3968- if (chunk[0] == '{')
3969- braceCount++;
3970- if (chunk[0] == '}')
3971- braceCount--;
3972- if (braceCount)
3973- data += chunk;
3974- }
3975-
3976- return data;
3977-}
3978-
3979-/*!
3980- * \internal
3981- * Parses the declaration block and fills the property map from it. Also resolves
3982- * macros and any other special tokens/tags in property value.
3983- */
3984-void QmlThemeLoader::parseDeclarationBlock(const QString &blockData, PropertyMap &propertyMap, const QTextStream &stream)
3985-{
3986- // parse data
3987- QString propertyName, propertyValue;
3988- const QChar *data = blockData.constData();
3989- while (!data->isNull()) {
3990- if (*data != ':')
3991- propertyName += *data;
3992- else {
3993- // and continue to parse string till we get the declaration end token ';'
3994- // note that we can have several of those as we can have object blocks inside
3995- // e.g. animation: NumberAnimation {duration: 100; easing.type: Easing.OutQuad};
3996- // in which case we need to pay attention on braces, and so on.
3997- propertyValue.clear();
3998- int braceCount = 0;
3999- data++;
4000- while (!data->isNull()) {
4001- if ((*data == ';') && !braceCount)
4002- break;
4003- if (*data == '{')
4004- braceCount++;
4005- if (*data == '}')
4006- braceCount--;
4007- propertyValue += *data;
4008- data++;
4009- }
4010- propertyValue = propertyValue.trimmed();
4011- if (!propertyValue.isEmpty()) {
4012- // resolve all macros and special tags/tokens
4013- patchDeclarationValue(propertyValue, stream);
4014- propertyMap.properties.insert(propertyName.trimmed(), propertyValue);
4015- }
4016- // check if we reached the end of the data
4017- if (data->isNull())
4018- return;
4019- propertyName.clear();
4020- propertyValue.clear();
4021- }
4022- data++;
4023- }
4024-}
4025-
4026-/*!
4027- * \internal
4028- * Resolves macros, tokens/tags in the property value data.
4029- */
4030-void QmlThemeLoader::patchDeclarationValue(QString &value, const QTextStream &stream)
4031-{
4032- // check if the value is declared using url() macro
4033- int atUrl;
4034- while ((atUrl = value.indexOf("url")) >= 0) {
4035- // check if it is the url() function, so the next valid character should be a "(" one
4036- int pathStart = value.indexOf('(', atUrl);
4037- if (pathStart >= 0) {
4038- int pathEnd = value.indexOf(')', pathStart);
4039- QString path = value.mid(pathStart + 1, pathEnd - pathStart - 1).trimmed();
4040- // replace url(path) with the resolved one
4041- value.replace(atUrl, pathEnd - atUrl + 1, urlMacro(path, stream).prepend('\"').append('\"'));
4042- }
4043- }
4044-}
4045-
4046-
4047-/*!
4048- \internal
4049- Resolves the "inheritance" between atomic selector items (the last items in a CSS selector component).
4050- */
4051-void QmlThemeLoader::handleSelector(const Selector &selector, const PropertyMap &newProperties)
4052-{
4053- PropertyMap propertyMap;
4054- if (selectorTable.contains(selector))
4055- propertyMap = selectorTable.value(selector);
4056- // merge tables;newProperties override the existing ones
4057- propertyMap.merge(newProperties, true);
4058- // save them (back) into the table
4059- selectorTable.insert(selector, propertyMap);
4060-}
4061-
4062-/*!
4063- \internal
4064- Normalizes the style table - copies the properties that were not overridden from the base
4065- styles into the derivates.
4066- */
4067-void QmlThemeLoader::normalizeStyles()
4068-{
4069- QHashIterator<Selector, PropertyMap > i(selectorTable);
4070- while (i.hasNext()) {
4071- i.next();
4072- Selector selector = i.key();
4073- if (normalizeSelector(selector))
4074- // start all over as hash iterator is not valid anymore
4075- i.toFront();
4076- }
4077-}
4078-
4079-/*!
4080- \internal
4081- Updates the properties of a rule based on the subset of the proeprty. May ignore relation
4082- and/or style ID when collecting properties. override should be true when properties from
4083- derivates are collected.
4084- */
4085-bool QmlThemeLoader::updateRuleProperties(Selector &selector, PropertyMap &propertyMap, bool override)
4086-{
4087- bool result = false;
4088- // make sure we don't have the styleId disturbing
4089- selector[0] = SelectorNode(selector[0], SelectorNode::NoStyleId);
4090- if (selectorTable.contains(selector)) {
4091- // make sure the selector is normalized
4092- normalizeSelector(selector);
4093- // get the properties and copy the base ones into the current selector
4094- propertyMap.merge(selectorTable.value(selector), override);
4095- }
4096- return result;
4097-}
4098-
4099-/*!
4100- * \internal
4101- * Normalizes a given selector. Returns true if the selector was normalized(updated)
4102- * otherwise returns false.
4103- */
4104-bool QmlThemeLoader::normalizeSelector(const Selector &selector)
4105-{
4106- PropertyMap propertyMap = selectorTable.value(selector);
4107- if (propertyMap.normalized)
4108- return false;
4109- // not normalized yet
4110-
4111- // collect properties from the derived ones
4112- SelectorNode last = selector.last();
4113- QString derivates = last.derivates();
4114- if (!derivates.isEmpty()) {
4115- // get the deriveds first then override those with the current properties
4116- PropertyMap derivedMap;
4117- Q_FOREACH(const QString& derived, derivates.split('.')) {
4118- if (!derived.isEmpty()) {
4119- Selector derivedSelector(derived);
4120- QHash<Selector, PropertyMap>::iterator i = selectorTable.find(derivedSelector);
4121- if (i != selectorTable.end() && i.key() == derivedSelector) {
4122- // update to the real selector as that may also be derived
4123- derivedSelector = i.key();
4124- updateRuleProperties(derivedSelector, derivedMap, true);
4125- } else {
4126- //FIXME: fire a warning in ThemeEngine, when error handling is done properly
4127- qmlInfo(ThemeEnginePrivate::themeEngine) << QString("Undefined selector: [%1]")
4128- .arg(derivedSelector.toString());
4129- }
4130- }
4131- }
4132- if (!derivedMap.properties.isEmpty()) {
4133- // override with the current stuff
4134- propertyMap.merge(derivedMap, false);
4135- }
4136- }
4137- // parse the cascade
4138- if (selector.count() > 1) {
4139- // need to check only the last node from the selector path
4140- Selector subset = selectorSubset(selector, 1);
4141- updateRuleProperties(subset, propertyMap, false);
4142- }
4143- propertyMap.normalized = true;
4144- selectorTable.insert(selector, propertyMap);
4145- return true;
4146-}
4147-
4148-
4149-/*!
4150- \internal
4151- Parses a QmlTheme theme. Reads the stream char-by-char to avoid seeking in the stream.
4152- Seeking would be needed when reading entire line and parsing tags out of it.
4153-*/
4154-bool QmlThemeLoader::parseTheme(const QUrl &url)
4155-{
4156- // open the file
4157- QString fname = (url.scheme() == "qrc") ? url.toString().remove("qrc") : url.path();
4158- QFile file(fname);
4159- if (file.open(QFile::ReadOnly | QFile::Text)) {
4160- QTextStream stream(&file);
4161-
4162- QString data;
4163-
4164- // read stream character by character so we don't need to seek
4165- while (!stream.atEnd()) {
4166-
4167- data += readChar(stream);
4168-
4169- if (data.isEmpty())
4170- break;
4171-
4172- if (data[0] == '@') {
4173- if (!parseAtRules(stream))
4174- return false;
4175- data.clear();
4176- continue;
4177- }
4178- if (!parseDeclarations(data, stream))
4179- return false;
4180- }
4181- return true;
4182- } else {
4183- ThemeEnginePrivate::setError(QString("%1: %2")
4184- .arg(file.errorString())
4185- .arg(file.fileName()));
4186- }
4187- return false;
4188-}
4189-
4190-bool QmlThemeLoader::parseAtRules(QTextStream &stream)
4191-{
4192- // rule!! read till the first token
4193- QString data = readTillToken(stream, QRegExp("[({]"), QRegExp("[\t]")).simplified();
4194-
4195- //lookup for the rule handler and continue parsing with it
4196- if (rules.contains(data))
4197- return rules.value(data)(this, stream);
4198- else
4199- ThemeEnginePrivate::setError(QString("Unhandled rule: %1").arg(data));
4200- return false;
4201-}
4202-
4203-bool QmlThemeLoader::parseDeclarations(QString &data, QTextStream &stream)
4204-{
4205- // read till we hit a '{' token
4206- data += readTillToken(stream, QRegExp("[{]"), QRegExp("[\t\r\n]")).simplified();
4207- if (data.isEmpty())
4208- return false;
4209-
4210- QList<Selector> selectors = ThemeEnginePrivate::parseSelector(data);
4211- if (selectors.isEmpty()) {
4212- ThemeEnginePrivate::setError(QString("Syntax error!\n%1").arg(data));
4213- return false;
4214- } else {
4215- // load declarator and apply on each selector
4216- data = readDeclarationBlock(stream);
4217- PropertyMap propertyMap;
4218- if (!data.isEmpty())
4219- parseDeclarationBlock(data, propertyMap, stream);
4220-
4221- Q_FOREACH (const Selector &selector, selectors) {
4222- handleSelector(selector, propertyMap);
4223- }
4224- }
4225-
4226- // clear data before continuing parsing
4227- data.clear();
4228- return true;
4229-}
4230-
4231-bool QmlThemeLoader::generateStyleQml(StyleCache &cache)
4232-{
4233- QString styleQml;
4234- QString delegateQml;
4235-
4236- // add delegates to cache
4237- QHashIterator<QString, QPair<QString, QString> > t(qmlMap);
4238- QStringList folders = importFolders(m_engine, imports);
4239- while (t.hasNext()) {
4240- t.next();
4241- QQmlComponent *delegate = createDelegate(m_engine, t.value().second, folders);
4242- if (delegate)
4243- cache.addDelegate(t.value().second, delegate);
4244- }
4245-
4246- // go through the selector map and build the styles to each
4247- QHashIterator<Selector, PropertyMap > i(selectorTable);
4248- while (i.hasNext()) {
4249- i.next();
4250- Selector selector = i.key();
4251- PropertyMap propertyMap = i.value();
4252-
4253- buildStyleAndDelegate(selector, propertyMap.properties, styleQml, delegateQml);
4254-
4255- QQmlComponent *style = createComponent(m_engine, styleQml);
4256- if (!style && delegateQml.isEmpty()) {
4257- return false;
4258- }
4259- cache.addStyleRule(selector, style, delegateQml);
4260- }
4261-
4262- return true;
4263-}
4264-
4265-QPair<QString, QString> QmlThemeLoader::selectorMapping(const Selector &selector)
4266-{
4267- Selector subset;
4268- QString qmap;
4269- for (int count = selector.count(); count > 0; count--) {
4270- subset = selectorSubset(selector, count, SelectorNode::IgnoreNone);
4271- qmap = subset.toString();
4272- if (qmlMap.contains(qmap)) {
4273- return qmlMap.value(qmap);
4274- }
4275- }
4276- // if none found, check the last node's style class
4277- qmap = '.' + selector.last().getClass();
4278- return (qmlMap.contains(qmap)) ? qmlMap.value(qmap) : QPair<QString, QString>();
4279-}
4280-
4281-
4282-void QmlThemeLoader::buildStyleAndDelegate(Selector &selector, PropertyHash &properties, QString &style, QString &delegate)
4283-{
4284- QPair<QString, QString> qmlTypes = selectorMapping(selector);
4285-
4286- style.clear();
4287- delegate.clear();
4288-
4289- // get the type for style and delegate
4290- if (properties.count() > 0) {
4291- QString propertyPrefix(" ");
4292-
4293- // do not consider style types
4294- style = QString(stylePropertyFormat).arg("Style");
4295- propertyPrefix += "property var";
4296-
4297- // add properties
4298- QHashIterator<QString, QString> i(properties);
4299- QString propertyArg;
4300- while (i.hasNext()) {
4301- i.next();
4302- propertyArg += QString(" %1 %2: %3\n")
4303- .arg(propertyPrefix)
4304- .arg(i.key())
4305- .arg(i.value());
4306- }
4307- // append the closing brace
4308- style = style.arg(propertyArg);
4309- style = QString(styleRuleComponent).arg(imports).arg(style);
4310- }
4311-
4312- // delegate
4313- delegate = qmlTypes.second;
4314-}
4315-
4316-/*============================================================================*/
4317-
4318-/*!
4319- \internal
4320- Extracts the theme specified to be imported, and loads it.
4321- */
4322-bool QmlThemeLoader::handleImport(QmlThemeLoader *loader, QTextStream &stream)
4323-{
4324- QString themeFile = QmlThemeLoader::readTillToken(stream, QRegExp("[;]"), QRegExp("[ )\t\r\n\"]"));
4325- // check if the imported theme file is an absolute path or not;
4326- // if not, build the path relative to the current parsed file
4327- // Note: resource stored theme files must use absolute paths, or should have
4328- // qrc: scheme specified
4329- bool result = false;
4330- themeFile = urlMacro(themeFile, stream);
4331- if (themeFile.startsWith("qrc"))
4332- result = loader->parseTheme(QUrl(themeFile));
4333- else {
4334- result = loader->parseTheme(QUrl::fromLocalFile(themeFile));
4335- if (result)
4336- loader->themeFiles << themeFile;
4337- }
4338- return result;
4339-}
4340-
4341-/*!
4342- \internal
4343- Parses qml-mapping rule needed when defing the QML Rule pattern. The qml-mapping rule
4344- syntax is as follows:
4345- qml-mapping(css-tag, style-qml-type, delegate-qml-type)
4346- where
4347- - css-tag is the tag used in CSS theme
4348- - style-qml-type is the name of the QML document defining the style properties
4349- - delegate-qml-type is the name of the QML document defining the item delegate.
4350- If no style is given, the theme engine will use QtObject for style and will declare all
4351- properties typed as variant.
4352-
4353- Example:
4354- css.
4355-
4356- @qml-mapping(button, ButonStyle, ButtonDelegate)
4357-
4358- .button {
4359- color: "blue"
4360- }
4361-
4362- .frame {
4363- border: 2
4364- }
4365-
4366- will be translated as
4367-
4368- Rule {
4369- selector: ".button"
4370- style: ButtonStyle {
4371- color: "blue"
4372- }
4373- delegate: ButtonDelegate{}
4374- }
4375-
4376- Rule {
4377- selector: ".frame"
4378- style: QtObject {
4379- property variant border: 2
4380- }
4381- }
4382- */
4383-bool QmlThemeLoader::handleQmlMapping(QmlThemeLoader *loader, QTextStream &stream)
4384-{
4385- QString params = QmlThemeLoader::readTillToken(stream, QRegExp("[;]"), QRegExp("[)\t\r\n\"]"));
4386- QStringList mapping = params.split(',');
4387-
4388- // we should have 3 elements in the list! if we don't we have an error!
4389- bool ret = (mapping.count() == 3);
4390- if (!ret)
4391- ThemeEnginePrivate::setError(QString("Mapping has %1 parameter(s), should have 3!").
4392- arg(mapping.count()));
4393- else
4394- loader->qmlMap.insert(mapping[0].trimmed().toLower(), qMakePair(mapping[1].trimmed(), mapping[2].trimmed()));
4395-
4396- return ret;
4397-}
4398-
4399-/*!
4400- \internal
4401- Callback handling qml-import tags. Adds the import sentence to the import list
4402- that will be added to the template creating the style rule, and the import path
4403- to engine. The import path may be relative or absolute, and can contain "app"
4404- and "sys" keywords, which result in application's current folder and global
4405- theme's folder.
4406- */
4407-bool QmlThemeLoader::handleQmlImport(QmlThemeLoader *loader, QTextStream &stream)
4408-{
4409- QString param = QmlThemeLoader::readTillToken(stream, QRegExp("[;]"), QRegExp("[)\t\r\n]")).simplified();
4410-
4411- if (param.isEmpty()) {
4412- ThemeEnginePrivate::setError("Empty QML import statement!");
4413- return false;
4414- }
4415-
4416- QStringList import = param.split(',');
4417- QString importUrl = (import.count() >= 1) ? import[0].simplified().prepend("import ") : QString();
4418- QString importPath = (import.count() < 2) ? QString() : import[1].simplified();
4419-
4420- // check whether we have the import set
4421- if (!loader->imports.contains(importUrl)) {
4422- loader->imports += importUrl + '\n';
4423-
4424- if (!importPath.isEmpty()) {
4425- importPath = urlMacro(importPath, stream);
4426- if (!loader->m_engine->importPathList().contains(importPath))
4427- loader->m_engine->addImportPath(importPath);
4428- }
4429-
4430- } else {
4431- // FIXME show warning instead of error, but continue parsing
4432-// ThemeEnginePrivate::setError(QString("QML import %1 allready added!").
4433-// arg(import[0]));
4434- return true;
4435- }
4436-
4437- return true;
4438-}
4439-
4440-/*=============================================================================
4441- CSS-LIKE THEME LOADER
4442-=============================================================================*/
4443-
4444-QmlThemeLoader::QmlThemeLoader(QQmlEngine *engine)
4445-{
4446- m_engine = engine;
4447- // fill the callback maps
4448- rules["import url"] = handleImport;
4449- rules["qml-mapping"] = handleQmlMapping;
4450- rules["qml-import"] = handleQmlImport;
4451-}
4452-
4453-bool QmlThemeLoader::loadTheme(const QUrl &url, QStringList &themeFiles, StyleCache &cache)
4454-{
4455- bool ok = true;
4456- // add toolkit as default import due to Style type
4457- imports = "import Ubuntu.Components 0.1\n";
4458- // parses the theme
4459- if (parseTheme(url)) {
4460-
4461- normalizeStyles();
4462- // build up the QML style tree
4463- if (!generateStyleQml(cache)) {
4464- ok = false;
4465- } else
4466- themeFiles<< url.path() << this->themeFiles;
4467-
4468- // cleanup
4469- ruleString.clear();
4470- imports.clear();
4471- qmlMap.clear();
4472- selectorTable.clear();
4473- }
4474-
4475- return ok;
4476-}
4477
4478=== removed file 'modules/Ubuntu/Components/plugin/qmlthemeloader_p.h'
4479--- modules/Ubuntu/Components/plugin/qmlthemeloader_p.h 2013-03-14 07:27:02 +0000
4480+++ modules/Ubuntu/Components/plugin/qmlthemeloader_p.h 1970-01-01 00:00:00 +0000
4481@@ -1,95 +0,0 @@
4482-/*
4483- * Copyright 2012 Canonical Ltd.
4484- *
4485- * This program is free software; you can redistribute it and/or modify
4486- * it under the terms of the GNU Lesser General Public License as published by
4487- * the Free Software Foundation; version 3.
4488- *
4489- * This program is distributed in the hope that it will be useful,
4490- * but WITHOUT ANY WARRANTY; without even the implied warranty of
4491- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4492- * GNU Lesser General Public License for more details.
4493- *
4494- * You should have received a copy of the GNU Lesser General Public License
4495- * along with this program. If not, see <http://www.gnu.org/licenses/>.
4496- *
4497- * Author: Zsombor Egri <zsombor.egri@canonical.com>
4498- */
4499-
4500-#ifndef QMLTHEMELOADER_P_H
4501-#define QMLTHEMELOADER_P_H
4502-
4503-#include "themeengine_p.h"
4504-#include "themeloader_p.h"
4505-#include <QtCore/QTextStream>
4506-
4507-// CSS-like theme loader
4508-class QmlThemeLoader;
4509-typedef bool (*ParserCallback)(QmlThemeLoader *loader, QTextStream &stream);
4510-
4511-typedef QHash<QString, QString> PropertyHash;
4512-
4513-class PropertyMap {
4514-public:
4515- PropertyMap() : normalized(false){}
4516- bool normalized;
4517- PropertyHash properties;
4518- inline bool merge(const PropertyMap &other, bool overrides)
4519- {
4520- bool result = false;
4521- QHashIterator<QString, QString> i(other.properties);
4522- while (i.hasNext()) {
4523- i.next();
4524- if (overrides || !properties.contains(i.key())) {
4525- properties.insert(i.key(), i.value());
4526- result = true;
4527- }
4528- }
4529- return result;
4530- }
4531-};
4532-
4533-class QmlThemeLoader : public ThemeLoader {
4534- Q_INTERFACES(ThemeLoader)
4535-public:
4536- QmlThemeLoader(QQmlEngine *engine);
4537- virtual ~QmlThemeLoader(){}
4538- bool loadTheme(const QUrl &path, QStringList &themeFiles, StyleCache &cache);
4539-
4540-private:
4541- QStringList themeFiles;
4542-
4543-private:
4544-
4545- static QString urlMacro(const QString &param, const QTextStream &stream);
4546- static QString readChar(QTextStream &stream, const QRegExp &bypassTokens = QRegExp("[ \t\r\n]"));
4547- static QString readTillToken(QTextStream &stream, const QRegExp &tokens, const QRegExp &bypassTokens = QRegExp(), bool excludeToken = true);
4548- static QString readDeclarationBlock(QTextStream &stream);
4549- static void parseDeclarationBlock(const QString &blockData, PropertyMap &properties, const QTextStream &stream);
4550- static void patchDeclarationValue(QString &value, const QTextStream &stream);
4551- void handleSelector(const Selector &path, const PropertyMap &newProperties);
4552- void normalizeStyles();
4553- bool updateRuleProperties(Selector &selector, PropertyMap &propertyMap, bool override);
4554- bool normalizeSelector(const Selector &selector);
4555- bool parseTheme(const QUrl &url);
4556- bool parseAtRules(QTextStream &stream);
4557- bool parseDeclarations(QString &data, QTextStream &stream);
4558- bool generateStyleQml(StyleCache &cache);
4559- QPair<QString, QString> selectorMapping(const Selector &selector);
4560- void buildStyleAndDelegate(Selector &selector, PropertyHash &properties, QString &style, QString &delegate);
4561-
4562- // @-rule handlers
4563- static bool handleImport(QmlThemeLoader *loader, QTextStream &stream);
4564- static bool handleQmlMapping(QmlThemeLoader *loader, QTextStream &stream);
4565- static bool handleQmlImport(QmlThemeLoader *loader, QTextStream &stream);
4566-
4567- QString imports;
4568- QString ruleString;
4569- QHash<QString, ParserCallback> rules;
4570- QHash<QString, QPair<QString, QString> > qmlMap;
4571- QHash<Selector, PropertyMap > selectorTable;
4572-};
4573-
4574-
4575-
4576-#endif // QMLTHEMELOADER_P_H
4577
4578=== removed file 'modules/Ubuntu/Components/plugin/selector.cpp'
4579--- modules/Ubuntu/Components/plugin/selector.cpp 2013-04-26 09:51:27 +0000
4580+++ modules/Ubuntu/Components/plugin/selector.cpp 1970-01-01 00:00:00 +0000
4581@@ -1,339 +0,0 @@
4582-/*
4583- * Copyright 2012 Canonical Ltd.
4584- *
4585- * This program is free software; you can redistribute it and/or modify
4586- * it under the terms of the GNU Lesser General Public License as published by
4587- * the Free Software Foundation; version 3.
4588- *
4589- * This program is distributed in the hope that it will be useful,
4590- * but WITHOUT ANY WARRANTY; without even the implied warranty of
4591- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4592- * GNU Lesser General Public License for more details.
4593- *
4594- * You should have received a copy of the GNU Lesser General Public License
4595- * along with this program. If not, see <http://www.gnu.org/licenses/>.
4596- *
4597- * Author: Zsombor Egri <zsombor.egri@canonical.com>
4598- */
4599-
4600-#include "selector_p.h"
4601-#include "itemstyleattached.h"
4602-#include "itemstyleattached_p.h"
4603-#include "themeengine_p.h"
4604-#include "quickutils.h"
4605-#include <QtCore/QStringList>
4606-#include <QtCore/QRegularExpression>
4607-#include <QtQuick/QQuickItem>
4608-
4609-SelectorNode::SelectorNode() :
4610- relationship(Descendant), ranking(RankNull)
4611-{}
4612-
4613-SelectorNode::SelectorNode(const SelectorNode &other):
4614- className(other.className), styleClass(other.styleClass),
4615- styleId(other.styleId), relationship(other.relationship), ranking(RankNull)
4616-{
4617- updateRanking();
4618-}
4619-
4620-SelectorNode::SelectorNode(const SelectorNode &other, int ignore) :
4621- className(other.className), relationship(Descendant), ranking(RankNull)
4622-{
4623- if ((ignore & NoStyleId) != NoStyleId)
4624- styleId = other.styleId;
4625- styleClass = other.styleClass;
4626- if ((ignore & NoDerivates) == NoDerivates)
4627- styleClass.remove(derivates());
4628- if ((ignore & NoRelation) != NoRelation)
4629- relationship = other.relationship;
4630- updateRanking();
4631-}
4632-
4633-/*!
4634- \internal
4635- Creates an instance of a SelectorNode by parsing the selectorString. The
4636- sensitivity parameter configures the node so that during string conversion
4637- and comparison ignores the relationship, the name both or none. This feature
4638- is used when building up QmlTheme selectorTable.
4639-*/
4640-SelectorNode::SelectorNode(const QString &selectorString) :
4641- relationship(Descendant), ranking(RankNull)
4642-{
4643- styleClass = selectorString.toLower().trimmed();
4644- if (styleClass.startsWith('>')) {
4645- relationship = Child;
4646- styleClass.remove('>');
4647- }
4648- int idIndex = styleClass.indexOf('#');
4649- if (idIndex != -1) {
4650- styleId = styleClass.mid(idIndex + 1).toLower();
4651- styleClass = styleClass.left(idIndex);
4652- if (idIndex > 1 && styleClass[0] == '.')
4653- styleClass = styleClass.mid(1, idIndex - 1);
4654- } else if (styleClass[0] == '.')
4655- styleClass = styleClass.mid(1);
4656- updateRanking();
4657-}
4658-/*!
4659- * \internal
4660- * Creates a selector node with the given type, class, id and relation.
4661- */
4662-SelectorNode::SelectorNode(const QString &stype, const QString &sclass, const QString &sid, SelectorNode::Relationship srelation) :
4663- className(stype), styleClass(sclass), styleId(sid), relationship(srelation), ranking(RankNull)
4664-{
4665- updateRanking();
4666-}
4667-
4668-/*!
4669- * \internal
4670- * Creates a selector node filling information gathered from the given item.
4671- */
4672-SelectorNode::SelectorNode(QQuickItem *item) :
4673- relationship(Descendant), ranking(RankNull)
4674-{
4675- update(item);
4676-}
4677-
4678-/*!
4679- \internal
4680- Converts a SelectorNode into string using "<relation> .<class>#<name>"
4681- format. Depending on the ignore flags set, may ignore the relationship, derivates
4682- and styleId. The default ignore flag is Nothing.
4683- */
4684-//FIXME: remove ignore flags after the lookup is cleaned&fixed
4685-QString SelectorNode::toString(int ignore) const
4686-{
4687- QString result;
4688- if (((ignore & NoRelation) != NoRelation) &&
4689- (relationship == SelectorNode::Child))
4690- result += ">";
4691- if (!styleClass.isEmpty())
4692- result += "." + styleClass;
4693- else if (!className.isEmpty()) {
4694- result += '.' + className;
4695- }
4696- if ((ignore & NoDerivates) == NoDerivates)
4697- result.remove(derivates());
4698- if (((ignore & NoStyleId) != NoStyleId) && !styleId.isEmpty())
4699- result += "#" + styleId;
4700- return result;
4701-}
4702-
4703-/*!
4704- * \internal
4705- * The method updates the selector node by fetching information from the item.
4706- */
4707-void SelectorNode::update(QQuickItem *item)
4708-{
4709- ItemStyleAttached *style = ThemeEnginePrivate::attachedStyle(item);
4710- if (!style)
4711- return;
4712- className = QuickUtils::instance().className(item);
4713- styleClass = style->d_ptr->styleClass;
4714- styleId = style->d_ptr->styleId;
4715- updateRanking();
4716-}
4717-
4718-/*!
4719- * \internal
4720- * The function returns the rank of the selector node based on the layer, which
4721- * is its index in the selector.
4722- * Each node has two bits reserved for ranking, where one bit specifies whether
4723- * the direct child separator is present and th eother bit specifies whether the
4724- * style ID is present. These bits are shifted leftwards with the layer -1 value,
4725- * layer 0 being the root node which is not in use.
4726- */
4727-unsigned SelectorNode::rank()
4728-{
4729- return ranking;
4730-}
4731-
4732-bool SelectorNode::operator==(const SelectorNode &other) const
4733-{
4734- QString myClass = (styleClass.isEmpty()) ? className : styleClass;
4735- QString otherClass = (other.styleClass.isEmpty()) ? other.className : other.styleClass;
4736-
4737- return (myClass == otherClass) && (styleId == other.styleId) && (relationship == other.relationship);
4738-}
4739-
4740-/*!
4741- * \internal
4742- * Returns the style type.
4743- * to QML.
4744- */
4745-QString SelectorNode::type() const
4746-{
4747- return className;
4748-}
4749-
4750-/*!
4751- * \internal
4752- * Returns the style class and its derivates in one string that is presentable
4753- * to QML.
4754- */
4755-QString SelectorNode::getClass() const
4756-{
4757- if (styleClass.indexOf('.') != -1)
4758- return styleClass.left(styleClass.indexOf('.'));
4759- return styleClass;
4760-}
4761-
4762-/*!
4763- * \internal
4764- * Returns the selectors the current one's properties are derived from.
4765- */
4766-QString SelectorNode::derivates() const
4767-{
4768- QString result;
4769- //cut the derivates from the style class
4770- int derivesIndex = styleClass.indexOf('.');
4771- if (derivesIndex != -1)
4772- result = styleClass.mid(derivesIndex);
4773-
4774- return result;
4775-}
4776-
4777-/*!
4778- * \internal
4779- * Returns the style ID;
4780- */
4781-QString SelectorNode::id() const
4782-{
4783- return styleId;
4784-}
4785-
4786-/*!
4787- * \internal
4788- * Retiurns the reference to the relationship.
4789- */
4790-SelectorNode::Relationship SelectorNode::relation()
4791-{
4792- return relationship;
4793-}
4794-
4795-/*!
4796- \internal
4797- Hash key for SelectorNode. Uses QString's hash function.
4798- */
4799-uint qHash(const SelectorNode &key)
4800-{
4801- return qHash(key.toString());
4802-}
4803-
4804-
4805-/*!
4806- * \internal
4807- * Converts a selector string into Selector object. Does not accept 32-node longer
4808- * selector;
4809- * Current support (ref: www.w3.org/TR/selector.html):
4810- * - Type selectors, e.g: "Button"
4811- * - Descendant selectors, e.g: "Dialog Button"
4812- * - Child selectors, e.g: "Dialog>Button"
4813- * - ID selectors, e.g: "Button#mySpecialButton"
4814- */
4815-Selector::Selector(const QString &string) :
4816- m_owner(0)
4817-{
4818- QString tmp(string.trimmed());
4819- // prepare for split
4820- if (tmp.contains('>')) {
4821- tmp.replace(QRegularExpression("[ ]*(>)[ ]*"), ">").replace('>', "|>");
4822- }
4823- tmp.replace(' ', '|');
4824-
4825- QStringList nodes = tmp.simplified().split('|');
4826- QStringListIterator inodes(nodes);
4827- inodes.toBack();
4828- while (inodes.hasPrevious()) {
4829- const QString &node = inodes.previous();
4830- if (node.isEmpty())
4831- continue;
4832- prepend(SelectorNode(node));
4833- }
4834-}
4835-
4836-/*!
4837- * \internal
4838- * Builds the selector for the given item.
4839- */
4840-Selector::Selector(QQuickItem *item) :
4841- m_owner(item)
4842-{
4843- SelectorNode::Relationship relation = SelectorNode::Child;
4844- QQuickItem *parent = m_owner->parentItem();
4845-
4846- prepend(SelectorNode(m_owner));
4847-
4848- while (parent) {
4849- if (!ThemeEnginePrivate::attachedStyle(parent))
4850- relation = SelectorNode::Descendant;
4851- else {
4852- // update relationship
4853- first().relationship = relation;
4854- prepend(SelectorNode(parent));
4855- relation = SelectorNode::Child;
4856- }
4857- parent = parent->parentItem();
4858- }
4859-}
4860-
4861-/*!
4862- \internal
4863- Converts a style path back to selector string.
4864-*/
4865-QString Selector::toString() const
4866-{
4867- QString result;
4868-
4869- QListIterator<SelectorNode> i(*this);
4870- while (i.hasNext()) {
4871- SelectorNode node = i.next();
4872- result += ' ' + node.toString();
4873- }
4874- result.replace(" >", ">");
4875- return result.simplified();
4876-}
4877-
4878-/*!
4879- * \internal
4880- * The method calculates the ranking of the selector itself, which is a
4881- * combination of the node rankings. The node rankings being bitmasks each of
4882- * them consuming 2 bits implies that the maximum depth of the selector can be
4883- * not more than 32 nodes.
4884- */
4885-int64_t Selector::rank() const
4886-{
4887- int64_t result = 0;
4888- int nodes = size();
4889- SelectorNode node;
4890- int i;
4891- for (i = nodes - 1; i >= 0; --i) {
4892- node = at(i);
4893- result |= ((int64_t)node.rank()) << 2 * i;
4894- }
4895- return result;
4896-}
4897-
4898-/*!
4899- * \internal
4900- * The method updates the selector by fetching information from the owner. This
4901- * method has meaning only if the selector was created using an item.
4902- */
4903-void Selector::update()
4904-{
4905- if (!m_owner)
4906- return;
4907- last().update(m_owner);
4908-}
4909-
4910-
4911-
4912-/*!
4913- \internal
4914- Hash key for Selector. Uses QString's hash function.
4915- */
4916-uint qHash(const Selector &key)
4917-{
4918- return qHash(key.toString());
4919-}
4920-
4921
4922=== removed file 'modules/Ubuntu/Components/plugin/selector_p.h'
4923--- modules/Ubuntu/Components/plugin/selector_p.h 2013-04-26 09:37:22 +0000
4924+++ modules/Ubuntu/Components/plugin/selector_p.h 1970-01-01 00:00:00 +0000
4925@@ -1,107 +0,0 @@
4926-/*
4927- * Copyright 2012 Canonical Ltd.
4928- *
4929- * This program is free software; you can redistribute it and/or modify
4930- * it under the terms of the GNU Lesser General Public License as published by
4931- * the Free Software Foundation; version 3.
4932- *
4933- * This program is distributed in the hope that it will be useful,
4934- * but WITHOUT ANY WARRANTY; without even the implied warranty of
4935- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4936- * GNU Lesser General Public License for more details.
4937- *
4938- * You should have received a copy of the GNU Lesser General Public License
4939- * along with this program. If not, see <http://www.gnu.org/licenses/>.
4940- *
4941- * Author: Zsombor Egri <zsombor.egri@canonical.com>
4942- */
4943-
4944-#ifndef SELECTOR_P_H
4945-#define SELECTOR_P_H
4946-
4947-#include <QtCore/QHash>
4948-#include <QtCore/QString>
4949-#include <QtCore/QList>
4950-
4951-class QQuickItem;
4952-class Selector;
4953-// node of a selector
4954-class SelectorNode {
4955- public:
4956- enum Relationship {
4957- Child,
4958- Descendant
4959- };
4960- enum IgnoreFlags {
4961- IgnoreNone = 0,
4962- NoRelation = 0x01,
4963- NoStyleId = 0x02,
4964- NoDerivates = 0x04,
4965- IgnoreAll = NoRelation | NoStyleId | NoDerivates};
4966- enum RankFlags {
4967- RankNull = 0,
4968- RankId = 0x01,
4969- RankChild = 0x02,
4970- RankFull = RankId | RankChild
4971- };
4972-
4973- SelectorNode();
4974- SelectorNode(const SelectorNode &other);
4975- SelectorNode(const SelectorNode &other, int ignore);
4976- SelectorNode(const QString &selectorString);
4977- SelectorNode(const QString &stype, const QString &sclass, const QString &sid, SelectorNode::Relationship srelation);
4978- SelectorNode(QQuickItem *item);
4979- inline bool isStrictRelationed() {
4980- return (relationship == Child);
4981- }
4982- inline bool isEmpty() {
4983- return className.isEmpty() && styleClass.isEmpty() && styleId.isEmpty();
4984- }
4985-
4986- QString toString(int ignore = IgnoreNone) const;
4987- void update(QQuickItem *item);
4988- unsigned rank();
4989- bool operator==(const SelectorNode &other) const;
4990- // getters
4991- QString type() const;
4992- QString getClass() const;
4993- QString derivates() const;
4994- QString id() const;
4995- Relationship relation();
4996-private:
4997- // hide them so we don't mess them accidentaly
4998- QString className;
4999- QString styleClass;
5000- QString styleId;
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to status/vote changes: