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
=== modified file 'CHANGES'
--- CHANGES 2013-06-21 11:35:19 +0000
+++ CHANGES 2013-07-01 22:15:52 +0000
@@ -9,6 +9,8 @@
99
10API Changes10API Changes
11***********11***********
12
13* REMOVED IN ALL: attached property ItemStyle
12* ADDED IN OrientationHelper: property alias rotating14* ADDED IN OrientationHelper: property alias rotating
13* ADDED IN OrientationHelper: property alias __orientationHelper15* ADDED IN OrientationHelper: property alias __orientationHelper
14* ADDED IN OrientationHelper: property bool transitionEnabled16* ADDED IN OrientationHelper: property bool transitionEnabled
1517
=== modified file 'components.api'
--- components.api 2013-07-01 20:32:20 +0000
+++ components.api 2013-07-01 22:15:52 +0000
@@ -15,7 +15,7 @@
15 property bool enabled15 property bool enabled
16 property Component itemHint16 property Component itemHint
17modules/Ubuntu/Components/ActionItem.qml17modules/Ubuntu/Components/ActionItem.qml
18Item18StyledItem
19 property Action action19 property Action action
20 property string text20 property string text
21 property url iconSource21 property url iconSource
@@ -28,7 +28,7 @@
28AnimatedItem28AnimatedItem
29 property bool running29 property bool running
30modules/Ubuntu/Components/AnimatedItem.qml30modules/Ubuntu/Components/AnimatedItem.qml
31Item31StyledItem
32 property bool onScreen32 property bool onScreen
33modules/Ubuntu/Components/Button.qml33modules/Ubuntu/Components/Button.qml
34AbstractButton34AbstractButton
@@ -55,7 +55,7 @@
55 function getEventSpeed(currentTime, event)55 function getEventSpeed(currentTime, event)
56 function pushDragEvent(event)56 function pushDragEvent(event)
57modules/Ubuntu/Components/Header.qml57modules/Ubuntu/Components/Header.qml
58Item58StyledItem
59 function show()59 function show()
60 function hide()60 function hide()
61 property string title61 property string title
@@ -108,7 +108,7 @@
108 function pop()108 function pop()
109 function clear()109 function clear()
110modules/Ubuntu/Components/PageTreeNode.qml110modules/Ubuntu/Components/PageTreeNode.qml
111Item111StyledItem
112 property bool __isPageTreeNode112 property bool __isPageTreeNode
113 property Header header113 property Header header
114 property Toolbar toolbar114 property Toolbar toolbar
@@ -139,7 +139,7 @@
139 property real maximumValue139 property real maximumValue
140 property real value140 property real value
141modules/Ubuntu/Components/Scrollbar.qml141modules/Ubuntu/Components/Scrollbar.qml
142Item142StyledItem
143 property Flickable flickableItem143 property Flickable flickableItem
144 property int align144 property int align
145 property bool __interactive145 property bool __interactive
@@ -153,6 +153,10 @@
153 signal touched(bool onThumb)153 signal touched(bool onThumb)
154 function formatValue(v)154 function formatValue(v)
155 property alias __internals155 property alias __internals
156modules/Ubuntu/Components/StyledItem.qml
157FocusScope
158 property Component style
159 readonly property Item __styleInstance
156modules/Ubuntu/Components/Switch.qml160modules/Ubuntu/Components/Switch.qml
157CheckBox161CheckBox
158modules/Ubuntu/Components/Tab.qml162modules/Ubuntu/Components/Tab.qml
@@ -172,7 +176,7 @@
172 default property alias tabChildren176 default property alias tabChildren
173 signal modelChanged()177 signal modelChanged()
174modules/Ubuntu/Components/TextArea.qml178modules/Ubuntu/Components/TextArea.qml
175FocusScope179StyledItem
176 property bool highlighted180 property bool highlighted
177 property alias placeholderText181 property alias placeholderText
178 readonly property alias displayText182 readonly property alias displayText
@@ -234,13 +238,13 @@
234 function forceActiveFocus()238 function forceActiveFocus()
235 property alias __internal239 property alias __internal
236modules/Ubuntu/Components/TextCursor.qml240modules/Ubuntu/Components/TextCursor.qml
237Item241StyledItem
238 property var editorItem242 property var editorItem
239 property string positionProperty243 property string positionProperty
240 property var popover244 property var popover
241 function openPopover()245 function openPopover()
242modules/Ubuntu/Components/TextField.qml246modules/Ubuntu/Components/TextField.qml
243FocusScope247StyledItem
244 property bool highlighted248 property bool highlighted
245 property alias placeholderText249 property alias placeholderText
246 property bool hasClearButton250 property bool hasClearButton
@@ -330,14 +334,6 @@
330 Method {334 Method {
331 name: "contains"335 name: "contains"
332 Parameter { name: "point"; type: "QPointF" }336 Parameter { name: "point"; type: "QPointF" }
333 name: "ItemStyleAttached"
334 prototype: "QObject"
335 exports: ["ItemStyle 0.1"]
336 Property { name: "class"; type: "string" }
337 Property { name: "name"; type: "string" }
338 Property { name: "style"; type: "UCStyle"; isPointer: true }
339 Property { name: "delegate"; type: "QQuickItem"; isPointer: true }
340 Property { name: "path"; type: "string"; isReadonly: true }
341 name: "QQmlPropertyMap"337 name: "QQmlPropertyMap"
342 prototype: "QObject"338 prototype: "QObject"
343 Signal {339 Signal {
@@ -412,9 +408,6 @@
412 Signal {408 Signal {
413 name: "sourceChanged"409 name: "sourceChanged"
414 Parameter { type: "QUrl" }410 Parameter { type: "QUrl" }
415 name: "UCStyle"
416 prototype: "QObject"
417 exports: ["Style 0.1"]
418 name: "UCUbuntuAnimation"411 name: "UCUbuntuAnimation"
419 prototype: "QObject"412 prototype: "QObject"
420 exports: ["UbuntuAnimation 0.1"]413 exports: ["UbuntuAnimation 0.1"]
421414
=== modified file 'debian/qtdeclarative5-ubuntu-ui-toolkit-plugin.install'
--- debian/qtdeclarative5-ubuntu-ui-toolkit-plugin.install 2013-02-15 11:52:44 +0000
+++ debian/qtdeclarative5-ubuntu-ui-toolkit-plugin.install 2013-07-01 22:15:52 +0000
@@ -1,1 +1,9 @@
1usr/lib/*/qt5/qml/1usr/lib/*/qt5/qml/Ubuntu/Layouts
2usr/lib/*/qt5/qml/Ubuntu/Components/*.qml
3usr/lib/*/qt5/qml/Ubuntu/Components/*.js
4usr/lib/*/qt5/qml/Ubuntu/Components/qmldir
5usr/lib/*/qt5/qml/Ubuntu/Components/plugins.qmltypes
6usr/lib/*/qt5/qml/Ubuntu/Components/libUbuntuComponents.so
7usr/lib/*/qt5/qml/Ubuntu/Components/artwork
8usr/lib/*/qt5/qml/Ubuntu/Components/ListItems
9usr/lib/*/qt5/qml/Ubuntu/Components/Popups
210
=== modified file 'debian/ubuntu-ui-toolkit-theme.install'
--- debian/ubuntu-ui-toolkit-theme.install 2013-02-15 11:52:44 +0000
+++ debian/ubuntu-ui-toolkit-theme.install 2013-07-01 22:15:52 +0000
@@ -1,1 +1,1 @@
1usr/share/themes/Ambiance1usr/lib/*/qt5/qml/Ubuntu/Components/Themes
22
=== modified file 'examples/examples.pro'
--- examples/examples.pro 2013-05-07 10:23:57 +0000
+++ examples/examples.pro 2013-07-01 22:15:52 +0000
@@ -8,7 +8,7 @@
88
99
10#examples = jokes unit-converter10#examples = jokes unit-converter
11#filetypes = qml png svg js qmltheme jpg wav11#filetypes = qml png svg js jpg wav
12 12
13#OTHER_FILES = ""13#OTHER_FILES = ""
1414
1515
=== modified file 'examples/jokes/jokes.pro'
--- examples/jokes/jokes.pro 2013-05-07 10:23:57 +0000
+++ examples/jokes/jokes.pro 2013-07-01 22:15:52 +0000
@@ -1,6 +1,6 @@
1TEMPLATE = subdirs1TEMPLATE = subdirs
22
3filetypes = qml png svg js qmltheme jpg qmlproject desktop wav3filetypes = qml png svg js jpg qmlproject desktop wav
44
5OTHER_FILES = ""5OTHER_FILES = ""
66
77
=== modified file 'examples/locale/locale.pro'
--- examples/locale/locale.pro 2013-05-07 10:23:57 +0000
+++ examples/locale/locale.pro 2013-07-01 22:15:52 +0000
@@ -1,6 +1,6 @@
1TEMPLATE = subdirs1TEMPLATE = subdirs
22
3filetypes = qml png svg js qmltheme jpg qmlproject desktop3filetypes = qml png svg js jpg qmlproject desktop
44
5OTHER_FILES = ""5OTHER_FILES = ""
66
77
=== modified file 'examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.pro'
--- examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.pro 2013-05-06 16:24:50 +0000
+++ examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.pro 2013-07-01 22:15:52 +0000
@@ -2,7 +2,7 @@
22
3SUBDIRS += po3SUBDIRS += po
44
5filetypes = qml png svg js qmltheme jpg qmlproject desktop5filetypes = qml png svg js jpg qmlproject desktop
66
7OTHER_FILES = ""7OTHER_FILES = ""
88
99
=== modified file 'examples/unit-converter/unit-converter.pro'
--- examples/unit-converter/unit-converter.pro 2013-05-07 10:23:57 +0000
+++ examples/unit-converter/unit-converter.pro 2013-07-01 22:15:52 +0000
@@ -1,6 +1,6 @@
1TEMPLATE = subdirs1TEMPLATE = subdirs
22
3filetypes = qml png svg js qmltheme jpg qmlproject desktop3filetypes = qml png svg js jpg qmlproject desktop
44
5OTHER_FILES = ""5OTHER_FILES = ""
66
77
=== modified file 'export_modules_dir.sh'
--- export_modules_dir.sh 2013-04-24 17:09:29 +0000
+++ export_modules_dir.sh 2013-07-01 22:15:52 +0000
@@ -17,4 +17,4 @@
1717
18export QML_IMPORT_PATH=$PWD/modules18export QML_IMPORT_PATH=$PWD/modules
19export QML2_IMPORT_PATH=$PWD/modules19export QML2_IMPORT_PATH=$PWD/modules
20export UITK_THEME_PATH=.20export UBUNTU_UI_TOOLKIT_THEMES_PATH=$PWD/modules
2121
=== modified file 'modules/Ubuntu/Components/ActionItem.qml'
--- modules/Ubuntu/Components/ActionItem.qml 2013-06-28 18:14:20 +0000
+++ modules/Ubuntu/Components/ActionItem.qml 2013-07-01 22:15:52 +0000
@@ -31,7 +31,7 @@
31 See \l ToolbarItems for examples of how to use \l ToolbarButton or other ActionItems31 See \l ToolbarItems for examples of how to use \l ToolbarButton or other ActionItems
32 in a toolbar.32 in a toolbar.
33*/33*/
34Item {34StyledItem {
35 id: actionItem35 id: actionItem
3636
37 /*!37 /*!
3838
=== modified file 'modules/Ubuntu/Components/ActivityIndicator.qml'
--- modules/Ubuntu/Components/ActivityIndicator.qml 2013-02-27 07:15:35 +0000
+++ modules/Ubuntu/Components/ActivityIndicator.qml 2013-07-01 22:15:52 +0000
@@ -15,11 +15,6 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18// FIXME: When a module contains QML, C++ and JavaScript elements exported,
19// we need to use named imports otherwise namespace collision is reported
20// by the QML engine. As workaround, we use Theming named import.
21// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
22import "." 0.1 as Theming
2318
24/*!19/*!
25 \qmltype ActivityIndicator20 \qmltype ActivityIndicator
@@ -63,6 +58,5 @@
63 implicitWidth: units.gu(3)58 implicitWidth: units.gu(3)
64 implicitHeight: units.gu(3)59 implicitHeight: units.gu(3)
6560
66 Theming.ItemStyle.class: "activityindicator"61 style: Theme.createStyleComponent("ActivityIndicatorStyle.qml", indicator)
67
68}62}
6963
=== modified file 'modules/Ubuntu/Components/AnimatedItem.qml'
--- modules/Ubuntu/Components/AnimatedItem.qml 2012-10-29 17:14:42 +0000
+++ modules/Ubuntu/Components/AnimatedItem.qml 2013-07-01 22:15:52 +0000
@@ -26,7 +26,7 @@
2626
27import QtQuick 2.027import QtQuick 2.0
2828
29Item {29StyledItem {
30 id: root30 id: root
31 /*!31 /*!
32 \preliminary32 \preliminary
3333
=== modified file 'modules/Ubuntu/Components/Button.qml'
--- modules/Ubuntu/Components/Button.qml 2013-06-26 23:42:39 +0000
+++ modules/Ubuntu/Components/Button.qml 2013-07-01 22:15:52 +0000
@@ -15,11 +15,6 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18// FIXME: When a module contains QML, C++ and JavaScript elements exported,
19// we need to use named imports otherwise namespace collision is reported
20// by the QML engine. As workaround, we use Theming named import.
21// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
22import Ubuntu.Components 0.1 as Theming
2318
24/*!19/*!
25 \qmltype Button20 \qmltype Button
@@ -69,8 +64,6 @@
69AbstractButton {64AbstractButton {
70 id: button65 id: button
7166
72 // FIXME: see FIXME above
73 Theming.ItemStyle.class: "button"
74 implicitWidth: units.gu(9)67 implicitWidth: units.gu(9)
75 implicitHeight: units.gu(4)68 implicitHeight: units.gu(4)
7669
@@ -107,4 +100,6 @@
107 https://bugreports.qt-project.org/browse/QTBUG-14861100 https://bugreports.qt-project.org/browse/QTBUG-14861
108 */101 */
109 property string iconPosition: "left"102 property string iconPosition: "left"
103
104 style: Theme.createStyleComponent("ButtonStyle.qml", button)
110}105}
111106
=== modified file 'modules/Ubuntu/Components/CheckBox.qml'
--- modules/Ubuntu/Components/CheckBox.qml 2013-05-24 09:12:56 +0000
+++ modules/Ubuntu/Components/CheckBox.qml 2013-07-01 22:15:52 +0000
@@ -15,11 +15,6 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18// FIXME: When a module contains QML, C++ and JavaScript elements exported,
19// we need to use named imports otherwise namespace collision is reported
20// by the QML engine. As workaround, we use Theming named import.
21// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
22import Ubuntu.Components 0.1 as Theming
2318
24/*!19/*!
25 \qmltype CheckBox20 \qmltype CheckBox
@@ -45,11 +40,6 @@
45AbstractButton {40AbstractButton {
46 id: checkBox41 id: checkBox
4742
48 // FIXME: see FIXME above
49 Theming.ItemStyle.class: "checkbox"
50 implicitWidth: units.gu(4)
51 implicitHeight: units.gu(4)
52
53 /*!43 /*!
54 \preliminary44 \preliminary
55 Specifies whether the checkbox is checked or not. By default the property45 Specifies whether the checkbox is checked or not. By default the property
@@ -61,4 +51,6 @@
61 \internal51 \internal
62 */52 */
63 onClicked: checked = !checked53 onClicked: checked = !checked
54
55 style: Theme.createStyleComponent("CheckBoxStyle.qml", checkBox)
64}56}
6557
=== modified file 'modules/Ubuntu/Components/Components.pro'
--- modules/Ubuntu/Components/Components.pro 2013-06-25 14:18:18 +0000
+++ modules/Ubuntu/Components/Components.pro 2013-07-01 22:15:52 +0000
@@ -1,5 +1,5 @@
1TEMPLATE = subdirs1TEMPLATE = subdirs
22
3SUBDIRS += plugin3SUBDIRS += plugin Themes
44
5include(deployment.pri)5include(deployment.pri)
66
=== modified file 'modules/Ubuntu/Components/Header.qml'
--- modules/Ubuntu/Components/Header.qml 2013-06-21 11:28:33 +0000
+++ modules/Ubuntu/Components/Header.qml 2013-07-01 22:15:52 +0000
@@ -17,9 +17,9 @@
17import QtQuick 2.017import QtQuick 2.0
18// FIXME: When a module contains QML, C++ and JavaScript elements exported,18// FIXME: When a module contains QML, C++ and JavaScript elements exported,
19// we need to use named imports otherwise namespace collision is reported19// we need to use named imports otherwise namespace collision is reported
20// by the QML engine. As workaround, we use Theming named import.20// by the QML engine. As workaround, we use Ubuntu named import.
21// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-2764521// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
22import Ubuntu.Components 0.1 as Theming22import Ubuntu.Components 0.1 as Ubuntu
2323
24/*!24/*!
25 \internal25 \internal
@@ -27,10 +27,8 @@
27 \inqmlmodule Ubuntu.Components 0.127 \inqmlmodule Ubuntu.Components 0.1
28 \ingroup ubuntu28 \ingroup ubuntu
29*/29*/
30Item {30StyledItem {
31 id: header31 id: header
32 // FIXME: see above
33 Theming.ItemStyle.class: "header"
3432
35 anchors {33 anchors {
36 left: parent.left34 left: parent.left
@@ -41,10 +39,9 @@
41 Behavior on y {39 Behavior on y {
42 enabled: !(header.flickable && header.flickable.moving)40 enabled: !(header.flickable && header.flickable.moving)
43 SmoothedAnimation {41 SmoothedAnimation {
44 duration: Theming.UbuntuAnimation.FastDuration42 duration: Ubuntu.UbuntuAnimation.FastDuration
45 }43 }
46 }44 }
47 height: units.gu(10)
4845
49 /*! \internal */46 /*! \internal */
50 onHeightChanged: internal.movementEnded()47 onHeightChanged: internal.movementEnded()
@@ -157,4 +154,6 @@
157 if (flickable && !flickable.interactive) header.show();154 if (flickable && !flickable.interactive) header.show();
158 }155 }
159 }156 }
157
158 style: Theme.createStyleComponent("HeaderStyle.qml", header)
160}159}
161160
=== modified file 'modules/Ubuntu/Components/Label.qml'
--- modules/Ubuntu/Components/Label.qml 2013-05-20 08:34:52 +0000
+++ modules/Ubuntu/Components/Label.qml 2013-07-01 22:15:52 +0000
@@ -15,11 +15,6 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18// FIXME: When a module contains QML, C++ and JavaScript elements exported,
19// we need to use named imports otherwise namespace collision is reported
20// by the QML engine. As workaround, we use Theming named import.
21// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
22import Ubuntu.Components 0.1 as Theming
2318
24/*!19/*!
25 \qmltype Label20 \qmltype Label
@@ -45,8 +40,6 @@
45Text {40Text {
46 id: label41 id: label
4742
48 Theming.ItemStyle.class: "label"
49
50 /*!43 /*!
51 The size of the text. One of the following strings (from smallest to largest):44 The size of the text. One of the following strings (from smallest to largest):
52 \list45 \list
@@ -63,8 +56,5 @@
6356
64 font.pixelSize: FontUtils.sizeToPixels(fontSize)57 font.pixelSize: FontUtils.sizeToPixels(fontSize)
65 font.family: "Ubuntu"58 font.family: "Ubuntu"
66 /* FIXME: do not set any font subproperties (e.g. font.family, font.italic, etc.)59 color: "#757373"
67 as setting there default value here will prevent them from being overriden
68 by the theme.
69 */
70}60}
7161
=== modified file 'modules/Ubuntu/Components/MainView.qml'
--- modules/Ubuntu/Components/MainView.qml 2013-06-14 16:28:04 +0000
+++ modules/Ubuntu/Components/MainView.qml 2013-07-01 22:15:52 +0000
@@ -15,11 +15,6 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18// FIXME: When a module contains QML, C++ and JavaScript elements exported,
19// we need to use named imports otherwise namespace collision is reported
20// by the QML engine. As workaround, we use Theming named import.
21// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
22import Ubuntu.Components 0.1 as Theming
2318
24/*!19/*!
25 \qmltype MainView20 \qmltype MainView
@@ -140,13 +135,13 @@
140 */135 */
141 property string applicationName136 property string applicationName
142137
143 // FIXME: Make sure that the theming is only in the background, and the delegate138 // FIXME: Make sure that the theming is only in the background, and the style
144 // should not occlude contents of the MainView. When making changes here, make139 // should not occlude contents of the MainView. When making changes here, make
145 // sure that bug https://bugs.launchpad.net/manhattan/+bug/1124076 does not come back.140 // sure that bug https://bugs.launchpad.net/manhattan/+bug/1124076 does not come back.
146 Item {141 StyledItem {
147 id: background142 id: background
148 Theming.ItemStyle.class: "mainview"
149 anchors.fill: parent143 anchors.fill: parent
144 style: Theme.createStyleComponent("MainViewStyle.qml", background)
150 }145 }
151146
152 /*!147 /*!
153148
=== modified file 'modules/Ubuntu/Components/PageTreeNode.qml'
--- modules/Ubuntu/Components/PageTreeNode.qml 2013-05-21 18:06:28 +0000
+++ modules/Ubuntu/Components/PageTreeNode.qml 2013-07-01 22:15:52 +0000
@@ -26,7 +26,7 @@
26 It is used to propagate properties such as \l header and \l toolbar from a26 It is used to propagate properties such as \l header and \l toolbar from a
27 \l MainView (the root node) to each \l Page (leaf node) in the tree.27 \l MainView (the root node) to each \l Page (leaf node) in the tree.
28*/28*/
29Item {29StyledItem {
30 id: node30 id: node
3131
32 /*!32 /*!
3333
=== modified file 'modules/Ubuntu/Components/Panel.qml'
--- modules/Ubuntu/Components/Panel.qml 2013-06-13 13:39:32 +0000
+++ modules/Ubuntu/Components/Panel.qml 2013-07-01 22:15:52 +0000
@@ -86,7 +86,6 @@
8686
87 Item {87 Item {
88 anchors.fill: parent88 anchors.fill: parent
89 ItemStyle.class: "toolbar"
9089
91 // two properties used by the toolbar delegate:90 // two properties used by the toolbar delegate:
92 property bool opened: panel.opened91 property bool opened: panel.opened
9392
=== modified file 'modules/Ubuntu/Components/Popups/ActionSelectionPopover.qml'
--- modules/Ubuntu/Components/Popups/ActionSelectionPopover.qml 2013-06-12 18:52:01 +0000
+++ modules/Ubuntu/Components/Popups/ActionSelectionPopover.qml 2013-07-01 22:15:52 +0000
@@ -17,7 +17,6 @@
17import QtQuick 2.017import QtQuick 2.0
18import "../" 0.118import "../" 0.1
19import "../ListItems" 0.119import "../ListItems" 0.1
20import "../" 0.1 as Theming
2120
22/*!21/*!
23 \qmltype ActionSelectionPopover22 \qmltype ActionSelectionPopover
2423
=== modified file 'modules/Ubuntu/Components/Popups/Dialog.qml'
--- modules/Ubuntu/Components/Popups/Dialog.qml 2013-05-28 19:25:47 +0000
+++ modules/Ubuntu/Components/Popups/Dialog.qml 2013-07-01 22:15:52 +0000
@@ -16,11 +16,6 @@
1616
17import QtQuick 2.017import QtQuick 2.0
18import Ubuntu.Components 0.118import Ubuntu.Components 0.1
19// FIXME: When a module contains QML, C++ and JavaScript elements exported,
20// we need to use named imports otherwise namespace collision is reported
21// by the QML engine. As workaround, we use Theming named import.
22// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
23import Ubuntu.Components 0.1 as Theming
24import "internalPopupUtils.js" as InternalPopupUtils19import "internalPopupUtils.js" as InternalPopupUtils
2520
26/*!21/*!
@@ -120,13 +115,13 @@
120 The property holds the margins from the dialog's dismissArea. The property115 The property holds the margins from the dialog's dismissArea. The property
121 is themed.116 is themed.
122 */117 */
123 property real edgeMargins118 property real edgeMargins: units.gu(2)
124119
125 /*!120 /*!
126 The property holds the margin from the dialog's caller. The property121 The property holds the margin from the dialog's caller. The property
127 is themed.122 is themed.
128 */123 */
129 property real callerMargin124 property real callerMargin: units.gu(1)
130125
131 /*!126 /*!
132 The property controls whether the dialog is modal or not. Modal dialogs block127 The property controls whether the dialog is modal or not. Modal dialogs block
@@ -138,8 +133,6 @@
138 */133 */
139 property bool modal: true134 property bool modal: true
140135
141 Theming.ItemStyle.class: "dialog"
142
143 /*136 /*
144 QtObject {137 QtObject {
145 id: internal138 id: internal
@@ -157,22 +150,21 @@
157 __foreground: foreground150 __foreground: foreground
158 __eventGrabber.enabled: modal151 __eventGrabber.enabled: modal
159 __dimBackground: modal152 __dimBackground: modal
153 fadingAnimation: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
160154
161 Item {155 StyledItem {
162 id: foreground156 id: foreground
163 // FIXME: see above
164 Theming.ItemStyle.class: "foreground"
165 width: Math.min(minimumWidth, dialog.width)157 width: Math.min(minimumWidth, dialog.width)
166 anchors.centerIn: parent158 anchors.centerIn: parent
167159
168 // used in the delegate160 // used in the style
169 property string title161 property string title
170 property string text162 property string text
171 property real minimumWidth163 property real minimumWidth: units.gu(38)
172 property real minimumHeight164 property real minimumHeight: units.gu(32)
173 property real maxHeight: 3*dialog.height/4165 property real maxHeight: 3*dialog.height/4
174 property real margins166 property real margins: units.gu(4)
175 property real itemSpacing167 property real itemSpacing: units.gu(2)
176 property Item dismissArea: dialog.dismissArea168 property Item dismissArea: dialog.dismissArea
177169
178 height: Math.min(childrenRect.height, dialog.height)170 height: Math.min(childrenRect.height, dialog.height)
@@ -190,14 +182,18 @@
190 onWidthChanged: updateChildrenWidths();182 onWidthChanged: updateChildrenWidths();
191183
192 Label {184 Label {
193 ItemStyle.class: "title"
194 horizontalAlignment: Text.AlignHCenter185 horizontalAlignment: Text.AlignHCenter
195 text: dialog.title186 text: dialog.title
187 fontSize: "large"
188 color: Qt.rgba(1, 1, 1, 0.9)
196 }189 }
197190
198 Label {191 Label {
199 horizontalAlignment: Text.AlignHCenter192 horizontalAlignment: Text.AlignHCenter
200 text: dialog.text193 text: dialog.text
194 fontSize: "medium"
195 color: Qt.rgba(1, 1, 1, 0.6)
196 wrapMode: Text.Wrap
201 }197 }
202198
203 onChildrenChanged: updateChildrenWidths()199 onChildrenChanged: updateChildrenWidths()
@@ -208,5 +204,7 @@
208 }204 }
209 }205 }
210 }206 }
207
208 style: Theme.createStyleComponent("DialogForegroundStyle.qml", foreground)
211 }209 }
212}210}
213211
=== modified file 'modules/Ubuntu/Components/Popups/Pointer.qml'
--- modules/Ubuntu/Components/Popups/Pointer.qml 2013-03-14 11:48:53 +0000
+++ modules/Ubuntu/Components/Popups/Pointer.qml 2013-07-01 22:15:52 +0000
@@ -15,21 +15,16 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18// FIXME: When a module contains QML, C++ and JavaScript elements exported,18import Ubuntu.Components 0.1
19// we need to use named imports otherwise namespace collision is reported
20// by the QML engine. As workaround, we use Theming named import.
21// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
22import Ubuntu.Components 0.1 as Theming
2319
24// internal class, used inside subclasses of PopupBase20// internal class, used inside subclasses of PopupBase
25Item {21StyledItem {
26 id: pointer22 id: pointer
27 Theming.ItemStyle.class: "pointer"
2823
29 // Using Item.Rotation does not play well with the24 // Using Item.Rotation does not play well with the
30 // translation that would be needed after rotating.25 // translation that would be needed after rotating.
31 property real longAxis26 property real longAxis: units.gu(2)
32 property real shortAxis27 property real shortAxis: units.gu(1)
3328
34 // up, down, left or right, or none to hide the pointer29 // up, down, left or right, or none to hide the pointer
35 property string direction: "down"30 property string direction: "down"
@@ -39,4 +34,6 @@
3934
40 width: rotate ? shortAxis : longAxis35 width: rotate ? shortAxis : longAxis
41 height: rotate ? longAxis : shortAxis36 height: rotate ? longAxis : shortAxis
37
38 style: Theme.createStyleComponent("PointerStyle.qml", pointer)
42}39}
4340
=== modified file 'modules/Ubuntu/Components/Popups/Popover.qml'
--- modules/Ubuntu/Components/Popups/Popover.qml 2013-05-24 09:12:56 +0000
+++ modules/Ubuntu/Components/Popups/Popover.qml 2013-07-01 22:15:52 +0000
@@ -16,11 +16,7 @@
1616
17import QtQuick 2.017import QtQuick 2.0
18import "internalPopupUtils.js" as InternalPopupUtils18import "internalPopupUtils.js" as InternalPopupUtils
19// FIXME: When a module contains QML, C++ and JavaScript elements exported,19import Ubuntu.Components 0.1
20// we need to use named imports otherwise namespace collision is reported
21// by the QML engine. As workaround, we use Theming named import.
22// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
23import Ubuntu.Components 0.1 as Theming
2420
25/*!21/*!
26 \qmltype Popover22 \qmltype Popover
@@ -129,13 +125,13 @@
129 The property holds the margins from the popover's dismissArea. The property125 The property holds the margins from the popover's dismissArea. The property
130 is themed.126 is themed.
131 */127 */
132 property real edgeMargins128 property real edgeMargins: units.gu(2)
133129
134 /*!130 /*!
135 The property holds the margin from the popover's caller. The property131 The property holds the margin from the popover's caller. The property
136 is themed.132 is themed.
137 */133 */
138 property real callerMargin134 property real callerMargin: units.gu(1)
139135
140 /*!136 /*!
141 The property drives the automatic closing of the Popover when user taps137 The property drives the automatic closing of the Popover when user taps
@@ -147,7 +143,7 @@
147 */143 */
148 property bool autoClose: true144 property bool autoClose: true
149145
150 Theming.ItemStyle.class: "popover"146 fadingAnimation: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
151147
152 QtObject {148 QtObject {
153 id: internal149 id: internal
@@ -164,13 +160,11 @@
164 __eventGrabber.enabled: autoClose160 __eventGrabber.enabled: autoClose
165 __closeOnDismissAreaPress: true161 __closeOnDismissAreaPress: true
166162
167 Item {163 StyledItem {
168 id: foreground164 id: foreground
169165
170 // FIXME: see above
171 Theming.ItemStyle.class: "foreground"
172 //styling properties166 //styling properties
173 property real minimumWidth167 property real minimumWidth: units.gu(40)
174168
175 property real maxWidth: dismissArea ? (internal.portrait ? dismissArea.width : dismissArea.width * 3/4) : 0.0169 property real maxWidth: dismissArea ? (internal.portrait ? dismissArea.width : dismissArea.width * 3/4) : 0.0
176 property real maxHeight: dismissArea ? (internal.portrait ? dismissArea.height * 3/4 : dismissArea.height) : 0.0170 property real maxHeight: dismissArea ? (internal.portrait ? dismissArea.height * 3/4 : dismissArea.height) : 0.0
@@ -179,6 +173,7 @@
179173
180 Item {174 Item {
181 id: containerItem175 id: containerItem
176 parent: foreground.__styleInstance.contentItem
182 anchors {177 anchors {
183 left: parent.left178 left: parent.left
184 top: parent.top179 top: parent.top
@@ -189,6 +184,8 @@
189184
190 onWidthChanged: internal.updatePosition()185 onWidthChanged: internal.updatePosition()
191 onHeightChanged: internal.updatePosition()186 onHeightChanged: internal.updatePosition()
187
188 style: Theme.createStyleComponent("PopoverForegroundStyle.qml", foreground)
192 }189 }
193190
194 Pointer { id: pointer }191 Pointer { id: pointer }
195192
=== modified file 'modules/Ubuntu/Components/Popups/PopupBase.qml'
--- modules/Ubuntu/Components/Popups/PopupBase.qml 2013-05-24 10:07:44 +0000
+++ modules/Ubuntu/Components/Popups/PopupBase.qml 2013-07-01 22:15:52 +0000
@@ -15,11 +15,6 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18// FIXME: When a module contains QML, C++ and JavaScript elements exported,
19// we need to use named imports otherwise namespace collision is reported
20// by the QML engine. As workaround, we use Theming named import.
21// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
22import Ubuntu.Components 0.1 as Theming
23import Ubuntu.Components 0.118import Ubuntu.Components 0.1
2419
25/*!20/*!
@@ -134,14 +129,14 @@
134 // dimmer129 // dimmer
135 Rectangle {130 Rectangle {
136 id: background131 id: background
137 Theming.ItemStyle.class: "background"
138 // styling properties132 // styling properties
139 property bool dim: false133 property bool dim: false
140 anchors.fill: parent134 anchors.fill: parent
141 visible: dim135 visible: dim
136 color: popupBase.width > units.gu(60) ? Qt.rgba(0, 0, 0, 0.6) : Qt.rgba(0, 0, 0, 0.9)
142 }137 }
143138
144 Theming.InverseMouseArea {139 InverseMouseArea {
145 id: eventGrabber140 id: eventGrabber
146 enabled: true141 enabled: true
147 anchors.fill: __foreground142 anchors.fill: __foreground
148143
=== modified file 'modules/Ubuntu/Components/Popups/SheetBase.qml'
--- modules/Ubuntu/Components/Popups/SheetBase.qml 2013-05-19 19:03:44 +0000
+++ modules/Ubuntu/Components/Popups/SheetBase.qml 2013-07-01 22:15:52 +0000
@@ -16,11 +16,6 @@
1616
17import QtQuick 2.017import QtQuick 2.0
18import Ubuntu.Components 0.118import Ubuntu.Components 0.1
19// FIXME: When a module contains QML, C++ and JavaScript elements exported,
20// we need to use named imports otherwise namespace collision is reported
21// by the QML engine. As workaround, we use Theming named import.
22// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
23import Ubuntu.Components 0.1 as Theming
2419
25/*!20/*!
26 \qmltype SheetBase21 \qmltype SheetBase
@@ -78,17 +73,14 @@
78 /*! \internal */73 /*! \internal */
79 property alias __rightButton: foreground.rightButton74 property alias __rightButton: foreground.rightButton
8075
81 Theming.ItemStyle.class: "sheet"76 fadingAnimation: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
8277
83 __foreground: foreground78 __foreground: foreground
84 __eventGrabber.enabled: modal79 __eventGrabber.enabled: modal
8580
86 Item {81 StyledItem {
87 id: foreground82 id: foreground
8883
89 // FIXME: see above
90 Theming.ItemStyle.class: "foreground"
91
92 property string title84 property string title
93 property real contentsWidth: units.gu(64)85 property real contentsWidth: units.gu(64)
94 property real contentsHeight: units.gu(40)86 property real contentsHeight: units.gu(40)
@@ -103,21 +95,15 @@
103 property real minHeight: Math.min(units.gu(40), sheet.height)95 property real minHeight: Math.min(units.gu(40), sheet.height)
104 property real maxHeight: sheet.height96 property real maxHeight: sheet.height
10597
106 // childrenRect includes the delegate which may add decoration
107 // to the sheet (such as a header with title), and thus width and height
108 // can differ from contentsWidth and contentsHeight.
109 // Delegate makes use of minWidth/maxWidth/minHeight/maxHeight properties
110 // which are defined above. Those properties are not moved to the delegate
111 // because here we have easy access to sheet.width and sheet.height.
112 width: childrenRect.width
113 height: childrenRect.height
114
115 Item {98 Item {
116 id: containerItem99 id: containerItem
100 parent: foreground.__styleInstance.contentItem
117 anchors {101 anchors {
118 fill: parent102 fill: parent
119 margins: units.gu(1)103 margins: units.gu(1)
120 }104 }
121 }105 }
106
107 style: Theme.createStyleComponent("SheetForegroundStyle.qml", sheet)
122 }108 }
123}109}
124110
=== modified file 'modules/Ubuntu/Components/Scrollbar.qml'
--- modules/Ubuntu/Components/Scrollbar.qml 2013-03-14 11:56:06 +0000
+++ modules/Ubuntu/Components/Scrollbar.qml 2013-07-01 22:15:52 +0000
@@ -15,11 +15,6 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18// FIXME: When a module contains QML, C++ and JavaScript elements exported,
19// we need to use named imports otherwise namespace collision is reported
20// by the QML engine. As workaround, we use Theming named import.
21// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
22import Ubuntu.Components 0.1 as Theming
2318
24/*!19/*!
25 \qmltype ScrollBar20 \qmltype ScrollBar
@@ -35,7 +30,7 @@
35 direction (RTL or LTR).30 direction (RTL or LTR).
3631
37 The content position is driven through the attached Flickable. Therefore every32 The content position is driven through the attached Flickable. Therefore every
38 delegate implementation should drive the position through contentX/contentY33 style implementation should drive the position through contentX/contentY
39 properties, depending on whether the orientation is vertical or horizontal.34 properties, depending on whether the orientation is vertical or horizontal.
4035
41 Example:36 Example:
@@ -63,7 +58,7 @@
63 \endqml58 \endqml
64 */59 */
6560
66Item {61StyledItem {
67 id: scrollbar62 id: scrollbar
6863
69 /*!64 /*!
@@ -94,9 +89,6 @@
94 */89 */
95 property bool __interactive: false90 property bool __interactive: false
9691
97 // styling
98 Theming.ItemStyle.class: "scrollbar"
99
100 implicitWidth: internals.vertical ? units.gu(4) : flickableItem.width92 implicitWidth: internals.vertical ? units.gu(4) : flickableItem.width
101 implicitHeight: !internals.vertical ? units.gu(4) : flickableItem.height93 implicitHeight: !internals.vertical ? units.gu(4) : flickableItem.height
10294
@@ -154,4 +146,6 @@
154 return undefined;146 return undefined;
155 }147 }
156 }148 }
149
150 style: Theme.createStyleComponent("ScrollbarStyle.qml", scrollbar)
157}151}
158152
=== modified file 'modules/Ubuntu/Components/Slider.qml'
--- modules/Ubuntu/Components/Slider.qml 2013-05-24 09:12:56 +0000
+++ modules/Ubuntu/Components/Slider.qml 2013-07-01 22:15:52 +0000
@@ -33,11 +33,6 @@
33import QtQuick 2.033import QtQuick 2.0
34import "mathUtils.js" as MathUtils34import "mathUtils.js" as MathUtils
35import "sliderUtils.js" as SliderFuncs35import "sliderUtils.js" as SliderFuncs
36// FIXME: When a module contains QML, C++ and JavaScript elements exported,
37// we need to use named imports otherwise namespace collision is reported
38// by the QML engine. As workaround, we use Theming named import.
39// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
40import "." 0.1 as Theming
4136
42/*!37/*!
43 \qmltype Slider38 \qmltype Slider
@@ -47,7 +42,7 @@
47 values.42 values.
4843
49 The slider's sensing area is defined by the width and height, therefore44 The slider's sensing area is defined by the width and height, therefore
50 delegates should take this into account when defining the visuals, and45 styles should take this into account when defining the visuals, and
51 alter these values to align the graphics' sizes.46 alter these values to align the graphics' sizes.
5247
53 \l {http://design.ubuntu.com/apps/building-blocks/slider}{See also the Design Guidelines on Sliders}.48 \l {http://design.ubuntu.com/apps/building-blocks/slider}{See also the Design Guidelines on Sliders}.
@@ -68,16 +63,16 @@
68 \section2 Theming63 \section2 Theming
6964
70 The slider's default style class is \b slider and style properties depend on65 The slider's default style class is \b slider and style properties depend on
71 the actual delegate defined by the theme, except of one property which defines66 the actual style defined by the theme, except of one property which defines
72 the spacing units between the slider's bar and thumb, called \b thumbSpacing.67 the spacing units between the slider's bar and thumb, called \b thumbSpacing.
73 The slider uses one single touch sensing area to position the thumb within the68 The slider uses one single touch sensing area to position the thumb within the
74 bar. Therefore However delegates must define the following properties:69 bar. Therefore However styles must define the following properties:
75 \list70 \list
76 \li * \b bar - the slider's bar object71 \li * \b bar - the slider's bar object
77 \li * \b thumb - the slider's thumb object72 \li * \b thumb - the slider's thumb object
78 \endlist73 \endlist
7974
80 Beside these, the library provies functions for delegates to update liveValue and75 Beside these, the library provies functions for styles to update liveValue and
81 normalizedValue in SliderUtils module.76 normalizedValue in SliderUtils module.
8277
83 \b{This component is under heavy development.}78 \b{This component is under heavy development.}
@@ -88,8 +83,6 @@
88 width: units.gu(38)83 width: units.gu(38)
89 height: units.gu(5)84 height: units.gu(5)
9085
91 Theming.ItemStyle.class: "slider"
92
93 // FIXME(loicm) Add Support for the inverted property. There's an ongoing86 // FIXME(loicm) Add Support for the inverted property. There's an ongoing
94 // debate on whether we should use that property (like every other87 // debate on whether we should use that property (like every other
95 // toolkits) or add new enumerations to the orientation property and88 // toolkits) or add new enumerations to the orientation property and
@@ -157,7 +150,7 @@
157 default, the value v is rounded to the nearest interger value.150 default, the value v is rounded to the nearest interger value.
158151
159 \b Note: this function will be deprecated, and will be solved with particular152 \b Note: this function will be deprecated, and will be solved with particular
160 delegates for the thumb.153 styles for the thumb.
161 */154 */
162 function formatValue(v) {155 function formatValue(v) {
163 return v.toFixed(0)156 return v.toFixed(0)
@@ -179,9 +172,9 @@
179 QtObject {172 QtObject {
180 id: internals173 id: internals
181174
182 property real thumbSpacing: slider.Theming.ItemStyle.delegate ? slider.Theming.ItemStyle.delegate.thumbSpacing : 0175 property real thumbSpacing: slider.__styleInstance ? slider.__styleInstance.thumbSpacing : 0
183 property Item bar: slider.Theming.ItemStyle.delegate ? slider.Theming.ItemStyle.delegate.bar : null176 property Item bar: slider.__styleInstance ? slider.__styleInstance.bar : null
184 property Item thumb: slider.Theming.ItemStyle.delegate ? slider.Theming.ItemStyle.delegate.thumb : null177 property Item thumb: slider.__styleInstance ? slider.__styleInstance.thumb : null
185178
186 property real liveValue: 0.0179 property real liveValue: 0.0
187 property real normalizedValue: MathUtils.clamp((liveValue - slider.minimumValue) /180 property real normalizedValue: MathUtils.clamp((liveValue - slider.minimumValue) /
@@ -244,4 +237,6 @@
244 }237 }
245 }238 }
246 }239 }
240
241 style: Theme.createStyleComponent("SliderStyle.qml", slider)
247}242}
248243
=== added file 'modules/Ubuntu/Components/StyledItem.qml'
--- modules/Ubuntu/Components/StyledItem.qml 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Components/StyledItem.qml 2013-07-01 22:15:52 +0000
@@ -0,0 +1,70 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18
19/*!
20 \qmlabstract StyledItem
21 \inqmlmodule Ubuntu.Components 0.1
22 \ingroup theming
23 \brief The StyledItem class allows items to be styled by the theme.
24
25 StyledItem provides facilities for making an Item stylable by the theme.
26
27 In order to make an Item stylable by the theme, it is enough to make the Item
28 inherit from StyledItem and set its \l style property to be the result of the
29 appropriate call to Theme.createStyleComponent().
30
31 Example definition of a custom Item MyItem.qml:
32 \qml
33 StyledItem {
34 id: myItem
35 style: Theme.createStyleComponent("MyItemStyle.qml", myItem)
36 }
37 \endqml
38
39 The Component set on \l style is instantiated and placed below everything else
40 that the Item contains.
41
42 A reference to the Item being styled is accessible from the style and named
43 'styledItem'.
44
45 \sa {Theme}
46*/
47FocusScope {
48 id: styledItem
49
50 /*!
51 Component instantiated immediately and placed below everything else.
52 */
53 property Component style
54
55 /*!
56 \internal
57 Instance of the \l style.
58 */
59 readonly property Item __styleInstance: styleLoader.status == Loader.Ready ? styleLoader.item : null
60
61 implicitWidth: __styleInstance ? __styleInstance.implicitWidth : 0
62 implicitHeight: __styleInstance ? __styleInstance.implicitHeight : 0
63
64 Loader {
65 id: styleLoader
66 anchors.fill: parent
67 sourceComponent: style
68 property Item styledItem: styledItem
69 }
70}
071
=== modified file 'modules/Ubuntu/Components/Switch.qml'
--- modules/Ubuntu/Components/Switch.qml 2013-05-24 09:12:56 +0000
+++ modules/Ubuntu/Components/Switch.qml 2013-07-01 22:15:52 +0000
@@ -19,12 +19,6 @@
1919
20import QtQuick 2.020import QtQuick 2.0
2121
22// FIXME: When a module contains QML, C++ and JavaScript elements exported,
23// we need to use named imports otherwise namespace collision is reported
24// by the QML engine. As workaround, we use Theming named import.
25// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
26import Ubuntu.Components 0.1 as Theming
27
28/*!22/*!
29 \qmltype Switch23 \qmltype Switch
30 \inqmlmodule Ubuntu.Components 0.124 \inqmlmodule Ubuntu.Components 0.1
@@ -47,5 +41,6 @@
47 \endqml41 \endqml
48*/42*/
49CheckBox {43CheckBox {
50 Theming.ItemStyle.class: "switch"44 id: switchItem
45 style: Theme.createStyleComponent("SwitchStyle.qml", switchItem)
51}46}
5247
=== modified file 'modules/Ubuntu/Components/Tabs.qml'
--- modules/Ubuntu/Components/Tabs.qml 2013-05-24 19:47:47 +0000
+++ modules/Ubuntu/Components/Tabs.qml 2013-07-01 22:15:52 +0000
@@ -15,11 +15,6 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18// FIXME: When a module contains QML, C++ and JavaScript elements exported,
19// we need to use named imports otherwise namespace collision is reported
20// by the QML engine. As workaround, we use Theming named import.
21// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
22import Ubuntu.Components 0.1 as Theming
2318
24/*!19/*!
25 \qmltype Tabs20 \qmltype Tabs
@@ -100,8 +95,6 @@
10095
101PageTreeNode {96PageTreeNode {
102 id: tabs97 id: tabs
103 // FIXME: see above
104 Theming.ItemStyle.class: "new-tabs"
105 anchors.fill: parent98 anchors.fill: parent
10699
107 /*!100 /*!
@@ -128,7 +121,7 @@
128 \internal121 \internal
129 Header contents that will be used to override the default title inside the header,122 Header contents that will be used to override the default title inside the header,
130 and provides scrollable tab buttons.123 and provides scrollable tab buttons.
131 FIXME: headerContents may be specified here directly, not taken from the delegate.124 FIXME: headerContents may be specified here directly, not taken from the style.
132 */125 */
133 property Component __headerContents126 property Component __headerContents
134127
@@ -147,7 +140,7 @@
147140
148 /*!141 /*!
149 \internal142 \internal
150 Used by the delegate to create the tabs header.143 Used by the style to create the tabs header.
151 */144 */
152 property alias __tabs: tabsModel.tabList145 property alias __tabs: tabsModel.tabList
153146
@@ -158,7 +151,7 @@
158 default property alias tabChildren: tabsModel.children151 default property alias tabChildren: tabsModel.children
159152
160 /*!153 /*!
161 Used by the tabs delegate to update the tabs header with the titles of all the tabs.154 Used by the tabs style to update the tabs header with the titles of all the tabs.
162 This signal is used in an intermediate step in transitioning the tabs to a new155 This signal is used in an intermediate step in transitioning the tabs to a new
163 implementation and may be removed in the future.156 implementation and may be removed in the future.
164 */157 */
@@ -166,7 +159,7 @@
166159
167 /*!160 /*!
168 \internal161 \internal
169 required by NewTabsDelegate162 required by TabsStyle
170 */163 */
171 Item {164 Item {
172 anchors.fill: parent165 anchors.fill: parent
@@ -218,4 +211,6 @@
218 }211 }
219 }212 }
220 }213 }
214
215 style: Theme.createStyleComponent("TabsStyle.qml", tabs)
221}216}
222217
=== modified file 'modules/Ubuntu/Components/TextArea.qml'
--- modules/Ubuntu/Components/TextArea.qml 2013-05-19 19:23:40 +0000
+++ modules/Ubuntu/Components/TextArea.qml 2013-07-01 22:15:52 +0000
@@ -15,11 +15,6 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18// FIXME: When a module contains QML, C++ and JavaScript elements exported,
19// we need to use named imports otherwise namespace collision is reported
20// by the QML engine. As workaround, we use Theming named import.
21// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
22import "." 0.1 as Theming
2318
24/*!19/*!
25 \qmltype TextArea20 \qmltype TextArea
@@ -76,12 +71,10 @@
76 character or word. The editor leaves the selection mode by pressing/tapping again on it71 character or word. The editor leaves the selection mode by pressing/tapping again on it
77 or by losing focus.72 or by losing focus.
7873
79 The default styling uses \b textarea selector.
80
81 \b{This component is under heavy development.}74 \b{This component is under heavy development.}
82 */75 */
8376
84FocusScope {77StyledItem {
85 id: control78 id: control
86 implicitWidth: units.gu(30)79 implicitWidth: units.gu(30)
87 implicitHeight: (autoSize) ? internal.minimumSize : internal.linesHeight(4)80 implicitHeight: (autoSize) ? internal.minimumSize : internal.linesHeight(4)
@@ -96,19 +89,7 @@
96 property bool highlighted: focus89 property bool highlighted: focus
97 /*!90 /*!
98 Text that appears when there is no focus and no content in the component91 Text that appears when there is no focus and no content in the component
99 (hint text). The hint style can be customized by defining a style selector which92 (hint text).
100 styles a label. For example the default styling defines the hint styling using
101 \b{.textarea .label} selector.
102
103 \code
104 .textarea .label {
105 italic: true;
106 color: "#B6B6B6";
107 fontSize: "small";
108 elide: Text.ElideRight;
109 wrapMode: Text.WordWrap;
110 }
111 \endcode
11293
113 \qmlproperty string placeholderText94 \qmlproperty string placeholderText
114 */95 */
@@ -740,8 +721,6 @@
740 // the editor activates automatically when pressed in the editor control,721 // the editor activates automatically when pressed in the editor control,
741 // however that one can be slightly spaced to the main control area722 // however that one can be slightly spaced to the main control area
742723
743 // styling
744 Theming.ItemStyle.class: "textarea"
745 //internals724 //internals
746725
747 /*!\internal */726 /*!\internal */
@@ -766,7 +745,7 @@
766 // public property locals enabling aliasing745 // public property locals enabling aliasing
767 property string displayText: editor.getText(0, editor.length)746 property string displayText: editor.getText(0, editor.length)
768 property real lineSpacing: units.dp(3)747 property real lineSpacing: units.dp(3)
769 property real frameSpacing: 0748 property real frameSpacing: control.__styleInstance.frameSpacing
770 property real lineSize: editor.font.pixelSize + lineSpacing749 property real lineSize: editor.font.pixelSize + lineSpacing
771 property real minimumSize: units.gu(4)750 property real minimumSize: units.gu(4)
772 property real inputAreaWidth: control.width - 2 * frameSpacing751 property real inputAreaWidth: control.width - 2 * frameSpacing
@@ -892,7 +871,6 @@
892 id: leftCursorLoader871 id: leftCursorLoader
893 onStatusChanged: {872 onStatusChanged: {
894 if (status == Loader.Ready && item) {873 if (status == Loader.Ready && item) {
895 item.Theming.ItemStyle.class = "left-pin";
896 item.positionProperty = "selectionStart";874 item.positionProperty = "selectionStart";
897 item.parent = editor;875 item.parent = editor;
898 }876 }
@@ -902,7 +880,6 @@
902 id: rightCursorLoader880 id: rightCursorLoader
903 onStatusChanged: {881 onStatusChanged: {
904 if (status == Loader.Ready && item) {882 if (status == Loader.Ready && item) {
905 item.Theming.ItemStyle.class = "right-pin";
906 item.positionProperty = "selectionEnd";883 item.positionProperty = "selectionEnd";
907 item.parent = editor;884 item.parent = editor;
908 }885 }
@@ -922,6 +899,10 @@
922 }899 }
923 // hint is shown till user types something in the field900 // hint is shown till user types something in the field
924 visible: (editor.getText(0, editor.length) == "") && !editor.inputMethodComposing901 visible: (editor.getText(0, editor.length) == "") && !editor.inputMethodComposing
902 color: Qt.rgba(0.5, 0.5, 0.5, 0.5)
903 fontSize: "medium"
904 elide: Text.ElideRight
905 wrapMode: Text.WordWrap
925 }906 }
926907
927 //scrollbars and flickable908 //scrollbars and flickable
@@ -976,6 +957,10 @@
976 mouseSelectionMode: TextEdit.SelectWords957 mouseSelectionMode: TextEdit.SelectWords
977 selectByMouse: false958 selectByMouse: false
978 cursorDelegate: cursor959 cursorDelegate: cursor
960 color: control.__styleInstance.color
961 selectedTextColor: "#F3F3E7"
962 selectionColor: "#19B6EE"
963 font.pixelSize: FontUtils.sizeToPixels("medium")
979 // forward keys to the root element so it can be captured outside of it964 // forward keys to the root element so it can be captured outside of it
980 Keys.forwardTo: [control]965 Keys.forwardTo: [control]
981966
@@ -1034,4 +1019,6 @@
1034 }1019 }
1035 }1020 }
1036 }1021 }
1022
1023 style: Theme.createStyleComponent("TextAreaStyle.qml", control)
1037}1024}
10381025
=== modified file 'modules/Ubuntu/Components/TextCursor.qml'
--- modules/Ubuntu/Components/TextCursor.qml 2013-02-13 09:36:45 +0000
+++ modules/Ubuntu/Components/TextCursor.qml 2013-07-01 22:15:52 +0000
@@ -15,12 +15,12 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18import "." 0.1 as Theming
19import "Popups" 0.118import "Popups" 0.1
2019
21Item {20StyledItem {
22 id: cursorItem21 id: cursorItem
23 Theming.ItemStyle.class: "cursor"22
23 width: units.dp(1)
2424
25 /*25 /*
26 Property holding the text input item instance.26 Property holding the text input item instance.
@@ -57,4 +57,6 @@
57 })57 })
58 }58 }
59 }59 }
60
61 style: Theme.createStyleComponent("TextCursorStyle.qml", cursorItem)
60}62}
6163
=== modified file 'modules/Ubuntu/Components/TextField.qml'
--- modules/Ubuntu/Components/TextField.qml 2013-06-03 13:51:10 +0000
+++ modules/Ubuntu/Components/TextField.qml 2013-07-01 22:15:52 +0000
@@ -15,11 +15,6 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18// FIXME: When a module contains QML, C++ and JavaScript elements exported,
19// we need to use named imports otherwise namespace collision is reported
20// by the QML engine. As workaround, we use Theming named import.
21// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
22import "." 0.1 as Theming
2318
24/*!19/*!
25 \qmltype TextField20 \qmltype TextField
@@ -59,14 +54,12 @@
59 }54 }
60 secondaryItem: Row {55 secondaryItem: Row {
61 Button {56 Button {
62 ItemStyle.class: "transparent-button"
63 height: parent.height57 height: parent.height
64 width: height58 width: height
65 iconSource: "caps-lock.png"59 iconSource: "caps-lock.png"
66 onClicked: doSomething()60 onClicked: doSomething()
67 }61 }
68 Button {62 Button {
69 ItemStyle.class: "transparent-button"
70 height: parent.height63 height: parent.height
71 width: height64 width: height
72 iconSource: "num-lock.png"65 iconSource: "num-lock.png"
@@ -78,7 +71,7 @@
78 \endqml71 \endqml
79*/72*/
8073
81FocusScope {74StyledItem {
82 id: control75 id: control
8376
84 implicitWidth: units.gu(25)77 implicitWidth: units.gu(25)
@@ -519,7 +512,6 @@
519 }512 }
520513
521 // internals514 // internals
522 Theming.ItemStyle.class: "textfield"
523515
524 /*! internal */516 /*! internal */
525 onVisibleChanged: {517 onVisibleChanged: {
@@ -545,7 +537,7 @@
545 id: internal537 id: internal
546 // array of borders in left, top, right, bottom order538 // array of borders in left, top, right, bottom order
547 property bool textChanged: false539 property bool textChanged: false
548 property real spacing: 0540 property real spacing: control.__styleInstance.overlaySpacing
549 property real lineSpacing: units.dp(3)541 property real lineSpacing: units.dp(3)
550 property real lineSize: editor.font.pixelSize + lineSpacing542 property real lineSize: editor.font.pixelSize + lineSpacing
551 //selection properties543 //selection properties
@@ -656,8 +648,7 @@
656648
657 AbstractButton {649 AbstractButton {
658 id: clearButton650 id: clearButton
659 Theming.ItemStyle.class: "clear-button"651 property url iconSource: control.__styleInstance.iconSource
660 property url iconSource
661 anchors {652 anchors {
662 top: parent.top653 top: parent.top
663 right: rightPane.left654 right: rightPane.left
@@ -695,6 +686,9 @@
695 }686 }
696 // hint is shown till user types something in the field687 // hint is shown till user types something in the field
697 visible: (editor.text == "") && !editor.inputMethodComposing688 visible: (editor.text == "") && !editor.inputMethodComposing
689 color: Qt.rgba(0.5, 0.5, 0.5, 0.5)
690 fontSize: "medium"
691 elide: Text.ElideRight
698 }692 }
699693
700694
@@ -713,6 +707,11 @@
713 clip: true707 clip: true
714 onTextChanged: internal.textChanged = true708 onTextChanged: internal.textChanged = true
715 cursorDelegate: cursor709 cursorDelegate: cursor
710 color: control.__styleInstance.color
711 selectedTextColor: "#F3F3E7"
712 selectionColor: "#19B6EE"
713 font.pixelSize: FontUtils.sizeToPixels("medium")
714 passwordCharacter: "\u2022"
716 // forward keys to the root element so it can be captured outside of it715 // forward keys to the root element so it can be captured outside of it
717 Keys.forwardTo: [control]716 Keys.forwardTo: [control]
718717
@@ -778,4 +777,6 @@
778 editor.accepted.connect(control.accepted);777 editor.accepted.connect(control.accepted);
779 cursorPosition = 0;778 cursorPosition = 0;
780 }779 }
780
781 style: Theme.createStyleComponent("TextFieldStyle.qml", control)
781}782}
782783
=== renamed directory 'themes' => 'modules/Ubuntu/Components/Themes'
=== renamed file 'themes/Ambiance/qmltheme/ActivityIndicatorDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/ActivityIndicatorStyle.qml'
--- themes/Ambiance/qmltheme/ActivityIndicatorDelegate.qml 2013-05-14 13:33:39 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/ActivityIndicatorStyle.qml 2013-07-01 22:15:52 +0000
@@ -22,13 +22,14 @@
2222
23 anchors.fill: parent23 anchors.fill: parent
24 smooth: true24 smooth: true
25 visible: item.running25 visible: styledItem.running
26 fillMode: Image.PreserveAspectFit26 fillMode: Image.PreserveAspectFit
27 horizontalAlignment: Image.AlignHCenter27 horizontalAlignment: Image.AlignHCenter
28 verticalAlignment: Image.AlignVCenter28 verticalAlignment: Image.AlignVCenter
29 source: "artwork/spinner.png"
2930
30 NumberAnimation on rotation {31 NumberAnimation on rotation {
31 running: item.running32 running: styledItem.running
32 from: 033 from: 0
33 to: 36034 to: 360
34 loops: Animation.Infinite35 loops: Animation.Infinite
3536
=== added file 'modules/Ubuntu/Components/Themes/Ambiance/Ambiance.pro'
--- modules/Ubuntu/Components/Themes/Ambiance/Ambiance.pro 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/Ambiance.pro 2013-07-01 22:15:52 +0000
@@ -0,0 +1,23 @@
1TEMPLATE = subdirs
2
3uri = Ubuntu.Components.Themes.Ambiance
4installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /)
5
6QMLDIR_FILE = qmldir
7QML_FILES = *.qml
8ARTWORK_FILES += artwork/*.png \
9 artwork/*.svg \
10 artwork/*.sci
11
12qmldir_file.path = $$installPath
13qmldir_file.files = $$QMLDIR_FILE
14
15qml_files.path = $$installPath
16qml_files.files = $$QML_FILES
17
18artwork_files.path = $$installPath/artwork
19artwork_files.files = $$ARTWORK_FILES
20
21
22INSTALLS += qmldir_file qml_files artwork_files
23OTHER_FILES += $$QMLDIR_FILE $$QML_FILES $$ARTWORK_FILES
024
=== renamed file 'themes/Ambiance/qmltheme/ButtonDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/ButtonStyle.qml'
--- themes/Ambiance/qmltheme/ButtonDelegate.qml 2013-06-26 23:42:39 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/ButtonStyle.qml 2013-07-01 22:15:52 +0000
@@ -22,8 +22,8 @@
22 anchors.fill: parent22 anchors.fill: parent
2323
24 // styling properties24 // styling properties
25 property url borderSource25 property url borderSource: "artwork/ubuntushape_small_radius_idle.sci"
26 property url borderPressed26 property url borderPressed: "artwork/ubuntushape_small_radius_pressed.sci"
2727
28 // pick either a clear or dark text color depending on the luminance of the28 // pick either a clear or dark text color depending on the luminance of the
29 // background color to maintain good contrast (works in most cases)29 // background color to maintain good contrast (works in most cases)
@@ -39,7 +39,7 @@
39 id: border39 id: border
4040
41 anchors.fill: parent41 anchors.fill: parent
42 color: item.color42 color: styledItem.color
43 borderSource: visuals.borderSource43 borderSource: visuals.borderSource
44 opacity: 1.0 - borderPressed.opacity44 opacity: 1.0 - borderPressed.opacity
45 visible: color.a != 0.045 visible: color.a != 0.0
@@ -49,14 +49,14 @@
49 id: borderPressed49 id: borderPressed
5050
51 anchors.fill: parent51 anchors.fill: parent
52 color: item.color52 color: styledItem.color
53 borderSource: visuals.borderPressed53 borderSource: visuals.borderPressed
54 opacity: item.pressed ? 1.0 : 0.054 opacity: styledItem.pressed ? 1.0 : 0.0
55 Behavior on opacity { UbuntuNumberAnimation {} }55 Behavior on opacity { UbuntuNumberAnimation {} }
56 visible: color.a != 0.056 visible: color.a != 0.0
57 }57 }
5858
59 TransparentButtonDelegate {59 TransparentButtonStyle {
60 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"60 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"
61 }61 }
62}62}
6363
=== renamed file 'themes/Ambiance/qmltheme/CheckBoxDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/CheckBoxStyle.qml'
--- themes/Ambiance/qmltheme/CheckBoxDelegate.qml 2013-07-01 12:50:42 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/CheckBoxStyle.qml 2013-07-01 22:15:52 +0000
@@ -20,24 +20,28 @@
20Item {20Item {
21 id: visuals21 id: visuals
22 // styling properties22 // styling properties
23 property color checkedColor23 property color checkedColor: "#DD4814"
24 property color uncheckedColor24 property color uncheckedColor: Qt.rgba(0.0, 0.0, 0.0, 0.1)
25
25 /*!26 /*!
26 The image to show inside the checkbox when it is checked.27 The image to show inside the checkbox when it is checked.
27 */28 */
28 property url checkMarkSource29 property url checkMarkSource: "artwork/CheckMark.png"
29 /*!30 /*!
30 The animation to fade the color from checkedColor to uncheckedColor and vice versa.31 The animation to fade the color from checkedColor to uncheckedColor and vice versa.
31 */32 */
32 property PropertyAnimation backgroundColorAnimation: PropertyAnimation{duration: 0}33 property PropertyAnimation backgroundColorAnimation: ColorAnimation { duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing }
3334
34 // code35 // code
35 anchors.fill: parent36 anchors.fill: parent
36 opacity: enabled ? 1.0 : 0.537 opacity: enabled ? 1.0 : 0.5
3738
39 implicitWidth: units.gu(4)
40 implicitHeight: units.gu(4)
41
38 UbuntuShape {42 UbuntuShape {
39 anchors.fill: parent43 anchors.fill: parent
40 color: item.checked ? checkedColor : uncheckedColor44 color: styledItem.checked ? checkedColor : uncheckedColor
41 Behavior on color {45 Behavior on color {
42 ColorAnimation {46 ColorAnimation {
43 duration: backgroundColorAnimation.duration47 duration: backgroundColorAnimation.duration
@@ -51,7 +55,7 @@
51 anchors.centerIn: parent55 anchors.centerIn: parent
52 smooth: true56 smooth: true
53 source: checkMarkSource57 source: checkMarkSource
54 opacity: item.checked ? 1.0 : 0.058 opacity: styledItem.checked ? 1.0 : 0.0
55 Behavior on opacity {59 Behavior on opacity {
56 UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }60 UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
57 }61 }
5862
=== renamed file 'themes/Ambiance/qmltheme/DialogForegroundDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/DialogForegroundStyle.qml'
--- themes/Ambiance/qmltheme/DialogForegroundDelegate.qml 2013-06-28 13:56:45 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/DialogForegroundStyle.qml 2013-07-01 22:15:52 +0000
@@ -20,8 +20,9 @@
20Item {20Item {
21 id: visuals21 id: visuals
22 // styling properties22 // styling properties
23 property color color23 visible: styledItem.dismissArea.width > units.gu(60)
24 property string radius24 property color color: visible ? Qt.rgba(0, 0, 0, 0.7) : "transparent"
25 property string radius: "medium"
2526
26 anchors.fill: parent27 anchors.fill: parent
27 z: -128 z: -1
2829
=== renamed file 'themes/Ambiance/qmltheme/HeaderDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/HeaderStyle.qml'
--- themes/Ambiance/qmltheme/HeaderDelegate.qml 2013-05-06 11:18:06 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/HeaderStyle.qml 2013-07-01 22:15:52 +0000
@@ -17,7 +17,7 @@
17import Ubuntu.Components 0.117import Ubuntu.Components 0.1
1818
19Item {19Item {
20 id: headerDelegate20 id: headerStyle
21 /*!21 /*!
22 The height of the headercontents, which is the full height of22 The height of the headercontents, which is the full height of
23 the header minus the separators shown at the bottom of it.23 the header minus the separators shown at the bottom of it.
@@ -27,43 +27,33 @@
27 /*!27 /*!
28 The background color of the header.28 The background color of the header.
29 */29 */
30 property color backgroundColor: "transparent"30 property color backgroundColor: "#ededf0"
3131
32 /*!32 /*!
33 The source of the background image of the header. If the image is has (semi-)transparent33 The source of the background image of the header. If the image is has (semi-)transparent
34 pixels, \l backgroundColor can be set to specify the color behind those (semi-)transparent34 pixels, \l backgroundColor can be set to specify the color behind those (semi-)transparent
35 pixels.35 pixels.
36 */36 */
37 property url backgroundSource: ""37 property url backgroundSource: "artwork/background_paper.png"
3838
39 /*!39 /*!
40 The source of the image that separates the header from the contents of a \l MainView.40 The source of the image that separates the header from the contents of a \l MainView.
41 The separator will be drawn over the contents.41 The separator will be drawn over the contents.
42 */42 */
43 property url separatorSource: ""43 property url separatorSource: "artwork/PageHeaderBaseDividerLight.sci"
4444
45 /*!45 /*!
46 The source of an additional image attached to the bottom of the separator. The contents46 The source of an additional image attached to the bottom of the separator. The contents
47 of the \l MainView will be drawn on top of the separator bottom image.47 of the \l MainView will be drawn on top of the separator bottom image.
48 */48 */
49 property url separatorBottomSource: ""49 property url separatorBottomSource: "artwork/PageHeaderBaseDividerBottom.png"
5050
51 property int fontWeight51 property int fontWeight: Font.Light
52 property string fontSize: "x-large"52 property string fontSize: "x-large"
53 property color textColor: "black"53 property color textColor: Qt.rgba(0.51, 0.51, 0.51, 0.9)
54 property real textLeftMargin54 property real textLeftMargin: units.gu(2)
5555
56 anchors {56 implicitHeight: headerStyle.contentHeight + separator.height + separatorBottom.height
57 left: parent ? parent.left : undefined
58 right: parent ? parent.right : undefined
59 top: parent ? parent.top : undefined
60 }
61 height: headerDelegate.contentHeight + separator.height + separatorBottom.height
62 Binding {
63 target: item
64 property: "height"
65 value: height
66 }
6757
68 Rectangle {58 Rectangle {
69 id: backgroundColor59 id: backgroundColor
@@ -72,9 +62,9 @@
72 right: parent.right62 right: parent.right
73 top: parent.top63 top: parent.top
74 }64 }
75 color: headerDelegate.backgroundColor65 color: headerStyle.backgroundColor
76 visible: color != "transparent"66 visible: color != "transparent"
77 height: headerDelegate.contentHeight + separator.height67 height: headerStyle.contentHeight + separator.height
78 }68 }
79 Image {69 Image {
80 id: background70 id: background
@@ -83,10 +73,10 @@
83 right: parent.right73 right: parent.right
84 top: parent.top74 top: parent.top
85 }75 }
86 source: headerDelegate.backgroundSource76 source: headerStyle.backgroundSource
87 visible: source != ""77 visible: source != ""
88 fillMode: Image.Tile78 fillMode: Image.Tile
89 height: headerDelegate.contentHeight + separator.height79 height: headerStyle.contentHeight + separator.height
90 }80 }
91 BorderImage {81 BorderImage {
92 id: separator82 id: separator
@@ -95,7 +85,7 @@
95 left: parent.left85 left: parent.left
96 right: parent.right86 right: parent.right
97 }87 }
98 source: headerDelegate.separatorSource88 source: headerStyle.separatorSource
99 }89 }
100 Image {90 Image {
101 id: separatorBottom91 id: separatorBottom
@@ -104,7 +94,7 @@
104 left: parent.left94 left: parent.left
105 right: parent.right95 right: parent.right
106 }96 }
107 source: headerDelegate.separatorBottomSource97 source: headerStyle.separatorBottomSource
108 }98 }
10999
110 Item {100 Item {
@@ -114,23 +104,22 @@
114 right: parent.right104 right: parent.right
115 top: parent.top105 top: parent.top
116 }106 }
117 height: headerDelegate.contentHeight107 height: headerStyle.contentHeight
118108
119 Label {109 Label {
120 anchors {110 anchors {
121 left: parent.left111 left: parent.left
122 verticalCenter: parent.verticalCenter112 verticalCenter: parent.verticalCenter
123 leftMargin: headerDelegate.textLeftMargin113 leftMargin: headerStyle.textLeftMargin
124 }114 }
125 text: item.title115 text: styledItem.title
126 font.weight: headerDelegate.fontWeight116 font.weight: headerStyle.fontWeight
127 visible: contentsLoader.status != Loader.Ready117 visible: contentsLoader.status != Loader.Ready
128 fontSize: headerDelegate.fontSize118 fontSize: headerStyle.fontSize
129 color: headerDelegate.textColor119 color: headerStyle.textColor
130 }120 }
131121
132 // Link to item here, because Loader has its own item property122 property Header header: styledItem
133 property Header header: item
134 Loader {123 Loader {
135 id: contentsLoader124 id: contentsLoader
136 sourceComponent: foreground.header.contents125 sourceComponent: foreground.header.contents
137126
=== renamed file 'themes/Ambiance/qmltheme/MainViewDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/MainViewStyle.qml'
--- themes/Ambiance/qmltheme/MainViewDelegate.qml 2013-03-14 12:52:13 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/MainViewStyle.qml 2013-07-01 22:15:52 +0000
@@ -20,29 +20,29 @@
20 // styling properties20 // styling properties
21 anchors.fill: parent21 anchors.fill: parent
22 z: -122 z: -1
23 id: mainViewDelegate23 id: mainViewStyle
2424
25 /*!25 /*!
26 The background color of the main view.26 The background color of the main view.
27 */27 */
28 property color backgroundColor28 property color backgroundColor: "#ededf0"
2929
30 /*!30 /*!
31 The background texture of the main view. The image will be drawn over the background color,31 The background texture of the main view. The image will be drawn over the background color,
32 so if it has (semi-)transparent pixels, in those pixels the background color will be visible.32 so if it has (semi-)transparent pixels, in those pixels the background color will be visible.
33 */33 */
34 property url backgroundSource: ""34 property url backgroundSource: "artwork/background_paper.png"
3535
36 Rectangle {36 Rectangle {
37 id: backgroundColor37 id: backgroundColor
38 anchors.fill: parent38 anchors.fill: parent
39 color: mainViewDelegate.backgroundColor39 color: mainViewStyle.backgroundColor
40 }40 }
4141
42 Image {42 Image {
43 id: backgroundTexture43 id: backgroundTexture
44 anchors.fill: parent44 anchors.fill: parent
45 source: mainViewDelegate.backgroundSource45 source: mainViewStyle.backgroundSource
46 fillMode: Image.Tile46 fillMode: Image.Tile
47 }47 }
48}48}
4949
=== renamed file 'themes/Ambiance/qmltheme/NewTabBar.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/NewTabBar.qml'
=== renamed file 'themes/Ambiance/qmltheme/PointerDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/PointerStyle.qml'
--- themes/Ambiance/qmltheme/PointerDelegate.qml 2013-03-14 12:01:42 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/PointerStyle.qml 2013-07-01 22:15:52 +0000
@@ -23,7 +23,11 @@
23 id: image23 id: image
24 anchors.fill: parent24 anchors.fill: parent
2525
26 visible: (item.direction !== "none")26 visible: (styledItem.direction !== "none")
27 source: (styledItem.direction === "left") ? "artwork/LeftArrow.png" :
28 (styledItem.direction === "right") ? "artwork/RightArrow.png" :
29 (styledItem.direction === "up") ? "artwork/UpArrow.png" :
30 "artwork/DownArrow.png"
2731
28 smooth: true32 smooth: true
29}33}
3034
=== renamed file 'themes/Ambiance/qmltheme/PointerDelegateShader.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/PointerStyleShader.qml'
--- themes/Ambiance/qmltheme/PointerDelegateShader.qml 2012-12-14 18:19:26 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/PointerStyleShader.qml 2013-07-01 22:15:52 +0000
@@ -29,12 +29,12 @@
29 // but I did not manage to get a 3x3 matrix from QML into the shader.29 // but I did not manage to get a 3x3 matrix from QML into the shader.
3030
31 // rotate pointer 90 degrees31 // rotate pointer 90 degrees
32 property bool rotate: (item.direction === "left" || item.direction === "right")32 property bool rotate: (styledItem.direction === "left" || styledItem.direction === "right")
3333
34 // flip the direction of the pointer34 // flip the direction of the pointer
35 property bool flip: (item.direction === "left" || item.direction === "up")35 property bool flip: (styledItem.direction === "left" || styledItem.direction === "up")
3636
37 visible: (item.direction !== "none")37 visible: (styledItem.direction !== "none")
3838
39 vertexShader: "39 vertexShader: "
40 uniform highp mat4 qt_Matrix;40 uniform highp mat4 qt_Matrix;
4141
=== renamed file 'themes/Ambiance/qmltheme/PopoverForegroundDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/PopoverForegroundStyle.qml'
--- themes/Ambiance/qmltheme/PopoverForegroundDelegate.qml 2013-06-28 13:56:45 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/PopoverForegroundStyle.qml 2013-07-01 22:15:52 +0000
@@ -21,8 +21,8 @@
21Item {21Item {
22 id: frame22 id: frame
23 // styling properties23 // styling properties
24 property string radius: "small"24 property string radius: "medium"
25 property color color25 property color color: "white"
2626
27 property alias contentItem: body27 property alias contentItem: body
2828
2929
=== renamed file 'themes/Ambiance/qmltheme/ScrollbarDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/ScrollbarStyle.qml'
--- themes/Ambiance/qmltheme/ScrollbarDelegate.qml 2013-03-13 12:26:20 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/ScrollbarStyle.qml 2013-07-01 22:15:52 +0000
@@ -19,7 +19,7 @@
1919
20/*20/*
21 The visuals handle both active and passive modes. This behavior is driven yet by21 The visuals handle both active and passive modes. This behavior is driven yet by
22 the item's __inactive property, however should be detected upon runtime based on22 the styledItem's __inactive property, however should be detected upon runtime based on
23 the device type.23 the device type.
24 On active scrollbars, positioning is handled so that the logic updates the flickable's24 On active scrollbars, positioning is handled so that the logic updates the flickable's
25 X/Y content positions, which is then synched with the contentPosition by the main25 X/Y content positions, which is then synched with the contentPosition by the main
@@ -63,36 +63,36 @@
63 property real overlayOpacityWhenShown: 0.663 property real overlayOpacityWhenShown: 0.6
64 property real overlayOpacityWhenHidden: 0.064 property real overlayOpacityWhenHidden: 0.0
6565
66 property PropertyAnimation scrollbarFadeInAnimation: PropertyAnimation{duration: 100}66 property PropertyAnimation scrollbarFadeInAnimation: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
67 property PropertyAnimation scrollbarFadeOutAnimation: PropertyAnimation{duration: 100}67 property PropertyAnimation scrollbarFadeOutAnimation: UbuntuNumberAnimation { duration: UbuntuAnimation.SlowDuration }
68 property int scrollbarFadeOutPause: 10068 property int scrollbarFadeOutPause: 300
69 property PropertyAnimation sliderAnimation: PropertyAnimation{duration: 100}69 property PropertyAnimation sliderAnimation: UbuntuNumberAnimation {}
70 property PropertyAnimation thumbConnectorFading: PropertyAnimation{duration: 100}70 property PropertyAnimation thumbConnectorFading: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
71 property PropertyAnimation thumbFading: PropertyAnimation{duration: 100}71 property PropertyAnimation thumbFading: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
7272
73 property color sliderColor73 property color sliderColor: Qt.rgba(0.5, 0.5, 0.5, 0.7)
74 property real sliderRadius74 property real sliderRadius: units.gu(0.5)
75 property color thumbConnectorColor75 property color thumbConnectorColor: "white"
76 property url forwardThumbReleased76 property url forwardThumbReleased: (styledItem.align === Qt.AlignLeading || styledItem.align === Qt.AlignTrailing) ? "artwork/ScrollbarBottomIdle.png" : "artwork/ScrollbarRightIdle.png"
77 property url forwardThumbPressed77 property url forwardThumbPressed: (styledItem.align === Qt.AlignLeading || styledItem.align === Qt.AlignTrailing) ? "artwork/ScrollbarBottomPressed.png" : "artwork/ScrollbarRightPressed.png"
78 property url backwardThumbReleased78 property url backwardThumbReleased: (styledItem.align === Qt.AlignLeading || styledItem.align === Qt.AlignTrailing) ? "artwork/ScrollbarTopIdle.png" : "artwork/ScrollbarLeftIdle.png"
79 property url backwardThumbPressed79 property url backwardThumbPressed: (styledItem.align === Qt.AlignLeading || styledItem.align === Qt.AlignTrailing) ? "artwork/ScrollbarTopPressed.png" : "artwork/ScrollbarLeftPressed.png"
8080
81 property real scrollAreaThickness81 property real scrollAreaThickness: units.gu(0.5)
82 property real thumbConnectorMargin82 property real thumbConnectorMargin: units.dp(3)
8383
84 // helper properties to ease code readability84 // helper properties to ease code readability
85 property Flickable flickableItem: item.flickableItem85 property Flickable flickableItem: styledItem.flickableItem
86 property bool isScrollable: item.__private.scrollable && pageSize > 0.086 property bool isScrollable: styledItem.__private.scrollable && pageSize > 0.0
87 && contentSize > 0.0 && contentSize > pageSize87 && contentSize > 0.0 && contentSize > pageSize
88 property bool isVertical: ScrollbarUtils.isVertical(item)88 property bool isVertical: ScrollbarUtils.isVertical(styledItem)
89 property bool frontAligned: (item.align === Qt.AlignLeading)89 property bool frontAligned: (styledItem.align === Qt.AlignLeading)
90 property bool rearAligned: (item.align === Qt.AlignTrailing)90 property bool rearAligned: (styledItem.align === Qt.AlignTrailing)
91 property bool topAligned: (item.align === Qt.AlignTop)91 property bool topAligned: (styledItem.align === Qt.AlignTop)
92 property bool bottomAligned: (item.align === Qt.AlignBottom)92 property bool bottomAligned: (styledItem.align === Qt.AlignBottom)
9393
94 property real pageSize: (isVertical) ? item.height : item.width94 property real pageSize: (isVertical) ? styledItem.height : styledItem.width
95 property real contentSize: (isVertical) ? item.flickableItem.contentHeight : item.flickableItem.contentWidth95 property real contentSize: (isVertical) ? styledItem.flickableItem.contentHeight : styledItem.flickableItem.contentWidth
9696
97 /*****************************************97 /*****************************************
98 Visuals98 Visuals
@@ -184,7 +184,7 @@
184184
185 duration: 200185 duration: 200
186 easing.type: Easing.InOutQuad186 easing.type: Easing.InOutQuad
187 target: item.flickableItem187 target: styledItem.flickableItem
188 property: (isVertical) ? "contentY" : "contentX"188 property: (isVertical) ? "contentY" : "contentX"
189 }189 }
190190
@@ -193,7 +193,7 @@
193 id: scrollbarArea193 id: scrollbarArea
194194
195 property real thickness: scrollAreaThickness195 property real thickness: scrollAreaThickness
196 property real proximityThickness: (isVertical) ? item.width - thickness : item.height - thickness196 property real proximityThickness: (isVertical) ? styledItem.width - thickness : styledItem.height - thickness
197 anchors {197 anchors {
198 fill: parent198 fill: parent
199 leftMargin: (!isVertical || frontAligned) ? 0 : proximityThickness199 leftMargin: (!isVertical || frontAligned) ? 0 : proximityThickness
@@ -230,13 +230,13 @@
230 // total size of the flickable.230 // total size of the flickable.
231 Item {231 Item {
232 id: scrollCursor232 id: scrollCursor
233 x: (isVertical) ? 0 : ScrollbarUtils.sliderPos(item, 0.0, item.width - scrollCursor.width)233 x: (isVertical) ? 0 : ScrollbarUtils.sliderPos(styledItem, 0.0, styledItem.width - scrollCursor.width)
234 y: (!isVertical) ? 0 : ScrollbarUtils.sliderPos(item, 0.0, item.height - scrollCursor.height)234 y: (!isVertical) ? 0 : ScrollbarUtils.sliderPos(styledItem, 0.0, styledItem.height - scrollCursor.height)
235 width: (isVertical) ? scrollbarArea.thickness : ScrollbarUtils.sliderSize(item, 0.0, flickableItem.width)235 width: (isVertical) ? scrollbarArea.thickness : ScrollbarUtils.sliderSize(styledItem, 0.0, flickableItem.width)
236 height: (!isVertical) ? scrollbarArea.thickness : ScrollbarUtils.sliderSize(item, 0.0, flickableItem.height)236 height: (!isVertical) ? scrollbarArea.thickness : ScrollbarUtils.sliderSize(styledItem, 0.0, flickableItem.height)
237237
238 function drag() {238 function drag() {
239 ScrollbarUtils.dragAndClamp(item, scrollCursor, contentSize, pageSize);239 ScrollbarUtils.dragAndClamp(styledItem, scrollCursor, contentSize, pageSize);
240 }240 }
241 }241 }
242242
@@ -252,10 +252,10 @@
252 bottom: (!isVertical) ? scrollbarArea.bottom : undefined252 bottom: (!isVertical) ? scrollbarArea.bottom : undefined
253 }253 }
254254
255 x: (isVertical) ? 0 : ScrollbarUtils.sliderPos(item, 0.0, item.width - slider.width)255 x: (isVertical) ? 0 : ScrollbarUtils.sliderPos(styledItem, 0.0, styledItem.width - slider.width)
256 y: (!isVertical) ? 0 : ScrollbarUtils.sliderPos(item, 0.0, item.height - slider.height)256 y: (!isVertical) ? 0 : ScrollbarUtils.sliderPos(styledItem, 0.0, styledItem.height - slider.height)
257 width: (isVertical) ? scrollbarArea.thickness : ScrollbarUtils.sliderSize(item, minimumSliderSize, flickableItem.width)257 width: (isVertical) ? scrollbarArea.thickness : ScrollbarUtils.sliderSize(styledItem, minimumSliderSize, flickableItem.width)
258 height: (!isVertical) ? scrollbarArea.thickness : ScrollbarUtils.sliderSize(item, minimumSliderSize, flickableItem.height)258 height: (!isVertical) ? scrollbarArea.thickness : ScrollbarUtils.sliderSize(styledItem, minimumSliderSize, flickableItem.height)
259 radius: visuals.sliderRadius259 radius: visuals.sliderRadius
260260
261 Behavior on width {261 Behavior on width {
@@ -274,7 +274,7 @@
274 }274 }
275275
276 function scroll(amount) {276 function scroll(amount) {
277 scrollAnimation.to = ScrollbarUtils.scrollAndClamp(item, amount, 0.0, contentSize - pageSize);277 scrollAnimation.to = ScrollbarUtils.scrollAndClamp(styledItem, amount, 0.0, contentSize - pageSize);
278 scrollAnimation.restart();278 scrollAnimation.restart();
279 }279 }
280 }280 }
@@ -417,7 +417,7 @@
417 height: childrenRect.height417 height: childrenRect.height
418418
419 property bool shown419 property bool shown
420 property int maximumPos: (isVertical) ? item.height - thumb.height : item.width - thumb.width420 property int maximumPos: (isVertical) ? styledItem.height - thumb.height : styledItem.width - thumb.width
421421
422 /* Show the thumb as close as possible to the mouse pointer */422 /* Show the thumb as close as possible to the mouse pointer */
423 onShownChanged: {423 onShownChanged: {
424424
=== renamed file 'themes/Ambiance/qmltheme/SelectionCursorDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/SelectionCursorStyle.qml'
--- themes/Ambiance/qmltheme/SelectionCursorDelegate.qml 2013-03-13 15:22:23 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/SelectionCursorStyle.qml 2013-07-01 22:15:52 +0000
@@ -17,11 +17,12 @@
17import QtQuick 2.017import QtQuick 2.0
18import Ubuntu.Components 0.118import Ubuntu.Components 0.1
1919
20EditorCursorDelegate {20EditorCursorStyle {
21 id: cursor21 id: cursor
2222
23 property bool startPin: (item.positionProperty === "selectionStart")23 blinking: false
24 property int cursorPosition: item.editorItem[item.positionProperty]24 property bool startPin: (styledItem.positionProperty === "selectionStart")
25 property int cursorPosition: styledItem.editorItem[styledItem.positionProperty]
2526
26 visible: true27 visible: true
2728
@@ -29,7 +30,7 @@
29 {30 {
30 if (undefined === pos)31 if (undefined === pos)
31 return;32 return;
32 var rect = item.editorItem.positionToRectangle(pos);33 var rect = styledItem.editorItem.positionToRectangle(pos);
33 x = rect.x;34 x = rect.x;
34 y = rect.y;35 y = rect.y;
35 }36 }
@@ -78,13 +79,13 @@
7879
79 function updateEditorCursorPosition()80 function updateEditorCursorPosition()
80 {81 {
81 var pos = item.editorItem.mapFromItem(item, cursor.x, cursor.y + cursor.height / 2);82 var pos = styledItem.editorItem.mapFromItem(styledItem, cursor.x, cursor.y + cursor.height / 2);
82 var dx = dragArea.cursorStartX + dragDX;83 var dx = dragArea.cursorStartX + dragDX;
83 var dy = dragArea.cursorStartY + dragDY;84 var dy = dragArea.cursorStartY + dragDY;
84 if (startPin)85 if (startPin)
85 item.editorItem.select(item.editorItem.positionAt(dx, dy), item.editorItem.selectionEnd);86 styledItem.editorItem.select(styledItem.editorItem.positionAt(dx, dy), styledItem.editorItem.selectionEnd);
86 else87 else
87 item.editorItem.select(item.editorItem.selectionStart, item.editorItem.positionAt(dx, dy));88 styledItem.editorItem.select(styledItem.editorItem.selectionStart, styledItem.editorItem.positionAt(dx, dy));
88 }89 }
89 }90 }
90 }91 }
9192
=== renamed file 'themes/Ambiance/qmltheme/SheetForegroundDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/SheetForegroundStyle.qml'
--- themes/Ambiance/qmltheme/SheetForegroundDelegate.qml 2013-04-08 13:30:17 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/SheetForegroundStyle.qml 2013-07-01 22:15:52 +0000
@@ -20,13 +20,13 @@
20Item {20Item {
21 id: visuals21 id: visuals
22 // styling properties22 // styling properties
23 property color backgroundColor23 property color backgroundColor: "lightgray"
24 property color headerColor24 property color headerColor: "darkgray"
25 property real headerHeight25 property real headerHeight: units.gu(8)
26 property real buttonContainerWidth26 property real buttonContainerWidth: units.gu(14)
2727
28 width: MathUtils.clamp(item.contentsWidth, item.minWidth, item.maxWidth)28 implicitWidth: MathUtils.clamp(styledItem.contentsWidth, styledItem.minWidth, styledItem.maxWidth)
29 height: header.height + containerItem.height29 implicitHeight: header.height + containerItem.height
3030
31 property alias contentItem: containerItem31 property alias contentItem: containerItem
3232
@@ -50,7 +50,7 @@
50 width: headerText.implicitWidth + units.gu(4)50 width: headerText.implicitWidth + units.gu(4)
51 elide: Text.ElideRight51 elide: Text.ElideRight
52 horizontalAlignment: Text.AlignHCenter52 horizontalAlignment: Text.AlignHCenter
53 text: item.title53 text: styledItem.title
54 }54 }
5555
56 Item {56 Item {
@@ -61,7 +61,7 @@
61 bottom: parent.bottom61 bottom: parent.bottom
62 }62 }
63 width: visuals.buttonContainerWidth63 width: visuals.buttonContainerWidth
64 Component.onCompleted: header.updateButton(item.leftButton, leftButtonContainer)64 Component.onCompleted: header.updateButton(styledItem.leftButton, leftButtonContainer)
65 }65 }
6666
67 Item {67 Item {
@@ -72,7 +72,7 @@
72 bottom: parent.bottom72 bottom: parent.bottom
73 }73 }
74 width: visuals.buttonContainerWidth74 width: visuals.buttonContainerWidth
75 Component.onCompleted: header.updateButton(item.rightButton, rightButtonContainer)75 Component.onCompleted: header.updateButton(styledItem.rightButton, rightButtonContainer)
76 }76 }
7777
78 function updateButton(button, container) {78 function updateButton(button, container) {
@@ -85,16 +85,16 @@
85 }85 }
8686
87 Connections {87 Connections {
88 target: item88 target: styledItem
89 onLeftButtonChanged: header.updateButton(item.leftButton, leftButtonContainer)89 onLeftButtonChanged: header.updateButton(styledItem.leftButton, leftButtonContainer)
90 onRightButtonChanged: header.updateButton(item.rightButton, rightButtonContainer)90 onRightButtonChanged: header.updateButton(styledItem.rightButton, rightButtonContainer)
91 }91 }
92 }92 }
9393
94 Rectangle {94 Rectangle {
95 id: containerItem95 id: containerItem
96 color: visuals.backgroundColor96 color: visuals.backgroundColor
97 height: MathUtils.clamp(item.contentsHeight, item.minHeight - header.height, item.maxHeight - header.height)97 height: MathUtils.clamp(styledItem.contentsHeight, styledItem.minHeight - header.height, styledItem.maxHeight - header.height)
98 anchors {98 anchors {
99 top: header.bottom99 top: header.bottom
100 left: parent.left100 left: parent.left
101101
=== renamed file 'themes/Ambiance/qmltheme/SliderDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/SliderStyle.qml'
--- themes/Ambiance/qmltheme/SliderDelegate.qml 2013-03-25 14:55:38 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/SliderStyle.qml 2013-07-01 22:15:52 +0000
@@ -19,10 +19,9 @@
1919
20/*20/*
21 The default slider style consists of a bar and a thumb shape, where the thumb21 The default slider style consists of a bar and a thumb shape, where the thumb
22 is having a label showing the actual value. This label can be styled using22 is having a label showing the actual value.
23 \b{.slider .label} selector.
2423
25 This delegate is styled using the following properties:24 This style is styled using the following properties:
26 - backgroundColor: color for the slider bar25 - backgroundColor: color for the slider bar
27 - thumbColor: color for the thumb26 - thumbColor: color for the thumb
28 - thumbSpacing: spacing between the thumb and the bar27 - thumbSpacing: spacing between the thumb and the bar
@@ -34,10 +33,10 @@
34 id: main33 id: main
35 // styling properties34 // styling properties
3635
37 property color backgroundColor: "white"36 property color backgroundColor: "#c0c0c0"
38 property color thumbColor: "darkgray"37 property color thumbColor: "#bbbbbb"
39 property real thumbSpacing: 038 property real thumbSpacing: units.dp(2)
40 property real backgroundOpacity: 1.039 property real backgroundOpacity: 0.1
41 property real thumbOpacity: 1.040 property real thumbOpacity: 1.0
4241
43 // visuals42 // visuals
@@ -49,10 +48,10 @@
4948
50 // private properties49 // private properties
5150
52 property real liveValue: SliderUtils.liveValue(item)51 property real liveValue: SliderUtils.liveValue(styledItem)
53 property real normalizedValue: SliderUtils.normalizedValue(item)52 property real normalizedValue: SliderUtils.normalizedValue(styledItem)
54 property real thumbSpace: backgroundShape.width - (2.0 * thumbSpacing + thumbWidth)53 property real thumbSpace: backgroundShape.width - (2.0 * thumbSpacing + thumbWidth)
55 property real thumbWidth: item.height - thumbSpacing54 property real thumbWidth: styledItem.height - thumbSpacing
5655
57 UbuntuShape {56 UbuntuShape {
58 id: backgroundShape57 id: backgroundShape
@@ -81,6 +80,9 @@
81 right: thumbShape.right80 right: thumbShape.right
82 }81 }
83 horizontalAlignment: Text.AlignHCenter82 horizontalAlignment: Text.AlignHCenter
84 text: item.formatValue(MathUtils.clamp(liveValue, item.minimumValue, item.maximumValue))83 text: styledItem.formatValue(MathUtils.clamp(liveValue, styledItem.minimumValue, styledItem.maximumValue))
84 fontSize: "medium"
85 color: "white"
86 font.weight: Font.Bold
85 }87 }
86}88}
8789
=== renamed file 'themes/Ambiance/qmltheme/SwitchDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/SwitchStyle.qml'
--- themes/Ambiance/qmltheme/SwitchDelegate.qml 2013-07-01 12:50:42 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/SwitchStyle.qml 2013-07-01 22:15:52 +0000
@@ -19,8 +19,8 @@
19Item {19Item {
20 id: visuals20 id: visuals
21 // style properties21 // style properties
22 property url crossSource22 property url crossSource: "artwork/Cross.png"
23 property url checkMarkSource23 property url checkMarkSource: "artwork/CheckMark.png"
24 /*!24 /*!
25 The opacity of the "cross" image when the switch is not checked,25 The opacity of the "cross" image when the switch is not checked,
26 and opacity of the "checkMark" image when the switch is checked.26 and opacity of the "checkMark" image when the switch is checked.
@@ -30,29 +30,29 @@
30 The opacity of the "cross" image when the switch is checked,30 The opacity of the "cross" image when the switch is checked,
31 and the opacity of the "checkMark" image when the switch is not checked.31 and the opacity of the "checkMark" image when the switch is not checked.
32 */32 */
33 property real unselectedImageOpacity: 1.033 property real unselectedImageOpacity: 0.4
34 /*!34 /*!
35 Spacing around the thumb.35 Spacing around the thumb.
36 */36 */
37 property real thumbSpacing: units.dp(1)37 property real thumbSpacing: units.dp(2)
38 /*!38 /*!
39 Color of the thumb when the switch is checked.39 Color of the thumb when the switch is checked.
40 */40 */
41 property color checkedThumbColor41 property color checkedThumbColor: "#DD4814"
42 /*!42 /*!
43 Color of the thumb when the switch is not checked.43 Color of the thumb when the switch is not checked.
44 */44 */
45 property color uncheckedThumbColor45 property color uncheckedThumbColor: "#bbbbbb"
46 /*!46 /*!
47 The animation to fade the color from checkedColor to uncheckedColor and vice versa.47 The animation to fade the color from checkedColor to uncheckedColor and vice versa.
48 */48 */
49 property ColorAnimation thumbColorAnimation: ColorAnimation{duration: 0}49 property ColorAnimation thumbColorAnimation: ColorAnimation { duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing }
50 /*!50 /*!
51 The animation on x to move the thumb.51 The animation on x to move the thumb.
52 */52 */
53 property NumberAnimation moveThumbAnimation: NumberAnimation{duration: 0}53 property NumberAnimation moveThumbAnimation: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
5454
55 property color backgroundColor: Qt.rgba(0.5, 0.5, 0.5, 0.5)55 property color backgroundColor: Qt.rgba(0.78, 0.78, 0.78, 0.1)
56 property real thumbWidth: units.gu(4)56 property real thumbWidth: units.gu(4)
57 property real thumbHeight: units.gu(4)57 property real thumbHeight: units.gu(4)
5858
@@ -60,11 +60,18 @@
60 anchors.fill: parent60 anchors.fill: parent
61 implicitWidth: 2*thumb.width + 3*thumb.spacing61 implicitWidth: 2*thumb.width + 3*thumb.spacing
62 implicitHeight: thumb.height + 2*thumb.spacing62 implicitHeight: thumb.height + 2*thumb.spacing
63 opacity: item.enabled ? 1.0 : 0.563 opacity: styledItem.enabled ? 1.0 : 0.5
6464
65 Component.onCompleted: {65 Binding {
66 item.implicitWidth = implicitWidth;66 target: styledItem
67 item.implicitHeight = implicitHeight;67 property: "implicitWidth"
68 value: implicitWidth
69 }
70
71 Binding {
72 target: styledItem
73 property: "implicitHeight"
74 value: implicitHeight
68 }75 }
6976
70 UbuntuShape {77 UbuntuShape {
@@ -80,10 +87,10 @@
8087
81 width: visuals.thumbHeight88 width: visuals.thumbHeight
82 height: visuals.thumbWidth89 height: visuals.thumbWidth
83 x: item.checked ? rightThumbPosition.x : leftThumbPosition.x90 x: styledItem.checked ? rightThumbPosition.x : leftThumbPosition.x
84 y: leftThumbPosition.y91 y: leftThumbPosition.y
8592
86 color: item.checked ? visuals.checkedThumbColor93 color: styledItem.checked ? visuals.checkedThumbColor
87 : visuals.uncheckedThumbColor94 : visuals.uncheckedThumbColor
8895
89 Behavior on x {96 Behavior on x {
@@ -113,7 +120,7 @@
113120
114 Image {121 Image {
115 anchors.centerIn: parent122 anchors.centerIn: parent
116 opacity: item.checked ? visuals.unselectedImageOpacity123 opacity: styledItem.checked ? visuals.unselectedImageOpacity
117 : visuals.selectedImageOpacity124 : visuals.selectedImageOpacity
118 source: visuals.crossSource125 source: visuals.crossSource
119 }126 }
@@ -132,7 +139,7 @@
132139
133 Image {140 Image {
134 anchors.centerIn: parent141 anchors.centerIn: parent
135 opacity: item.checked ? visuals.selectedImageOpacity142 opacity: styledItem.checked ? visuals.selectedImageOpacity
136 : visuals.unselectedImageOpacity143 : visuals.unselectedImageOpacity
137 source: visuals.checkMarkSource144 source: visuals.checkMarkSource
138 }145 }
139146
=== renamed file 'themes/Ambiance/qmltheme/NewTabsDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/TabsStyle.qml'
--- themes/Ambiance/qmltheme/NewTabsDelegate.qml 2013-05-03 21:07:40 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/TabsStyle.qml 2013-07-01 22:15:52 +0000
@@ -38,35 +38,34 @@
38 */38 */
39 onSwipeToSwitchTabsChanged: print("swipeToSwitchTabs property is DEPRECATED.")39 onSwipeToSwitchTabsChanged: print("swipeToSwitchTabs property is DEPRECATED.")
4040
41 property color headerTextColor41 property color headerTextColor: "#333333"
42 property color headerTextSelectedColor42 property color headerTextSelectedColor: "#333333"
43 property real headerTextOpacity43 property real headerTextOpacity: 0.4
44 property real headerTextSelectedOpacity44 property real headerTextSelectedOpacity: 0.9
45 property int headerTextFadeDuration45 property int headerTextFadeDuration: 350
46 property string headerFontSize46 property string headerFontSize: "x-large"
47 property int headerFontWeight47 property int headerFontWeight: Font.Light
48 property real headerTextLeftMargin48 property real headerTextLeftMargin: units.gu(2)
49 property real headerTextRightMargin49 property real headerTextRightMargin: units.gu(2)
50 property real headerTextBottomMargin50 property real headerTextBottomMargin: units.gu(2)
51 property url indicatorImageSource51 property url indicatorImageSource: "artwork/chevron.png"
52 property real tabBarHeight52 property real tabBarHeight: units.gu(7.5)
5353
54 /*!54 /*!
55 The time of inactivity in ms before the tab bar is automatically deactivated55 The time of inactivity in ms before the tab bar is automatically deactivated
56 */56 */
57 property int deactivateTime: 100057 property int deactivateTime: 3000
5858
59 /*!59 /*!
60 The velocity at which buttons are repositioned when a new tab gets selected.60 The velocity at which buttons are repositioned when a new tab gets selected.
61 */61 */
62 property real buttonPositioningVelocity62 property real buttonPositioningVelocity: 1.0
6363
64 // visuals64 // visuals
65 id: tabsDelegate65 id: tabsStyle
66 anchors.fill: parent66 anchors.fill: parent
6767
68 // use theTabs property because item gives problems in the loader68 property Tabs theTabs: styledItem
69 property Tabs theTabs: item
70 property Component headerContents: Component {69 property Component headerContents: Component {
71 NewTabBar {70 NewTabBar {
72 id: tabBar71 id: tabBar
@@ -77,23 +76,23 @@
77 right: parent ? parent.right : undefined76 right: parent ? parent.right : undefined
78 }77 }
79 //height: tabBarHeight78 //height: tabBarHeight
80 headerTextColor: tabsDelegate.headerTextColor79 headerTextColor: tabsStyle.headerTextColor
81 headerTextSelectedColor: tabsDelegate.headerTextSelectedColor80 headerTextSelectedColor: tabsStyle.headerTextSelectedColor
82 headerTextOpacity: tabsDelegate.headerTextOpacity81 headerTextOpacity: tabsStyle.headerTextOpacity
83 headerTextSelectedOpacity: tabsDelegate.headerTextSelectedOpacity82 headerTextSelectedOpacity: tabsStyle.headerTextSelectedOpacity
84 headerTextFadeDuration: tabsDelegate.headerTextFadeDuration83 headerTextFadeDuration: tabsStyle.headerTextFadeDuration
85 indicatorImageSource: tabsDelegate.indicatorImageSource84 indicatorImageSource: tabsStyle.indicatorImageSource
86 headerFontSize: tabsDelegate.headerFontSize85 headerFontSize: tabsStyle.headerFontSize
87 headerFontWeight: tabsDelegate.headerFontWeight86 headerFontWeight: tabsStyle.headerFontWeight
88 headerTextLeftMargin: tabsDelegate.headerTextLeftMargin87 headerTextLeftMargin: tabsStyle.headerTextLeftMargin
89 headerTextRightMargin: tabsDelegate.headerTextRightMargin88 headerTextRightMargin: tabsStyle.headerTextRightMargin
90 headerTextBottomMargin: tabsDelegate.headerTextBottomMargin89 headerTextBottomMargin: tabsStyle.headerTextBottomMargin
91 buttonPositioningVelocity: tabsDelegate.buttonPositioningVelocity90 buttonPositioningVelocity: tabsStyle.buttonPositioningVelocity
92 deactivateTime: tabsDelegate.deactivateTime91 deactivateTime: tabsStyle.deactivateTime
93 }92 }
94 }93 }
9594
96 Component.onCompleted: {95 Component.onCompleted: {
97 item.__headerContents = headerContents;96 styledItem.__headerContents = headerContents;
98 }97 }
99}98}
10099
=== renamed file 'themes/Ambiance/qmltheme/TextAreaDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/TextAreaStyle.qml'
--- themes/Ambiance/qmltheme/TextAreaDelegate.qml 2013-04-18 05:42:22 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/TextAreaStyle.qml 2013-07-01 22:15:52 +0000
@@ -21,40 +21,30 @@
21Item {21Item {
22 id: visuals22 id: visuals
23 // style properties23 // style properties
24 property url iconSource: "artwork/clear.svg"
24 // FIXME: needs type checking in themes to define the proper type to be used25 // FIXME: needs type checking in themes to define the proper type to be used
25 // if color type is used, alpha value gets lost26 // if color type is used, alpha value gets lost
2627
27 property color color28 property color color: (styledItem.enabled) ? "#757373" : "darkgray"
28 /*!29 /*!
29 Background fill color30 Background fill color
30 */31 */
31 property color backgroundColor: Qt.rgba(0, 0, 0, 0.1)32 property color backgroundColor: (styledItem.focus || styledItem.highlighted) ? "white" : Qt.rgba(0, 0, 0, 0.1)
32 property color errorColor: "red"33 property color errorColor: "red"
33 property real backgroundOpacity34 property real backgroundOpacity: styledItem.enabled ? 1.0 : 0.1
3435
35 /*!36 /*!
36 Spacing between the frame and the text editor area37 Spacing between the frame and the text editor area
37 */38 */
38 property var frameSpacing39 property real frameSpacing: units.gu(1)
39 property real overlaySpacing40 property real overlaySpacing: units.gu(0.5)
4041
41 anchors.fill: parent42 anchors.fill: parent
4243
43 Binding {
44 target: item.__internal
45 property: "frameSpacing"
46 value: visuals.frameSpacing
47 }
48 Binding {
49 target: item.__internal
50 property: "spacing"
51 value: visuals.overlaySpacing
52 }
53
54 z: -144 z: -1
55 UbuntuShape {45
56 id: shape46 property Component background: UbuntuShape {
57 property bool error: (item.hasOwnProperty("errorHighlight") && item.errorHighlight && !item.acceptableInput)47 property bool error: (styledItem.hasOwnProperty("errorHighlight") && styledItem.errorHighlight && !styledItem.acceptableInput)
58 onErrorChanged: (error) ? visuals.errorColor : visuals.backgroundColor;48 onErrorChanged: (error) ? visuals.errorColor : visuals.backgroundColor;
59 color: visuals.backgroundColor;49 color: visuals.backgroundColor;
60 anchors.fill: parent50 anchors.fill: parent
@@ -62,7 +52,13 @@
6252
63 MouseArea {53 MouseArea {
64 anchors.fill: parent54 anchors.fill: parent
65 onPressed: if (!item.activeFocus && item.activeFocusOnPress) item.forceActiveFocus()55 onPressed: if (!styledItem.activeFocus && styledItem.activeFocusOnPress) styledItem.forceActiveFocus()
66 }56 }
67 }57 }
58
59 Loader {
60 id: backgroundLoader
61 sourceComponent: background
62 anchors.fill: parent
63 }
68}64}
6965
=== renamed file 'themes/Ambiance/qmltheme/EditorCursorDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/TextCursorStyle.qml'
--- themes/Ambiance/qmltheme/EditorCursorDelegate.qml 2013-05-20 09:06:47 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/TextCursorStyle.qml 2013-07-01 22:15:52 +0000
@@ -21,28 +21,28 @@
21 /*!21 /*!
22 Cursor color22 Cursor color
23 */23 */
24 property color color24 property color color: Qt.rgba(0.4, 0.4, 0.4, 1.0)
2525
26 /*!26 /*!
27 Properties driving cursor blinking. If either of these values are 0, no27 Properties driving cursor blinking. If either of these values are 0, no
28 blinking is provided.28 blinking is provided.
29 */29 */
30 property bool blinking30 property bool blinking: true
31 property int blinkTimeoutShown31 property int blinkTimeoutShown: 800
32 property int blinkTimeoutHidden32 property int blinkTimeoutHidden: 400
3333
34 /*!34 /*!
35 Selection mode pin styles35 Selection mode pin styles
36 */36 */
37 property var pinSize37 property var pinSize: units.gu(1.2)
38 property var pinSensingOffset38 property var pinSensingOffset: units.dp(4)
39 property color pinColor39 property color pinColor: "blue"
4040
41 anchors.fill: parent41 anchors.fill: parent
42 Rectangle {42 Rectangle {
43 id: cursor43 id: cursor
4444
45 property bool showCursor: item.visible45 property bool showCursor: styledItem.visible
46 property bool timerShowCursor: true46 property bool timerShowCursor: true
4747
48 visible: showCursor && timerShowCursor48 visible: showCursor && timerShowCursor
4949
=== added file 'modules/Ubuntu/Components/Themes/Ambiance/TextFieldStyle.qml'
--- modules/Ubuntu/Components/Themes/Ambiance/TextFieldStyle.qml 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/TextFieldStyle.qml 2013-07-01 22:15:52 +0000
@@ -0,0 +1,20 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18
19TextAreaStyle {
20}
021
=== renamed file 'themes/Ambiance/qmltheme/ToolbarButtonDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/ToolbarButtonStyle.qml'
--- themes/Ambiance/qmltheme/ToolbarButtonDelegate.qml 2013-04-29 18:36:03 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/ToolbarButtonStyle.qml 2013-07-01 22:15:52 +0000
@@ -20,15 +20,15 @@
20Item {20Item {
21 id: visuals21 id: visuals
22 // styling properties22 // styling properties
23 property int iconWidth: 023 property int iconWidth: units.gu(2)
24 property int iconHeight: 024 property int iconHeight: units.gu(2)
2525
26 anchors.fill: parent26 anchors.fill: parent
2727
28 Item {28 Item {
29 anchors.centerIn: parent29 anchors.centerIn: parent
30 height: icon.height + label.height + label.anchors.topMargin30 height: icon.height + label.height + label.anchors.topMargin
31 opacity: item.enabled ? 1.0 : 0.331 opacity: styledItem.enabled ? 1.0 : 0.3
3232
33 Image {33 Image {
34 id: icon34 id: icon
@@ -38,7 +38,7 @@
38 }38 }
39 width: iconWidth39 width: iconWidth
40 height: iconWidth40 height: iconWidth
41 source: item.iconSource41 source: styledItem.iconSource
42 }42 }
4343
44 Label {44 Label {
@@ -49,9 +49,11 @@
49 topMargin: units.gu(1)49 topMargin: units.gu(1)
50 }50 }
51 width: paintedWidth51 width: paintedWidth
52 text: item.text52 text: styledItem.text
53 fontSize: "x-small"
54 color: "#888888"
53 }55 }
54 }56 }
5557
56 Component.onCompleted: item.implicitWidth = implicitWidth58 Component.onCompleted: styledItem.implicitWidth = implicitWidth
57}59}
5860
=== renamed file 'themes/Ambiance/qmltheme/ToolbarDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/ToolbarStyle.qml'
--- themes/Ambiance/qmltheme/ToolbarDelegate.qml 2013-05-14 13:33:39 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/ToolbarStyle.qml 2013-07-01 22:15:52 +0000
@@ -19,11 +19,10 @@
19Item {19Item {
20 id: visuals20 id: visuals
21 // styling properties21 // styling properties
22 property color color22 property color color: "white"
23 property real barOpacity23 property real barOpacity: 0.9
2424
25 anchors.fill: parent25 anchors.fill: parent
26 property alias contentItem: background
2726
28 Rectangle {27 Rectangle {
29 id: background28 id: background
@@ -40,7 +39,7 @@
40 bottom: background.top39 bottom: background.top
41 }40 }
42 source: Qt.resolvedUrl("artwork/toolbar_dropshadow.png")41 source: Qt.resolvedUrl("artwork/toolbar_dropshadow.png")
43 opacity: item.opened || item.animating ? 0.5 : 0.042 opacity: styledItem.opened || styledItem.animating ? 0.5 : 0.0
44 Behavior on opacity {43 Behavior on opacity {
45 UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }44 UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
46 }45 }
4746
=== renamed file 'themes/Ambiance/qmltheme/TransparentButtonDelegate.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/TransparentButtonStyle.qml'
--- themes/Ambiance/qmltheme/TransparentButtonDelegate.qml 2013-01-28 16:40:37 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/TransparentButtonStyle.qml 2013-07-01 22:15:52 +0000
@@ -28,31 +28,31 @@
28 The padding on the left and right side of the button foreground.28 The padding on the left and right side of the button foreground.
29 */29 */
30 property real horizontalPadding: units.gu(2)30 property real horizontalPadding: units.gu(2)
31 property real maximumWidth: item.width - 2*foreground.horizontalPadding31 property real maximumWidth: styledItem.width - 2*foreground.horizontalPadding
32 property real spacing: (item.text == "" || item.iconSource == "") ? 0 : units.gu(1)32 property real spacing: (styledItem.text == "" || styledItem.iconSource == "") ? 0 : units.gu(1)
33 property real verticalPadding: units.gu(0.5)33 property real verticalPadding: units.gu(0.5)
3434
35 width: icon.width + label.width + foreground.spacing35 width: icon.width + label.width + foreground.spacing
36 height: item.height - 2*foreground.verticalPadding36 height: styledItem.height - 2*foreground.verticalPadding
37 implicitWidth: icon.width + label.implicitWidth + foreground.spacing37 implicitWidth: icon.width + label.implicitWidth + foreground.spacing
3838
39 Image {39 Image {
40 id: icon40 id: icon
41 source: item.iconSource41 source: styledItem.iconSource
42 fillMode: Image.PreserveAspectFit42 fillMode: Image.PreserveAspectFit
43 anchors.verticalCenter: foreground.verticalCenter43 anchors.verticalCenter: foreground.verticalCenter
44 opacity: item.enabled ? 1.0 : 0.544 opacity: styledItem.enabled ? 1.0 : 0.5
45 }45 }
4646
47 Label {47 Label {
48 id: label48 id: label
49 text: item.text49 text: styledItem.text
50 anchors {50 anchors {
51 verticalCenter: foreground.verticalCenter51 verticalCenter: foreground.verticalCenter
52 verticalCenterOffset: units.dp(-1)52 verticalCenterOffset: units.dp(-1)
53 }53 }
54 fontSize: "medium"54 fontSize: "medium"
55 opacity: item.enabled ? 1.0 : 0.555 opacity: styledItem.enabled ? 1.0 : 0.5
56 elide: Text.ElideRight56 elide: Text.ElideRight
5757
58 property real availableWidth: foreground.maximumWidth - icon.width - foreground.spacing58 property real availableWidth: foreground.maximumWidth - icon.width - foreground.spacing
@@ -97,6 +97,6 @@
97 }97 }
98 }98 }
99 ]99 ]
100 state: (item.iconSource == "" || item.text == "") ? "center" : item.iconPosition100 state: (styledItem.iconSource == "" || styledItem.text == "") ? "center" : styledItem.iconPosition
101 }101 }
102}102}
103103
=== renamed directory 'themes/Ambiance/qmltheme/artwork' => 'modules/Ubuntu/Components/Themes/Ambiance/artwork'
=== renamed file 'themes/Ambiance/qmltheme/qmldir' => 'modules/Ubuntu/Components/Themes/Ambiance/qmldir'
--- themes/Ambiance/qmltheme/qmldir 2013-06-29 19:10:44 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/qmldir 2013-07-01 22:15:52 +0000
@@ -1,32 +1,22 @@
1module qmltheme1module Ubuntu.Components.Themes.Ambiance
2ButtonStyle 0.1 ButtonStyle.qml2internal ActivityIndicatorStyle ActivityIndicatorStyle.qml
3ButtonDelegate 0.1 ButtonDelegate.qml3internal ButtonStyle ButtonStyle.qml
4ToolbarDelegate 0.1 ToolbarDelegate.qml4internal CheckBoxStyle CheckBoxStyle.qml
5ToolbarButtonDelegate 0.1 ToolbarButtonDelegate.qml5internal DialogForegroundStyle DialogForegroundStyle.qml
6HeaderDelegate 0.1 HeaderDelegate.qml6internal HeaderStyle HeaderStyle.qml
7MainViewDelegate 0.1 MainViewDelegate.qml7internal MainViewStyle MainViewStyle.qml
8CheckBoxStyle 0.1 CheckBoxStyle.qml8internal PointerStyle PointerStyle.qml
9CheckBoxDelegate 0.1 CheckBoxDelegate.qml9internal PointerStyleShader PointerStyleShader.qml
10SwitchStyle 0.1 SwitchStyle.qml10internal PopoverForegroundStyle PopoverForegroundStyle.qml
11SwitchDelegate 0.1 SwitchDelegate.qml11internal ScrollbarStyle ScrollbarStyle.qml
12NewTabBar 0.1 NewTabBar.qml12internal SelectionCursorStyle SelectionCursorStyle.qml
13NewTabsDelegate 0.1 NewTabsDelegate.qml13internal SheetForegroundStyle SheetForegroundStyle.qml
14NewTabsStyle 0.1 NewTabsStyle.qml14internal SliderStyle SliderStyle.qml
15TransparentButtonDelegate 0.1 TransparentButtonDelegate.qml15internal SwitchStyle SwitchStyle.qml
16UbuntuShapeStyle 0.1 UbuntuShapeStyle.qml16TextAreaStyle 0.1 TextAreaStyle.qml
17DialogForegroundDelegate 0.1 DialogForegroundDelegate.qml17internal TextCursorStyle TextCursorStyle.qml
18PopoverForegroundDelegate 0.1 PopoverForegroundDelegate.qml
19SheetForegroundDelegate 0.1 SheetForegroundDelegate.qml
20PointerDelegate 0.1 PointerDelegate.qml
21ScrollbarStyle 0.1 ScrollbarStyle.qml
22ScrollbarDelegate 0.1 ScrollbarDelegate.qml
23ScrollSliderSizer 0.1 ScrollSliderSizer.qml
24TextFieldStyle 0.1 TextFieldStyle.qml18TextFieldStyle 0.1 TextFieldStyle.qml
25TextFieldDelegate 0.1 TextFieldDelegate.qml19internal ToolbarButtonStyle ToolbarButtonStyle.qml
26EditorCursorStyle 0.1 EditorCursorStyle.qml20internal ToolbarStyle ToolbarStyle.qml
27EditorCursorDelegate 0.1 EditorCursorDelegate.qml21internal TransparentButtonStyle TransparentButtonStyle.qml
28SelectionCursorDelegate 0.1 SelectionCursorDelegate.qml22
29TextAreaStyle 0.1 TextAreaStyle.qml
30TextAreaDelegate 0.1 TextAreaDelegate.qml
31SliderDelegate 0.1 SliderDelegate.qml
32ActivityIndicatorDelegate 0.1 ActivityIndicatorDelegate.qml
3323
=== renamed file 'themes/themes.pro' => 'modules/Ubuntu/Components/Themes/Themes.pro'
--- themes/themes.pro 2013-06-28 16:33:57 +0000
+++ modules/Ubuntu/Components/Themes/Themes.pro 2013-07-01 22:15:52 +0000
@@ -1,26 +1,2 @@
1TEMPLATE = subdirs1TEMPLATE = subdirs
22SUBDIRS += Ambiance
3THEME_FILES = Ambiance/qmltheme/*.qmltheme
4QML_FILES = $$system(ls Ambiance/qmltheme/*.qml)
5QML_FILES += $$system(ls Ambiance/qmltheme/*.js)
6QMLDIR_FILE = Ambiance/qmltheme/qmldir
7
8OTHER_FILES += $$THEME_FILES $$QML_FILES $$QMLDIR_FILE
9
10theme_files.path = /usr/share/themes/Ambiance/qmltheme
11theme_files.files = $$THEME_FILES
12
13ARTWORK_FILES += \
14 Ambiance/qmltheme/artwork/*.png \
15 Ambiance/qmltheme/artwork/*.svg \
16 Ambiance/qmltheme/artwork/*.sci
17theme_artworks.path = /usr/share/themes/Ambiance/qmltheme/artwork
18theme_artworks.files = $$ARTWORK_FILES
19
20qmldir_file.path = /usr/share/themes/Ambiance/qmltheme
21qmldir_file.files = $$QMLDIR_FILE
22
23qml_files.path = /usr/share/themes/Ambiance/qmltheme
24qml_files.files = $$QML_FILES
25
26INSTALLS += theme_files theme_artworks qmldir_file qml_files
273
=== modified file 'modules/Ubuntu/Components/Toolbar.qml'
--- modules/Ubuntu/Components/Toolbar.qml 2013-06-19 10:17:28 +0000
+++ modules/Ubuntu/Components/Toolbar.qml 2013-07-01 22:15:52 +0000
@@ -15,11 +15,6 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18// FIXME: When a module contains QML, C++ and JavaScript elements exported,
19// we need to use named imports otherwise namespace collision is reported
20// by the QML engine. As workaround, we use Theming named import.
21// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
22import Ubuntu.Components 0.1 as Theming
2318
24/*!19/*!
25 \internal20 \internal
@@ -111,7 +106,7 @@
111 }106 }
112 }107 }
113108
114 Item {109 StyledItem {
115 // FIXME:110 // FIXME:
116 // All theming items go into the background because only the children111 // All theming items go into the background because only the children
117 // of the Panel are being shown/hidden while the toolbar112 // of the Panel are being shown/hidden while the toolbar
@@ -124,10 +119,11 @@
124 }119 }
125 height: units.gu(8)120 height: units.gu(8)
126121
127 Theming.ItemStyle.class: "toolbar"122 // The values of opened and animated properties are used in the style
128 // The values of opened and animated properties are used in the delegate
129 property bool opened: toolbar.opened123 property bool opened: toolbar.opened
130 property bool animating: toolbar.animating124 property bool animating: toolbar.animating
125
126 style: Theme.createStyleComponent("ToolbarStyle.qml", background)
131 }127 }
132128
133 Item {129 Item {
134130
=== modified file 'modules/Ubuntu/Components/ToolbarActions.qml'
--- modules/Ubuntu/Components/ToolbarActions.qml 2013-06-17 17:34:41 +0000
+++ modules/Ubuntu/Components/ToolbarActions.qml 2013-07-01 22:15:52 +0000
@@ -246,7 +246,7 @@
246 // Disable the mouse area so swipes on the button will not be blocked246 // Disable the mouse area so swipes on the button will not be blocked
247 // from going to the toolbar. The panel will take care calling the button's clicked().247 // from going to the toolbar. The panel will take care calling the button's clicked().
248 __mouseArea.visible: false248 __mouseArea.visible: false
249 Theming.ItemStyle.class: "toolbar-button"249 style: Theme.createStyleComponent("ToolbarButtonStyle.qml", toolButton)
250 width: visible ? units.gu(5) : 0250 width: visible ? units.gu(5) : 0
251 height: toolbarActions.height251 height: toolbarActions.height
252 }252 }
253253
=== modified file 'modules/Ubuntu/Components/ToolbarButton.qml'
--- modules/Ubuntu/Components/ToolbarButton.qml 2013-06-14 16:28:04 +0000
+++ modules/Ubuntu/Components/ToolbarButton.qml 2013-07-01 22:15:52 +0000
@@ -15,11 +15,6 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18// FIXME: When a module contains QML, C++ and JavaScript elements exported,
19// we need to use named imports otherwise namespace collision is reported
20// by the QML engine. As workaround, we use Theming named import.
21// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
22import Ubuntu.Components 0.1 as Theming
2318
24/*!19/*!
25 \qmltype ToolbarButton20 \qmltype ToolbarButton
@@ -85,7 +80,8 @@
85*/80*/
86ActionItem {81ActionItem {
87 id: toolbarButton82 id: toolbarButton
88 Theming.ItemStyle.class: "toolbar-button"
89 height: parent ? parent.height : undefined83 height: parent ? parent.height : undefined
90 width: units.gu(5)84 width: units.gu(5)
85
86 style: Theme.createStyleComponent("ToolbarButtonStyle.qml", toolbarButton)
91}87}
9288
=== modified file 'modules/Ubuntu/Components/ToolbarItems.qml'
--- modules/Ubuntu/Components/ToolbarItems.qml 2013-06-17 12:36:11 +0000
+++ modules/Ubuntu/Components/ToolbarItems.qml 2013-07-01 22:15:52 +0000
@@ -15,11 +15,6 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18// FIXME: When a module contains QML, C++ and JavaScript elements exported,
19// we need to use named imports otherwise namespace collision is reported
20// by the QML engine. As workaround, we use Theming named import.
21// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
22import Ubuntu.Components 0.1 as Theming
2318
24/*!19/*!
25 \qmltype ToolbarItems20 \qmltype ToolbarItems
2621
=== modified file 'modules/Ubuntu/Components/overview.qdoc'
--- modules/Ubuntu/Components/overview.qdoc 2013-06-27 12:54:26 +0000
+++ modules/Ubuntu/Components/overview.qdoc 2013-07-01 22:15:52 +0000
@@ -20,8 +20,6 @@
2020
21 \part General Topics21 \part General Topics
22 \list22 \list
23 \li \l{theming-components.html}{Theming} describes the styling capabilities
24 provided by the toolkit.
25 \li \l{ubuntu-layouts.html}{Layouts} describes a flexible layouting engine23 \li \l{ubuntu-layouts.html}{Layouts} describes a flexible layouting engine
26 to ease the development of responsive user interfaces.24 to ease the development of responsive user interfaces.
27 \li \l {Resolution Independence} describes the facilities that should be25 \li \l {Resolution Independence} describes the facilities that should be
2826
=== removed file 'modules/Ubuntu/Components/plugin/itemstyleattached.cpp'
--- modules/Ubuntu/Components/plugin/itemstyleattached.cpp 2013-05-20 09:06:47 +0000
+++ modules/Ubuntu/Components/plugin/itemstyleattached.cpp 1970-01-01 00:00:00 +0000
@@ -1,715 +0,0 @@
1/*
2 * Copyright 2012 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Zsombor Egri <zsombor.egri@canonical.com>
17 */
18
19#include <QtQml/QQmlComponent>
20#include <QtQml/QQmlContext>
21#include <QtQml/QQmlEngine>
22#include <QtQml/QQmlInfo>
23#include <QtQuick/QQuickItem>
24
25#include "itemstyleattached.h"
26#include "itemstyleattached_p.h"
27#include "themeengine.h"
28#include "themeengine_p.h"
29#include "quickutils.h"
30
31#include <private/qqmlproperty_p.h>
32#include <private/qqmlcomponentattached_p.h>
33
34const char *itemProperty = "item";
35
36/*!
37 \qmltype ItemStyle
38 \inqmlmodule Ubuntu.Components 0.1
39 \ingroup theming
40 \brief The ItemStyle attached property contains styling properties for a
41 particular UI element.
42
43 The element provides styling support to any element derived from Item
44 (QQuickItem).
45 The style is selected based on the \a class and \a name properties. If neither
46 of these is defined, the framework will use the meta class name to identify the
47 style rule to be used. However this can happen only if the document defining the
48 item refers to the styling attached property.
49
50 The following items will use styling as they declare and refer to styling
51 attached properties, and styling Text can be done by defining the ".Text"
52 selector.
53
54 \qml
55 Item {
56 ItemStyle.class: "button"
57 }
58 \endqml
59 \qml
60 Text {
61 ItemStyle.class: "text"
62 }
63 \endqml
64
65 An item can use private styling by setting the style and/or the delegate property
66 locally. In this case the item won't use the theme defined style/delegate but will
67 use the styling elements defined locally. Switching back to theme defined styles
68 can be achieved by clearing the style/delegate property. It is also possible to
69 set only one of the styling elements locally and use the theme defined one for
70 the other.
71
72 \qml
73 // Button.qml
74 Item {
75 id: root
76 property bool pressed: false
77 property bool hovered: false
78 property color color: "lightgray"
79
80 signal clicked
81
82 MouseArea {
83 anchors.fill: parent
84 onClicked: control.clicked()
85 }
86 }
87 \endqml
88 In the example above the Button document refers to the style property of the attached
89 styling, therefore the element by default will use the style defined using
90 the ".button" selector.
91
92 The following example shows a Button item that uses a private delegate but the
93 styles from the themes.
94
95 \qml
96 Button {
97 id: control
98 ItemStyle.delegate: Rectangle {
99 anchors.fill: parent
100 color: ItemStyle.style.color
101 radius: 15
102 border {
103 width: 2
104 color: Qt.darker(color, 1.4)
105 }
106 }
107 }
108 \endqml
109
110 Attached styling defines a context property which can be used from delegates and
111 also in style declaration to access the item properties. This property is called
112 \b item.
113*/
114
115
116ItemStyleAttachedPrivate::ItemStyleAttachedPrivate(ItemStyleAttached *qq, QObject *attached):
117 q_ptr(qq),
118 attachee(qobject_cast<QQuickItem*>(attached)),
119 style(0),
120 delegate(0),
121 styleRule(0),
122 completed(false),
123 customStyle(false),
124 customDelegate(false),
125 connectedToEngine(false)
126{
127 styleClass = QuickUtils::instance().className(attachee).toLower();
128 // refresh style upon reparenting!
129 // there is no reason to do styling till the parent is not set and this applies
130 // to the root objects too as even those have an internal parent
131 QObject::connect(attachee, SIGNAL(parentChanged(QQuickItem*)), q_ptr, SLOT(_q_reapplyStyling(QQuickItem*)));
132
133 // connect to one of the attached components to receive completion
134 QQmlComponentAttached *component = QQmlComponent::qmlAttachedProperties(attachee);
135 if (component) {
136 QObject::connect(component, SIGNAL(completed()), q_ptr, SLOT(_q_refreshStyle()));
137 } else {
138 qmlInfo(q_ptr) << "WARNING: no attached component found for " << styleClass;
139 }
140
141 listenThemeEngine();
142
143 //enum attachee properties and watch them
144 watchAttacheeProperties();
145}
146
147ItemStyleAttachedPrivate::~ItemStyleAttachedPrivate()
148{
149 // remove name from the theming engine
150 if (!styleId.isEmpty())
151 ThemeEnginePrivate::registerName(attachee, QString());
152 resetDelegate();
153 resetStyle();
154}
155
156/*!
157 * \internal
158 * Enumerates attachee properties and marks them all candidates for styling. Connects
159 * each property's notify signal so we get notified when those are binded in QML, so we
160 * won't alter their value.
161 */
162void ItemStyleAttachedPrivate::watchAttacheeProperties()
163{
164 Q_Q(ItemStyleAttached);
165 // enumerate properties and figure out which one has binding
166 const QMetaObject *mo = attachee->metaObject();
167 QMetaMethod onAttacheePropertyChanged = q->metaObject()->method(q->metaObject()->indexOfSlot("_q_attacheePropertyChanged()"));
168 for (int i = 0; i < mo->propertyCount(); i++) {
169 const QMetaProperty prop = mo->property(i);
170
171 if (!prop.hasNotifySignal() || UCStyle::omitProperty(prop.name())) {
172 continue;
173 }
174
175 QQmlProperty qmlProp(attachee, prop.name(), QQmlEngine::contextForObject(attachee));
176 QQmlAbstractBinding *binding = QQmlPropertyPrivate::binding(qmlProp);
177 if (binding) {
178 // mark as first time bound, so further styling can unbind it and do styling
179 watchedProperties.mark(i, StyledPropertyMap::Bound, binding);
180 } else {
181 watchedProperties.mark(i, StyledPropertyMap::Enabled);
182 }
183
184 if (QLatin1String(prop.name()) == QLatin1String("font")) {
185 // never ban the font property from being styled
186 continue;
187 }
188
189 // connect property's notify signal to watch when it gets changed so we can stop watching it
190 QObject::connect(attachee, prop.notifySignal(), q, onAttacheePropertyChanged);
191 }
192}
193
194/*!
195 * \internal
196 * Captures attachee property changes which are to be removed from stylable ones.
197 */
198void ItemStyleAttachedPrivate::_q_attacheePropertyChanged()
199{
200 Q_Q(ItemStyleAttached);
201
202 const QMetaObject *mo = attachee->metaObject();
203 QMetaMethod signal = mo->method(q->senderSignalIndex());
204 QString property = QString(signal.name()).remove("Changed");
205
206 // was the property change invoked by the style update, exit
207 if (style && style->isUpdating(property))
208 return;
209
210 int index = mo->indexOfProperty(property.toLatin1());
211 if (watchedProperties.isBanned(index))
212 return;
213
214 // ban property from being styled
215 watchedProperties.mark(index, StyledPropertyMap::Banned);
216
217 // unbind style from attachee
218 if (style)
219 style->unbindProperty(property);
220}
221
222bool ItemStyleAttachedPrivate::updateStyle()
223{
224 bool result = false;
225 // do not do anything till the component gets complete?
226 if (!completed)
227 return result;
228
229 if (!customStyle) {
230 // make sure we have a theme
231 if (styleRule && styleRule->style) {
232 QQmlContext *context = new QQmlContext(qmlContext(attachee));
233 context->setContextProperty(itemProperty, attachee);
234 QObject *obj = styleRule->style->create(context);
235 style = qobject_cast<UCStyle*>(obj);
236 if (!style) {
237 delete obj;
238 delete context;
239 } else {
240 // set style as parent for the context so it gets deleted together with the style
241 context->setParent(style);
242 // set owner so we know that the style object has been created by theming
243 style->setOwner(attachee);
244 }
245 result = (style != 0);
246 }
247 } else
248 result = true;
249
250 // reparent also custom styles!
251 if (result && style) {
252 style->bindItem(attachee, watchedProperties, true);
253 style->bindItem(delegate, watchedProperties, false);
254 }
255 return result;
256}
257
258bool ItemStyleAttachedPrivate::updateDelegate()
259{
260 bool result = false;
261 // do not do anything till the component gets complete?
262 if (!completed)
263 return result;
264
265 if (!customDelegate) {
266 // make sure we have a theme
267 if (styleRule && styleRule->delegate) {
268 QQmlContext * context = new QQmlContext(qmlContext(attachee));
269 context->setContextProperty(itemProperty, attachee);
270 delegate = qobject_cast<QQuickItem*>(styleRule->delegate->create(context));
271 if (delegate) {
272 // set delegate as parent for the context so it gets deleted together with the style
273 context->setParent(delegate);
274 // set delegate's parent to attachee
275 delegate->setParent(attachee);
276 } else {
277 delete context;
278 }
279 result = (delegate != 0);
280 }
281 } else
282 result = true;
283
284 if (delegate && ((delegate->parent() != attachee) || (delegate->parentItem() != attachee))) {
285 delegate->setParentItem(attachee);
286 // If style item contains a property "contentItem" that points
287 // to an item, reparent all children into it:
288 QVariant contentVariant = delegate->property("contentItem");
289 QQuickItem *contentItem = qvariant_cast<QQuickItem *>(contentVariant);
290 if (contentItem) {
291 Q_FOREACH (QObject *child, attachee->children()) {
292 QQuickItem *childItem = qobject_cast<QQuickItem *>(child);
293 if (childItem && (childItem != delegate))
294 childItem->setParentItem(contentItem);
295 }
296 }
297 // setup property "bindings" towards delegate properties
298 if (style)
299 style->bindItem(delegate, watchedProperties, false);
300 }
301 return result;
302}
303
304/*!
305 \internal
306 Updates the style and delegate variables. The style update is forced
307 when the item changes the style lookup from private to theme.
308*/
309int ItemStyleAttachedPrivate::updateTheme()
310{
311 int result = NoUpdate;
312 // check if the new rule differs from the previous one
313 StyleCache::StyleData *newRule = ThemeEnginePrivate::styleRuleForPath(styleSelector);
314 if (newRule && (styleRule != newRule)) {
315 // check what has been changed
316 bool styleChanged = (!styleRule || (styleRule && (styleRule->style != newRule->style)));
317 bool delegateChanged = (!styleRule || (styleRule && (styleRule->delegate != newRule->delegate)));
318 styleRule = newRule;
319
320 // the order is: clean up delegate then style, then create style and then delegate
321 // so that when delegate is built we already have the styles ready for that
322 if (delegateChanged) {
323 resetDelegate();
324 }
325 if (styleChanged) {
326 resetStyle();
327 styleChanged = updateStyle();
328 }
329 if (delegateChanged) {
330 delegateChanged = updateDelegate();
331 } else if (style) {
332 style->bindItem(delegate, watchedProperties, false);
333 }
334 if (styleChanged || delegateChanged) {
335 if (styleChanged) {
336 result |= StyleUpdated;
337 }
338 if (delegateChanged) {
339 result |= DelegateUpdated;
340 }
341 Q_Q(ItemStyleAttached);
342 Q_EMIT q->styleChanged();
343 }
344 }
345 return result;
346}
347
348void ItemStyleAttachedPrivate::resetStyle()
349{
350 if (!style)
351 return;
352 // clear bindings, disconnect as properties may change before the style
353 // is deleted
354 style->unbindItem(delegate);
355 style->unbindItem(attachee);
356
357 // delete style also if there is an owner set to it
358 if (!customStyle || style->owner()) {
359 // reset style object before we delete it, themed animations may get changed
360 // during the style deletion which will cause invalid pointer operations
361 // in style bindings cleanup
362 // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1175394
363 QObject *object = style;
364 style = 0;
365 delete object;
366 }
367}
368
369void ItemStyleAttachedPrivate::resetDelegate()
370{
371 if (!delegate)
372 return;
373 // remove all bindings between style and delegate
374 if (style)
375 style->unbindItem(delegate);
376
377 // delete delegate also if there is an owner set to it
378 if (!customDelegate || (delegate->parent() == attachee)) {
379 delegate->setParent(0);
380 delegate->setParentItem(0);
381 delete delegate;
382 delegate = 0;
383 }
384}
385
386/*!
387 * \internal
388 * Applies styling on children recoursively.
389 */
390void ItemStyleAttachedPrivate::applyStyleOnChildren(QQuickItem *item)
391{
392 QList<QQuickItem*> children = item->childItems();
393 Q_FOREACH(QQuickItem *child, children) {
394 ItemStyleAttached *style = ThemeEnginePrivate::attachedStyle(child);
395 if (style)
396 style->d_ptr->_q_reapplyStyling(child->parentItem());
397 else
398 applyStyleOnChildren(child);
399 }
400}
401
402/*!
403 \internal
404 Registers the element with the given instance \a id. Returns true on
405 successful registration. On error, the theme engine's error string is set.
406 */
407bool ItemStyleAttachedPrivate::registerName(const QString &id)
408{
409 bool result = true;
410 if (ThemeEnginePrivate::registerName(attachee, id)) {
411 styleId = id;
412 attachee->setProperty("name", styleId);
413 } else {
414 ThemeEnginePrivate::setError(QString("Instance %1 already registered. Resetting instance for %2.")
415 .arg(styleId)
416 .arg(styleClass));
417 styleId = QString();
418 result = false;
419 }
420 return result;
421}
422
423/*!
424 \internal
425 Checks if the item needs to receive updates from theme engine or not. Connects to
426 or disconnects from the engine.
427 */
428void ItemStyleAttachedPrivate::listenThemeEngine()
429{
430 Q_Q(ItemStyleAttached);
431 if (!customStyle || !customDelegate) {
432 if (!connectedToEngine) {
433 connectedToEngine = (bool)QObject::connect(ThemeEngine::instance(), SIGNAL(themeChanged()), q, SLOT(_q_refreshStyle()));
434 }
435 } else {
436 if (connectedToEngine)
437 connectedToEngine = !QObject::disconnect(ThemeEngine::instance(), SIGNAL(themeChanged()), q, SLOT(_q_refreshStyle()));
438 if (!connectedToEngine) {
439 styleRule = 0;
440 styleSelector.clear();
441 }
442 }
443}
444
445/*!
446 * \internal
447 * Transfers the ownership of the style object (style or delegate) to teh current item.
448 */
449void ItemStyleAttachedPrivate::gainOwnershipOverStyleObject(QObject *styleObject, bool style)
450{
451 if (!styleObject)
452 return;
453
454 if (style) {
455 UCStyle *style = qobject_cast<UCStyle*>(styleObject);
456 if (!style)
457 return;
458 ItemStyleAttached *attached = ThemeEnginePrivate::attachedStyle(style->owner());
459 if (attached) {
460 attached->d_ptr->style = 0;
461 style->setOwner(attachee);
462 }
463 } else {
464 QQuickItem *delegate = qobject_cast<QQuickItem*>(styleObject);
465 if (!delegate)
466 return;
467 // return if the delegate has no parent item set - case ItemStyle.delegate: Item{}
468 if (!delegate->parentItem())
469 return;
470 ItemStyleAttached *attached = ThemeEnginePrivate::attachedStyle(delegate->parentItem());
471 // check if the object is set as parent's delegate
472 if (attached && (attached->d_ptr->delegate == delegate)) {
473 // need to take ownership
474 attached->d_ptr->delegate = 0;
475 // set the new parent of the delegate
476 delegate->setParent(attachee);
477 }
478 }
479}
480
481
482/*!
483 \internal
484 Internal slot to update the style of an item when the theme is changed. The slot
485 is connected to the engine's themeChanged() signal. The slot should not be used
486 from other methods as it will cause performance problems.
487 */
488void ItemStyleAttachedPrivate::_q_refreshStyle()
489{
490 // no need to delay style applying any longer
491 bool applyOnChildren = !completed;
492 if (!completed) {
493 styleSelector = Selector(attachee);
494 }
495 completed = true;
496
497 // ... but style refresh is needed as the old styles are dead
498 styleRule = 0;
499
500 int update = updateTheme();
501 if (applyOnChildren) {
502 // theme applied first time, style on custom style objects
503 if (((update & StyleUpdated) != StyleUpdated) && customStyle) {
504 updateStyle();
505 }
506 if (((update & DelegateUpdated) != DelegateUpdated) && customDelegate) {
507 updateDelegate();
508 }
509 // this will happen only upon the styled item gets completed
510 applyStyleOnChildren(attachee);
511 }
512}
513
514/*!
515 * \internal
516 * Reapply styling on parent change.
517 */
518void ItemStyleAttachedPrivate::_q_reapplyStyling(QQuickItem *parentItem)
519{
520 if (!parentItem || !completed)
521 // the component is most likely used in a delegate, is being deleted
522 // or not yet complete
523 return;
524
525 Selector newSelector(attachee);
526 if (newSelector != styleSelector) {
527 styleSelector = newSelector;
528 updateTheme();
529 }
530 // need to reapply styling on each child of the attachee!
531 // this will cause performance issues!
532 applyStyleOnChildren(attachee);
533}
534
535/*==============================================================================
536 */
537
538ItemStyleAttached::ItemStyleAttached(QObject *parent) :
539 QObject(parent),
540 d_ptr(new ItemStyleAttachedPrivate(this, parent))
541{
542 d_ptr->styleSelector = Selector(d_ptr->attachee);
543}
544
545ItemStyleAttached::~ItemStyleAttached()
546{}
547
548ItemStyleAttached *ItemStyleAttached::qmlAttachedProperties(QObject *obj)
549{
550 ItemStyleAttached *ret = 0;
551 if (qobject_cast<QQuickItem*>(obj)) {
552 ret = new ItemStyleAttached(obj);
553 }
554 return ret;
555}
556
557/*!
558 \qmlproperty string ItemStyle::name
559 This property holds the item unique identifier used in styling.
560 */
561/*!
562 name property.
563 */
564QString ItemStyleAttached::name() const
565{
566 Q_D(const ItemStyleAttached);
567 return d->styleId;
568}
569/*!
570 Updates the name property.
571 */
572void ItemStyleAttached::setName(const QString &name)
573{
574 Q_D(ItemStyleAttached);
575 if (d->styleId.compare(name, Qt::CaseInsensitive)) {
576 if (d->registerName(name.toLower())) {
577 d->styleSelector.update();
578 if (!d->completed)
579 return;
580 d->updateTheme();
581 // refresh children theme
582 d->applyStyleOnChildren(d->attachee);
583 }
584 }
585}
586
587/*!
588 \qmlproperty string ItemStyle::class
589 This property holds the style class identifier used by the item.
590 When the engine locates the style rule to be applied on the item, it takes
591 the class and name properties. If none is specified, the meta class
592 name will be used to search for the style. This must be taken into account both
593 when defining themes and designing items and applications.
594 */
595/*!
596 class property.
597 */
598QString ItemStyleAttached::styleClass()
599{
600 Q_D(ItemStyleAttached);
601 return d->styleClass.replace('.', ' ');
602}
603/*!
604 Sets the class property value.
605 */
606void ItemStyleAttached::setStyleClass(const QString &styleClass)
607{
608 Q_D(ItemStyleAttached);
609 if (d->styleClass.compare(styleClass.trimmed(), Qt::CaseInsensitive)) {
610 // replace spaces with dots
611 d->styleClass = styleClass.toLower().trimmed().replace(' ', '.');
612 d->styleSelector.update();
613 if (!d->completed)
614 return;
615 d->updateTheme();
616 // refresh children theme
617 d->applyStyleOnChildren(d->attachee);
618 }
619}
620
621/*!
622 *\qmlproperty string ItemStyle::path
623 * This property holds the style path applied on the attachee item.
624 */
625QString ItemStyleAttached::path() const
626{
627 Q_D(const ItemStyleAttached);
628 return d->styleRule ?
629 d->styleRule->selector().toString() :
630 QString("(null)");
631}
632
633/*!
634 \qmlproperty Style ItemStyle::style
635 The property holds the object containing the style configuration properties. This can
636 either be defined by a theme style rule or the private style. When set, the item will
637 no longer use the theme defined style properties but the ones set. The property must be
638 reset (set to null object) in order to use the theme defined styles.
639
640 Modifying the property alone will only affect the styling. The delegate will be used
641 from the theme unless specified explicitly. Therefore items can be used with custom
642 styling and theme defined delegate, theme style and custom delegate or both theme defined/
643 custom.
644 */
645/*!
646 \internal
647 Returns the object created out of the style used.
648 */
649UCStyle *ItemStyleAttached::style() const
650{
651 Q_D(const ItemStyleAttached);
652 return d->style;
653}
654
655
656/*!
657 \internal
658 Sets/resets the style object for the item.
659 */
660void ItemStyleAttached::setStyle(UCStyle *style)
661{
662 Q_D(ItemStyleAttached);
663 if (d->style != style) {
664 // clear the previous style
665 d->resetStyle();
666 // check if style belongs to a styled item, if it does, detach it
667 d->customStyle = (style != 0);
668 d->gainOwnershipOverStyleObject(style, true);
669 d->style = style;
670 d->listenThemeEngine();
671 if (d->updateStyle())
672 Q_EMIT styleChanged();
673 }
674}
675
676/*!
677 \qmlproperty Item ItemStyle::delegate
678 The property holds the Item containing the visuals. This can either be defined
679 by a theme or can be a private element. When set, the item will no longer use
680 the theme defined visuals but the ones set. The property must be reset (set to
681 null object) in order to use the theme defined visuals.
682
683 Modifying the property alone will only affect the visuals. Styles can be still
684 used from the theme, unless specified explicitly. Therefore custom visuals can
685 be made so that are aware of the styling properties.
686 */
687/*!
688 Returns the delegate Item created out of the style.
689 */
690QQuickItem *ItemStyleAttached::delegate() const
691{
692 Q_D(const ItemStyleAttached);
693 return d->delegate;
694}
695
696/*!
697 \internal
698 Sets/resets the delegate item for the item.
699 */
700void ItemStyleAttached::setDelegate(QQuickItem *delegate)
701{
702 Q_D(ItemStyleAttached);
703 if (d->delegate != delegate) {
704 // clear the previous theme delegate
705 d->resetDelegate();
706 d->customDelegate = (delegate != 0);
707 d->gainOwnershipOverStyleObject(delegate, false);
708 d->delegate = delegate;
709 d->listenThemeEngine();
710 if (d->updateDelegate())
711 Q_EMIT styleChanged();
712 }
713}
714
715#include "moc_itemstyleattached.cpp"
7160
=== removed file 'modules/Ubuntu/Components/plugin/itemstyleattached.h'
--- modules/Ubuntu/Components/plugin/itemstyleattached.h 2013-04-26 07:23:32 +0000
+++ modules/Ubuntu/Components/plugin/itemstyleattached.h 1970-01-01 00:00:00 +0000
@@ -1,76 +0,0 @@
1/*
2 * Copyright 2012 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Zsombor Egri <zsombor.egri@canonical.com>
17 */
18
19#ifndef ITEMSTYLEATTACHED_H
20#define ITEMSTYLEATTACHED_H
21
22#include <QtCore/QObject>
23#include <QtQml>
24
25class QQuickItem;
26class UCStyle;
27class ItemStyleAttachedPrivate;
28class ItemStyleAttached : public QObject
29{
30 Q_OBJECT
31
32 Q_PROPERTY(QString class READ styleClass WRITE setStyleClass NOTIFY styleChanged)
33 Q_PROPERTY(QString name READ name WRITE setName NOTIFY styleChanged)
34 Q_PROPERTY(UCStyle *style READ style WRITE setStyle NOTIFY styleChanged)
35 Q_PROPERTY(QQuickItem *delegate READ delegate WRITE setDelegate NOTIFY styleChanged)
36
37 Q_PROPERTY(QString path READ path NOTIFY styleChanged)
38
39public:
40 explicit ItemStyleAttached(QObject *parent = 0);
41 ~ItemStyleAttached();
42 static ItemStyleAttached *qmlAttachedProperties(QObject *obj);
43
44Q_SIGNALS:
45 void styleChanged();
46
47public Q_SLOTS:
48
49public: //getters
50 QString name() const;
51 QString styleClass();
52 QString path() const;
53
54private:
55 void setName(const QString &name);
56 void setStyleClass(const QString &styleClass);
57 UCStyle *style() const;
58 void setStyle(UCStyle *style);
59 QQuickItem *delegate() const;
60 void setDelegate(QQuickItem *delegate);
61
62private:
63 Q_DISABLE_COPY(ItemStyleAttached)
64 Q_DECLARE_PRIVATE(ItemStyleAttached)
65 QScopedPointer<ItemStyleAttachedPrivate> d_ptr;
66 friend class ThemeEnginePrivate;
67 friend class SelectorNode;
68
69 Q_PRIVATE_SLOT(d_func(), void _q_attacheePropertyChanged())
70 Q_PRIVATE_SLOT(d_func(), void _q_reapplyStyling(QQuickItem *))
71 Q_PRIVATE_SLOT(d_func(), void _q_refreshStyle())
72};
73
74QML_DECLARE_TYPEINFO(ItemStyleAttached, QML_HAS_ATTACHED_PROPERTIES)
75
76#endif // ITEMSTYLEATTACHED_H
770
=== removed file 'modules/Ubuntu/Components/plugin/itemstyleattached_p.h'
--- modules/Ubuntu/Components/plugin/itemstyleattached_p.h 2013-05-07 10:55:24 +0000
+++ modules/Ubuntu/Components/plugin/itemstyleattached_p.h 1970-01-01 00:00:00 +0000
@@ -1,75 +0,0 @@
1/*
2 * Copyright 2012 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Zsombor Egri <zsombor.egri@canonical.com>
17 */
18
19#ifndef ITEMSTYLEATTACHED_P_H
20#define ITEMSTYLEATTACHED_P_H
21
22#include "itemstyleattached.h"
23#include "stylecache_p.h"
24#include "ucstyle.h"
25
26class QQmlContext;
27class ItemStyleAttachedPrivate {
28 Q_DECLARE_PUBLIC(ItemStyleAttached)
29
30public:
31 enum UpdateThemeResult {
32 NoUpdate = 0,
33 StyleUpdated = 0x01,
34 DelegateUpdated = 0x02
35 };
36 ItemStyleAttachedPrivate(ItemStyleAttached *qq, QObject *attached);
37 ~ItemStyleAttachedPrivate();
38
39 ItemStyleAttached *q_ptr;
40 QQuickItem *attachee;
41 UCStyle *style;
42 QQuickItem *delegate;
43 QString styleClass;
44 QString styleId;
45 Selector styleSelector;
46
47 // internal members
48 StyleCache::StyleData *styleRule;
49 // hash of attachee property indexes as key, containing enabled/disabled value
50 StyledPropertyMap watchedProperties;
51 bool completed;
52 bool customStyle;
53 bool customDelegate;
54 bool connectedToEngine;
55
56 void watchAttacheeProperties();
57 bool updateStyle();
58 bool updateDelegate();
59 int updateTheme();
60 void resetStyle();
61 void resetDelegate();
62 void applyStyleOnChildren(QQuickItem *item);
63 bool registerName(const QString &id);
64 void listenThemeEngine();
65 void gainOwnershipOverStyleObject(QObject *styleObject, bool style);
66 void _q_attacheePropertyChanged();
67 void _q_refreshStyle();
68 void _q_reapplyStyling(QQuickItem *);
69
70#ifdef QT_TESTLIB_LIB
71 friend class tst_ThemeEngineStyle;
72#endif
73};
74
75#endif // ITEMSTYLEATTACHED_P_H
760
=== modified file 'modules/Ubuntu/Components/plugin/plugin.cpp'
--- modules/Ubuntu/Components/plugin/plugin.cpp 2013-06-28 13:56:45 +0000
+++ modules/Ubuntu/Components/plugin/plugin.cpp 2013-07-01 22:15:52 +0000
@@ -23,8 +23,7 @@
23#include <QtGui/QScreen>23#include <QtGui/QScreen>
2424
25#include "plugin.h"25#include "plugin.h"
26#include "themeengine.h"26#include "uctheme.h"
27#include "itemstyleattached.h"
2827
29#include <QtQml/QQmlContext>28#include <QtQml/QQmlContext>
30#include "i18n.h"29#include "i18n.h"
@@ -39,7 +38,6 @@
39#include "qquickclipboard.h"38#include "qquickclipboard.h"
40#include "qquickmimedata.h"39#include "qquickmimedata.h"
41#include "bottombarvisibilitycommunicator.h"40#include "bottombarvisibilitycommunicator.h"
42#include "ucstyle.h"
43#include "ucubuntuanimation.h"41#include "ucubuntuanimation.h"
44#include "ucfontutils.h"42#include "ucfontutils.h"
45#include "ucarguments.h"43#include "ucarguments.h"
@@ -64,7 +62,6 @@
64{62{
65 Q_ASSERT(uri == QLatin1String("Ubuntu.Components"));63 Q_ASSERT(uri == QLatin1String("Ubuntu.Components"));
6664
67 qmlRegisterUncreatableType<ItemStyleAttached>(uri, 0, 1, "ItemStyle", "Type is not instantiable.");
68 qmlRegisterUncreatableType<UbuntuI18n>(uri, 0, 1, "i18n", "Singleton object");65 qmlRegisterUncreatableType<UbuntuI18n>(uri, 0, 1, "i18n", "Singleton object");
69 qmlRegisterExtendedType<QQuickImageBase, UCQQuickImageExtension>(uri, 0, 1, "QQuickImageBase");66 qmlRegisterExtendedType<QQuickImageBase, UCQQuickImageExtension>(uri, 0, 1, "QQuickImageBase");
70 qmlRegisterUncreatableType<UCUnits>(uri, 0, 1, "UCUnits", "Not instantiable");67 qmlRegisterUncreatableType<UCUnits>(uri, 0, 1, "UCUnits", "Not instantiable");
@@ -74,7 +71,6 @@
74 qmlRegisterType<InverseMouseAreaType>(uri, 0, 1, "InverseMouseArea");71 qmlRegisterType<InverseMouseAreaType>(uri, 0, 1, "InverseMouseArea");
75 qmlRegisterType<QQuickMimeData>(uri, 0, 1, "MimeData");72 qmlRegisterType<QQuickMimeData>(uri, 0, 1, "MimeData");
76 qmlRegisterSingletonType<QQuickClipboard>(uri, 0, 1, "Clipboard", registerClipboard);73 qmlRegisterSingletonType<QQuickClipboard>(uri, 0, 1, "Clipboard", registerClipboard);
77 qmlRegisterType<UCStyle>(uri, 0, 1, "Style");
78 qmlRegisterSingletonType<UCUbuntuAnimation>(uri, 0, 1, "UbuntuAnimation", registerUCUbuntuAnimation);74 qmlRegisterSingletonType<UCUbuntuAnimation>(uri, 0, 1, "UbuntuAnimation", registerUCUbuntuAnimation);
79 qmlRegisterType<UCArguments>(uri, 0, 1, "Arguments");75 qmlRegisterType<UCArguments>(uri, 0, 1, "Arguments");
80 qmlRegisterType<UCArgument>(uri, 0, 1, "Argument");76 qmlRegisterType<UCArgument>(uri, 0, 1, "Argument");
@@ -84,14 +80,14 @@
84void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)80void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
85{81{
86 QQmlExtensionPlugin::initializeEngine(engine, uri);82 QQmlExtensionPlugin::initializeEngine(engine, uri);
87 // call engine registration method to load the theme
88 QQmlContext* context = engine->rootContext();83 QQmlContext* context = engine->rootContext();
8984
90 // register root object watcher that sets a global property with the root object85 // register root object watcher that sets a global property with the root object
91 // that can be accessed from any object86 // that can be accessed from any object
92 context->setContextProperty("QuickUtils", &QuickUtils::instance());87 context->setContextProperty("QuickUtils", &QuickUtils::instance());
9388
94 context->setContextProperty("Theme", ThemeEngine::initializeEngine(engine));89 UCTheme::instance().registerToContext(context);
90
95 context->setContextProperty("i18n", &UbuntuI18n::instance());91 context->setContextProperty("i18n", &UbuntuI18n::instance());
96 static ContextPropertyChangeListener i18nChangeListener(context, "i18n");92 static ContextPropertyChangeListener i18nChangeListener(context, "i18n");
97 QObject::connect(&UbuntuI18n::instance(), SIGNAL(domainChanged()),93 QObject::connect(&UbuntuI18n::instance(), SIGNAL(domainChanged()),
9894
=== modified file 'modules/Ubuntu/Components/plugin/plugin.pro'
--- modules/Ubuntu/Components/plugin/plugin.pro 2013-06-25 14:18:18 +0000
+++ modules/Ubuntu/Components/plugin/plugin.pro 2013-07-01 22:15:52 +0000
@@ -18,14 +18,8 @@
18uri = Ubuntu.Components18uri = Ubuntu.Components
1919
20HEADERS += plugin.h \20HEADERS += plugin.h \
21 themeengine.h \21 uctheme.h \
22 themeengine_p.h \22 ucthemesettings.h \
23 themeloader_p.h \
24 themesettings_p.h \
25 stylecache_p.h \
26 itemstyleattached.h \
27 itemstyleattached_p.h \
28 qmlthemeloader_p.h \
29 i18n.h \23 i18n.h \
30 listener.h \24 listener.h \
31 ucscalingimageprovider.h \25 ucscalingimageprovider.h \
@@ -40,19 +34,14 @@
40 qquickclipboard.h \34 qquickclipboard.h \
41 qquickmimedata.h \35 qquickmimedata.h \
42 qquickclipboard_p.h \36 qquickclipboard_p.h \
43 selector_p.h \
44 ucstyle.h \
45 ucubuntuanimation.h \37 ucubuntuanimation.h \
46 ucfontutils.h \38 ucfontutils.h \
47 ucarguments.h \39 ucarguments.h \
48 ucargument.h40 ucargument.h
4941
50SOURCES += plugin.cpp \42SOURCES += plugin.cpp \
51 themeengine.cpp \43 uctheme.cpp \
52 stylecache.cpp \44 ucthemesettings.cpp \
53 themesettings.cpp \
54 itemstyleattached.cpp \
55 qmlthemeloader.cpp \
56 i18n.cpp \45 i18n.cpp \
57 listener.cpp \46 listener.cpp \
58 ucscalingimageprovider.cpp \47 ucscalingimageprovider.cpp \
@@ -65,8 +54,6 @@
65 bottombarvisibilitycommunicator.cpp \54 bottombarvisibilitycommunicator.cpp \
66 qquickclipboard.cpp \55 qquickclipboard.cpp \
67 qquickmimedata.cpp \56 qquickmimedata.cpp \
68 selector.cpp \
69 ucstyle.cpp \
70 ucubuntuanimation.cpp \57 ucubuntuanimation.cpp \
71 ucfontutils.cpp \58 ucfontutils.cpp \
72 ucarguments.cpp \59 ucarguments.cpp \
7360
=== removed file 'modules/Ubuntu/Components/plugin/qmlthemeloader.cpp'
--- modules/Ubuntu/Components/plugin/qmlthemeloader.cpp 2013-05-02 00:54:44 +0000
+++ modules/Ubuntu/Components/plugin/qmlthemeloader.cpp 1970-01-01 00:00:00 +0000
@@ -1,777 +0,0 @@
1/*
2 * Copyright 2012 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Zsombor Egri <zsombor.egri@canonical.com>
17 */
18
19#include "themeengine.h"
20#include "themeengine_p.h"
21#include "qmlthemeloader_p.h"
22#include <QtQml/QQmlEngine>
23#include <QtQml/QQmlContext>
24#include <QtQml/QQmlComponent>
25#include <QtCore/QFileInfo>
26#include <QtCore/QDir>
27#include <QtCore/QCoreApplication>
28#include <QtQml/QQmlInfo>
29#include <QtCore/QRegularExpression>
30#include <QDebug>
31
32/*
33 QmlTheme file parser
34
35 The parsing steps are:
36 1. load file and build up selectorTable
37 2. normalize selectorTable by updating each selector with the non-overridden
38 properties from the base selector
39 3. build ThemeEngine's styleCache by creating Rule elements using the styles,
40 mappings and imports specified.
41
42 TODOs:
43 - optimization
44 - merge steps 1 and 2
45 - export into QML theme file for comparison in between CSS-like and QML theme
46 loading
47*/
48
49const char *styleRuleComponent = \
50 "import QtQuick 2.0\n"
51 "%1\n"
52 "%2\n";
53
54const char *stylePropertyFormat = \
55 "%1 {\n"
56 "%2"
57 " }";
58
59/*!
60 * \internal
61 * The function lists the folders the listed import modules can be found.
62 */
63QStringList importFolders(QQmlEngine *engine, QString imports)
64{
65 QStringList importPaths = engine->importPathList();
66 imports.remove("import ");
67 imports.remove(QRegularExpression(" \\d.\\d"));
68 imports.replace(QChar('.'), QDir::separator());
69 QStringList importList = imports.split('\n');
70
71 QStringList result;
72 Q_FOREACH(const QString &import, importList) {
73 Q_FOREACH(const QString &path, importPaths) {
74 QDir dir(path + QDir::separator() + import);
75 if (dir.exists())
76 result << dir.path();
77 }
78 }
79 return result;
80}
81
82/*!
83 \internal
84 Returns a subset from the given selector and configures it to ignore relation
85 and name.
86 */
87Selector selectorSubset(const Selector &path, int elements, int ignoreFlags = SelectorNode::IgnoreAll)
88{
89 Selector result;
90 while (elements > 0) {
91 result << SelectorNode(path[path.length() - elements], ignoreFlags);
92 elements--;
93 }
94 return result;
95}
96
97/*!
98 * \internal
99 * Create a QQmlComponent from a given QML string using the given engine
100 */
101QQmlComponent *createComponent(QQmlEngine *engine, const QString &qmlCode)
102{
103 if (qmlCode.isEmpty())
104 return 0;
105
106 QQmlComponent *ret = new QQmlComponent(engine);
107 ret->setData(qmlCode.toLatin1(), QUrl());
108 if (ret->isError() || !ret->isReady()) {
109 QString errorString = ret->isError() ? ret->errorString() : "Component not ready";
110 ThemeEnginePrivate::setError(QString("Error on creating style rule: \n%2\n%3")
111 .arg(qmlCode)
112 .arg(errorString));
113 delete ret;
114 ret = 0;
115 }
116 return ret;
117}
118
119/*!
120 * \internal
121 * Create a QQmlComponent delegate from a given file. The file is searched in the folders
122 * specified in folderList parameter.
123 */
124QQmlComponent *createDelegate(QQmlEngine *engine, const QString &qmlType, const QStringList &folderList)
125{
126 if (qmlType.isEmpty() || folderList.isEmpty())
127 return 0;
128
129 QFile f;
130 Q_FOREACH(const QString &folder, folderList) {
131 f.setFileName(folder + QDir::separator() + qmlType + ".qml");
132 if (f.exists()) {
133 QQmlComponent *ret = new QQmlComponent(engine, f.fileName());
134 if (ret->isError() || !ret->isReady()) {
135 QString errorString = ret->isError() ? ret->errorString() : "Component not ready";
136 ThemeEnginePrivate::setError(QString("Error on creating delegate: \n%2\n%3")
137 .arg(qmlType)
138 .arg(errorString));
139 delete ret;
140 ret = 0;
141 }
142 return ret;
143 }
144 }
145 // the QML type wasn't found in the folders, try to create a component
146 // using inline QML document
147 return createComponent(engine, QString("import QtQuick 2.0; %1{}").arg(qmlType));
148}
149
150/*!
151 * \brief QmlThemeLoader::urlMacro resolves the QmlTheme url() macro.
152 */
153QString QmlThemeLoader::urlMacro(const QString &param, const QTextStream &stream)
154{
155 QString path(param);
156 path.remove('\"');
157
158 if (!path.startsWith('/') && !path.startsWith("qrc:/") &&
159 !path.startsWith("image:/") && !path.startsWith(":/")) {
160 // check if we have one of the location tags: current, system, application
161 if (path.startsWith("current:")) {
162 path.remove("current:");
163 if (!path.startsWith('/'))
164 path.prepend('/');
165 path.prepend(QDir::currentPath());
166 } else if (path.startsWith("application:")) {
167 path.remove("application:");
168 if (!path.startsWith('/'))
169 path.prepend('/');
170 path.prepend(QCoreApplication::applicationDirPath());
171 } else if (path.startsWith("system:")) {
172 path.remove("system:");
173 if (!path.startsWith('/'))
174 path.prepend('/');
175 path.prepend(themeFolder());
176 } else {
177 QFile *file = qobject_cast<QFile*>(stream.device());
178 QFileInfo fi(*file);
179 //create the path so that returns the absolute path to the URL given
180 path = QFileInfo(fi.absoluteDir().path() + '/' + path).absoluteFilePath();
181 }
182 }
183 return path;
184}
185
186/*!
187 \internal
188 Reads the stream character by character skipping characters specified in \a bypassTokens
189 parameter and comments. Returns a string which in the most cases contains a single character
190 except when a '/' chracter was followed by a valid one, when returns two chars.
191 */
192QString QmlThemeLoader::readChar(QTextStream &stream, const QRegExp &bypassTokens)
193{
194 QString data;
195 while (!stream.atEnd()) {
196
197 data += stream.read(1);
198
199 // skip comments by default; as we read character by character, it's easier to
200 // implement by checking the comment limitators than using QRegExp, which would
201 // ease our life if we'd work with strings.
202 if (data[0] == '/') {
203 if (data == "/*") {
204 // read till we get the comment's end mark
205 QChar charData;
206 // consume comment
207 while ((charData = stream.read(1)[0]) != '/') {
208 while (charData != '*')
209 charData = stream.read(1)[0];
210 }
211 data.clear();
212 continue;
213 } else if (data.length() <= 1)
214 // we don't know yet the next character, so stay in
215 continue;
216 else
217 // we have the next one and that's not a comment marker, so return it
218 return data;
219 }
220
221 // check if we have something to skip
222 if (!data.contains(bypassTokens))
223 return data;
224 else
225 data.clear();
226 }
227 return QString();
228}
229
230/*!
231 \internal
232 Reads the stream content till one of the \a tokens is reached. The characters
233 specified in \a bypassTokens will be skipped. \a excludeToken specifies whether
234 the limiting token reached should be included in the data read or not (default
235 is not to include).
236 */
237QString QmlThemeLoader::readTillToken(QTextStream &stream, const QRegExp &tokens, const QRegExp &bypassTokens, bool excludeToken)
238{
239 QString ret;
240 while (!stream.atEnd() && !ret.contains(tokens)) {
241 ret += readChar(stream, bypassTokens);
242 }
243 if (excludeToken)
244 // remove the last character as that is the token
245 ret.remove(ret.length() - 1, 1);
246 return ret;
247}
248
249/*!
250 \internal
251 Special read function for reading declaration block where we may have objects
252 defined and we need to count the opened and closed parenthesis.
253 Example of such a declaration block:
254 \code
255 .button {
256 pressedAnimation: NumberAnimation {duration: 300; easing.type: Easing.OutQuad};
257 }
258 \endcode
259 */
260QString QmlThemeLoader::readDeclarationBlock(QTextStream &stream)
261{
262 // read till the close brace count is zero
263 // the first opened brace is consumed, therefore start from 1
264 int braceCount = 1;
265 QString chunk, data;
266
267 while (!stream.atEnd() && (braceCount > 0)) {
268 chunk = readChar(stream, QRegExp("[\r\n]"));
269 if (chunk[0] == '{')
270 braceCount++;
271 if (chunk[0] == '}')
272 braceCount--;
273 if (braceCount)
274 data += chunk;
275 }
276
277 return data;
278}
279
280/*!
281 * \internal
282 * Parses the declaration block and fills the property map from it. Also resolves
283 * macros and any other special tokens/tags in property value.
284 */
285void QmlThemeLoader::parseDeclarationBlock(const QString &blockData, PropertyMap &propertyMap, const QTextStream &stream)
286{
287 // parse data
288 QString propertyName, propertyValue;
289 const QChar *data = blockData.constData();
290 while (!data->isNull()) {
291 if (*data != ':')
292 propertyName += *data;
293 else {
294 // and continue to parse string till we get the declaration end token ';'
295 // note that we can have several of those as we can have object blocks inside
296 // e.g. animation: NumberAnimation {duration: 100; easing.type: Easing.OutQuad};
297 // in which case we need to pay attention on braces, and so on.
298 propertyValue.clear();
299 int braceCount = 0;
300 data++;
301 while (!data->isNull()) {
302 if ((*data == ';') && !braceCount)
303 break;
304 if (*data == '{')
305 braceCount++;
306 if (*data == '}')
307 braceCount--;
308 propertyValue += *data;
309 data++;
310 }
311 propertyValue = propertyValue.trimmed();
312 if (!propertyValue.isEmpty()) {
313 // resolve all macros and special tags/tokens
314 patchDeclarationValue(propertyValue, stream);
315 propertyMap.properties.insert(propertyName.trimmed(), propertyValue);
316 }
317 // check if we reached the end of the data
318 if (data->isNull())
319 return;
320 propertyName.clear();
321 propertyValue.clear();
322 }
323 data++;
324 }
325}
326
327/*!
328 * \internal
329 * Resolves macros, tokens/tags in the property value data.
330 */
331void QmlThemeLoader::patchDeclarationValue(QString &value, const QTextStream &stream)
332{
333 // check if the value is declared using url() macro
334 int atUrl;
335 while ((atUrl = value.indexOf("url")) >= 0) {
336 // check if it is the url() function, so the next valid character should be a "(" one
337 int pathStart = value.indexOf('(', atUrl);
338 if (pathStart >= 0) {
339 int pathEnd = value.indexOf(')', pathStart);
340 QString path = value.mid(pathStart + 1, pathEnd - pathStart - 1).trimmed();
341 // replace url(path) with the resolved one
342 value.replace(atUrl, pathEnd - atUrl + 1, urlMacro(path, stream).prepend('\"').append('\"'));
343 }
344 }
345}
346
347
348/*!
349 \internal
350 Resolves the "inheritance" between atomic selector items (the last items in a CSS selector component).
351 */
352void QmlThemeLoader::handleSelector(const Selector &selector, const PropertyMap &newProperties)
353{
354 PropertyMap propertyMap;
355 if (selectorTable.contains(selector))
356 propertyMap = selectorTable.value(selector);
357 // merge tables;newProperties override the existing ones
358 propertyMap.merge(newProperties, true);
359 // save them (back) into the table
360 selectorTable.insert(selector, propertyMap);
361}
362
363/*!
364 \internal
365 Normalizes the style table - copies the properties that were not overridden from the base
366 styles into the derivates.
367 */
368void QmlThemeLoader::normalizeStyles()
369{
370 QHashIterator<Selector, PropertyMap > i(selectorTable);
371 while (i.hasNext()) {
372 i.next();
373 Selector selector = i.key();
374 if (normalizeSelector(selector))
375 // start all over as hash iterator is not valid anymore
376 i.toFront();
377 }
378}
379
380/*!
381 \internal
382 Updates the properties of a rule based on the subset of the proeprty. May ignore relation
383 and/or style ID when collecting properties. override should be true when properties from
384 derivates are collected.
385 */
386bool QmlThemeLoader::updateRuleProperties(Selector &selector, PropertyMap &propertyMap, bool override)
387{
388 bool result = false;
389 // make sure we don't have the styleId disturbing
390 selector[0] = SelectorNode(selector[0], SelectorNode::NoStyleId);
391 if (selectorTable.contains(selector)) {
392 // make sure the selector is normalized
393 normalizeSelector(selector);
394 // get the properties and copy the base ones into the current selector
395 propertyMap.merge(selectorTable.value(selector), override);
396 }
397 return result;
398}
399
400/*!
401 * \internal
402 * Normalizes a given selector. Returns true if the selector was normalized(updated)
403 * otherwise returns false.
404 */
405bool QmlThemeLoader::normalizeSelector(const Selector &selector)
406{
407 PropertyMap propertyMap = selectorTable.value(selector);
408 if (propertyMap.normalized)
409 return false;
410 // not normalized yet
411
412 // collect properties from the derived ones
413 SelectorNode last = selector.last();
414 QString derivates = last.derivates();
415 if (!derivates.isEmpty()) {
416 // get the deriveds first then override those with the current properties
417 PropertyMap derivedMap;
418 Q_FOREACH(const QString& derived, derivates.split('.')) {
419 if (!derived.isEmpty()) {
420 Selector derivedSelector(derived);
421 QHash<Selector, PropertyMap>::iterator i = selectorTable.find(derivedSelector);
422 if (i != selectorTable.end() && i.key() == derivedSelector) {
423 // update to the real selector as that may also be derived
424 derivedSelector = i.key();
425 updateRuleProperties(derivedSelector, derivedMap, true);
426 } else {
427 //FIXME: fire a warning in ThemeEngine, when error handling is done properly
428 qmlInfo(ThemeEnginePrivate::themeEngine) << QString("Undefined selector: [%1]")
429 .arg(derivedSelector.toString());
430 }
431 }
432 }
433 if (!derivedMap.properties.isEmpty()) {
434 // override with the current stuff
435 propertyMap.merge(derivedMap, false);
436 }
437 }
438 // parse the cascade
439 if (selector.count() > 1) {
440 // need to check only the last node from the selector path
441 Selector subset = selectorSubset(selector, 1);
442 updateRuleProperties(subset, propertyMap, false);
443 }
444 propertyMap.normalized = true;
445 selectorTable.insert(selector, propertyMap);
446 return true;
447}
448
449
450/*!
451 \internal
452 Parses a QmlTheme theme. Reads the stream char-by-char to avoid seeking in the stream.
453 Seeking would be needed when reading entire line and parsing tags out of it.
454*/
455bool QmlThemeLoader::parseTheme(const QUrl &url)
456{
457 // open the file
458 QString fname = (url.scheme() == "qrc") ? url.toString().remove("qrc") : url.path();
459 QFile file(fname);
460 if (file.open(QFile::ReadOnly | QFile::Text)) {
461 QTextStream stream(&file);
462
463 QString data;
464
465 // read stream character by character so we don't need to seek
466 while (!stream.atEnd()) {
467
468 data += readChar(stream);
469
470 if (data.isEmpty())
471 break;
472
473 if (data[0] == '@') {
474 if (!parseAtRules(stream))
475 return false;
476 data.clear();
477 continue;
478 }
479 if (!parseDeclarations(data, stream))
480 return false;
481 }
482 return true;
483 } else {
484 ThemeEnginePrivate::setError(QString("%1: %2")
485 .arg(file.errorString())
486 .arg(file.fileName()));
487 }
488 return false;
489}
490
491bool QmlThemeLoader::parseAtRules(QTextStream &stream)
492{
493 // rule!! read till the first token
494 QString data = readTillToken(stream, QRegExp("[({]"), QRegExp("[\t]")).simplified();
495
496 //lookup for the rule handler and continue parsing with it
497 if (rules.contains(data))
498 return rules.value(data)(this, stream);
499 else
500 ThemeEnginePrivate::setError(QString("Unhandled rule: %1").arg(data));
501 return false;
502}
503
504bool QmlThemeLoader::parseDeclarations(QString &data, QTextStream &stream)
505{
506 // read till we hit a '{' token
507 data += readTillToken(stream, QRegExp("[{]"), QRegExp("[\t\r\n]")).simplified();
508 if (data.isEmpty())
509 return false;
510
511 QList<Selector> selectors = ThemeEnginePrivate::parseSelector(data);
512 if (selectors.isEmpty()) {
513 ThemeEnginePrivate::setError(QString("Syntax error!\n%1").arg(data));
514 return false;
515 } else {
516 // load declarator and apply on each selector
517 data = readDeclarationBlock(stream);
518 PropertyMap propertyMap;
519 if (!data.isEmpty())
520 parseDeclarationBlock(data, propertyMap, stream);
521
522 Q_FOREACH (const Selector &selector, selectors) {
523 handleSelector(selector, propertyMap);
524 }
525 }
526
527 // clear data before continuing parsing
528 data.clear();
529 return true;
530}
531
532bool QmlThemeLoader::generateStyleQml(StyleCache &cache)
533{
534 QString styleQml;
535 QString delegateQml;
536
537 // add delegates to cache
538 QHashIterator<QString, QPair<QString, QString> > t(qmlMap);
539 QStringList folders = importFolders(m_engine, imports);
540 while (t.hasNext()) {
541 t.next();
542 QQmlComponent *delegate = createDelegate(m_engine, t.value().second, folders);
543 if (delegate)
544 cache.addDelegate(t.value().second, delegate);
545 }
546
547 // go through the selector map and build the styles to each
548 QHashIterator<Selector, PropertyMap > i(selectorTable);
549 while (i.hasNext()) {
550 i.next();
551 Selector selector = i.key();
552 PropertyMap propertyMap = i.value();
553
554 buildStyleAndDelegate(selector, propertyMap.properties, styleQml, delegateQml);
555
556 QQmlComponent *style = createComponent(m_engine, styleQml);
557 if (!style && delegateQml.isEmpty()) {
558 return false;
559 }
560 cache.addStyleRule(selector, style, delegateQml);
561 }
562
563 return true;
564}
565
566QPair<QString, QString> QmlThemeLoader::selectorMapping(const Selector &selector)
567{
568 Selector subset;
569 QString qmap;
570 for (int count = selector.count(); count > 0; count--) {
571 subset = selectorSubset(selector, count, SelectorNode::IgnoreNone);
572 qmap = subset.toString();
573 if (qmlMap.contains(qmap)) {
574 return qmlMap.value(qmap);
575 }
576 }
577 // if none found, check the last node's style class
578 qmap = '.' + selector.last().getClass();
579 return (qmlMap.contains(qmap)) ? qmlMap.value(qmap) : QPair<QString, QString>();
580}
581
582
583void QmlThemeLoader::buildStyleAndDelegate(Selector &selector, PropertyHash &properties, QString &style, QString &delegate)
584{
585 QPair<QString, QString> qmlTypes = selectorMapping(selector);
586
587 style.clear();
588 delegate.clear();
589
590 // get the type for style and delegate
591 if (properties.count() > 0) {
592 QString propertyPrefix(" ");
593
594 // do not consider style types
595 style = QString(stylePropertyFormat).arg("Style");
596 propertyPrefix += "property var";
597
598 // add properties
599 QHashIterator<QString, QString> i(properties);
600 QString propertyArg;
601 while (i.hasNext()) {
602 i.next();
603 propertyArg += QString(" %1 %2: %3\n")
604 .arg(propertyPrefix)
605 .arg(i.key())
606 .arg(i.value());
607 }
608 // append the closing brace
609 style = style.arg(propertyArg);
610 style = QString(styleRuleComponent).arg(imports).arg(style);
611 }
612
613 // delegate
614 delegate = qmlTypes.second;
615}
616
617/*============================================================================*/
618
619/*!
620 \internal
621 Extracts the theme specified to be imported, and loads it.
622 */
623bool QmlThemeLoader::handleImport(QmlThemeLoader *loader, QTextStream &stream)
624{
625 QString themeFile = QmlThemeLoader::readTillToken(stream, QRegExp("[;]"), QRegExp("[ )\t\r\n\"]"));
626 // check if the imported theme file is an absolute path or not;
627 // if not, build the path relative to the current parsed file
628 // Note: resource stored theme files must use absolute paths, or should have
629 // qrc: scheme specified
630 bool result = false;
631 themeFile = urlMacro(themeFile, stream);
632 if (themeFile.startsWith("qrc"))
633 result = loader->parseTheme(QUrl(themeFile));
634 else {
635 result = loader->parseTheme(QUrl::fromLocalFile(themeFile));
636 if (result)
637 loader->themeFiles << themeFile;
638 }
639 return result;
640}
641
642/*!
643 \internal
644 Parses qml-mapping rule needed when defing the QML Rule pattern. The qml-mapping rule
645 syntax is as follows:
646 qml-mapping(css-tag, style-qml-type, delegate-qml-type)
647 where
648 - css-tag is the tag used in CSS theme
649 - style-qml-type is the name of the QML document defining the style properties
650 - delegate-qml-type is the name of the QML document defining the item delegate.
651 If no style is given, the theme engine will use QtObject for style and will declare all
652 properties typed as variant.
653
654 Example:
655 css.
656
657 @qml-mapping(button, ButonStyle, ButtonDelegate)
658
659 .button {
660 color: "blue"
661 }
662
663 .frame {
664 border: 2
665 }
666
667 will be translated as
668
669 Rule {
670 selector: ".button"
671 style: ButtonStyle {
672 color: "blue"
673 }
674 delegate: ButtonDelegate{}
675 }
676
677 Rule {
678 selector: ".frame"
679 style: QtObject {
680 property variant border: 2
681 }
682 }
683 */
684bool QmlThemeLoader::handleQmlMapping(QmlThemeLoader *loader, QTextStream &stream)
685{
686 QString params = QmlThemeLoader::readTillToken(stream, QRegExp("[;]"), QRegExp("[)\t\r\n\"]"));
687 QStringList mapping = params.split(',');
688
689 // we should have 3 elements in the list! if we don't we have an error!
690 bool ret = (mapping.count() == 3);
691 if (!ret)
692 ThemeEnginePrivate::setError(QString("Mapping has %1 parameter(s), should have 3!").
693 arg(mapping.count()));
694 else
695 loader->qmlMap.insert(mapping[0].trimmed().toLower(), qMakePair(mapping[1].trimmed(), mapping[2].trimmed()));
696
697 return ret;
698}
699
700/*!
701 \internal
702 Callback handling qml-import tags. Adds the import sentence to the import list
703 that will be added to the template creating the style rule, and the import path
704 to engine. The import path may be relative or absolute, and can contain "app"
705 and "sys" keywords, which result in application's current folder and global
706 theme's folder.
707 */
708bool QmlThemeLoader::handleQmlImport(QmlThemeLoader *loader, QTextStream &stream)
709{
710 QString param = QmlThemeLoader::readTillToken(stream, QRegExp("[;]"), QRegExp("[)\t\r\n]")).simplified();
711
712 if (param.isEmpty()) {
713 ThemeEnginePrivate::setError("Empty QML import statement!");
714 return false;
715 }
716
717 QStringList import = param.split(',');
718 QString importUrl = (import.count() >= 1) ? import[0].simplified().prepend("import ") : QString();
719 QString importPath = (import.count() < 2) ? QString() : import[1].simplified();
720
721 // check whether we have the import set
722 if (!loader->imports.contains(importUrl)) {
723 loader->imports += importUrl + '\n';
724
725 if (!importPath.isEmpty()) {
726 importPath = urlMacro(importPath, stream);
727 if (!loader->m_engine->importPathList().contains(importPath))
728 loader->m_engine->addImportPath(importPath);
729 }
730
731 } else {
732 // FIXME show warning instead of error, but continue parsing
733// ThemeEnginePrivate::setError(QString("QML import %1 allready added!").
734// arg(import[0]));
735 return true;
736 }
737
738 return true;
739}
740
741/*=============================================================================
742 CSS-LIKE THEME LOADER
743=============================================================================*/
744
745QmlThemeLoader::QmlThemeLoader(QQmlEngine *engine)
746{
747 m_engine = engine;
748 // fill the callback maps
749 rules["import url"] = handleImport;
750 rules["qml-mapping"] = handleQmlMapping;
751 rules["qml-import"] = handleQmlImport;
752}
753
754bool QmlThemeLoader::loadTheme(const QUrl &url, QStringList &themeFiles, StyleCache &cache)
755{
756 bool ok = true;
757 // add toolkit as default import due to Style type
758 imports = "import Ubuntu.Components 0.1\n";
759 // parses the theme
760 if (parseTheme(url)) {
761
762 normalizeStyles();
763 // build up the QML style tree
764 if (!generateStyleQml(cache)) {
765 ok = false;
766 } else
767 themeFiles<< url.path() << this->themeFiles;
768
769 // cleanup
770 ruleString.clear();
771 imports.clear();
772 qmlMap.clear();
773 selectorTable.clear();
774 }
775
776 return ok;
777}
7780
=== removed file 'modules/Ubuntu/Components/plugin/qmlthemeloader_p.h'
--- modules/Ubuntu/Components/plugin/qmlthemeloader_p.h 2013-03-14 07:27:02 +0000
+++ modules/Ubuntu/Components/plugin/qmlthemeloader_p.h 1970-01-01 00:00:00 +0000
@@ -1,95 +0,0 @@
1/*
2 * Copyright 2012 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Zsombor Egri <zsombor.egri@canonical.com>
17 */
18
19#ifndef QMLTHEMELOADER_P_H
20#define QMLTHEMELOADER_P_H
21
22#include "themeengine_p.h"
23#include "themeloader_p.h"
24#include <QtCore/QTextStream>
25
26// CSS-like theme loader
27class QmlThemeLoader;
28typedef bool (*ParserCallback)(QmlThemeLoader *loader, QTextStream &stream);
29
30typedef QHash<QString, QString> PropertyHash;
31
32class PropertyMap {
33public:
34 PropertyMap() : normalized(false){}
35 bool normalized;
36 PropertyHash properties;
37 inline bool merge(const PropertyMap &other, bool overrides)
38 {
39 bool result = false;
40 QHashIterator<QString, QString> i(other.properties);
41 while (i.hasNext()) {
42 i.next();
43 if (overrides || !properties.contains(i.key())) {
44 properties.insert(i.key(), i.value());
45 result = true;
46 }
47 }
48 return result;
49 }
50};
51
52class QmlThemeLoader : public ThemeLoader {
53 Q_INTERFACES(ThemeLoader)
54public:
55 QmlThemeLoader(QQmlEngine *engine);
56 virtual ~QmlThemeLoader(){}
57 bool loadTheme(const QUrl &path, QStringList &themeFiles, StyleCache &cache);
58
59private:
60 QStringList themeFiles;
61
62private:
63
64 static QString urlMacro(const QString &param, const QTextStream &stream);
65 static QString readChar(QTextStream &stream, const QRegExp &bypassTokens = QRegExp("[ \t\r\n]"));
66 static QString readTillToken(QTextStream &stream, const QRegExp &tokens, const QRegExp &bypassTokens = QRegExp(), bool excludeToken = true);
67 static QString readDeclarationBlock(QTextStream &stream);
68 static void parseDeclarationBlock(const QString &blockData, PropertyMap &properties, const QTextStream &stream);
69 static void patchDeclarationValue(QString &value, const QTextStream &stream);
70 void handleSelector(const Selector &path, const PropertyMap &newProperties);
71 void normalizeStyles();
72 bool updateRuleProperties(Selector &selector, PropertyMap &propertyMap, bool override);
73 bool normalizeSelector(const Selector &selector);
74 bool parseTheme(const QUrl &url);
75 bool parseAtRules(QTextStream &stream);
76 bool parseDeclarations(QString &data, QTextStream &stream);
77 bool generateStyleQml(StyleCache &cache);
78 QPair<QString, QString> selectorMapping(const Selector &selector);
79 void buildStyleAndDelegate(Selector &selector, PropertyHash &properties, QString &style, QString &delegate);
80
81 // @-rule handlers
82 static bool handleImport(QmlThemeLoader *loader, QTextStream &stream);
83 static bool handleQmlMapping(QmlThemeLoader *loader, QTextStream &stream);
84 static bool handleQmlImport(QmlThemeLoader *loader, QTextStream &stream);
85
86 QString imports;
87 QString ruleString;
88 QHash<QString, ParserCallback> rules;
89 QHash<QString, QPair<QString, QString> > qmlMap;
90 QHash<Selector, PropertyMap > selectorTable;
91};
92
93
94
95#endif // QMLTHEMELOADER_P_H
960
=== removed file 'modules/Ubuntu/Components/plugin/selector.cpp'
--- modules/Ubuntu/Components/plugin/selector.cpp 2013-04-26 09:51:27 +0000
+++ modules/Ubuntu/Components/plugin/selector.cpp 1970-01-01 00:00:00 +0000
@@ -1,339 +0,0 @@
1/*
2 * Copyright 2012 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Zsombor Egri <zsombor.egri@canonical.com>
17 */
18
19#include "selector_p.h"
20#include "itemstyleattached.h"
21#include "itemstyleattached_p.h"
22#include "themeengine_p.h"
23#include "quickutils.h"
24#include <QtCore/QStringList>
25#include <QtCore/QRegularExpression>
26#include <QtQuick/QQuickItem>
27
28SelectorNode::SelectorNode() :
29 relationship(Descendant), ranking(RankNull)
30{}
31
32SelectorNode::SelectorNode(const SelectorNode &other):
33 className(other.className), styleClass(other.styleClass),
34 styleId(other.styleId), relationship(other.relationship), ranking(RankNull)
35{
36 updateRanking();
37}
38
39SelectorNode::SelectorNode(const SelectorNode &other, int ignore) :
40 className(other.className), relationship(Descendant), ranking(RankNull)
41{
42 if ((ignore & NoStyleId) != NoStyleId)
43 styleId = other.styleId;
44 styleClass = other.styleClass;
45 if ((ignore & NoDerivates) == NoDerivates)
46 styleClass.remove(derivates());
47 if ((ignore & NoRelation) != NoRelation)
48 relationship = other.relationship;
49 updateRanking();
50}
51
52/*!
53 \internal
54 Creates an instance of a SelectorNode by parsing the selectorString. The
55 sensitivity parameter configures the node so that during string conversion
56 and comparison ignores the relationship, the name both or none. This feature
57 is used when building up QmlTheme selectorTable.
58*/
59SelectorNode::SelectorNode(const QString &selectorString) :
60 relationship(Descendant), ranking(RankNull)
61{
62 styleClass = selectorString.toLower().trimmed();
63 if (styleClass.startsWith('>')) {
64 relationship = Child;
65 styleClass.remove('>');
66 }
67 int idIndex = styleClass.indexOf('#');
68 if (idIndex != -1) {
69 styleId = styleClass.mid(idIndex + 1).toLower();
70 styleClass = styleClass.left(idIndex);
71 if (idIndex > 1 && styleClass[0] == '.')
72 styleClass = styleClass.mid(1, idIndex - 1);
73 } else if (styleClass[0] == '.')
74 styleClass = styleClass.mid(1);
75 updateRanking();
76}
77/*!
78 * \internal
79 * Creates a selector node with the given type, class, id and relation.
80 */
81SelectorNode::SelectorNode(const QString &stype, const QString &sclass, const QString &sid, SelectorNode::Relationship srelation) :
82 className(stype), styleClass(sclass), styleId(sid), relationship(srelation), ranking(RankNull)
83{
84 updateRanking();
85}
86
87/*!
88 * \internal
89 * Creates a selector node filling information gathered from the given item.
90 */
91SelectorNode::SelectorNode(QQuickItem *item) :
92 relationship(Descendant), ranking(RankNull)
93{
94 update(item);
95}
96
97/*!
98 \internal
99 Converts a SelectorNode into string using "<relation> .<class>#<name>"
100 format. Depending on the ignore flags set, may ignore the relationship, derivates
101 and styleId. The default ignore flag is Nothing.
102 */
103//FIXME: remove ignore flags after the lookup is cleaned&fixed
104QString SelectorNode::toString(int ignore) const
105{
106 QString result;
107 if (((ignore & NoRelation) != NoRelation) &&
108 (relationship == SelectorNode::Child))
109 result += ">";
110 if (!styleClass.isEmpty())
111 result += "." + styleClass;
112 else if (!className.isEmpty()) {
113 result += '.' + className;
114 }
115 if ((ignore & NoDerivates) == NoDerivates)
116 result.remove(derivates());
117 if (((ignore & NoStyleId) != NoStyleId) && !styleId.isEmpty())
118 result += "#" + styleId;
119 return result;
120}
121
122/*!
123 * \internal
124 * The method updates the selector node by fetching information from the item.
125 */
126void SelectorNode::update(QQuickItem *item)
127{
128 ItemStyleAttached *style = ThemeEnginePrivate::attachedStyle(item);
129 if (!style)
130 return;
131 className = QuickUtils::instance().className(item);
132 styleClass = style->d_ptr->styleClass;
133 styleId = style->d_ptr->styleId;
134 updateRanking();
135}
136
137/*!
138 * \internal
139 * The function returns the rank of the selector node based on the layer, which
140 * is its index in the selector.
141 * Each node has two bits reserved for ranking, where one bit specifies whether
142 * the direct child separator is present and th eother bit specifies whether the
143 * style ID is present. These bits are shifted leftwards with the layer -1 value,
144 * layer 0 being the root node which is not in use.
145 */
146unsigned SelectorNode::rank()
147{
148 return ranking;
149}
150
151bool SelectorNode::operator==(const SelectorNode &other) const
152{
153 QString myClass = (styleClass.isEmpty()) ? className : styleClass;
154 QString otherClass = (other.styleClass.isEmpty()) ? other.className : other.styleClass;
155
156 return (myClass == otherClass) && (styleId == other.styleId) && (relationship == other.relationship);
157}
158
159/*!
160 * \internal
161 * Returns the style type.
162 * to QML.
163 */
164QString SelectorNode::type() const
165{
166 return className;
167}
168
169/*!
170 * \internal
171 * Returns the style class and its derivates in one string that is presentable
172 * to QML.
173 */
174QString SelectorNode::getClass() const
175{
176 if (styleClass.indexOf('.') != -1)
177 return styleClass.left(styleClass.indexOf('.'));
178 return styleClass;
179}
180
181/*!
182 * \internal
183 * Returns the selectors the current one's properties are derived from.
184 */
185QString SelectorNode::derivates() const
186{
187 QString result;
188 //cut the derivates from the style class
189 int derivesIndex = styleClass.indexOf('.');
190 if (derivesIndex != -1)
191 result = styleClass.mid(derivesIndex);
192
193 return result;
194}
195
196/*!
197 * \internal
198 * Returns the style ID;
199 */
200QString SelectorNode::id() const
201{
202 return styleId;
203}
204
205/*!
206 * \internal
207 * Retiurns the reference to the relationship.
208 */
209SelectorNode::Relationship SelectorNode::relation()
210{
211 return relationship;
212}
213
214/*!
215 \internal
216 Hash key for SelectorNode. Uses QString's hash function.
217 */
218uint qHash(const SelectorNode &key)
219{
220 return qHash(key.toString());
221}
222
223
224/*!
225 * \internal
226 * Converts a selector string into Selector object. Does not accept 32-node longer
227 * selector;
228 * Current support (ref: www.w3.org/TR/selector.html):
229 * - Type selectors, e.g: "Button"
230 * - Descendant selectors, e.g: "Dialog Button"
231 * - Child selectors, e.g: "Dialog>Button"
232 * - ID selectors, e.g: "Button#mySpecialButton"
233 */
234Selector::Selector(const QString &string) :
235 m_owner(0)
236{
237 QString tmp(string.trimmed());
238 // prepare for split
239 if (tmp.contains('>')) {
240 tmp.replace(QRegularExpression("[ ]*(>)[ ]*"), ">").replace('>', "|>");
241 }
242 tmp.replace(' ', '|');
243
244 QStringList nodes = tmp.simplified().split('|');
245 QStringListIterator inodes(nodes);
246 inodes.toBack();
247 while (inodes.hasPrevious()) {
248 const QString &node = inodes.previous();
249 if (node.isEmpty())
250 continue;
251 prepend(SelectorNode(node));
252 }
253}
254
255/*!
256 * \internal
257 * Builds the selector for the given item.
258 */
259Selector::Selector(QQuickItem *item) :
260 m_owner(item)
261{
262 SelectorNode::Relationship relation = SelectorNode::Child;
263 QQuickItem *parent = m_owner->parentItem();
264
265 prepend(SelectorNode(m_owner));
266
267 while (parent) {
268 if (!ThemeEnginePrivate::attachedStyle(parent))
269 relation = SelectorNode::Descendant;
270 else {
271 // update relationship
272 first().relationship = relation;
273 prepend(SelectorNode(parent));
274 relation = SelectorNode::Child;
275 }
276 parent = parent->parentItem();
277 }
278}
279
280/*!
281 \internal
282 Converts a style path back to selector string.
283*/
284QString Selector::toString() const
285{
286 QString result;
287
288 QListIterator<SelectorNode> i(*this);
289 while (i.hasNext()) {
290 SelectorNode node = i.next();
291 result += ' ' + node.toString();
292 }
293 result.replace(" >", ">");
294 return result.simplified();
295}
296
297/*!
298 * \internal
299 * The method calculates the ranking of the selector itself, which is a
300 * combination of the node rankings. The node rankings being bitmasks each of
301 * them consuming 2 bits implies that the maximum depth of the selector can be
302 * not more than 32 nodes.
303 */
304int64_t Selector::rank() const
305{
306 int64_t result = 0;
307 int nodes = size();
308 SelectorNode node;
309 int i;
310 for (i = nodes - 1; i >= 0; --i) {
311 node = at(i);
312 result |= ((int64_t)node.rank()) << 2 * i;
313 }
314 return result;
315}
316
317/*!
318 * \internal
319 * The method updates the selector by fetching information from the owner. This
320 * method has meaning only if the selector was created using an item.
321 */
322void Selector::update()
323{
324 if (!m_owner)
325 return;
326 last().update(m_owner);
327}
328
329
330
331/*!
332 \internal
333 Hash key for Selector. Uses QString's hash function.
334 */
335uint qHash(const Selector &key)
336{
337 return qHash(key.toString());
338}
339
3400
=== removed file 'modules/Ubuntu/Components/plugin/selector_p.h'
--- modules/Ubuntu/Components/plugin/selector_p.h 2013-04-26 09:37:22 +0000
+++ modules/Ubuntu/Components/plugin/selector_p.h 1970-01-01 00:00:00 +0000
@@ -1,107 +0,0 @@
1/*
2 * Copyright 2012 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Zsombor Egri <zsombor.egri@canonical.com>
17 */
18
19#ifndef SELECTOR_P_H
20#define SELECTOR_P_H
21
22#include <QtCore/QHash>
23#include <QtCore/QString>
24#include <QtCore/QList>
25
26class QQuickItem;
27class Selector;
28// node of a selector
29class SelectorNode {
30 public:
31 enum Relationship {
32 Child,
33 Descendant
34 };
35 enum IgnoreFlags {
36 IgnoreNone = 0,
37 NoRelation = 0x01,
38 NoStyleId = 0x02,
39 NoDerivates = 0x04,
40 IgnoreAll = NoRelation | NoStyleId | NoDerivates};
41 enum RankFlags {
42 RankNull = 0,
43 RankId = 0x01,
44 RankChild = 0x02,
45 RankFull = RankId | RankChild
46 };
47
48 SelectorNode();
49 SelectorNode(const SelectorNode &other);
50 SelectorNode(const SelectorNode &other, int ignore);
51 SelectorNode(const QString &selectorString);
52 SelectorNode(const QString &stype, const QString &sclass, const QString &sid, SelectorNode::Relationship srelation);
53 SelectorNode(QQuickItem *item);
54 inline bool isStrictRelationed() {
55 return (relationship == Child);
56 }
57 inline bool isEmpty() {
58 return className.isEmpty() && styleClass.isEmpty() && styleId.isEmpty();
59 }
60
61 QString toString(int ignore = IgnoreNone) const;
62 void update(QQuickItem *item);
63 unsigned rank();
64 bool operator==(const SelectorNode &other) const;
65 // getters
66 QString type() const;
67 QString getClass() const;
68 QString derivates() const;
69 QString id() const;
70 Relationship relation();
71private:
72 // hide them so we don't mess them accidentaly
73 QString className;
74 QString styleClass;
75 QString styleId;
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to status/vote changes: