Merge lp:~bzoltan/ubuntu-ui-toolkit/landing-2015-09-04 into lp:ubuntu-ui-toolkit
- landing-2015-09-04
- Merge into trunk
Proposed by
Zoltan Balogh
Status: | Merged |
---|---|
Approved by: | Zoltan Balogh |
Approved revision: | 1629 |
Merged at revision: | 1224 |
Proposed branch: | lp:~bzoltan/ubuntu-ui-toolkit/landing-2015-09-04 |
Merge into: | lp:ubuntu-ui-toolkit |
Diff against target: |
9558 lines (+6169/-1099) 129 files modified
.bzrignore (+11/-11) .qmake.conf (+4/-0) components.api (+44/-31) debian/changelog (+58/-0) debian/control (+5/-0) documentation/documentation.pro (+1/-1) documentation/ubuntu-ui-toolkit-common.qdocconf (+1/-1) examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.qml (+23/-2) features/ubuntu_enable_testing.prf (+1/-1) features/ubuntu_qml_plugin.prf (+52/-51) po/po.pro (+1/-1) src/Ubuntu/Components/1.1/Haptics.qml (+0/-91) src/Ubuntu/Components/1.2/ActionItem.qml (+0/-96) src/Ubuntu/Components/1.2/TextField.qml (+1/-1) src/Ubuntu/Components/1.2/TextInputPopover.qml (+1/-0) src/Ubuntu/Components/1.2/ToolbarButton.qml (+1/-0) src/Ubuntu/Components/1.3/AbstractButton.qml (+0/-109) src/Ubuntu/Components/1.3/ActionItem.qml (+0/-96) src/Ubuntu/Components/1.3/AdaptivePageLayout.qml (+266/-30) src/Ubuntu/Components/1.3/AppHeader.qml (+1/-6) src/Ubuntu/Components/1.3/Button.qml (+1/-1) src/Ubuntu/Components/1.3/ComboButton.qml (+1/-0) src/Ubuntu/Components/1.3/Header.qml (+0/-39) src/Ubuntu/Components/1.3/MainView.qml (+0/-3) src/Ubuntu/Components/1.3/MainViewBase.qml (+24/-27) src/Ubuntu/Components/1.3/PageColumn.qml (+16/-11) src/Ubuntu/Components/1.3/PageColumnsLayout.qml (+115/-0) src/Ubuntu/Components/1.3/PageWrapper.qml (+25/-2) src/Ubuntu/Components/1.3/PageWrapperUtils.js (+167/-0) src/Ubuntu/Components/1.3/TextField.qml (+2/-2) src/Ubuntu/Components/ComponentModule.pro (+7/-8) src/Ubuntu/Components/ListItems/1.3/SingleControl.qml (+2/-1) src/Ubuntu/Components/Popups/1.3/Popover.qml (+1/-1) src/Ubuntu/Components/Themes/Ambiance/1.2/ListItemStyle.qml (+14/-1) src/Ubuntu/Components/Themes/Ambiance/1.3/ActionBarStyle.qml (+0/-2) src/Ubuntu/Components/Themes/Ambiance/1.3/HeadDividerStyle.qml (+0/-56) src/Ubuntu/Components/Themes/Ambiance/1.3/HeaderStyle.qml (+0/-124) src/Ubuntu/Components/Themes/Ambiance/1.3/ListItemStyle.qml (+65/-0) src/Ubuntu/Components/Themes/Ambiance/1.3/OverflowPanel.qml (+1/-1) src/Ubuntu/Components/Themes/Ambiance/Ambiance.pro (+0/-2) src/Ubuntu/Components/plugin/adapters/actionsproxy_p.cpp (+7/-7) src/Ubuntu/Components/plugin/adapters/actionsproxy_p.h (+1/-1) src/Ubuntu/Components/plugin/i18n.cpp (+74/-0) src/Ubuntu/Components/plugin/i18n.h (+1/-0) src/Ubuntu/Components/plugin/plugin.cpp (+18/-0) src/Ubuntu/Components/plugin/plugin.pri (+9/-2) src/Ubuntu/Components/plugin/privates/listitemdragarea.cpp (+2/-3) src/Ubuntu/Components/plugin/privates/listitemdragarea.h (+1/-1) src/Ubuntu/Components/plugin/privates/listitemexpansion.cpp (+106/-0) src/Ubuntu/Components/plugin/sortfiltermodel.cpp (+6/-3) src/Ubuntu/Components/plugin/timeutils_p.h (+24/-0) src/Ubuntu/Components/plugin/ucabstractbutton.cpp (+156/-0) src/Ubuntu/Components/plugin/ucabstractbutton.h (+64/-0) src/Ubuntu/Components/plugin/ucaction.cpp (+5/-5) src/Ubuntu/Components/plugin/ucaction.h (+8/-7) src/Ubuntu/Components/plugin/ucactioncontext.cpp (+6/-1) src/Ubuntu/Components/plugin/ucactioncontext.h (+3/-2) src/Ubuntu/Components/plugin/ucactionitem.cpp (+316/-0) src/Ubuntu/Components/plugin/ucactionitem.h (+79/-0) src/Ubuntu/Components/plugin/uchaptics.cpp (+179/-0) src/Ubuntu/Components/plugin/uchaptics.h (+78/-0) src/Ubuntu/Components/plugin/uclistitem.cpp (+134/-22) src/Ubuntu/Components/plugin/uclistitem.h (+76/-1) src/Ubuntu/Components/plugin/uclistitem_p.h (+15/-6) src/Ubuntu/Components/plugin/uclistitemstyle.cpp (+38/-9) src/Ubuntu/Components/plugin/uclistitemstyle.h (+6/-0) src/Ubuntu/Components/plugin/ucqquickimageextension.cpp (+23/-3) src/Ubuntu/Components/plugin/ucstatesaver.cpp (+2/-2) src/Ubuntu/Components/plugin/ucubuntushape.cpp (+45/-34) src/Ubuntu/Components/plugin/ucubuntushape.h (+0/-1) src/Ubuntu/Components/plugin/ucunits.cpp (+46/-5) src/Ubuntu/Components/plugin/ucunits.h (+1/-0) src/Ubuntu/Components/plugin/ucviewitemsattached.cpp (+141/-1) src/Ubuntu/Components/qmldir (+2/-8) tests/apicheck/apicheck.cpp (+8/-4) tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_tabbar.py (+6/-1) tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_textarea.py (+16/-20) tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_textfield.py (+34/-48) tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_toolbar.py (+1/-1) tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/popups.py (+5/-1) tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_tabs.TabsTestCase.deprecated_TabBar.1.3.qml (+62/-0) tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_tabs.TabsTestCase.new_header.1.3.qml (+43/-0) tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_tabs.py (+6/-0) tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_textfield.1.0.qml (+37/-0) tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_textfield.1.3.qml (+37/-0) tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_textfield.py (+15/-31) tests/resources/listitems/ListItemExpansion.qml (+121/-0) tests/unit/add_makecheck.pri (+12/-1) tests/unit/custom_qpa/README (+15/-0) tests/unit/custom_qpa/custom.json (+3/-0) tests/unit/custom_qpa/custom_qpa.pro (+15/-0) tests/unit/custom_qpa/main.cpp (+54/-0) tests/unit/custom_qpa/qcustombackingstore.cpp (+64/-0) tests/unit/custom_qpa/qcustombackingstore.h (+55/-0) tests/unit/custom_qpa/qcustomintegration.cpp (+112/-0) tests/unit/custom_qpa/qcustomintegration.h (+74/-0) tests/unit/runtest.sh (+2/-0) tests/unit/tst_components/tst_action.qml (+16/-0) tests/unit/tst_components/tst_actionitem.qml (+13/-5) tests/unit/tst_i18n/tst_i18n.pro (+3/-18) tests/unit/tst_i18n/tst_i18n_LocalizedApp/src/LocalizedApp.qml (+43/-1) tests/unit/tst_i18n/tst_i18n_LocalizedApp/src/tst_i18n_LocalizedApp.cpp (+5/-5) tests/unit/tst_i18n/tst_i18n_LocalizedApp/tst_i18n_LocalizedApp.pro (+17/-0) tests/unit/tst_i18n/tst_i18n_RelativeTime/po/en_US.po (+54/-0) tests/unit/tst_i18n/tst_i18n_RelativeTime/src/RelativeTime.qml (+71/-0) tests/unit/tst_i18n/tst_i18n_RelativeTime/src/tst_i18n_RelativeTime.cpp (+202/-0) tests/unit/tst_i18n/tst_i18n_RelativeTime/tst_i18n_RelativeTime.pro (+17/-0) tests/unit/tst_performance/AbstractButton13Grid.qml (+30/-0) tests/unit/tst_performance/AbstractButtonGrid.qml (+30/-0) tests/unit/tst_performance/tst_performance.cpp (+2/-0) tests/unit/tst_performance/tst_performance.pro (+3/-1) tests/unit/tst_units/dpr1/dpr1.pro (+3/-0) tests/unit/tst_units/dpr2/dpr2.pro (+3/-0) tests/unit/tst_units/dpr2/tst_units_dpr2.cpp (+143/-0) tests/unit/tst_units/dpr3/dpr3.pro (+3/-0) tests/unit/tst_units/dpr3/tst_units_dpr3.cpp (+88/-0) tests/unit/tst_units/tst_units.pro (+6/-3) tests/unit/unit.pro (+3/-1) tests/unit_x11/tst_components/ListItemTestCase.qml (+6/-0) tests/unit_x11/tst_components/ListItemTestCase13.qml (+143/-0) tests/unit_x11/tst_components/tst_abstractbutton13.qml (+115/-0) tests/unit_x11/tst_components/tst_adaptivepagelayout.qml (+63/-0) tests/unit_x11/tst_components/tst_adaptivepagelayout_configuration.qml (+229/-0) tests/unit_x11/tst_components/tst_listitem.qml (+1/-21) tests/unit_x11/tst_components/tst_listitem13.qml (+1211/-0) tests/unit_x11/tst_components/tst_listitem_expansion.qml (+199/-0) tests/unit_x11/tst_components/tst_listitem_extras.qml (+28/-2) tests/unit_x11/tst_components/tst_multicolumnheader.qml (+37/-1) ubuntu-sdk.pro (+1/-1) |
To merge this branch: | bzr merge lp:~bzoltan/ubuntu-ui-toolkit/landing-2015-09-04 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu SDK team | Pending | ||
Review via email: mp+270197@code.launchpad.net |
Commit message
Landing 2015.09.04
Description of the change
Landing 2015.09.04
To post a comment you must log in.
- 1630. By Zoltan Balogh
-
Cope with different AbstractButton class name in 1.3
- 1631. By Zoltan Balogh
-
license fix
- 1632. By Zoltan Balogh
-
update
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2015-05-20 14:47:16 +0000 | |||
3 | +++ .bzrignore 2015-09-08 04:09:38 +0000 | |||
4 | @@ -1,25 +1,25 @@ | |||
5 | 1 | .obj | ||
6 | 2 | .pch | ||
7 | 3 | .qmake.cache | ||
8 | 4 | .rcc | ||
9 | 5 | qml | ||
10 | 6 | |||
11 | 1 | Makefile* | 7 | Makefile* |
12 | 2 | src/Makefile* | ||
13 | 3 | src/Ubuntu/Components/Makefile* | ||
14 | 4 | src/Ubuntu/Components/plugin/Makefile* | ||
15 | 5 | src/Ubuntu/Components/plugin/qrc_plugin.cpp | ||
16 | 6 | src/Ubuntu/Components/Themes/Makefile* | ||
17 | 7 | src/Ubuntu/Components/Layouts/Makefile* | ||
18 | 8 | src/Ubuntu/Components/PerformanceMetrics/Makefile* | ||
19 | 9 | src/Ubuntu/Test/Makefile* | ||
20 | 10 | documentation/html/* | 8 | documentation/html/* |
21 | 11 | *.moc | 9 | *.moc |
22 | 12 | moc_*.cpp | 10 | moc_*.cpp |
23 | 13 | qrc_tst_*.cpp | 11 | qrc_tst_*.cpp |
24 | 14 | tests/test_tst_*.xml | 12 | tests/test_tst_*.xml |
25 | 15 | tests/tst_*.qml.xml | 13 | tests/tst_*.qml.xml |
27 | 16 | tests/unit*/tst_*/tst_[^.]* | 14 | tests/unit*/tst_*/tst_* |
28 | 15 | tests/unit/tst_*/tst_*/tst_* | ||
29 | 17 | tests/unit*/testparser/testparser | 16 | tests/unit*/testparser/testparser |
30 | 18 | plugins.qmltypes | 17 | plugins.qmltypes |
31 | 19 | po/*.mo | 18 | po/*.mo |
32 | 20 | examples/ubuntu-ui-toolkit-gallery/po/*.mo | 19 | examples/ubuntu-ui-toolkit-gallery/po/*.mo |
34 | 21 | tests/unit/tst_i18n/locale/en/LC_MESSAGES/*.mo | 20 | tests/unit/tst_i18n/tst_*/*/share/locale/en/LC_MESSAGES/*.mo |
35 | 21 | tests/unit/tst_i18n/*/share/locale/en/LC_MESSAGES/*.mo | ||
36 | 22 | tests/unit/tst_units/dpr*/dpr* | ||
37 | 22 | tests/apicheck/apicheck | 23 | tests/apicheck/apicheck |
38 | 23 | tests/launcher/launcher | 24 | tests/launcher/launcher |
39 | 24 | build_paths.inc | 25 | build_paths.inc |
40 | 25 | tests/unit/tst_i18n/localizedApp/share/locale/en/LC_MESSAGES/localizedApp.mo | ||
41 | 26 | 26 | ||
42 | === modified file '.qmake.conf' | |||
43 | --- .qmake.conf 2015-05-18 09:53:55 +0000 | |||
44 | +++ .qmake.conf 2015-09-08 04:09:38 +0000 | |||
45 | @@ -12,3 +12,7 @@ | |||
46 | 12 | 12 | ||
47 | 13 | ROOT_SOURCE_DIR=$$PWD | 13 | ROOT_SOURCE_DIR=$$PWD |
48 | 14 | ROOT_BUILD_DIR=$$shadowed($$PWD) | 14 | ROOT_BUILD_DIR=$$shadowed($$PWD) |
49 | 15 | |||
50 | 16 | exists($$PWD/../qt.pro) { | ||
51 | 17 | CONFIG += build_with_qt | ||
52 | 18 | } | ||
53 | 15 | 19 | ||
54 | === modified file 'components.api' | |||
55 | --- components.api 2015-08-12 09:55:50 +0000 | |||
56 | +++ components.api 2015-09-08 04:09:38 +0000 | |||
57 | @@ -4,10 +4,10 @@ | |||
58 | 4 | signal pressAndHold() | 4 | signal pressAndHold() |
59 | 5 | property bool pressed | 5 | property bool pressed |
60 | 6 | Ubuntu.Components.AbstractButton 1.3: ActionItem | 6 | Ubuntu.Components.AbstractButton 1.3: ActionItem |
62 | 7 | property bool hovered | 7 | readonly property bool hovered |
63 | 8 | signal clicked() | 8 | signal clicked() |
64 | 9 | signal pressAndHold() | 9 | signal pressAndHold() |
66 | 10 | property bool pressed | 10 | readonly property bool pressed |
67 | 11 | Ubuntu.Components.Action 1.3 1.0 0.1: QtObject | 11 | Ubuntu.Components.Action 1.3 1.0 0.1: QtObject |
68 | 12 | property string description | 12 | property string description |
69 | 13 | property bool enabled | 13 | property bool enabled |
70 | @@ -43,14 +43,8 @@ | |||
71 | 43 | property string iconName | 43 | property string iconName |
72 | 44 | property url iconSource | 44 | property url iconSource |
73 | 45 | signal triggered(var value) | 45 | signal triggered(var value) |
82 | 46 | function var trigger(var value) | 46 | function trigger(var value) |
83 | 47 | property string text | 47 | function trigger() |
76 | 48 | Ubuntu.Components.ActionItem 1.3: StyledItem | ||
77 | 49 | property Action action | ||
78 | 50 | property string iconName | ||
79 | 51 | property url iconSource | ||
80 | 52 | signal triggered(var value) | ||
81 | 53 | function var trigger(var value) | ||
84 | 54 | property string text | 48 | property string text |
85 | 55 | Ubuntu.Components.ActionList 1.0 0.1: QtObject | 49 | Ubuntu.Components.ActionList 1.0 0.1: QtObject |
86 | 56 | readonly property Action actions | 50 | readonly property Action actions |
87 | @@ -82,6 +76,8 @@ | |||
88 | 82 | property bool onScreen | 76 | property bool onScreen |
89 | 83 | property bool running | 77 | property bool running |
90 | 84 | Ubuntu.Components.AdaptivePageLayout 1.3: PageTreeNode | 78 | Ubuntu.Components.AdaptivePageLayout 1.3: PageTreeNode |
91 | 79 | readonly property int columns | ||
92 | 80 | readonly property PageColumnsLayout layouts | ||
93 | 85 | function var addPageToCurrentColumn(var sourcePage, var page, var properties) | 81 | function var addPageToCurrentColumn(var sourcePage, var page, var properties) |
94 | 86 | function var addPageToNextColumn(var sourcePage, var page, var properties) | 82 | function var addPageToNextColumn(var sourcePage, var page, var properties) |
95 | 87 | function var removePages(var page) | 83 | function var removePages(var page) |
96 | @@ -92,6 +88,7 @@ | |||
97 | 92 | property bool enabled | 88 | property bool enabled |
98 | 93 | readonly property int error | 89 | readonly property int error |
99 | 94 | property string message | 90 | property string message |
100 | 91 | signal statusChanged(Operation operation) | ||
101 | 95 | function save() | 92 | function save() |
102 | 96 | function cancel() | 93 | function cancel() |
103 | 97 | function reset() | 94 | function reset() |
104 | @@ -305,6 +302,9 @@ | |||
105 | 305 | Ubuntu.Components.ListItems.Divider 1.0 0.1: QQuickImageBase | 302 | Ubuntu.Components.ListItems.Divider 1.0 0.1: QQuickImageBase |
106 | 306 | property FillMode fillMode | 303 | property FillMode fillMode |
107 | 307 | property HAlignment horizontalAlignment | 304 | property HAlignment horizontalAlignment |
108 | 305 | signal horizontalAlignmentChanged(HAlignment alignment) | ||
109 | 306 | signal verticalAlignmentChanged(VAlignment alignment) | ||
110 | 307 | signal mipmapChanged(bool ) | ||
111 | 308 | property bool mipmap | 308 | property bool mipmap |
112 | 309 | readonly property double paintedHeight | 309 | readonly property double paintedHeight |
113 | 310 | readonly property double paintedWidth | 310 | readonly property double paintedWidth |
114 | @@ -312,6 +312,9 @@ | |||
115 | 312 | Ubuntu.Components.ListItems.Divider 1.3: QQuickImageBase | 312 | Ubuntu.Components.ListItems.Divider 1.3: QQuickImageBase |
116 | 313 | property FillMode fillMode | 313 | property FillMode fillMode |
117 | 314 | property HAlignment horizontalAlignment | 314 | property HAlignment horizontalAlignment |
118 | 315 | signal horizontalAlignmentChanged(HAlignment alignment) | ||
119 | 316 | signal verticalAlignmentChanged(VAlignment alignment) | ||
120 | 317 | signal mipmapChanged(bool ) | ||
121 | 315 | property bool mipmap | 318 | property bool mipmap |
122 | 316 | readonly property double paintedHeight | 319 | readonly property double paintedHeight |
123 | 317 | readonly property double paintedWidth | 320 | readonly property double paintedWidth |
124 | @@ -361,10 +364,11 @@ | |||
125 | 361 | Ubuntu.Components.FilterBehavior 1.1: QtObject | 364 | Ubuntu.Components.FilterBehavior 1.1: QtObject |
126 | 362 | property QRegExp pattern | 365 | property QRegExp pattern |
127 | 363 | property string property | 366 | property string property |
130 | 364 | Ubuntu.Components.Haptics 1.0 0.1: Object singleton | 367 | Ubuntu.Components.Haptics 1.0 0.1: QtObject singleton |
131 | 365 | readonly property HapticsEffect effect | 368 | readonly property QtObject effect |
132 | 366 | readonly property bool enabled | 369 | readonly property bool enabled |
134 | 367 | function var play(var customEffect) | 370 | function play(var customEffect) |
135 | 371 | function play() | ||
136 | 368 | Ubuntu.Components.ListItems.Header 1.0 0.1: Item | 372 | Ubuntu.Components.ListItems.Header 1.0 0.1: Item |
137 | 369 | property string text | 373 | property string text |
138 | 370 | Ubuntu.Components.Header 1.0 0.1: AppHeader | 374 | Ubuntu.Components.Header 1.0 0.1: AppHeader |
139 | @@ -385,22 +389,6 @@ | |||
140 | 385 | property bool useDeprecatedToolbar | 389 | property bool useDeprecatedToolbar |
141 | 386 | Ubuntu.Components.ListItems.Header 1.3: Item | 390 | Ubuntu.Components.ListItems.Header 1.3: Item |
142 | 387 | property string text | 391 | property string text |
143 | 388 | Ubuntu.Components.Header 1.3: AppHeader | ||
144 | 389 | property string _for_autopilot | ||
145 | 390 | property var actions | ||
146 | 391 | property bool animate | ||
147 | 392 | property QtObject config | ||
148 | 393 | property Item contents | ||
149 | 394 | property color dividerColor | ||
150 | 395 | property Flickable flickable | ||
151 | 396 | function var show() | ||
152 | 397 | function var hide() | ||
153 | 398 | readonly property bool moving | ||
154 | 399 | property var pageStack | ||
155 | 400 | property color panelColor | ||
156 | 401 | property var tabsModel | ||
157 | 402 | property string title | ||
158 | 403 | property bool useDeprecatedToolbar | ||
159 | 404 | Ubuntu.Components.Icon 1.0 0.1: Item | 392 | Ubuntu.Components.Icon 1.0 0.1: Item |
160 | 405 | property color color | 393 | property color color |
161 | 406 | property color keyColor | 394 | property color keyColor |
162 | @@ -466,6 +454,7 @@ | |||
163 | 466 | property bool selected | 454 | property bool selected |
164 | 467 | property ListItemActions trailingActions | 455 | property ListItemActions trailingActions |
165 | 468 | Ubuntu.Components.ListItem 1.3: ListItem | 456 | Ubuntu.Components.ListItem 1.3: ListItem |
166 | 457 | readonly property UCListItemExpansion expansion | ||
167 | 469 | Ubuntu.Components.ListItemActions 1.2: QtObject | 458 | Ubuntu.Components.ListItemActions 1.2: QtObject |
168 | 470 | readonly property Action actions | 459 | readonly property Action actions |
169 | 471 | default readonly property QtObject data | 460 | default readonly property QtObject data |
170 | @@ -485,6 +474,7 @@ | |||
171 | 485 | readonly property bool animatePanels | 474 | readonly property bool animatePanels |
172 | 486 | property Item dragPanel | 475 | property Item dragPanel |
173 | 487 | property PropertyAnimation dropAnimation | 476 | property PropertyAnimation dropAnimation |
174 | 477 | readonly property Flickable flickable 1.3 | ||
175 | 488 | readonly property int listItemIndex 1.3 | 478 | readonly property int listItemIndex 1.3 |
176 | 489 | function swipeEvent(SwipeEvent event) | 479 | function swipeEvent(SwipeEvent event) |
177 | 490 | function rebound() | 480 | function rebound() |
178 | @@ -528,6 +518,7 @@ | |||
179 | 528 | signal clicked(QQuickMouseEvent mouse, Item host) | 518 | signal clicked(QQuickMouseEvent mouse, Item host) |
180 | 529 | signal pressAndHold(QQuickMouseEvent mouse, Item host) | 519 | signal pressAndHold(QQuickMouseEvent mouse, Item host) |
181 | 530 | signal doubleClicked(QQuickMouseEvent mouse, Item host) | 520 | signal doubleClicked(QQuickMouseEvent mouse, Item host) |
182 | 521 | signal positionChanged(QQuickMouseEvent mouse, Item host) | ||
183 | 531 | signal entered(QQuickMouseEvent event, Item host) | 522 | signal entered(QQuickMouseEvent event, Item host) |
184 | 532 | signal exited(QQuickMouseEvent event, Item host) | 523 | signal exited(QQuickMouseEvent event, Item host) |
185 | 533 | property Priority priority | 524 | property Priority priority |
186 | @@ -603,6 +594,14 @@ | |||
187 | 603 | property Flickable flickable | 594 | property Flickable flickable |
188 | 604 | readonly property PageHeadConfiguration head | 595 | readonly property PageHeadConfiguration head |
189 | 605 | property string title | 596 | property string title |
190 | 597 | Ubuntu.Components.PageColumn 1.3: QtObject | ||
191 | 598 | property bool fillWidth | ||
192 | 599 | property double maximumWidth | ||
193 | 600 | property double minimumWidth | ||
194 | 601 | property double preferredWidth | ||
195 | 602 | Ubuntu.Components.PageColumnsLayout 1.3: QtObject | ||
196 | 603 | default readonly property PageColumn data | ||
197 | 604 | property bool when | ||
198 | 606 | Ubuntu.Components.PageHeadConfiguration 1.1: Object | 605 | Ubuntu.Components.PageHeadConfiguration 1.1: Object |
199 | 607 | readonly property Action actions | 606 | readonly property Action actions |
200 | 608 | property Action backAction | 607 | property Action backAction |
201 | @@ -1222,14 +1221,16 @@ | |||
202 | 1222 | property string iconName | 1221 | property string iconName |
203 | 1223 | property url iconSource | 1222 | property url iconSource |
204 | 1224 | signal triggered(var value) | 1223 | signal triggered(var value) |
206 | 1225 | function var trigger(var value) | 1224 | function trigger(var value) |
207 | 1225 | function trigger() | ||
208 | 1226 | property string text | 1226 | property string text |
209 | 1227 | Ubuntu.Components.ToolbarButton 1.3: StyledItem | 1227 | Ubuntu.Components.ToolbarButton 1.3: StyledItem |
210 | 1228 | property Action action | 1228 | property Action action |
211 | 1229 | property string iconName | 1229 | property string iconName |
212 | 1230 | property url iconSource | 1230 | property url iconSource |
213 | 1231 | signal triggered(var value) | 1231 | signal triggered(var value) |
215 | 1232 | function var trigger(var value) | 1232 | function trigger(var value) |
216 | 1233 | function trigger() | ||
217 | 1233 | property string text | 1234 | property string text |
218 | 1234 | Ubuntu.Components.ToolbarItems 1.0 0.1: Item | 1235 | Ubuntu.Components.ToolbarItems 1.0 0.1: Item |
219 | 1235 | property Item back | 1236 | property Item back |
220 | @@ -1246,6 +1247,9 @@ | |||
221 | 1246 | UCListItemDivider: Item | 1247 | UCListItemDivider: Item |
222 | 1247 | property color colorFrom | 1248 | property color colorFrom |
223 | 1248 | property color colorTo | 1249 | property color colorTo |
224 | 1250 | UCListItemExpansion: QtObject | ||
225 | 1251 | property bool expanded | ||
226 | 1252 | property double height | ||
227 | 1249 | UCStateSaverAttached: QtObject | 1253 | UCStateSaverAttached: QtObject |
228 | 1250 | property bool enabled | 1254 | property bool enabled |
229 | 1251 | property string properties | 1255 | property string properties |
230 | @@ -1393,6 +1397,14 @@ | |||
231 | 1393 | signal dragUpdated(ListItemDrag event) | 1397 | signal dragUpdated(ListItemDrag event) |
232 | 1394 | property bool selectMode | 1398 | property bool selectMode |
233 | 1395 | property QList<int> selectedIndices | 1399 | property QList<int> selectedIndices |
234 | 1400 | Ubuntu.Components.ViewItems 1.3: ViewItems | ||
235 | 1401 | property QList<int> expandedIndices | ||
236 | 1402 | property int expansionFlags | ||
237 | 1403 | signal expandedIndicesChanged(QList<int> indices) | ||
238 | 1404 | Ubuntu.Components.ViewItems.ExpansionFlag: Enum | ||
239 | 1405 | CollapseOnOutsidePress | ||
240 | 1406 | Exclusive | ||
241 | 1407 | UnlockExpanded | ||
242 | 1396 | Ubuntu.Components.i18n 1.0 0.1: QtObject | 1408 | Ubuntu.Components.i18n 1.0 0.1: QtObject |
243 | 1397 | property string domain | 1409 | property string domain |
244 | 1398 | property string language | 1410 | property string language |
245 | @@ -1405,3 +1417,4 @@ | |||
246 | 1405 | function string dctr(string domain, string context, string text) | 1417 | function string dctr(string domain, string context, string text) |
247 | 1406 | function string tag(string text) | 1418 | function string tag(string text) |
248 | 1407 | function string tag(string context, string text) | 1419 | function string tag(string context, string text) |
249 | 1420 | function string relativeDateTime(QDateTime datetime) | ||
250 | 1408 | 1421 | ||
251 | === modified file 'debian/changelog' | |||
252 | --- debian/changelog 2015-08-24 20:49:45 +0000 | |||
253 | +++ debian/changelog 2015-09-08 04:09:38 +0000 | |||
254 | @@ -1,3 +1,61 @@ | |||
255 | 1 | ubuntu-ui-toolkit (1.3.1627+15.10.20150904-0ubuntu1) UNRELEASED; urgency=medium | ||
256 | 2 | |||
257 | 3 | [ Zsombor Egri ] | ||
258 | 4 | * Implement list item expansion. | ||
259 | 5 | * Turn AdaptivePageLayout page creation to be asynchronous. | ||
260 | 6 | * Fix ListItem swipe handling when gesture is initiated over an overlay | ||
261 | 7 | MouseArea which does not accept pressed event. Fixes LP: #1484545 | ||
262 | 8 | * AbstractButton to C++. Fixes LP: #1365471, LP: #1458028 | ||
263 | 9 | * Haptics singleton moved to C++. | ||
264 | 10 | * ActionItem moved to C++. | ||
265 | 11 | * Making columns resizable in an AdaptivePageLayout. | ||
266 | 12 | * Introducing column configuration into AdaptivePageLayout. | ||
267 | 13 | |||
268 | 14 | [ Benjamin Zeller ] | ||
269 | 15 | * Fix build inside qt and shadowbuild. | ||
270 | 16 | |||
271 | 17 | [ Tim Peeters ] | ||
272 | 18 | * Remove old and unused header-related files, and update unit test filenames. | ||
273 | 19 | * Don't unset the subheader style when Page.head changes because that unsets | ||
274 | 20 | the parent of Page.head.contents. Fixes LP: #1488922 | ||
275 | 21 | * Fix the theming of the MainView. | ||
276 | 22 | * Fix the background color of the overflow panel. | ||
277 | 23 | |||
278 | 24 | [ Christian Dywan ] | ||
279 | 25 | * Include change signals with arguments in .api. | ||
280 | 26 | * A public QML type with no version is an error. Rather than silently breaking | ||
281 | 27 | as QML does normally at least apicheck can make this fatal. | ||
282 | 28 | * UbuntuShape shouldn't emit redundant deprecation warnings. Fixes LP: #1481791 | ||
283 | 29 | * Update .bzrignore to new upstream style layout. Fixes LP: #1433308 | ||
284 | 30 | * Revert unnecessary change of Popover minimumWidth. Fixes LP: #1483708 | ||
285 | 31 | |||
286 | 32 | [ Ken VanDine ] | ||
287 | 33 | * Fixed a few typos in the api docs for StateSaver. | ||
288 | 34 | |||
289 | 35 | [ Olivier Tilloy ] | ||
290 | 36 | * Take custom key indexes into account to allow sorting on custom roles. | ||
291 | 37 | Fixes LP: #1485674 | ||
292 | 38 | |||
293 | 39 | [ Albert Astals Cid ] | ||
294 | 40 | * Properly free shapeTextures[index] The old code assumes that the UbuntuShape | ||
295 | 41 | will still be around when the opengl context is destroyed, but that seldom | ||
296 | 42 | happens so connect the signal to a lambda that will be there and does the | ||
297 | 43 | cleanup properly. Without this patch testDirectionalDragArea from unity8 was | ||
298 | 44 | hitting the qFatal because it ran out of space in shapeTextures. | ||
299 | 45 | |||
300 | 46 | [ Richard Huddie ] | ||
301 | 47 | * Remove all usage of the autopilot simulated keyboard when the OSK is being | ||
302 | 48 | used. Fixes LP: 31483668 | ||
303 | 49 | |||
304 | 50 | [ Gerry Boland ] | ||
305 | 51 | * Compensate for Qt's device pixel ratio multiplier. | ||
306 | 52 | Fixes: LP: #1207270, LP: #1275748, LP: #1468402 | ||
307 | 53 | |||
308 | 54 | [ Nick Dedekind ] | ||
309 | 55 | * Added relative date time i18n. | ||
310 | 56 | |||
311 | 57 | -- Zoltán Balogh <zoltan@bakter.hu> Fri, 04 Sep 2015 19:25:03 +0300 | ||
312 | 58 | |||
313 | 1 | ubuntu-ui-toolkit (1.3.1603+15.10.20150824.1-0ubuntu1) wily; urgency=medium | 59 | ubuntu-ui-toolkit (1.3.1603+15.10.20150824.1-0ubuntu1) wily; urgency=medium |
314 | 2 | 60 | ||
315 | 3 | [ CI Train Bot ] | 61 | [ CI Train Bot ] |
316 | 4 | 62 | ||
317 | === modified file 'debian/control' | |||
318 | --- debian/control 2015-07-10 05:40:21 +0000 | |||
319 | +++ debian/control 2015-09-08 04:09:38 +0000 | |||
320 | @@ -45,6 +45,11 @@ | |||
321 | 45 | suru-icon-theme, | 45 | suru-icon-theme, |
322 | 46 | uuid-runtime, | 46 | uuid-runtime, |
323 | 47 | python3-sphinx, | 47 | python3-sphinx, |
324 | 48 | libfontconfig1-dev, | ||
325 | 49 | libfreetype6-dev, | ||
326 | 50 | libmtdev-dev, | ||
327 | 51 | libudev-dev, | ||
328 | 52 | libxrender-dev | ||
329 | 48 | Standards-Version: 3.9.4 | 53 | Standards-Version: 3.9.4 |
330 | 49 | Homepage: https://launchpad.net/ubuntu-ui-toolkit | 54 | Homepage: https://launchpad.net/ubuntu-ui-toolkit |
331 | 50 | # If you aren't a member of ~ubuntu-sdk-team but need to upload packaging | 55 | # If you aren't a member of ~ubuntu-sdk-team but need to upload packaging |
332 | 51 | 56 | ||
333 | === modified file 'documentation/documentation.pro' | |||
334 | --- documentation/documentation.pro 2015-06-02 15:47:45 +0000 | |||
335 | +++ documentation/documentation.pro 2015-09-08 04:09:38 +0000 | |||
336 | @@ -17,7 +17,7 @@ | |||
337 | 17 | generate_docs.commands = cd $$ROOT_SOURCE_DIR; SRC=$$ROOT_SOURCE_DIR/documentation BLD=$$ROOT_BUILD_DIR/documentation $$ROOT_SOURCE_DIR/documentation/docs.sh \'$$QDOC\' \'$$QHELPGENERATOR\' $$DOC_PATH | 17 | generate_docs.commands = cd $$ROOT_SOURCE_DIR; SRC=$$ROOT_SOURCE_DIR/documentation BLD=$$ROOT_BUILD_DIR/documentation $$ROOT_SOURCE_DIR/documentation/docs.sh \'$$QDOC\' \'$$QHELPGENERATOR\' $$DOC_PATH |
338 | 18 | 18 | ||
339 | 19 | #install the online docs only when building outside of Qt | 19 | #install the online docs only when building outside of Qt |
341 | 20 | force_independent: { | 20 | !build_with_qt{ |
342 | 21 | install_docs.files = $$shadowed($$ROOT_SOURCE_DIR)/documentation/html | 21 | install_docs.files = $$shadowed($$ROOT_SOURCE_DIR)/documentation/html |
343 | 22 | install_docs.path = /usr/share/ubuntu-ui-toolkit/doc | 22 | install_docs.path = /usr/share/ubuntu-ui-toolkit/doc |
344 | 23 | install_docs.CONFIG += no_check_exist directory no_build | 23 | install_docs.CONFIG += no_check_exist directory no_build |
345 | 24 | 24 | ||
346 | === modified file 'documentation/ubuntu-ui-toolkit-common.qdocconf' | |||
347 | --- documentation/ubuntu-ui-toolkit-common.qdocconf 2015-07-24 18:00:54 +0000 | |||
348 | +++ documentation/ubuntu-ui-toolkit-common.qdocconf 2015-09-08 04:09:38 +0000 | |||
349 | @@ -26,7 +26,7 @@ | |||
350 | 26 | sources.fileextensions = "*.qml *.qdoc *.cpp *.js" | 26 | sources.fileextensions = "*.qml *.qdoc *.cpp *.js" |
351 | 27 | headers.fileextensions = "*.h" | 27 | headers.fileextensions = "*.h" |
352 | 28 | # exclude qml files that have the component documented in a separate qdoc file | 28 | # exclude qml files that have the component documented in a separate qdoc file |
354 | 29 | excludefiles = $BLD/../src/Ubuntu/Components/MainView.qml | 29 | excludefiles += $BLD/../src/Ubuntu/Components/1.3/PageWrapperUtils.js |
355 | 30 | outputdir = $BLD/html | 30 | outputdir = $BLD/html |
356 | 31 | outputformats = HTML | 31 | outputformats = HTML |
357 | 32 | version = 1.2 | 32 | version = 1.2 |
358 | 33 | 33 | ||
359 | === modified file 'examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.qml' | |||
360 | --- examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.qml 2015-08-07 13:48:39 +0000 | |||
361 | +++ examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.qml 2015-09-08 04:09:38 +0000 | |||
362 | @@ -37,6 +37,28 @@ | |||
363 | 37 | anchors.fill: parent | 37 | anchors.fill: parent |
364 | 38 | primaryPage: mainPage | 38 | primaryPage: mainPage |
365 | 39 | 39 | ||
366 | 40 | layouts: [ | ||
367 | 41 | PageColumnsLayout { | ||
368 | 42 | when: layout.width > units.gu(80) | ||
369 | 43 | PageColumn { | ||
370 | 44 | minimumWidth: units.gu(30) | ||
371 | 45 | maximumWidth: units.gu(50) | ||
372 | 46 | preferredWidth: units.gu(40) | ||
373 | 47 | } | ||
374 | 48 | PageColumn { | ||
375 | 49 | fillWidth: true | ||
376 | 50 | } | ||
377 | 51 | }, | ||
378 | 52 | // configure single column mode so we can only size it to minimum 20 GU | ||
379 | 53 | PageColumnsLayout { | ||
380 | 54 | when: true | ||
381 | 55 | PageColumn { | ||
382 | 56 | minimumWidth: units.gu(20) | ||
383 | 57 | fillWidth: true | ||
384 | 58 | } | ||
385 | 59 | } | ||
386 | 60 | ] | ||
387 | 61 | |||
388 | 40 | Page { | 62 | Page { |
389 | 41 | id: mainPage | 63 | id: mainPage |
390 | 42 | title: "Ubuntu UI Toolkit" | 64 | title: "Ubuntu UI Toolkit" |
391 | @@ -74,9 +96,8 @@ | |||
392 | 74 | selected: index === widgetList.currentIndex | 96 | selected: index === widgetList.currentIndex |
393 | 75 | onClicked: { | 97 | onClicked: { |
394 | 76 | var source = Qt.resolvedUrl(model.source); | 98 | var source = Qt.resolvedUrl(model.source); |
396 | 77 | var newPage = layout.addPageToNextColumn(mainPage, source); | 99 | layout.addPageToNextColumn(mainPage, source, {title: model.label}); |
397 | 78 | 100 | ||
398 | 79 | newPage.title = model.label; | ||
399 | 80 | widgetList.currentIndex = index; | 101 | widgetList.currentIndex = index; |
400 | 81 | } | 102 | } |
401 | 82 | } | 103 | } |
402 | 83 | 104 | ||
403 | === modified file 'features/ubuntu_enable_testing.prf' | |||
404 | --- features/ubuntu_enable_testing.prf 2015-05-19 07:55:27 +0000 | |||
405 | +++ features/ubuntu_enable_testing.prf 2015-09-08 04:09:38 +0000 | |||
406 | @@ -1,6 +1,6 @@ | |||
407 | 1 | instbase = $$ROOT_BUILD_DIR/qml | 1 | instbase = $$ROOT_BUILD_DIR/qml |
408 | 2 | 2 | ||
410 | 3 | force_independent: { | 3 | !build_with_qt { |
411 | 4 | # These bizarre rules copy the files to the build directory | 4 | # These bizarre rules copy the files to the build directory |
412 | 5 | 5 | ||
413 | 6 | defineReplace(qmlModStripSrcDir) { | 6 | defineReplace(qmlModStripSrcDir) { |
414 | 7 | 7 | ||
415 | === modified file 'features/ubuntu_qml_plugin.prf' | |||
416 | --- features/ubuntu_qml_plugin.prf 2015-07-30 13:47:23 +0000 | |||
417 | +++ features/ubuntu_qml_plugin.prf 2015-09-08 04:09:38 +0000 | |||
418 | @@ -1,64 +1,65 @@ | |||
419 | 1 | load(qml_plugin) | 1 | load(qml_plugin) |
420 | 2 | CONFIG -= hide_symbols | 2 | CONFIG -= hide_symbols |
421 | 3 | 3 | ||
422 | 4 | |||
423 | 5 | load(ubuntu_enable_testing) | 4 | load(ubuntu_enable_testing) |
424 | 6 | 5 | ||
425 | 7 | #hacky hacks to build the qmltypes | 6 | #hacky hacks to build the qmltypes |
426 | 8 | 7 | ||
476 | 9 | #should be already set by the qml_plugin.prf, but lets be safe | 8 | !build_with_qt{ |
477 | 10 | isEmpty(IMPORT_VERSION): error("Must set IMPORT_VERSION") | 9 | #should be already set by the qml_plugin.prf, but lets be safe |
478 | 11 | 10 | isEmpty(IMPORT_VERSION): error("Must set IMPORT_VERSION") | |
479 | 12 | load(resolve_target) | 11 | |
480 | 13 | 12 | load(resolve_target) | |
481 | 14 | qml1_target { | 13 | |
482 | 15 | qmlplugindump = qml1plugindump | 14 | qml1_target { |
483 | 16 | importpath.name = QML_IMPORT_PATH | 15 | qmlplugindump = qml1plugindump |
484 | 17 | } else { | 16 | importpath.name = QML_IMPORT_PATH |
485 | 18 | qmlplugindump = qmlplugindump | 17 | } else { |
486 | 19 | importpath.name = QML2_IMPORT_PATH | 18 | qmlplugindump = qmlplugindump |
487 | 20 | } | 19 | importpath.name = QML2_IMPORT_PATH |
488 | 21 | 20 | } | |
489 | 22 | qtPrepareTool(QMLPLUGINDUMP, $$qmlplugindump) | 21 | |
490 | 23 | importpath.value = | 22 | qtPrepareTool(QMLPLUGINDUMP, $$qmlplugindump) |
491 | 24 | for(qmod, QTREPOS) { | 23 | importpath.value = |
492 | 25 | qml1_target: \ | 24 | for(qmod, QTREPOS) { |
493 | 26 | qmod = $$qmod/imports | 25 | qml1_target: \ |
494 | 27 | else: \ | 26 | qmod = $$qmod/imports |
495 | 28 | qmod = $$qmod/qml | 27 | else: \ |
496 | 29 | exists($$qmod): importpath.value += $$shell_path($$qmod) | 28 | qmod = $$qmod/qml |
497 | 30 | } | 29 | exists($$qmod): importpath.value += $$shell_path($$qmod) |
498 | 31 | 30 | } | |
499 | 32 | #add our path, somehow its not added automatically | 31 | |
500 | 33 | importpath.value += $$shell_path($$instbase) | 32 | #add our path, somehow its not added automatically |
501 | 34 | importpath.value = $$unique(importpath.value) | 33 | importpath.value += $$shell_path($$instbase) |
502 | 35 | 34 | importpath.value = $$unique(importpath.value) | |
503 | 36 | membackend.name = ALARM_BACKEND | 35 | |
504 | 37 | membackend.value = memory | 36 | membackend.name = ALARM_BACKEND |
505 | 38 | 37 | membackend.value = memory | |
506 | 39 | qtAddToolEnv(QMLPLUGINDUMP, importpath) | 38 | |
507 | 40 | qtAddToolEnv(QMLPLUGINDUMP, membackend) | 39 | qtAddToolEnv(QMLPLUGINDUMP, importpath) |
508 | 41 | 40 | qtAddToolEnv(QMLPLUGINDUMP, membackend) | |
509 | 42 | TARGETPATHBASE = $$replace(TARGETPATH, \\.\\d+\$, ) | 41 | |
510 | 43 | 42 | TARGETPATHBASE = $$replace(TARGETPATH, \\.\\d+\$, ) | |
511 | 44 | QMLTYPEFILE = $$instbase/$$TARGETPATH/plugins.qmltypes | 43 | |
512 | 45 | autobld_qmltypes.target = $$QMLTYPEFILE | 44 | QMLTYPEFILE = $$instbase/$$TARGETPATH/plugins.qmltypes |
513 | 46 | autobld_qmltypes.commands = $$QMLPLUGINDUMP -nonrelocatable $$replace(TARGETPATHBASE, /, .) $$IMPORT_VERSION > $$QMLTYPEFILE | 45 | autobld_qmltypes.target = $$QMLTYPEFILE |
514 | 47 | autobld_qmltypes.commands += && sed -i \'s?-1.-1\"?0.1\"?\' $$QMLTYPEFILE | 46 | autobld_qmltypes.commands = $$QMLPLUGINDUMP -nonrelocatable $$replace(TARGETPATHBASE, /, .) $$IMPORT_VERSION > $$QMLTYPEFILE |
515 | 48 | autobld_qmltypes.commands += && sed -i \'s?exportMetaObjectRevisions: \\[-1\\]?exportMetaObjectRevisions: [0,0]?\' $$QMLTYPEFILE | 47 | autobld_qmltypes.commands += && sed -i \'s?-1.-1\"?0.1\"?\' $$QMLTYPEFILE |
516 | 49 | autobld_qmltypes.depends = $$QMAKE_RESOLVED_TARGET | 48 | autobld_qmltypes.commands += && sed -i \'s?exportMetaObjectRevisions: \\[-1\\]?exportMetaObjectRevisions: [0,0]?\' $$QMLTYPEFILE |
517 | 50 | 49 | autobld_qmltypes.depends = $$QMAKE_RESOLVED_TARGET | |
518 | 51 | autobld_install_qmltypes.files = $$QMLTYPEFILE | 50 | |
519 | 52 | autobld_install_qmltypes.depends = $$QMLTYPEFILE | 51 | autobld_install_qmltypes.files = $$QMLTYPEFILE |
520 | 53 | autobld_install_qmltypes.path = $$[QT_INSTALL_QML]/$$TARGETPATH | 52 | autobld_install_qmltypes.depends = $$QMLTYPEFILE |
521 | 54 | autobld_install_qmltypes.CONFIG += no_check_exist | 53 | autobld_install_qmltypes.path = $$[QT_INSTALL_QML]/$$TARGETPATH |
522 | 55 | 54 | autobld_install_qmltypes.CONFIG += no_check_exist | |
523 | 56 | INSTALLS+=autobld_install_qmltypes | 55 | |
524 | 57 | QMAKE_EXTRA_TARGETS += autobld_qmltypes | 56 | INSTALLS+=autobld_install_qmltypes |
525 | 57 | QMAKE_EXTRA_TARGETS += autobld_qmltypes | ||
526 | 58 | } | ||
527 | 58 | 59 | ||
528 | 59 | # when building against the system Qt we pick up the CXX_FLAGS for a release build | 60 | # when building against the system Qt we pick up the CXX_FLAGS for a release build |
529 | 60 | # reset them to the default debug build flags | 61 | # reset them to the default debug build flags |
531 | 61 | force_independent: { | 62 | !build_with_qt: { |
532 | 62 | CONFIG(debug, debug|release) { | 63 | CONFIG(debug, debug|release) { |
533 | 63 | QMAKE_CFLAGS = $$QMAKE_CFLAGS_DEBUG | 64 | QMAKE_CFLAGS = $$QMAKE_CFLAGS_DEBUG |
534 | 64 | QMAKE_CXXFLAGS = $$QMAKE_CXXFLAGS_DEBUG | 65 | QMAKE_CXXFLAGS = $$QMAKE_CXXFLAGS_DEBUG |
535 | 65 | 66 | ||
536 | === modified file 'po/po.pro' | |||
537 | --- po/po.pro 2014-12-02 09:00:30 +0000 | |||
538 | +++ po/po.pro 2015-09-08 04:09:38 +0000 | |||
539 | @@ -30,7 +30,7 @@ | |||
540 | 30 | mo_file = $$replace(po_file,.po,.mo) | 30 | mo_file = $$replace(po_file,.po,.mo) |
541 | 31 | system(msgfmt $$po_file -o $$mo_file) | 31 | system(msgfmt $$po_file -o $$mo_file) |
542 | 32 | mo_name = $$replace(mo_file,.mo,) | 32 | mo_name = $$replace(mo_file,.mo,) |
544 | 33 | mo_targetpath = $(INSTALL_ROOT)/usr/share/locale/$${mo_name}/LC_MESSAGES | 33 | mo_targetpath = $(INSTALL_ROOT)$$[QT_INSTALL_PREFIX]/share/locale/$${mo_name}/LC_MESSAGES |
545 | 34 | mo_target = $${mo_targetpath}/ubuntu-ui-toolkit.mo | 34 | mo_target = $${mo_targetpath}/ubuntu-ui-toolkit.mo |
546 | 35 | !isEmpty(install_mo_commands): install_mo_commands += && | 35 | !isEmpty(install_mo_commands): install_mo_commands += && |
547 | 36 | install_mo_commands += test -d $$mo_targetpath || mkdir -p $$mo_targetpath | 36 | install_mo_commands += test -d $$mo_targetpath || mkdir -p $$mo_targetpath |
548 | 37 | 37 | ||
549 | === modified file 'src/Ubuntu/Components/1.1/Haptics.qml' | |||
550 | --- src/Ubuntu/Components/1.1/Haptics.qml 2015-07-24 09:54:03 +0000 | |||
551 | +++ src/Ubuntu/Components/1.1/Haptics.qml 2015-09-08 04:09:38 +0000 | |||
552 | @@ -14,105 +14,14 @@ | |||
553 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
554 | 15 | */ | 15 | */ |
555 | 16 | 16 | ||
556 | 17 | pragma Singleton | ||
557 | 18 | import QtQuick 2.4 | 17 | import QtQuick 2.4 |
558 | 19 | import QtFeedback 5.0 | 18 | import QtFeedback 5.0 |
559 | 20 | import Ubuntu.Components 1.1 | 19 | import Ubuntu.Components 1.1 |
560 | 21 | 20 | ||
561 | 22 | /*! | ||
562 | 23 | \qmltype Haptics | ||
563 | 24 | \inqmlmodule Ubuntu.Components 1.1 | ||
564 | 25 | \ingroup ubuntu-services | ||
565 | 26 | \brief Singleton defining the haptics feedback used in components, where execution | ||
566 | 27 | of the feedback is controlled by the system settings. | ||
567 | 28 | |||
568 | 29 | Supports global feedback as well as custom feedback. Global feedback can be | ||
569 | 30 | configured through its properties, and \l play function will play the default | ||
570 | 31 | configuration, or a custom one if parameter is given. | ||
571 | 32 | |||
572 | 33 | Example of using Haptics: | ||
573 | 34 | \qml | ||
574 | 35 | import QtQuick 2.4 | ||
575 | 36 | import Ubuntu.Components 1.2 | ||
576 | 37 | |||
577 | 38 | Item { | ||
578 | 39 | implicitWidth: units.gu(20) | ||
579 | 40 | implicitHeight: units.gu(5) | ||
580 | 41 | |||
581 | 42 | Label { | ||
582 | 43 | text: "Press me" | ||
583 | 44 | anchors.fill: parent | ||
584 | 45 | horizontalAlignment: Text.AlignHCenter | ||
585 | 46 | verticalAlignment: Text.AlignVCenter | ||
586 | 47 | } | ||
587 | 48 | MouseArea { | ||
588 | 49 | anchors.fill: parent | ||
589 | 50 | onClicked: Haptics.play() | ||
590 | 51 | } | ||
591 | 52 | } | ||
592 | 53 | \endqml | ||
593 | 54 | |||
594 | 55 | Custom effects can be played as follows: | ||
595 | 56 | \qml | ||
596 | 57 | import QtQuick 2.4 | ||
597 | 58 | import Ubuntu.Components 1.2 | ||
598 | 59 | |||
599 | 60 | Item { | ||
600 | 61 | implicitWidth: units.gu(20) | ||
601 | 62 | implicitHeight: units.gu(5) | ||
602 | 63 | |||
603 | 64 | Label { | ||
604 | 65 | text: "Press me" | ||
605 | 66 | anchors.fill: parent | ||
606 | 67 | horizontalAlignment: Text.AlignHCenter | ||
607 | 68 | verticalAlignment: Text.AlignVCenter | ||
608 | 69 | } | ||
609 | 70 | MouseArea { | ||
610 | 71 | anchors.fill: parent | ||
611 | 72 | onClicked: Haptics.play({duration: 25, attackIntensity: 0.7}) | ||
612 | 73 | } | ||
613 | 74 | } | ||
614 | 75 | \endqml | ||
615 | 76 | |||
616 | 77 | \note Though the \l effect property exposes \c start, \c stop and \c pause | ||
617 | 78 | functions, use those only if you want to have feedback independent on what the | ||
618 | 79 | system setting is. | ||
619 | 80 | */ | ||
620 | 81 | Object { | 21 | Object { |
621 | 82 | |||
622 | 83 | /*! | ||
623 | 84 | \qmlproperty bool enabled | ||
624 | 85 | \readonly | ||
625 | 86 | The property specifies whether the haptics feedback is enabled or not by the system. | ||
626 | 87 | */ | ||
627 | 88 | readonly property alias enabled: vibra.otherVibrate | 22 | readonly property alias enabled: vibra.otherVibrate |
628 | 89 | |||
629 | 90 | /*! | ||
630 | 91 | \qmlproperty HapticsEffect effect | ||
631 | 92 | The property defines the settings of the haptics effect used by the component. | ||
632 | 93 | The default setting is a haptics effect with a duration of 10 milliseconds | ||
633 | 94 | with an intensity of 1.0, having fading time of 50 millisecods and fading | ||
634 | 95 | intensity 0.0, and attack time of 50 milliseconds and with an intensity of | ||
635 | 96 | 0.0. | ||
636 | 97 | */ | ||
637 | 98 | property alias effect: effect | 23 | property alias effect: effect |
638 | 99 | 24 | ||
639 | 100 | /*! | ||
640 | 101 | \qmlmethod play([customEffect]) | ||
641 | 102 | The function plays the feedback with the configuration specified in \l effect | ||
642 | 103 | if no parameter is given. Custom effect can be played by specifying the effect | ||
643 | 104 | properties in a JSON object in \c customEffect. | ||
644 | 105 | |||
645 | 106 | The function will exit unconditionaly if playing the effects is blocked by | ||
646 | 107 | system settings. | ||
647 | 108 | |||
648 | 109 | The function will not stop any ongoing haptics effect played, if that one | ||
649 | 110 | was a default haptics effect. In case of custom effects, the previous effect | ||
650 | 111 | will be stopped, and settings will be restored before the new haptics will | ||
651 | 112 | be played. The custom settings properties (the ones which are required to | ||
652 | 113 | be different from the ones defined in the \l effect) must be specified in | ||
653 | 114 | the parameter in a JSON object. | ||
654 | 115 | */ | ||
655 | 116 | function play(customEffect) { | 25 | function play(customEffect) { |
656 | 117 | if (!vibra.otherVibrate) { | 26 | if (!vibra.otherVibrate) { |
657 | 118 | return; | 27 | return; |
658 | 119 | 28 | ||
659 | === removed file 'src/Ubuntu/Components/1.2/ActionItem.qml' | |||
660 | --- src/Ubuntu/Components/1.2/ActionItem.qml 2015-04-30 08:32:44 +0000 | |||
661 | +++ src/Ubuntu/Components/1.2/ActionItem.qml 1970-01-01 00:00:00 +0000 | |||
662 | @@ -1,96 +0,0 @@ | |||
663 | 1 | /* | ||
664 | 2 | * Copyright 2012 Canonical Ltd. | ||
665 | 3 | * | ||
666 | 4 | * This program is free software; you can redistribute it and/or modify | ||
667 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
668 | 6 | * the Free Software Foundation; version 3. | ||
669 | 7 | * | ||
670 | 8 | * This program is distributed in the hope that it will be useful, | ||
671 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
672 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
673 | 11 | * GNU Lesser General Public License for more details. | ||
674 | 12 | * | ||
675 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
676 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
677 | 15 | */ | ||
678 | 16 | |||
679 | 17 | import QtQuick 2.4 | ||
680 | 18 | import Ubuntu.Components 1.2 | ||
681 | 19 | |||
682 | 20 | /*! | ||
683 | 21 | \qmlabstract ActionItem | ||
684 | 22 | \inqmlmodule Ubuntu.Components 1.1 | ||
685 | 23 | \ingroup ubuntu | ||
686 | 24 | \brief A visual representation of an Action. The API of ActionItem is a | ||
687 | 25 | copy of the API of \l Action, with additional properties to define | ||
688 | 26 | visual aspects of the ActionItem. | ||
689 | 27 | |||
690 | 28 | If \l action is set, the values of the other properties will by default | ||
691 | 29 | be identical to the \l Action's property values. Setting the other properties | ||
692 | 30 | will override the properties copied from the \l Action. | ||
693 | 31 | |||
694 | 32 | See \l ToolbarItems for examples of how to use \l ToolbarButton or other ActionItems | ||
695 | 33 | in a toolbar. | ||
696 | 34 | */ | ||
697 | 35 | StyledItem { | ||
698 | 36 | id: actionItem | ||
699 | 37 | |||
700 | 38 | /*! | ||
701 | 39 | The \l Action associated with this ActionItem. If action is set, | ||
702 | 40 | the values of the Action properties are copied to the values of | ||
703 | 41 | the ActionItem properties. | ||
704 | 42 | */ | ||
705 | 43 | property Action action: null | ||
706 | 44 | |||
707 | 45 | visible: action ? action.visible : true | ||
708 | 46 | enabled: action ? action.enabled : true | ||
709 | 47 | |||
710 | 48 | /*! | ||
711 | 49 | The title of the actionItem. | ||
712 | 50 | Default value: action.text | ||
713 | 51 | */ | ||
714 | 52 | property string text: action ? action.text : "" | ||
715 | 53 | |||
716 | 54 | /*! | ||
717 | 55 | The image associated with the actionItem. | ||
718 | 56 | Default value: action.iconSource. | ||
719 | 57 | |||
720 | 58 | This is the URL of any image file | ||
721 | 59 | If both iconSource and iconName are defined, iconName will be ignored. | ||
722 | 60 | */ | ||
723 | 61 | property url iconSource: action ? action.iconSource : (iconName ? "image://theme/" + iconName : "") | ||
724 | 62 | |||
725 | 63 | /*! | ||
726 | 64 | The icon associated with the actionItem in the suru icon theme. | ||
727 | 65 | Default value: action.iconName. | ||
728 | 66 | |||
729 | 67 | \note The complete list of icons available in Ubuntu is not published yet. | ||
730 | 68 | For now please refer to the folders where the icon themes are installed: | ||
731 | 69 | \list | ||
732 | 70 | \li Ubuntu Touch: \l file:/usr/share/icons/suru | ||
733 | 71 | \li Ubuntu Desktop: \l file:/usr/share/icons/ubuntu-mono-dark | ||
734 | 72 | \endlist | ||
735 | 73 | These 2 separate icon themes will be merged soon. | ||
736 | 74 | |||
737 | 75 | If both iconSource and iconName are defined, iconName will be ignored. | ||
738 | 76 | */ | ||
739 | 77 | property string iconName: action ? action.iconName : "" | ||
740 | 78 | |||
741 | 79 | /*! | ||
742 | 80 | Called when the actionItem is triggered. | ||
743 | 81 | */ | ||
744 | 82 | signal triggered(var value) | ||
745 | 83 | |||
746 | 84 | /*! | ||
747 | 85 | If \l action is set, this will trigger it. | ||
748 | 86 | */ | ||
749 | 87 | onTriggered: if (action) action.trigger(value) | ||
750 | 88 | |||
751 | 89 | /*! | ||
752 | 90 | Trigger this action item if it is enabled. | ||
753 | 91 | */ | ||
754 | 92 | function trigger(value) { | ||
755 | 93 | var passingValue = value ? value : null | ||
756 | 94 | if (actionItem.enabled) actionItem.triggered(passingValue); | ||
757 | 95 | } | ||
758 | 96 | } | ||
759 | 97 | 0 | ||
760 | === modified file 'src/Ubuntu/Components/1.2/TextField.qml' | |||
761 | --- src/Ubuntu/Components/1.2/TextField.qml 2015-05-01 19:38:57 +0000 | |||
762 | +++ src/Ubuntu/Components/1.2/TextField.qml 2015-09-08 04:09:38 +0000 | |||
763 | @@ -99,7 +99,7 @@ | |||
764 | 99 | \note During text selection all interactive parent Flickables are turned off. | 99 | \note During text selection all interactive parent Flickables are turned off. |
765 | 100 | */ | 100 | */ |
766 | 101 | 101 | ||
768 | 102 | ActionItem { | 102 | Ubuntu.ActionItem { |
769 | 103 | id: control | 103 | id: control |
770 | 104 | 104 | ||
771 | 105 | implicitWidth: units.gu(25) | 105 | implicitWidth: units.gu(25) |
772 | 106 | 106 | ||
773 | === modified file 'src/Ubuntu/Components/1.2/TextInputPopover.qml' | |||
774 | --- src/Ubuntu/Components/1.2/TextInputPopover.qml 2015-07-02 23:33:22 +0000 | |||
775 | +++ src/Ubuntu/Components/1.2/TextInputPopover.qml 2015-09-08 04:09:38 +0000 | |||
776 | @@ -88,6 +88,7 @@ | |||
777 | 88 | action.text so we can get the proper button by text, action being not | 88 | action.text so we can get the proper button by text, action being not |
778 | 89 | accessible. https://bugs.launchpad.net/autopilot/+bug/1334599 | 89 | accessible. https://bugs.launchpad.net/autopilot/+bug/1334599 |
779 | 90 | */ | 90 | */ |
780 | 91 | // FIXME: AbstractButton has text property, which is getting the action.text, so no need to override! | ||
781 | 91 | property string text: action.text | 92 | property string text: action.text |
782 | 92 | width: Math.max(units.gu(5), implicitWidth) + units.gu(2) | 93 | width: Math.max(units.gu(5), implicitWidth) + units.gu(2) |
783 | 93 | height: units.gu(6) | 94 | height: units.gu(6) |
784 | 94 | 95 | ||
785 | === modified file 'src/Ubuntu/Components/1.2/ToolbarButton.qml' | |||
786 | --- src/Ubuntu/Components/1.2/ToolbarButton.qml 2015-04-30 08:32:44 +0000 | |||
787 | +++ src/Ubuntu/Components/1.2/ToolbarButton.qml 2015-09-08 04:09:38 +0000 | |||
788 | @@ -15,6 +15,7 @@ | |||
789 | 15 | */ | 15 | */ |
790 | 16 | 16 | ||
791 | 17 | import QtQuick 2.4 | 17 | import QtQuick 2.4 |
792 | 18 | import Ubuntu.Components 1.2 | ||
793 | 18 | 19 | ||
794 | 19 | /*! | 20 | /*! |
795 | 20 | \qmltype ToolbarButton | 21 | \qmltype ToolbarButton |
796 | 21 | 22 | ||
797 | === removed file 'src/Ubuntu/Components/1.3/AbstractButton.qml' | |||
798 | --- src/Ubuntu/Components/1.3/AbstractButton.qml 2015-04-25 08:54:58 +0000 | |||
799 | +++ src/Ubuntu/Components/1.3/AbstractButton.qml 1970-01-01 00:00:00 +0000 | |||
800 | @@ -1,109 +0,0 @@ | |||
801 | 1 | /* | ||
802 | 2 | * Copyright 2012 Canonical Ltd. | ||
803 | 3 | * | ||
804 | 4 | * This program is free software; you can redistribute it and/or modify | ||
805 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
806 | 6 | * the Free Software Foundation; version 3. | ||
807 | 7 | * | ||
808 | 8 | * This program is distributed in the hope that it will be useful, | ||
809 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
810 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
811 | 11 | * GNU Lesser General Public License for more details. | ||
812 | 12 | * | ||
813 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
814 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
815 | 15 | */ | ||
816 | 16 | |||
817 | 17 | import QtQuick 2.4 | ||
818 | 18 | import Ubuntu.Components 1.3 | ||
819 | 19 | |||
820 | 20 | /*! | ||
821 | 21 | \qmlabstract AbstractButton | ||
822 | 22 | \inqmlmodule Ubuntu.Components 1.1 | ||
823 | 23 | \ingroup ubuntu | ||
824 | 24 | \brief The AbstractButton class defines the behavior of the button. | ||
825 | 25 | |||
826 | 26 | This class defines the behavior of the button: it defines the MouseArea | ||
827 | 27 | and the states. | ||
828 | 28 | All components deriving from this class support haptic feedback out of the box. | ||
829 | 29 | */ | ||
830 | 30 | ActionItem { | ||
831 | 31 | id: button | ||
832 | 32 | |||
833 | 33 | /*! | ||
834 | 34 | If an action is specified, the button's clicked signal will trigger the action. | ||
835 | 35 | Subclasses of AbstractButton can use other properties of action (for example | ||
836 | 36 | the text and iconName). | ||
837 | 37 | \qmlproperty Action action | ||
838 | 38 | */ | ||
839 | 39 | |||
840 | 40 | /*! | ||
841 | 41 | This handler is called when there is a mouse click on the button | ||
842 | 42 | and the button is not disabled. If \b action is defined, | ||
843 | 43 | the action will be triggered. | ||
844 | 44 | */ | ||
845 | 45 | signal clicked() | ||
846 | 46 | |||
847 | 47 | /*! | ||
848 | 48 | If a button is clicked, its triggered() signal will automatically be called. | ||
849 | 49 | */ | ||
850 | 50 | onClicked: button.trigger() | ||
851 | 51 | |||
852 | 52 | Keys.onEnterPressed: clicked() | ||
853 | 53 | Keys.onReturnPressed: clicked() | ||
854 | 54 | |||
855 | 55 | /*! | ||
856 | 56 | This handler is called when there is a long press. | ||
857 | 57 | */ | ||
858 | 58 | signal pressAndHold() | ||
859 | 59 | |||
860 | 60 | /*! | ||
861 | 61 | True if the user presses a mouse button in the button's mouse area. | ||
862 | 62 | */ | ||
863 | 63 | property bool pressed: mouseArea.pressed | ||
864 | 64 | |||
865 | 65 | /*! | ||
866 | 66 | True if the mouse cursor hovers over the button's mouse area. | ||
867 | 67 | */ | ||
868 | 68 | property bool hovered: __acceptEvents && mouseArea.containsMouse | ||
869 | 69 | |||
870 | 70 | /*! | ||
871 | 71 | \internal | ||
872 | 72 | Disable or enable signal emition by default. | ||
873 | 73 | Some classes want to emit the signal by themselves (ListItem.Standard) | ||
874 | 74 | */ | ||
875 | 75 | property bool __acceptEvents: true | ||
876 | 76 | |||
877 | 77 | /*! | ||
878 | 78 | \internal | ||
879 | 79 | To get the properties of the mouse area in subclasses. | ||
880 | 80 | */ | ||
881 | 81 | property alias __mouseArea: mouseArea | ||
882 | 82 | |||
883 | 83 | activeFocusOnPress: true | ||
884 | 84 | |||
885 | 85 | MouseArea { | ||
886 | 86 | id: mouseArea | ||
887 | 87 | anchors.fill: parent | ||
888 | 88 | // if mouseArea is given a new value, disable defaultMouseArea | ||
889 | 89 | // as it might occlude the newly assigned mouse area. | ||
890 | 90 | hoverEnabled: true | ||
891 | 91 | |||
892 | 92 | // invoke Haptics singleton earlier than we press the button, | ||
893 | 93 | // so we give some time for the singleton to sync settings with the service | ||
894 | 94 | property bool hapticsEnabled: Haptics.enabled | ||
895 | 95 | |||
896 | 96 | onClicked: { | ||
897 | 97 | if (button.__acceptEvents) { | ||
898 | 98 | // FIXME (Vivid) call this in the style rather than from AbstractButton | ||
899 | 99 | Haptics.play(); | ||
900 | 100 | button.clicked() | ||
901 | 101 | } | ||
902 | 102 | } | ||
903 | 103 | onPressAndHold: { | ||
904 | 104 | if (button.__acceptEvents) { | ||
905 | 105 | button.pressAndHold() | ||
906 | 106 | } | ||
907 | 107 | } | ||
908 | 108 | } | ||
909 | 109 | } | ||
910 | 110 | 0 | ||
911 | === removed file 'src/Ubuntu/Components/1.3/ActionItem.qml' | |||
912 | --- src/Ubuntu/Components/1.3/ActionItem.qml 2015-04-25 08:54:58 +0000 | |||
913 | +++ src/Ubuntu/Components/1.3/ActionItem.qml 1970-01-01 00:00:00 +0000 | |||
914 | @@ -1,96 +0,0 @@ | |||
915 | 1 | /* | ||
916 | 2 | * Copyright 2012 Canonical Ltd. | ||
917 | 3 | * | ||
918 | 4 | * This program is free software; you can redistribute it and/or modify | ||
919 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
920 | 6 | * the Free Software Foundation; version 3. | ||
921 | 7 | * | ||
922 | 8 | * This program is distributed in the hope that it will be useful, | ||
923 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
924 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
925 | 11 | * GNU Lesser General Public License for more details. | ||
926 | 12 | * | ||
927 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
928 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
929 | 15 | */ | ||
930 | 16 | |||
931 | 17 | import QtQuick 2.4 | ||
932 | 18 | import Ubuntu.Components 1.3 | ||
933 | 19 | |||
934 | 20 | /*! | ||
935 | 21 | \qmlabstract ActionItem | ||
936 | 22 | \inqmlmodule Ubuntu.Components 1.1 | ||
937 | 23 | \ingroup ubuntu | ||
938 | 24 | \brief A visual representation of an Action. The API of ActionItem is a | ||
939 | 25 | copy of the API of \l Action, with additional properties to define | ||
940 | 26 | visual aspects of the ActionItem. | ||
941 | 27 | |||
942 | 28 | If \l action is set, the values of the other properties will by default | ||
943 | 29 | be identical to the \l Action's property values. Setting the other properties | ||
944 | 30 | will override the properties copied from the \l Action. | ||
945 | 31 | |||
946 | 32 | See \l ToolbarItems for examples of how to use \l ToolbarButton or other ActionItems | ||
947 | 33 | in a toolbar. | ||
948 | 34 | */ | ||
949 | 35 | StyledItem { | ||
950 | 36 | id: actionItem | ||
951 | 37 | |||
952 | 38 | /*! | ||
953 | 39 | The \l Action associated with this ActionItem. If action is set, | ||
954 | 40 | the values of the Action properties are copied to the values of | ||
955 | 41 | the ActionItem properties. | ||
956 | 42 | */ | ||
957 | 43 | property Action action: null | ||
958 | 44 | |||
959 | 45 | visible: action ? action.visible : true | ||
960 | 46 | enabled: action ? action.enabled : true | ||
961 | 47 | |||
962 | 48 | /*! | ||
963 | 49 | The title of the actionItem. | ||
964 | 50 | Default value: action.text | ||
965 | 51 | */ | ||
966 | 52 | property string text: action ? action.text : "" | ||
967 | 53 | |||
968 | 54 | /*! | ||
969 | 55 | The image associated with the actionItem. | ||
970 | 56 | Default value: action.iconSource. | ||
971 | 57 | |||
972 | 58 | This is the URL of any image file | ||
973 | 59 | If both iconSource and iconName are defined, iconName will be ignored. | ||
974 | 60 | */ | ||
975 | 61 | property url iconSource: action ? action.iconSource : (iconName ? "image://theme/" + iconName : "") | ||
976 | 62 | |||
977 | 63 | /*! | ||
978 | 64 | The icon associated with the actionItem in the suru icon theme. | ||
979 | 65 | Default value: action.iconName. | ||
980 | 66 | |||
981 | 67 | \note The complete list of icons available in Ubuntu is not published yet. | ||
982 | 68 | For now please refer to the folders where the icon themes are installed: | ||
983 | 69 | \list | ||
984 | 70 | \li Ubuntu Touch: \l file:/usr/share/icons/suru | ||
985 | 71 | \li Ubuntu Desktop: \l file:/usr/share/icons/ubuntu-mono-dark | ||
986 | 72 | \endlist | ||
987 | 73 | These 2 separate icon themes will be merged soon. | ||
988 | 74 | |||
989 | 75 | If both iconSource and iconName are defined, iconName will be ignored. | ||
990 | 76 | */ | ||
991 | 77 | property string iconName: action ? action.iconName : "" | ||
992 | 78 | |||
993 | 79 | /*! | ||
994 | 80 | Called when the actionItem is triggered. | ||
995 | 81 | */ | ||
996 | 82 | signal triggered(var value) | ||
997 | 83 | |||
998 | 84 | /*! | ||
999 | 85 | If \l action is set, this will trigger it. | ||
1000 | 86 | */ | ||
1001 | 87 | onTriggered: if (action) action.trigger(value) | ||
1002 | 88 | |||
1003 | 89 | /*! | ||
1004 | 90 | Trigger this action item if it is enabled. | ||
1005 | 91 | */ | ||
1006 | 92 | function trigger(value) { | ||
1007 | 93 | var passingValue = value ? value : null | ||
1008 | 94 | if (actionItem.enabled) actionItem.triggered(passingValue); | ||
1009 | 95 | } | ||
1010 | 96 | } | ||
1011 | 97 | 0 | ||
1012 | === modified file 'src/Ubuntu/Components/1.3/AdaptivePageLayout.qml' | |||
1013 | --- src/Ubuntu/Components/1.3/AdaptivePageLayout.qml 2015-07-28 15:04:07 +0000 | |||
1014 | +++ src/Ubuntu/Components/1.3/AdaptivePageLayout.qml 2015-09-08 04:09:38 +0000 | |||
1015 | @@ -83,10 +83,85 @@ | |||
1016 | 83 | } | 83 | } |
1017 | 84 | \endqml | 84 | \endqml |
1018 | 85 | 85 | ||
1019 | 86 | \note Observe the use of the \c Page::pageStack property in the example above. | ||
1020 | 87 | The same property is used to share the AdaptivePageLayout instance the Page is | ||
1021 | 88 | used in, therefore the same page can be used in a PageStack or in an AdaptivePageLayout. | ||
1022 | 89 | However implementations must make sure the desired PageStack or AdaptivePageLayout | ||
1023 | 90 | function exists in the instance before using it. | ||
1024 | 91 | |||
1025 | 86 | AdaptivePageLayout supports adaptive column handling. When the number of columns changes at | 92 | AdaptivePageLayout supports adaptive column handling. When the number of columns changes at |
1026 | 87 | runtime the pages are automatically rearranged. | 93 | runtime the pages are automatically rearranged. |
1027 | 88 | 94 | ||
1029 | 89 | \sa PageStack | 95 | By default the component splits the layout in two columns when the width of the |
1030 | 96 | layout exceeds 80 grid units. The first column is sized to 40 grid unit width and | ||
1031 | 97 | the second one to fill the rest of the remaining space. When the 80 grid unit breakpoint | ||
1032 | 98 | is reached, the component will switch from one column to two, and vice versa. | ||
1033 | 99 | These defaults can be overridden through the \l layouts property by defining the | ||
1034 | 100 | possible layouts, their column sizing and the breakpoints when the layouts should | ||
1035 | 101 | be activated. PageColumn configurations must appear in the same order (from left | ||
1036 | 102 | to right) as the columns appear in the layout. If none of the layouts condition | ||
1037 | 103 | is met, a one column layout will be used. | ||
1038 | 104 | |||
1039 | 105 | \qml | ||
1040 | 106 | import QtQuick 2.4 | ||
1041 | 107 | import Ubuntu.Components 1.3 | ||
1042 | 108 | |||
1043 | 109 | MainView { | ||
1044 | 110 | width: units.gu(100) | ||
1045 | 111 | height: units.gu(60) | ||
1046 | 112 | |||
1047 | 113 | AdaptivePageLayout { | ||
1048 | 114 | anchors.fill: parent | ||
1049 | 115 | primaryPage: page1 | ||
1050 | 116 | layouts: PageColumnsLayout { | ||
1051 | 117 | when: width > units.gu(80) | ||
1052 | 118 | // column #0 | ||
1053 | 119 | PageColumn { | ||
1054 | 120 | minimumWidth: units.gu(30) | ||
1055 | 121 | maximumWidth: units.gu(60) | ||
1056 | 122 | preferredWidth: units.gu(40) | ||
1057 | 123 | } | ||
1058 | 124 | // column #1 | ||
1059 | 125 | PageColumn { | ||
1060 | 126 | fillWidth: true | ||
1061 | 127 | } | ||
1062 | 128 | } | ||
1063 | 129 | |||
1064 | 130 | Page { | ||
1065 | 131 | id: page1 | ||
1066 | 132 | title: "Main page" | ||
1067 | 133 | Column { | ||
1068 | 134 | Button { | ||
1069 | 135 | text: "Add Page2 above " + page1.title | ||
1070 | 136 | onClicked: page1.pageStack.addPageToCurrentColumn(page1, page2) | ||
1071 | 137 | } | ||
1072 | 138 | Button { | ||
1073 | 139 | text: "Add Page3 next to " + page1.title | ||
1074 | 140 | onClicked: page1.pageStack.addPageToNextColumn(page1, page3) | ||
1075 | 141 | } | ||
1076 | 142 | } | ||
1077 | 143 | } | ||
1078 | 144 | Page { | ||
1079 | 145 | id: page2 | ||
1080 | 146 | title: "Page #2" | ||
1081 | 147 | } | ||
1082 | 148 | Page { | ||
1083 | 149 | id: page3 | ||
1084 | 150 | title: "Page #3" | ||
1085 | 151 | } | ||
1086 | 152 | } | ||
1087 | 153 | } | ||
1088 | 154 | \endqml | ||
1089 | 155 | |||
1090 | 156 | A column is considered to be resizable if the \l PageColumn::minimumWidth and | ||
1091 | 157 | \l PageColumn::maximumWidth configuration differs. This implies that if a column | ||
1092 | 158 | is not meant to be resized, it should have \l PageColumn::minimumWidth and | ||
1093 | 159 | \l PageColumn::maximumWidth set to the same value. In the example above, the | ||
1094 | 160 | first column can be resized to a minimum of 30, and a maximum of 60 grid units, | ||
1095 | 161 | and the preferred width is set to 40 grid units. This width is set every time | ||
1096 | 162 | the layout is activated. | ||
1097 | 163 | |||
1098 | 164 | \sa PageStack, PageColumnsLayout, PageColumn | ||
1099 | 90 | */ | 165 | */ |
1100 | 91 | 166 | ||
1101 | 92 | PageTreeNode { | 167 | PageTreeNode { |
1102 | @@ -113,12 +188,86 @@ | |||
1103 | 113 | property Page primaryPage | 188 | property Page primaryPage |
1104 | 114 | 189 | ||
1105 | 115 | /*! | 190 | /*! |
1107 | 116 | \qmlmethod Item addPageToCurrentColumn(Item sourcePage, var page[, var properties]) | 191 | \qmlproperty int columns |
1108 | 192 | \readonly | ||
1109 | 193 | The property holds the number of columns shown in the layout. | ||
1110 | 194 | */ | ||
1111 | 195 | readonly property alias columns: d.columns | ||
1112 | 196 | |||
1113 | 197 | /*! | ||
1114 | 198 | The property holds the different layout configurations overriding the default | ||
1115 | 199 | configurations. Defaults to an empty list. | ||
1116 | 200 | \sa PageColumnsLayout | ||
1117 | 201 | */ | ||
1118 | 202 | property list<PageColumnsLayout> layouts | ||
1119 | 203 | |||
1120 | 204 | /*! | ||
1121 | 205 | \qmlmethod object addPageToCurrentColumn(Item sourcePage, var page[, var properties]) | ||
1122 | 117 | Adds a \c page to the column the \c sourcePage resides in and removes all pages | 206 | Adds a \c page to the column the \c sourcePage resides in and removes all pages |
1123 | 118 | from the higher columns. \c page can be a Component or a file. | 207 | from the higher columns. \c page can be a Component or a file. |
1127 | 119 | \c properties is a JSON object containing properties | 208 | \c properties is a JSON object containing properties to be set when page |
1128 | 120 | to be set when page is created. \c sourcePage must be active. Returns the | 209 | is created. \c sourcePage must be active. |
1129 | 121 | instance of the page created. | 210 | |
1130 | 211 | The function creates the new page asynchronously if the new \c page to be | ||
1131 | 212 | added is a Component or a QML document. In this case the function returns | ||
1132 | 213 | an incubator which can be used to track the page creation.For more about | ||
1133 | 214 | incubation in QML and creating components asynchronously, see | ||
1134 | 215 | \l {http://doc.qt.io/qt-5/qml-qtqml-component.html#incubateObject-method} | ||
1135 | 216 | {Component.incubateObject()}. | ||
1136 | 217 | The following example removes an element from the list model whenever the | ||
1137 | 218 | page opened in the second column is closed. Note, the example must be run | ||
1138 | 219 | on desktop or on a device with at least 90 grid units screen width. | ||
1139 | 220 | \qml | ||
1140 | 221 | import QtQuick 2.4 | ||
1141 | 222 | import Ubuntu.Components 1.3 | ||
1142 | 223 | |||
1143 | 224 | MainView { | ||
1144 | 225 | width: units.gu(90) | ||
1145 | 226 | height: units.gu(70) | ||
1146 | 227 | |||
1147 | 228 | Component { | ||
1148 | 229 | id: page2Component | ||
1149 | 230 | Page { | ||
1150 | 231 | title: "Second Page" | ||
1151 | 232 | Button { | ||
1152 | 233 | text: "Close me" | ||
1153 | 234 | onClicked: pageStack.removePages(pageStack.primaryPage); | ||
1154 | 235 | } | ||
1155 | 236 | } | ||
1156 | 237 | } | ||
1157 | 238 | |||
1158 | 239 | AdaptivePageLayout { | ||
1159 | 240 | id: pageLayout | ||
1160 | 241 | anchors.fill: parent | ||
1161 | 242 | primaryPage: Page { | ||
1162 | 243 | title: "Primary Page" | ||
1163 | 244 | ListView { | ||
1164 | 245 | id: listView | ||
1165 | 246 | anchors.fill: parent | ||
1166 | 247 | model: 10 | ||
1167 | 248 | delegate: ListItem { | ||
1168 | 249 | Label { text: modelData } | ||
1169 | 250 | onClicked: { | ||
1170 | 251 | var incubator = pageLayout.addPageToNextColumn(pageLayout.primaryPage, page2Component); | ||
1171 | 252 | if (incubator && incubator.status == Component.Loading) { | ||
1172 | 253 | incubator.onStatusChanged = function(status) { | ||
1173 | 254 | if (status == Component.Ready) { | ||
1174 | 255 | // connect page's destruction to decrement model | ||
1175 | 256 | incubator.object.Component.destruction.connect(function() { | ||
1176 | 257 | listView.model--; | ||
1177 | 258 | }); | ||
1178 | 259 | } | ||
1179 | 260 | } | ||
1180 | 261 | } | ||
1181 | 262 | } | ||
1182 | 263 | } | ||
1183 | 264 | } | ||
1184 | 265 | } | ||
1185 | 266 | } | ||
1186 | 267 | } | ||
1187 | 268 | \endqml | ||
1188 | 269 | |||
1189 | 270 | \sa {http://doc.qt.io/qt-5/qml-qtqml-component.html#incubateObject-method}{Component.incubateObject} | ||
1190 | 122 | */ | 271 | */ |
1191 | 123 | function addPageToCurrentColumn(sourcePage, page, properties) { | 272 | function addPageToCurrentColumn(sourcePage, page, properties) { |
1192 | 124 | var nextColumn = d.columnForPage(sourcePage) + 1; | 273 | var nextColumn = d.columnForPage(sourcePage) + 1; |
1193 | @@ -138,6 +287,7 @@ | |||
1194 | 138 | holds \c sourcePage) and all following columns, and then add \c page to the next column. | 287 | holds \c sourcePage) and all following columns, and then add \c page to the next column. |
1195 | 139 | If \c sourcePage is located in the | 288 | If \c sourcePage is located in the |
1196 | 140 | rightmost column, the new page will be pushed to the same column as \c sourcePage. | 289 | rightmost column, the new page will be pushed to the same column as \c sourcePage. |
1197 | 290 | The return value is the same as in \l addPageToCurrentColumn case. | ||
1198 | 141 | */ | 291 | */ |
1199 | 142 | function addPageToNextColumn(sourcePage, page, properties) { | 292 | function addPageToNextColumn(sourcePage, page, properties) { |
1200 | 143 | var nextColumn = d.columnForPage(sourcePage) + 1; | 293 | var nextColumn = d.columnForPage(sourcePage) + 1; |
1201 | @@ -168,7 +318,12 @@ | |||
1202 | 168 | */ | 318 | */ |
1203 | 169 | 319 | ||
1204 | 170 | Component.onCompleted: { | 320 | Component.onCompleted: { |
1206 | 171 | d.relayout(); | 321 | // check layout configuration |
1207 | 322 | if (layouts.length > 0) { | ||
1208 | 323 | d.prepareLayouts(); | ||
1209 | 324 | } else { | ||
1210 | 325 | d.relayout(); | ||
1211 | 326 | } | ||
1212 | 172 | d.completed = true; | 327 | d.completed = true; |
1213 | 173 | if (primaryPage) { | 328 | if (primaryPage) { |
1214 | 174 | var wrapper = d.createWrapper(primaryPage); | 329 | var wrapper = d.createWrapper(primaryPage); |
1215 | @@ -183,6 +338,13 @@ | |||
1216 | 183 | return; | 338 | return; |
1217 | 184 | } | 339 | } |
1218 | 185 | } | 340 | } |
1219 | 341 | onLayoutsChanged: { | ||
1220 | 342 | if (d.completed) { | ||
1221 | 343 | // only deal with this if the layouts array changes after completion | ||
1222 | 344 | // to avoid unnecessary rendering | ||
1223 | 345 | d.prepareLayouts(); | ||
1224 | 346 | } | ||
1225 | 347 | } | ||
1226 | 186 | 348 | ||
1227 | 187 | QtObject { | 349 | QtObject { |
1228 | 188 | id: d | 350 | id: d |
1229 | @@ -190,7 +352,12 @@ | |||
1230 | 190 | property bool completed: false | 352 | property bool completed: false |
1231 | 191 | property var tree: new Tree.Tree() | 353 | property var tree: new Tree.Tree() |
1232 | 192 | 354 | ||
1234 | 193 | property int columns: layout.width >= units.gu(80) ? 2 : 1 | 355 | property int columns: !layout.layouts.length ? |
1235 | 356 | (layout.width >= units.gu(80) ? 2 : 1) : | ||
1236 | 357 | (activeLayout ? activeLayout.data.length : 1) | ||
1237 | 358 | property PageColumnsLayout activeLayout: null | ||
1238 | 359 | property list<PageColumnsLayout> prevLayouts | ||
1239 | 360 | |||
1240 | 194 | /*! internal */ | 361 | /*! internal */ |
1241 | 195 | onColumnsChanged: { | 362 | onColumnsChanged: { |
1242 | 196 | if (columns <= 0) { | 363 | if (columns <= 0) { |
1243 | @@ -201,11 +368,10 @@ | |||
1244 | 201 | } | 368 | } |
1245 | 202 | property real defaultColumnWidth: units.gu(40) | 369 | property real defaultColumnWidth: units.gu(40) |
1246 | 203 | onDefaultColumnWidthChanged: body.applyMetrics() | 370 | onDefaultColumnWidthChanged: body.applyMetrics() |
1247 | 204 | property list<ColumnMetrics> columnMetrics | ||
1248 | 205 | 371 | ||
1249 | 206 | function createWrapper(page, properties) { | 372 | function createWrapper(page, properties) { |
1250 | 207 | var wrapperComponent = Qt.createComponent("PageWrapper.qml"); | 373 | var wrapperComponent = Qt.createComponent("PageWrapper.qml"); |
1252 | 208 | var wrapperObject = wrapperComponent.createObject(hiddenPages); | 374 | var wrapperObject = wrapperComponent.createObject(hiddenPages, {synchronous: false}); |
1253 | 209 | wrapperObject.pageStack = layout; | 375 | wrapperObject.pageStack = layout; |
1254 | 210 | wrapperObject.properties = properties; | 376 | wrapperObject.properties = properties; |
1255 | 211 | // set reference last because it will trigger creation of the object | 377 | // set reference last because it will trigger creation of the object |
1256 | @@ -221,7 +387,14 @@ | |||
1257 | 221 | // replace page holder's child | 387 | // replace page holder's child |
1258 | 222 | var holder = body.children[targetColumn]; | 388 | var holder = body.children[targetColumn]; |
1259 | 223 | holder.detachCurrentPage(); | 389 | holder.detachCurrentPage(); |
1261 | 224 | holder.attachPage(pageWrapper) | 390 | if ((pageWrapper.incubator && pageWrapper.incubator.status == Component.Ready) || pageWrapper.object) { |
1262 | 391 | holder.attachPage(pageWrapper); | ||
1263 | 392 | } else { | ||
1264 | 393 | // asynchronous, connect to page load completion and attach when page is available | ||
1265 | 394 | pageWrapper.pageLoaded.connect(function () { | ||
1266 | 395 | holder.attachPage(pageWrapper); | ||
1267 | 396 | }); | ||
1268 | 397 | } | ||
1269 | 225 | } | 398 | } |
1270 | 226 | 399 | ||
1271 | 227 | function getWrapper(page) { | 400 | function getWrapper(page) { |
1272 | @@ -279,7 +452,7 @@ | |||
1273 | 279 | newWrapper.parentPage = sourcePage; | 452 | newWrapper.parentPage = sourcePage; |
1274 | 280 | newWrapper.column = column; | 453 | newWrapper.column = column; |
1275 | 281 | d.addWrappedPage(newWrapper); | 454 | d.addWrappedPage(newWrapper); |
1277 | 282 | return newWrapper.object; | 455 | return newWrapper.incubator; |
1278 | 283 | } | 456 | } |
1279 | 284 | 457 | ||
1280 | 285 | // update the page for the specified column | 458 | // update the page for the specified column |
1281 | @@ -301,6 +474,33 @@ | |||
1282 | 301 | } | 474 | } |
1283 | 302 | } | 475 | } |
1284 | 303 | 476 | ||
1285 | 477 | // prepares layout management, listens on layout condition changes and performs re-layouting | ||
1286 | 478 | function prepareLayouts() { | ||
1287 | 479 | // disconnect from the previous layouts | ||
1288 | 480 | for (var i = 0; i < prevLayouts.length; i++) { | ||
1289 | 481 | prevLayouts[i].whenChanged.disconnect(updateLayout); | ||
1290 | 482 | } | ||
1291 | 483 | prevLayouts = layouts; | ||
1292 | 484 | for (var i = 0; i < layouts.length; i++) { | ||
1293 | 485 | layouts[i].whenChanged.connect(updateLayout); | ||
1294 | 486 | } | ||
1295 | 487 | // first time evaluation | ||
1296 | 488 | updateLayout(); | ||
1297 | 489 | } | ||
1298 | 490 | |||
1299 | 491 | // function called when one of the layout condition is satisfied | ||
1300 | 492 | function updateLayout() { | ||
1301 | 493 | var newLayout = null; | ||
1302 | 494 | for (var i = 0; i < layouts.length; i++) { | ||
1303 | 495 | // get the first affirmative condition | ||
1304 | 496 | if (layouts[i].when) { | ||
1305 | 497 | newLayout = layouts[i]; | ||
1306 | 498 | break; | ||
1307 | 499 | } | ||
1308 | 500 | } | ||
1309 | 501 | d.activeLayout = newLayout; | ||
1310 | 502 | } | ||
1311 | 503 | |||
1312 | 304 | // relayouts when column count changes | 504 | // relayouts when column count changes |
1313 | 305 | function relayout() { | 505 | function relayout() { |
1314 | 306 | if (body.children.length == d.columns) return; | 506 | if (body.children.length == d.columns) return; |
1315 | @@ -357,8 +557,8 @@ | |||
1316 | 357 | // default metrics | 557 | // default metrics |
1317 | 358 | Component { | 558 | Component { |
1318 | 359 | id: defaultMetrics | 559 | id: defaultMetrics |
1321 | 360 | ColumnMetrics { | 560 | PageColumn { |
1322 | 361 | fillWidth: column == d.columns | 561 | fillWidth: __column == d.columns |
1323 | 362 | minimumWidth: d.defaultColumnWidth | 562 | minimumWidth: d.defaultColumnWidth |
1324 | 363 | } | 563 | } |
1325 | 364 | } | 564 | } |
1326 | @@ -376,13 +576,12 @@ | |||
1327 | 376 | property PageWrapper pageWrapper | 576 | property PageWrapper pageWrapper |
1328 | 377 | property int column | 577 | property int column |
1329 | 378 | property alias config: subHeader.config | 578 | property alias config: subHeader.config |
1331 | 379 | property ColumnMetrics metrics: setDefaultMetrics() | 579 | property PageColumn metrics: getDefaultMetrics() |
1332 | 580 | readonly property real dividerThickness: units.dp(1) | ||
1333 | 380 | 581 | ||
1334 | 381 | Layout.fillWidth: metrics.fillWidth | 582 | Layout.fillWidth: metrics.fillWidth |
1335 | 382 | Layout.fillHeight: true | 583 | Layout.fillHeight: true |
1339 | 383 | Layout.preferredWidth: metrics.maximumWidth > 0 ? | 584 | Layout.preferredWidth: MathUtils.clamp(metrics.preferredWidth, metrics.minimumWidth, metrics.maximumWidth) |
1337 | 384 | MathUtils.clamp(d.defaultColumnWidth, metrics.minimumWidth, metrics.maximumWidth) : | ||
1338 | 385 | d.defaultColumnWidth | ||
1340 | 386 | Layout.minimumWidth: metrics.minimumWidth | 585 | Layout.minimumWidth: metrics.minimumWidth |
1341 | 387 | Layout.maximumWidth: metrics.maximumWidth | 586 | Layout.maximumWidth: metrics.maximumWidth |
1342 | 388 | 587 | ||
1343 | @@ -396,7 +595,7 @@ | |||
1344 | 396 | bottom: parent.bottom | 595 | bottom: parent.bottom |
1345 | 397 | left: parent.left | 596 | left: parent.left |
1346 | 398 | right: parent.right | 597 | right: parent.right |
1348 | 399 | rightMargin: verticalDivider.width | 598 | rightMargin: dividerThickness |
1349 | 400 | } | 599 | } |
1350 | 401 | // we need to clip because the header does not have a background | 600 | // we need to clip because the header does not have a background |
1351 | 402 | clip: true | 601 | clip: true |
1352 | @@ -412,7 +611,7 @@ | |||
1353 | 412 | } | 611 | } |
1354 | 413 | height: body.headerHeight | 612 | height: body.headerHeight |
1355 | 414 | 613 | ||
1357 | 415 | styleName: config ? "PageHeadStyle" : "" | 614 | styleName: "PageHeadStyle" |
1358 | 416 | theme.version: Ubuntu.toolkitVersion | 615 | theme.version: Ubuntu.toolkitVersion |
1359 | 417 | objectName: "Header" + column | 616 | objectName: "Header" + column |
1360 | 418 | 617 | ||
1361 | @@ -457,9 +656,52 @@ | |||
1362 | 457 | top: parent.top | 656 | top: parent.top |
1363 | 458 | bottom: parent.bottom | 657 | bottom: parent.bottom |
1364 | 459 | right: parent.right | 658 | right: parent.right |
1365 | 659 | rightMargin: dividerThickness | ||
1366 | 460 | } | 660 | } |
1367 | 461 | width: (column == (d.columns - 1)) || !pageWrapper ? 0 : units.dp(1) | 661 | width: (column == (d.columns - 1)) || !pageWrapper ? 0 : units.dp(1) |
1369 | 462 | color: subHeader.dividerColor | 662 | color: theme.palette.selected.background |
1370 | 663 | MouseArea { | ||
1371 | 664 | id: resizerSensing | ||
1372 | 665 | objectName: "Divider" | ||
1373 | 666 | enabled: verticalDivider.width > 0 | ||
1374 | 667 | anchors { | ||
1375 | 668 | fill: parent | ||
1376 | 669 | leftMargin: enabled ? -units.gu(1) : 0 | ||
1377 | 670 | rightMargin: enabled ? -units.gu(1) : 0 | ||
1378 | 671 | } | ||
1379 | 672 | cursorShape: Qt.SizeHorCursor | ||
1380 | 673 | drag { | ||
1381 | 674 | axis: Drag.XAxis | ||
1382 | 675 | target: resizer | ||
1383 | 676 | smoothed: false | ||
1384 | 677 | minimumX: holder.Layout.minimumWidth | ||
1385 | 678 | maximumX: holder.Layout.maximumWidth | ||
1386 | 679 | } | ||
1387 | 680 | onPressed: resizer.x = holder.Layout.preferredWidth | ||
1388 | 681 | } | ||
1389 | 682 | states: State { | ||
1390 | 683 | name: "active" | ||
1391 | 684 | when: resizerSensing.pressed | ||
1392 | 685 | PropertyChanges { | ||
1393 | 686 | target: verticalDivider | ||
1394 | 687 | color: Qt.darker(theme.palette.normal.background, 1.5) | ||
1395 | 688 | } | ||
1396 | 689 | } | ||
1397 | 690 | transitions: Transition { | ||
1398 | 691 | from: "" | ||
1399 | 692 | to: "*" | ||
1400 | 693 | reversible: true | ||
1401 | 694 | ColorAnimation { | ||
1402 | 695 | target: verticalDivider | ||
1403 | 696 | property: "color" | ||
1404 | 697 | duration: UbuntuAnimation.SlowDuration | ||
1405 | 698 | } | ||
1406 | 699 | } | ||
1407 | 700 | } | ||
1408 | 701 | Item { | ||
1409 | 702 | id: resizer | ||
1410 | 703 | height: parent.height | ||
1411 | 704 | onXChanged: holder.Layout.preferredWidth = x | ||
1412 | 463 | } | 705 | } |
1413 | 464 | 706 | ||
1414 | 465 | function attachPage(page) { | 707 | function attachPage(page) { |
1415 | @@ -488,9 +730,9 @@ | |||
1416 | 488 | return wrapper; | 730 | return wrapper; |
1417 | 489 | } | 731 | } |
1418 | 490 | 732 | ||
1420 | 491 | function setDefaultMetrics() { | 733 | function getDefaultMetrics() { |
1421 | 492 | var result = defaultMetrics.createObject(holder); | 734 | var result = defaultMetrics.createObject(holder); |
1423 | 493 | result.column = Qt.binding(function() { return holder.column + 1; }); | 735 | result.__column = Qt.binding(function() { return holder.column + 1; }); |
1424 | 494 | return result; | 736 | return result; |
1425 | 495 | } | 737 | } |
1426 | 496 | } | 738 | } |
1427 | @@ -545,15 +787,9 @@ | |||
1428 | 545 | for (var i = 0; i < children.length; i++) { | 787 | for (var i = 0; i < children.length; i++) { |
1429 | 546 | var holder = children[i]; | 788 | var holder = children[i]; |
1430 | 547 | // search for the column metrics | 789 | // search for the column metrics |
1438 | 548 | var metrics = null; | 790 | var metrics = d.activeLayout ? d.activeLayout.data[i] : null; |
1432 | 549 | for (var j = 0; j < d.columnMetrics.length; j++) { | ||
1433 | 550 | if (d.columnMetrics[j].column == (i + 1)) { | ||
1434 | 551 | metrics = d.columnMetrics[j]; | ||
1435 | 552 | break; | ||
1436 | 553 | } | ||
1437 | 554 | } | ||
1439 | 555 | if (!metrics) { | 791 | if (!metrics) { |
1441 | 556 | metrics = holder.setDefaultMetrics(); | 792 | metrics = holder.getDefaultMetrics(); |
1442 | 557 | } | 793 | } |
1443 | 558 | holder.metrics = metrics; | 794 | holder.metrics = metrics; |
1444 | 559 | updateHeaderHeight(0); | 795 | updateHeaderHeight(0); |
1445 | 560 | 796 | ||
1446 | === modified file 'src/Ubuntu/Components/1.3/AppHeader.qml' | |||
1447 | --- src/Ubuntu/Components/1.3/AppHeader.qml 2015-08-03 15:02:42 +0000 | |||
1448 | +++ src/Ubuntu/Components/1.3/AppHeader.qml 2015-09-08 04:09:38 +0000 | |||
1449 | @@ -184,11 +184,6 @@ | |||
1450 | 184 | } | 184 | } |
1451 | 185 | 185 | ||
1452 | 186 | /*! | 186 | /*! |
1453 | 187 | Set by \l MainView | ||
1454 | 188 | */ | ||
1455 | 189 | property bool useDeprecatedToolbar: true | ||
1456 | 190 | |||
1457 | 191 | /*! | ||
1458 | 192 | Configuration of the header. | 187 | Configuration of the header. |
1459 | 193 | FIXME: Must be of type PageHeadConfiguration. Setting that as the property type | 188 | FIXME: Must be of type PageHeadConfiguration. Setting that as the property type |
1460 | 194 | however will use the latest version (1.3) and a Page that uses an older | 189 | however will use the latest version (1.3) and a Page that uses an older |
1461 | @@ -355,5 +350,5 @@ | |||
1462 | 355 | } | 350 | } |
1463 | 356 | 351 | ||
1464 | 357 | theme.version: Components.Ubuntu.toolkitVersion | 352 | theme.version: Components.Ubuntu.toolkitVersion |
1466 | 358 | styleName: header.useDeprecatedToolbar ? "HeaderStyle" : "PageHeadStyle" | 353 | styleName: "PageHeadStyle" |
1467 | 359 | } | 354 | } |
1468 | 360 | 355 | ||
1469 | === modified file 'src/Ubuntu/Components/1.3/Button.qml' | |||
1470 | --- src/Ubuntu/Components/1.3/Button.qml 2015-05-26 15:05:46 +0000 | |||
1471 | +++ src/Ubuntu/Components/1.3/Button.qml 2015-09-08 04:09:38 +0000 | |||
1472 | @@ -105,7 +105,7 @@ | |||
1473 | 105 | /*! | 105 | /*! |
1474 | 106 | The font used for the button's text. | 106 | The font used for the button's text. |
1475 | 107 | */ | 107 | */ |
1477 | 108 | property font font: __styleInstance ? __styleInstance.defaultFont : Qt.font({family: "Ubuntu", pixelSize: FontUtils.sizeToPixels("medium")}) | 108 | property font font: __styleInstance.defaultFont |
1478 | 109 | 109 | ||
1479 | 110 | /*! | 110 | /*! |
1480 | 111 | The position of the icon relative to the text. Options | 111 | The position of the icon relative to the text. Options |
1481 | 112 | 112 | ||
1482 | === modified file 'src/Ubuntu/Components/1.3/ComboButton.qml' | |||
1483 | --- src/Ubuntu/Components/1.3/ComboButton.qml 2015-05-21 10:50:35 +0000 | |||
1484 | +++ src/Ubuntu/Components/1.3/ComboButton.qml 2015-09-08 04:09:38 +0000 | |||
1485 | @@ -15,6 +15,7 @@ | |||
1486 | 15 | */ | 15 | */ |
1487 | 16 | 16 | ||
1488 | 17 | import QtQuick 2.4 | 17 | import QtQuick 2.4 |
1489 | 18 | import Ubuntu.Components 1.3 | ||
1490 | 18 | import Ubuntu.Components.Popups 1.3 | 19 | import Ubuntu.Components.Popups 1.3 |
1491 | 19 | 20 | ||
1492 | 20 | /*! | 21 | /*! |
1493 | 21 | 22 | ||
1494 | === removed file 'src/Ubuntu/Components/1.3/Header.qml' | |||
1495 | --- src/Ubuntu/Components/1.3/Header.qml 2015-04-25 08:54:58 +0000 | |||
1496 | +++ src/Ubuntu/Components/1.3/Header.qml 1970-01-01 00:00:00 +0000 | |||
1497 | @@ -1,39 +0,0 @@ | |||
1498 | 1 | /* | ||
1499 | 2 | * Copyright 2014 Canonical Ltd. | ||
1500 | 3 | * | ||
1501 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1502 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1503 | 6 | * the Free Software Foundation; version 3. | ||
1504 | 7 | * | ||
1505 | 8 | * This program is distributed in the hope that it will be useful, | ||
1506 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1507 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1508 | 11 | * GNU Lesser General Public License for more details. | ||
1509 | 12 | * | ||
1510 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1511 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1512 | 15 | */ | ||
1513 | 16 | |||
1514 | 17 | import QtQuick 2.4 | ||
1515 | 18 | |||
1516 | 19 | /*! | ||
1517 | 20 | \qmltype Header | ||
1518 | 21 | \internal | ||
1519 | 22 | \deprecated | ||
1520 | 23 | */ | ||
1521 | 24 | AppHeader { | ||
1522 | 25 | |||
1523 | 26 | /*! | ||
1524 | 27 | \internal | ||
1525 | 28 | We need this property so QML exposes this class as Header instead of | ||
1526 | 29 | AppHeader. This way autopilot can select the deprecated header. | ||
1527 | 30 | */ | ||
1528 | 31 | property string _for_autopilot | ||
1529 | 32 | |||
1530 | 33 | Component.onCompleted: { | ||
1531 | 34 | print("WARNING: Header is an internal component of Ubuntu.Components and" + | ||
1532 | 35 | "its API may change or be removed at any moment." + | ||
1533 | 36 | "Please use MainView and Page instead." | ||
1534 | 37 | ); | ||
1535 | 38 | } | ||
1536 | 39 | } | ||
1537 | 40 | 0 | ||
1538 | === modified file 'src/Ubuntu/Components/1.3/MainView.qml' | |||
1539 | --- src/Ubuntu/Components/1.3/MainView.qml 2015-08-10 15:35:04 +0000 | |||
1540 | +++ src/Ubuntu/Components/1.3/MainView.qml 2015-09-08 04:09:38 +0000 | |||
1541 | @@ -191,9 +191,6 @@ | |||
1542 | 191 | window.title = headerItem.title | 191 | window.title = headerItem.title |
1543 | 192 | } | 192 | } |
1544 | 193 | } | 193 | } |
1545 | 194 | |||
1546 | 195 | // Use of the deprecated toolbar is no longer supported in MainView 1.2. | ||
1547 | 196 | useDeprecatedToolbar: false | ||
1548 | 197 | } | 194 | } |
1549 | 198 | 195 | ||
1550 | 199 | Connections { | 196 | Connections { |
1551 | 200 | 197 | ||
1552 | === modified file 'src/Ubuntu/Components/1.3/MainViewBase.qml' | |||
1553 | --- src/Ubuntu/Components/1.3/MainViewBase.qml 2015-08-06 22:32:02 +0000 | |||
1554 | +++ src/Ubuntu/Components/1.3/MainViewBase.qml 2015-09-08 04:09:38 +0000 | |||
1555 | @@ -28,6 +28,8 @@ | |||
1556 | 28 | */ | 28 | */ |
1557 | 29 | PageTreeNode { | 29 | PageTreeNode { |
1558 | 30 | id: mainView | 30 | id: mainView |
1559 | 31 | styleName: "MainViewStyle" | ||
1560 | 32 | |||
1561 | 31 | /*! | 33 | /*! |
1562 | 32 | The property holds the application's name, which must be the same as the | 34 | The property holds the application's name, which must be the same as the |
1563 | 33 | desktop file's name. | 35 | desktop file's name. |
1564 | @@ -53,7 +55,7 @@ | |||
1565 | 53 | 55 | ||
1566 | 54 | \sa backgroundColor, footerColor | 56 | \sa backgroundColor, footerColor |
1567 | 55 | */ | 57 | */ |
1569 | 56 | property alias headerColor: background.headerColor | 58 | property color headerColor: backgroundColor |
1570 | 57 | 59 | ||
1571 | 58 | /*! | 60 | /*! |
1572 | 59 | \qmlproperty color MainView::backgroundColor | 61 | \qmlproperty color MainView::backgroundColor |
1573 | @@ -80,7 +82,7 @@ | |||
1574 | 80 | 82 | ||
1575 | 81 | \sa footerColor, headerColor | 83 | \sa footerColor, headerColor |
1576 | 82 | */ | 84 | */ |
1578 | 83 | property alias backgroundColor: background.backgroundColor | 85 | property color backgroundColor: theme.palette.normal.background |
1579 | 84 | 86 | ||
1580 | 85 | /*! | 87 | /*! |
1581 | 86 | \qmlproperty color MainView::footerColor | 88 | \qmlproperty color MainView::footerColor |
1582 | @@ -88,22 +90,12 @@ | |||
1583 | 88 | 90 | ||
1584 | 89 | \sa backgroundColor, headerColor | 91 | \sa backgroundColor, headerColor |
1585 | 90 | */ | 92 | */ |
1602 | 91 | property alias footerColor: background.footerColor | 93 | property color footerColor: backgroundColor |
1603 | 92 | 94 | ||
1604 | 93 | // FIXME: Make sure that the theming is only in the background, and the style | 95 | Toolkit.Object { |
1605 | 94 | // should not occlude contents of the MainView. When making changes here, make | 96 | id: autoTheme |
1606 | 95 | // sure that bug https://bugs.launchpad.net/manhattan/+bug/1124076 does not come back. | 97 | // FIXME: Define the background colors in MainViewStyle and get rid of the properties |
1607 | 96 | Toolkit.StyledItem { | 98 | // in MainViewBase. That removes the need for auto-theming. |
1592 | 97 | id: background | ||
1593 | 98 | anchors.fill: parent | ||
1594 | 99 | // theme is inherited from PageTreeNode, no need to update versioning | ||
1595 | 100 | styleName: "MainViewStyle" | ||
1596 | 101 | |||
1597 | 102 | // FIXME: Define the colors in MainViewStyle and get rid of the properties | ||
1598 | 103 | // in MainViewBase. | ||
1599 | 104 | property color headerColor: backgroundColor | ||
1600 | 105 | property color backgroundColor: theme.palette.normal.background | ||
1601 | 106 | property color footerColor: backgroundColor | ||
1608 | 107 | 99 | ||
1609 | 108 | /* | 100 | /* |
1610 | 109 | As we don't know the order the property bindings and onXXXChanged signals are evaluated | 101 | As we don't know the order the property bindings and onXXXChanged signals are evaluated |
1611 | @@ -113,18 +105,23 @@ | |||
1612 | 113 | Qt bug: https://bugreports.qt-project.org/browse/QTBUG-11712 | 105 | Qt bug: https://bugreports.qt-project.org/browse/QTBUG-11712 |
1613 | 114 | */ | 106 | */ |
1614 | 115 | 107 | ||
1620 | 116 | onBackgroundColorChanged: { | 108 | Connections { |
1621 | 117 | if (backgroundColor != theme.palette.normal.background) { | 109 | target: mainView |
1622 | 118 | // custom color, proceed with auto-theming | 110 | |
1623 | 119 | autoThemeName = (ColorUtils.luminance(backgroundColor) >= 0.85) ? | 111 | onBackgroundColorChanged: { |
1624 | 120 | "Ambiance" : "SuruDark"; | 112 | if (mainView.backgroundColor != theme.palette.normal.background) { |
1625 | 113 | // custom color, proceed with auto-theming | ||
1626 | 114 | autoTheme.themeName = (ColorUtils.luminance(backgroundColor) >= 0.85) ? | ||
1627 | 115 | "Ambiance" : "SuruDark"; | ||
1628 | 116 | } | ||
1629 | 121 | } | 117 | } |
1630 | 122 | } | 118 | } |
1633 | 123 | property string autoThemeName | 119 | |
1634 | 124 | onAutoThemeNameChanged: { | 120 | property string themeName |
1635 | 121 | onThemeNameChanged: { | ||
1636 | 125 | // only change the theme if the current one is a system one. | 122 | // only change the theme if the current one is a system one. |
1639 | 126 | if (autoThemeName !== "" && (theme.name.search("Ubuntu.Components.Themes") == 0)) { | 123 | if (themeName !== "" && (theme.name.search("Ubuntu.Components.Themes") == 0)) { |
1640 | 127 | mainView.theme.name = "Ubuntu.Components.Themes.%1".arg(autoThemeName); | 124 | mainView.theme.name = "Ubuntu.Components.Themes.%1".arg(themeName); |
1641 | 128 | } | 125 | } |
1642 | 129 | } | 126 | } |
1643 | 130 | } | 127 | } |
1644 | 131 | 128 | ||
1645 | === renamed file 'src/Ubuntu/Components/1.3/ColumnMetrics.qml' => 'src/Ubuntu/Components/1.3/PageColumn.qml' | |||
1646 | --- src/Ubuntu/Components/1.3/ColumnMetrics.qml 2015-06-24 16:16:13 +0000 | |||
1647 | +++ src/Ubuntu/Components/1.3/PageColumn.qml 2015-09-08 04:09:38 +0000 | |||
1648 | @@ -17,37 +17,42 @@ | |||
1649 | 17 | import QtQuick 2.4 | 17 | import QtQuick 2.4 |
1650 | 18 | 18 | ||
1651 | 19 | /*! | 19 | /*! |
1653 | 20 | \qmltype ColumnMetrics | 20 | \qmltype PageColumn |
1654 | 21 | \inqmlmodule Ubuntu.Components 1.3 | 21 | \inqmlmodule Ubuntu.Components 1.3 |
1655 | 22 | \since Ubuntu.Components 1.3 | 22 | \since Ubuntu.Components 1.3 |
1656 | 23 | \ingroup ubuntu | 23 | \ingroup ubuntu |
1659 | 24 | \brief Component configuring the metrics of a column in MultiColumnView. | 24 | \brief Component configuring the metrics of a column in AdaptivePageLayout. |
1658 | 25 | \internal | ||
1660 | 26 | 25 | ||
1661 | 27 | */ | 26 | */ |
1662 | 28 | QtObject { | 27 | QtObject { |
1663 | 29 | /*! | 28 | /*! |
1664 | 30 | 1-based value identifying the column the metrics to be applied to. | 29 | 1-based value identifying the column the metrics to be applied to. |
1665 | 30 | \internal | ||
1666 | 31 | */ | 31 | */ |
1668 | 32 | property int column | 32 | property int __column |
1669 | 33 | 33 | ||
1670 | 34 | /*! | 34 | /*! |
1671 | 35 | Specifies whether the width of the column should fill the available space | 35 | Specifies whether the width of the column should fill the available space |
1673 | 36 | of the MultiColumnView column or not. Defaults to \a false. | 36 | of the AdaptivePageLayout column or not. Defaults to \a false. |
1674 | 37 | */ | 37 | */ |
1675 | 38 | property bool fillWidth: false | 38 | property bool fillWidth: false |
1676 | 39 | 39 | ||
1677 | 40 | /*! | 40 | /*! |
1681 | 41 | Specifies the minimum width of the column. If the value is greater than | 41 | Specifies the minimum width of the column. Defaults to 0. |
1679 | 42 | \b MultiColumnView::defaultColumnWidth, the value will be set as width for | ||
1680 | 43 | the column. | ||
1682 | 44 | */ | 42 | */ |
1683 | 45 | property real minimumWidth: 0 | 43 | property real minimumWidth: 0 |
1684 | 46 | 44 | ||
1685 | 47 | /*! | 45 | /*! |
1689 | 48 | Specifies the maximum width of the column. If the value is smaller than | 46 | Specifies the maximum width of the column. A maximum value of 0 will be ignored. |
1690 | 49 | \b MultiColumnView::defaultColumnWidth, the value will be set as width for | 47 | Defaults to the maximum positive value. |
1688 | 50 | the column. A maximum value of 0 will be ignored. | ||
1691 | 51 | */ | 48 | */ |
1692 | 52 | property real maximumWidth: Number.POSITIVE_INFINITY | 49 | property real maximumWidth: Number.POSITIVE_INFINITY |
1693 | 50 | |||
1694 | 51 | /*! | ||
1695 | 52 | Specifies the preferred width of the column when the layout is initialized. | ||
1696 | 53 | Defaults to 0. AdaptivePageLayout clamps the given value between \l minimumWidth | ||
1697 | 54 | and \l maximumWidth. The value must be set if the \l fillWidth and \l minimumWidth | ||
1698 | 55 | are not set. | ||
1699 | 56 | */ | ||
1700 | 57 | property real preferredWidth: 0 | ||
1701 | 53 | } | 58 | } |
1702 | 54 | 59 | ||
1703 | === added file 'src/Ubuntu/Components/1.3/PageColumnsLayout.qml' | |||
1704 | --- src/Ubuntu/Components/1.3/PageColumnsLayout.qml 1970-01-01 00:00:00 +0000 | |||
1705 | +++ src/Ubuntu/Components/1.3/PageColumnsLayout.qml 2015-09-08 04:09:38 +0000 | |||
1706 | @@ -0,0 +1,115 @@ | |||
1707 | 1 | /* | ||
1708 | 2 | * Copyright 2015 Canonical Ltd. | ||
1709 | 3 | * | ||
1710 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1711 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1712 | 6 | * the Free Software Foundation; version 3. | ||
1713 | 7 | * | ||
1714 | 8 | * This program is distributed in the hope that it will be useful, | ||
1715 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1716 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1717 | 11 | * GNU Lesser General Public License for more details. | ||
1718 | 12 | * | ||
1719 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1720 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1721 | 15 | */ | ||
1722 | 16 | |||
1723 | 17 | import QtQuick 2.4 | ||
1724 | 18 | |||
1725 | 19 | /*! | ||
1726 | 20 | \qmltype PageColumnsLayout | ||
1727 | 21 | \inqmlmodule Ubuntu.Components 1.3 | ||
1728 | 22 | \since Ubuntu.Components 1.3 | ||
1729 | 23 | \ingroup ubuntu | ||
1730 | 24 | \brief Component configuring a layout in an AdaptivePageLayout component. | ||
1731 | 25 | |||
1732 | 26 | The component specifies the column configuration of a specific layout. The layout | ||
1733 | 27 | will have as many columns as many PageColumn elements will be declared. The layout | ||
1734 | 28 | will be activated when the \l when property evaluates to \c true. There can be | ||
1735 | 29 | many layouts evaluated to true, only the first one evaluated to true in the | ||
1736 | 30 | \l AdaptivePageLayout::layouts list will be activated. | ||
1737 | 31 | |||
1738 | 32 | \qml | ||
1739 | 33 | import QtQuick 2.4 | ||
1740 | 34 | import Ubuntu.Components 1.3 | ||
1741 | 35 | |||
1742 | 36 | MainView { | ||
1743 | 37 | width: units.gu(100) | ||
1744 | 38 | height: units.gu(60) | ||
1745 | 39 | |||
1746 | 40 | AdaptivePageLayout { | ||
1747 | 41 | anchors.fill: parent | ||
1748 | 42 | primaryPage: page1 | ||
1749 | 43 | layouts: [ | ||
1750 | 44 | PageColumnsLayout { | ||
1751 | 45 | when: width > units.gu(80) | ||
1752 | 46 | // column #0 | ||
1753 | 47 | PageColumn { | ||
1754 | 48 | minimumWidth: units.gu(30) | ||
1755 | 49 | maximumWidth: units.gu(60) | ||
1756 | 50 | preferredWidth: units.gu(40) | ||
1757 | 51 | } | ||
1758 | 52 | // column #1 | ||
1759 | 53 | PageColumn { | ||
1760 | 54 | fillWidth: true | ||
1761 | 55 | } | ||
1762 | 56 | }, | ||
1763 | 57 | PageColumnsLayout { | ||
1764 | 58 | when: true | ||
1765 | 59 | PageColumn { | ||
1766 | 60 | fillWidth: true | ||
1767 | 61 | minimumWidth: units.gu(10) | ||
1768 | 62 | } | ||
1769 | 63 | } | ||
1770 | 64 | ] | ||
1771 | 65 | |||
1772 | 66 | Page { | ||
1773 | 67 | id: page1 | ||
1774 | 68 | title: "Main page" | ||
1775 | 69 | Column { | ||
1776 | 70 | Button { | ||
1777 | 71 | text: "Add Page2 above " + page1.title | ||
1778 | 72 | onClicked: page1.pageStack.addPageToCurrentColumn(page1, page2) | ||
1779 | 73 | } | ||
1780 | 74 | Button { | ||
1781 | 75 | text: "Add Page3 next to " + page1.title | ||
1782 | 76 | onClicked: page1.pageStack.addPageToNextColumn(page1, page3) | ||
1783 | 77 | } | ||
1784 | 78 | } | ||
1785 | 79 | } | ||
1786 | 80 | Page { | ||
1787 | 81 | id: page2 | ||
1788 | 82 | title: "Page #2" | ||
1789 | 83 | } | ||
1790 | 84 | Page { | ||
1791 | 85 | id: page3 | ||
1792 | 86 | title: "Page #3" | ||
1793 | 87 | } | ||
1794 | 88 | } | ||
1795 | 89 | } | ||
1796 | 90 | \endqml | ||
1797 | 91 | In the example above the second PageColumnLayout's condition is always set to | ||
1798 | 92 | true, which means that that the layout will be always active unless the first | ||
1799 | 93 | layout's condition evaluates to true. The layout overrides the single column | ||
1800 | 94 | minimumWidth default value. Note that \l PageColumn::fillWidth must be also set. | ||
1801 | 95 | |||
1802 | 96 | \note When none of the conditions is met, a single column layout will be used. | ||
1803 | 97 | |||
1804 | 98 | \sa PageColumn | ||
1805 | 99 | */ | ||
1806 | 100 | QtObject { | ||
1807 | 101 | id: layout | ||
1808 | 102 | |||
1809 | 103 | /*! | ||
1810 | 104 | Condition activating the layout. Defaults to false. | ||
1811 | 105 | */ | ||
1812 | 106 | property bool when: false | ||
1813 | 107 | |||
1814 | 108 | /*! | ||
1815 | 109 | \qmlproperty list<PageColumn> data | ||
1816 | 110 | \default | ||
1817 | 111 | Default property holding the PageColumn elements configuring each column. | ||
1818 | 112 | */ | ||
1819 | 113 | default property alias data: layout.__data | ||
1820 | 114 | property list<PageColumn> __data | ||
1821 | 115 | } | ||
1822 | 0 | 116 | ||
1823 | === modified file 'src/Ubuntu/Components/1.3/PageWrapper.qml' | |||
1824 | --- src/Ubuntu/Components/1.3/PageWrapper.qml 2015-06-15 07:45:34 +0000 | |||
1825 | +++ src/Ubuntu/Components/1.3/PageWrapper.qml 2015-09-08 04:09:38 +0000 | |||
1826 | @@ -15,7 +15,7 @@ | |||
1827 | 15 | */ | 15 | */ |
1828 | 16 | 16 | ||
1829 | 17 | import QtQuick 2.4 | 17 | import QtQuick 2.4 |
1831 | 18 | import "../1.2/PageWrapperUtils.js" as Utils | 18 | import "PageWrapperUtils.js" as Utils |
1832 | 19 | 19 | ||
1833 | 20 | /*! | 20 | /*! |
1834 | 21 | \internal | 21 | \internal |
1835 | @@ -66,6 +66,22 @@ | |||
1836 | 66 | property Item pageHolder | 66 | property Item pageHolder |
1837 | 67 | 67 | ||
1838 | 68 | /*! | 68 | /*! |
1839 | 69 | Instructs to load the page synchronously or not. Used by AdaptivePageLayout. | ||
1840 | 70 | True by default to keep PageStack integrity. | ||
1841 | 71 | */ | ||
1842 | 72 | property bool synchronous: true | ||
1843 | 73 | |||
1844 | 74 | /*! | ||
1845 | 75 | Incubator for the asynchronous page creation | ||
1846 | 76 | */ | ||
1847 | 77 | property var incubator: null | ||
1848 | 78 | |||
1849 | 79 | /*! | ||
1850 | 80 | Signal emitted when incubator completes page loading. | ||
1851 | 81 | */ | ||
1852 | 82 | signal pageLoaded() | ||
1853 | 83 | |||
1854 | 84 | /*! | ||
1855 | 69 | Returns true if the current PageWrapper is a child of the given page | 85 | Returns true if the current PageWrapper is a child of the given page |
1856 | 70 | */ | 86 | */ |
1857 | 71 | function childOf(page) { | 87 | function childOf(page) { |
1858 | @@ -114,7 +130,14 @@ | |||
1859 | 114 | if (pageWrapper.object) pageWrapper.object = null; | 130 | if (pageWrapper.object) pageWrapper.object = null; |
1860 | 115 | Utils.initPage(pageWrapper); | 131 | Utils.initPage(pageWrapper); |
1861 | 116 | if (pageWrapper.active && reference) { | 132 | if (pageWrapper.active && reference) { |
1863 | 117 | Utils.activate(pageWrapper); | 133 | if ((pageWrapper.incubator && pageWrapper.incubator.status == Component.Ready) || pageWrapper.object) { |
1864 | 134 | Utils.activate(pageWrapper); | ||
1865 | 135 | } else { | ||
1866 | 136 | // asynchronous, connect page activation | ||
1867 | 137 | pageLoaded.connect(function () { | ||
1868 | 138 | Utils.activate(pageWrapper); | ||
1869 | 139 | }); | ||
1870 | 140 | } | ||
1871 | 118 | } | 141 | } |
1872 | 119 | } | 142 | } |
1873 | 120 | 143 | ||
1874 | 121 | 144 | ||
1875 | === added file 'src/Ubuntu/Components/1.3/PageWrapperUtils.js' | |||
1876 | --- src/Ubuntu/Components/1.3/PageWrapperUtils.js 1970-01-01 00:00:00 +0000 | |||
1877 | +++ src/Ubuntu/Components/1.3/PageWrapperUtils.js 2015-09-08 04:09:38 +0000 | |||
1878 | @@ -0,0 +1,167 @@ | |||
1879 | 1 | /* | ||
1880 | 2 | * Copyright 2015 Canonical Ltd. | ||
1881 | 3 | * | ||
1882 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1883 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1884 | 6 | * the Free Software Foundation; version 3. | ||
1885 | 7 | * | ||
1886 | 8 | * This program is distributed in the hope that it will be useful, | ||
1887 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1888 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1889 | 11 | * GNU Lesser General Public License for more details. | ||
1890 | 12 | * | ||
1891 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1892 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1893 | 15 | */ | ||
1894 | 16 | |||
1895 | 17 | //.pragma library // FIXME: cannot refer to Component.Error if I use this. | ||
1896 | 18 | // FIXME: ideally we would make this a stateless library, but that breaks applications | ||
1897 | 19 | // that rely on accessing context variables in pages that were pushed on a PageStack | ||
1898 | 20 | // by url (PageStack.push("FileName.qml")) because of a Qt bug: | ||
1899 | 21 | // https://bugreports.qt-project.org/browse/QTBUG-31347 | ||
1900 | 22 | |||
1901 | 23 | /*! | ||
1902 | 24 | \internal | ||
1903 | 25 | Incubator wrapper object. Used when page is loaded asynchronously. | ||
1904 | 26 | */ | ||
1905 | 27 | |||
1906 | 28 | function Incubator(pageWrapper, pageComponent) { | ||
1907 | 29 | // private variable for QmlIncubatorObject | ||
1908 | 30 | var incubator = null; | ||
1909 | 31 | |||
1910 | 32 | // public API | ||
1911 | 33 | this.status = Component.Ready; | ||
1912 | 34 | this.object = null; | ||
1913 | 35 | this.onStatusChanged = null; | ||
1914 | 36 | this.forceCompletion = function () { | ||
1915 | 37 | if (incubator) { | ||
1916 | 38 | incubator.forceCompletion(); | ||
1917 | 39 | } | ||
1918 | 40 | } | ||
1919 | 41 | |||
1920 | 42 | // internal function to catch status changes | ||
1921 | 43 | function incubatorStatusChanged(status) { | ||
1922 | 44 | // update wrapper incubator fields | ||
1923 | 45 | pageWrapper.incubator.status = status; | ||
1924 | 46 | pageWrapper.incubator.object = pageWrapper.object = incubator.object; | ||
1925 | 47 | |||
1926 | 48 | // emit pageWrapper's pageLoaded signal to complete page activation and loading | ||
1927 | 49 | if (status === Component.Ready) { | ||
1928 | 50 | pageWrapper.pageLoaded(); | ||
1929 | 51 | } | ||
1930 | 52 | |||
1931 | 53 | // forward state change to the user | ||
1932 | 54 | if (pageWrapper.incubator.onStatusChanged) { | ||
1933 | 55 | // call onStatusChanged | ||
1934 | 56 | pageWrapper.incubator.onStatusChanged(status); | ||
1935 | 57 | } | ||
1936 | 58 | |||
1937 | 59 | // cleanup of ready or error | ||
1938 | 60 | if (status !== Component.Loading) { | ||
1939 | 61 | pageWrapper.incubator = null; | ||
1940 | 62 | incubator = null; | ||
1941 | 63 | } | ||
1942 | 64 | } | ||
1943 | 65 | |||
1944 | 66 | if (pageWrapper.properties) { | ||
1945 | 67 | incubator = pageComponent.incubateObject(pageWrapper, pageWrapper.properties); | ||
1946 | 68 | } else { | ||
1947 | 69 | incubator = pageComponent.incubateObject(pageWrapper); | ||
1948 | 70 | } | ||
1949 | 71 | |||
1950 | 72 | this.status = incubator.status; | ||
1951 | 73 | if (incubator.status != Component.Ready) { | ||
1952 | 74 | incubator.onStatusChanged = incubatorStatusChanged; | ||
1953 | 75 | } else { | ||
1954 | 76 | incubatorStatusChanged(incubator.status); | ||
1955 | 77 | } | ||
1956 | 78 | } | ||
1957 | 79 | |||
1958 | 80 | /******************************************************* | ||
1959 | 81 | * | ||
1960 | 82 | */ | ||
1961 | 83 | /*! | ||
1962 | 84 | \internal | ||
1963 | 85 | Initialize pageWrapper.object. | ||
1964 | 86 | */ | ||
1965 | 87 | function initPage(pageWrapper) { | ||
1966 | 88 | var pageComponent; | ||
1967 | 89 | |||
1968 | 90 | if (pageWrapper.reference.createObject) { | ||
1969 | 91 | // page reference is a component | ||
1970 | 92 | pageComponent = pageWrapper.reference; | ||
1971 | 93 | } else if (typeof pageWrapper.reference == "string") { | ||
1972 | 94 | // page reference is a string (url) | ||
1973 | 95 | pageComponent = Qt.createComponent(pageWrapper.reference); | ||
1974 | 96 | } | ||
1975 | 97 | |||
1976 | 98 | // PageWrapper can override the synchronous loading | ||
1977 | 99 | var synchronous = pageWrapper.hasOwnProperty("synchronous") ? pageWrapper.synchronous : true; | ||
1978 | 100 | |||
1979 | 101 | if (pageComponent) { | ||
1980 | 102 | if (pageComponent.status === Component.Error) { | ||
1981 | 103 | throw new Error("Error while loading page: " + pageComponent.errorString()); | ||
1982 | 104 | } else { | ||
1983 | 105 | // create the object | ||
1984 | 106 | pageWrapper.incubator = new Incubator(pageWrapper, pageComponent); | ||
1985 | 107 | if (synchronous) { | ||
1986 | 108 | pageWrapper.incubator.forceCompletion(); | ||
1987 | 109 | } | ||
1988 | 110 | pageWrapper.canDestroy = true; | ||
1989 | 111 | } | ||
1990 | 112 | } else { | ||
1991 | 113 | // page reference is an object | ||
1992 | 114 | pageWrapper.object = pageWrapper.reference; | ||
1993 | 115 | pageWrapper.object.parent = pageWrapper; | ||
1994 | 116 | pageWrapper.canDestroy = false; | ||
1995 | 117 | |||
1996 | 118 | // copy the properties to the page object | ||
1997 | 119 | for (var prop in pageWrapper.properties) { | ||
1998 | 120 | if (pageWrapper.properties.hasOwnProperty(prop)) { | ||
1999 | 121 | pageWrapper.object[prop] = pageWrapper.properties[prop]; | ||
2000 | 122 | } | ||
2001 | 123 | } | ||
2002 | 124 | } | ||
2003 | 125 | |||
2004 | 126 | return pageWrapper.object; | ||
2005 | 127 | } | ||
2006 | 128 | |||
2007 | 129 | /*! | ||
2008 | 130 | \internal | ||
2009 | 131 | Create the page object if needed, and make the page object visible. | ||
2010 | 132 | */ | ||
2011 | 133 | function activate(pageWrapper) { | ||
2012 | 134 | if (!pageWrapper.object) { | ||
2013 | 135 | initPage(pageWrapper); | ||
2014 | 136 | } | ||
2015 | 137 | |||
2016 | 138 | // Having the same page pushed multiple times on a stack changes | ||
2017 | 139 | // the parent of the page object. Change it back here. | ||
2018 | 140 | pageWrapper.object.parent = pageWrapper; | ||
2019 | 141 | |||
2020 | 142 | // Some page objects are invisible initially. Make visible. | ||
2021 | 143 | |||
2022 | 144 | pageWrapper.object.visible = true; | ||
2023 | 145 | pageWrapper.active = true; | ||
2024 | 146 | } | ||
2025 | 147 | |||
2026 | 148 | /*! | ||
2027 | 149 | \internal | ||
2028 | 150 | Hide page object. | ||
2029 | 151 | */ | ||
2030 | 152 | function deactivate(pageWrapper) { | ||
2031 | 153 | pageWrapper.active = false; | ||
2032 | 154 | } | ||
2033 | 155 | |||
2034 | 156 | /*! | ||
2035 | 157 | \internal | ||
2036 | 158 | Destroy the page object if pageWrapper.canDestroy is true. | ||
2037 | 159 | Do nothing if pageWrapper.canDestroy is false. | ||
2038 | 160 | */ | ||
2039 | 161 | function destroyObject(pageWrapper) { | ||
2040 | 162 | if (pageWrapper.canDestroy) { | ||
2041 | 163 | pageWrapper.object.destroy(); | ||
2042 | 164 | pageWrapper.object = null; | ||
2043 | 165 | pageWrapper.canDestroy = false; | ||
2044 | 166 | } | ||
2045 | 167 | } | ||
2046 | 0 | 168 | ||
2047 | === modified file 'src/Ubuntu/Components/1.3/TextField.qml' | |||
2048 | --- src/Ubuntu/Components/1.3/TextField.qml 2015-08-11 17:15:59 +0000 | |||
2049 | +++ src/Ubuntu/Components/1.3/TextField.qml 2015-09-08 04:09:38 +0000 | |||
2050 | @@ -99,7 +99,7 @@ | |||
2051 | 99 | \note During text selection all interactive parent Flickables are turned off. | 99 | \note During text selection all interactive parent Flickables are turned off. |
2052 | 100 | */ | 100 | */ |
2053 | 101 | 101 | ||
2055 | 102 | ActionItem { | 102 | Ubuntu.ActionItem { |
2056 | 103 | id: control | 103 | id: control |
2057 | 104 | 104 | ||
2058 | 105 | implicitWidth: units.gu(25) | 105 | implicitWidth: units.gu(25) |
2059 | @@ -896,7 +896,7 @@ | |||
2060 | 896 | } | 896 | } |
2061 | 897 | } | 897 | } |
2062 | 898 | 898 | ||
2064 | 899 | AbstractButton { | 899 | Ubuntu.AbstractButton { |
2065 | 900 | id: clearButton | 900 | id: clearButton |
2066 | 901 | objectName: "clear_button" | 901 | objectName: "clear_button" |
2067 | 902 | activeFocusOnPress: false | 902 | activeFocusOnPress: false |
2068 | 903 | 903 | ||
2069 | === modified file 'src/Ubuntu/Components/ComponentModule.pro' | |||
2070 | --- src/Ubuntu/Components/ComponentModule.pro 2015-07-29 10:12:07 +0000 | |||
2071 | +++ src/Ubuntu/Components/ComponentModule.pro 2015-09-08 04:09:38 +0000 | |||
2072 | @@ -25,7 +25,6 @@ | |||
2073 | 25 | 25 | ||
2074 | 26 | #1.2 | 26 | #1.2 |
2075 | 27 | QML_FILES += 1.2/AbstractButton.qml \ | 27 | QML_FILES += 1.2/AbstractButton.qml \ |
2076 | 28 | 1.2/ActionItem.qml \ | ||
2077 | 29 | 1.2/ActionList.qml \ | 28 | 1.2/ActionList.qml \ |
2078 | 30 | 1.2/ActivityIndicator.qml \ | 29 | 1.2/ActivityIndicator.qml \ |
2079 | 31 | 1.2/AnimatedItem.qml \ | 30 | 1.2/AnimatedItem.qml \ |
2080 | @@ -81,9 +80,7 @@ | |||
2081 | 81 | 1.2/UbuntuNumberAnimation.qml | 80 | 1.2/UbuntuNumberAnimation.qml |
2082 | 82 | 81 | ||
2083 | 83 | #1.3 | 82 | #1.3 |
2087 | 84 | QML_FILES += 1.3/AbstractButton.qml \ | 83 | QML_FILES += 1.3/ActionBar.qml \ |
2085 | 85 | 1.3/ActionBar.qml \ | ||
2086 | 86 | 1.3/ActionItem.qml \ | ||
2088 | 87 | 1.3/ActionList.qml \ | 84 | 1.3/ActionList.qml \ |
2089 | 88 | 1.3/ActivityIndicator.qml \ | 85 | 1.3/ActivityIndicator.qml \ |
2090 | 89 | 1.3/AdaptivePageLayout.qml \ | 86 | 1.3/AdaptivePageLayout.qml \ |
2091 | @@ -92,12 +89,10 @@ | |||
2092 | 92 | 1.3/Button.qml \ | 89 | 1.3/Button.qml \ |
2093 | 93 | 1.3/Captions.qml \ | 90 | 1.3/Captions.qml \ |
2094 | 94 | 1.3/CheckBox.qml \ | 91 | 1.3/CheckBox.qml \ |
2095 | 95 | 1.3/ColumnMetrics.qml \ | ||
2096 | 96 | 1.3/ComboButton.qml \ | 92 | 1.3/ComboButton.qml \ |
2097 | 97 | 1.3/CrossFadeImage.qml \ | 93 | 1.3/CrossFadeImage.qml \ |
2098 | 98 | 1.3/dateUtils.js \ | 94 | 1.3/dateUtils.js \ |
2099 | 99 | 1.3/DraggingArea.qml \ | 95 | 1.3/DraggingArea.qml \ |
2100 | 100 | 1.3/Header.qml \ | ||
2101 | 101 | 1.3/InputHandler.qml \ | 96 | 1.3/InputHandler.qml \ |
2102 | 102 | 1.3/Label.qml \ | 97 | 1.3/Label.qml \ |
2103 | 103 | 1.3/MainViewBase.qml \ | 98 | 1.3/MainViewBase.qml \ |
2104 | @@ -114,6 +109,7 @@ | |||
2105 | 114 | 1.3/PageTreeNode.qml \ | 109 | 1.3/PageTreeNode.qml \ |
2106 | 115 | 1.3/pageUtils.js \ | 110 | 1.3/pageUtils.js \ |
2107 | 116 | 1.3/PageWrapper.qml \ | 111 | 1.3/PageWrapper.qml \ |
2108 | 112 | 1.3/PageWrapperUtils.js \ | ||
2109 | 117 | 1.3/Panel.qml \ | 113 | 1.3/Panel.qml \ |
2110 | 118 | 1.3/ProgressBar.qml \ | 114 | 1.3/ProgressBar.qml \ |
2111 | 119 | 1.3/PullToRefresh.qml \ | 115 | 1.3/PullToRefresh.qml \ |
2112 | @@ -137,9 +133,12 @@ | |||
2113 | 137 | 1.3/UbuntuListView.qml \ | 133 | 1.3/UbuntuListView.qml \ |
2114 | 138 | 1.3/UbuntuNumberAnimation.qml \ | 134 | 1.3/UbuntuNumberAnimation.qml \ |
2115 | 139 | 1.3/ListItemPopover.qml \ | 135 | 1.3/ListItemPopover.qml \ |
2117 | 140 | 1.3/BottomEdgeHint.qml | 136 | 1.3/BottomEdgeHint.qml \ |
2118 | 137 | 1.3/PageColumn.qml \ | ||
2119 | 138 | 1.3/PageColumnsLayout.qml | ||
2120 | 141 | 139 | ||
2122 | 142 | OTHER_FILES+= 1.3/CrossFadeImage.qdoc \ | 140 | OTHER_FILES+= qmldir \ |
2123 | 141 | 1.3/CrossFadeImage.qdoc \ | ||
2124 | 143 | 1.3/UbuntuListView11.qdoc \ | 142 | 1.3/UbuntuListView11.qdoc \ |
2125 | 144 | 1.3/Page.qdoc \ | 143 | 1.3/Page.qdoc \ |
2126 | 145 | 1.3/PageHeadConfiguration.qdoc \ | 144 | 1.3/PageHeadConfiguration.qdoc \ |
2127 | 146 | 145 | ||
2128 | === modified file 'src/Ubuntu/Components/ListItems/1.3/SingleControl.qml' | |||
2129 | --- src/Ubuntu/Components/ListItems/1.3/SingleControl.qml 2015-04-29 07:21:29 +0000 | |||
2130 | +++ src/Ubuntu/Components/ListItems/1.3/SingleControl.qml 2015-09-08 04:09:38 +0000 | |||
2131 | @@ -54,7 +54,8 @@ | |||
2132 | 54 | 54 | ||
2133 | 55 | /*! \internal */ | 55 | /*! \internal */ |
2134 | 56 | onClicked: if (control && control.enabled && control.hasOwnProperty("clicked")) control.clicked() | 56 | onClicked: if (control && control.enabled && control.hasOwnProperty("clicked")) control.clicked() |
2136 | 57 | pressed: __mouseArea.pressed || (control && control.hasOwnProperty("pressed") && control.pressed) | 57 | /*! \internal */ |
2137 | 58 | property bool pressed: __mouseArea.pressed || (control && control.hasOwnProperty("pressed") && control.pressed) | ||
2138 | 58 | /*! \internal */ | 59 | /*! \internal */ |
2139 | 59 | onPressedChanged: if (control && control.enabled && control.hasOwnProperty("pressed")) control.pressed = singleControlListItem.pressed | 60 | onPressedChanged: if (control && control.enabled && control.hasOwnProperty("pressed")) control.pressed = singleControlListItem.pressed |
2140 | 60 | 61 | ||
2141 | 61 | 62 | ||
2142 | === modified file 'src/Ubuntu/Components/Popups/1.3/Popover.qml' | |||
2143 | --- src/Ubuntu/Components/Popups/1.3/Popover.qml 2015-07-19 17:54:49 +0000 | |||
2144 | +++ src/Ubuntu/Components/Popups/1.3/Popover.qml 2015-09-08 04:09:38 +0000 | |||
2145 | @@ -210,7 +210,7 @@ | |||
2146 | 210 | objectName: "popover_foreground" | 210 | objectName: "popover_foreground" |
2147 | 211 | 211 | ||
2148 | 212 | //styling properties | 212 | //styling properties |
2150 | 213 | property real minimumWidth: units.gu(25) | 213 | property real minimumWidth: units.gu(40) |
2151 | 214 | 214 | ||
2152 | 215 | property real maxWidth: dismissArea ? (internal.portrait ? dismissArea.width : dismissArea.width * 3/4) : 0.0 | 215 | property real maxWidth: dismissArea ? (internal.portrait ? dismissArea.width : dismissArea.width * 3/4) : 0.0 |
2153 | 216 | property real maxHeight: dismissArea ? (internal.portrait ? dismissArea.height * 3/4 : dismissArea.height) : 0.0 | 216 | property real maxHeight: dismissArea ? (internal.portrait ? dismissArea.height * 3/4 : dismissArea.height) : 0.0 |
2154 | 217 | 217 | ||
2155 | === modified file 'src/Ubuntu/Components/Themes/Ambiance/1.2/ListItemStyle.qml' | |||
2156 | --- src/Ubuntu/Components/Themes/Ambiance/1.2/ListItemStyle.qml 2015-07-22 18:57:58 +0000 | |||
2157 | +++ src/Ubuntu/Components/Themes/Ambiance/1.2/ListItemStyle.qml 2015-09-08 04:09:38 +0000 | |||
2158 | @@ -25,7 +25,7 @@ | |||
2159 | 25 | * Take over the ListItem's index context property as repeater used in panel | 25 | * Take over the ListItem's index context property as repeater used in panel |
2160 | 26 | * overrides the property. | 26 | * overrides the property. |
2161 | 27 | */ | 27 | */ |
2163 | 28 | readonly property int listItemIndex: index | 28 | readonly property int listItemIndex: (typeof index !== "undefined") ? index : internals.childIndex() |
2164 | 29 | 29 | ||
2165 | 30 | /* | 30 | /* |
2166 | 31 | * Coloring properties | 31 | * Coloring properties |
2167 | @@ -343,6 +343,19 @@ | |||
2168 | 343 | readonly property real threshold: units.gu(1.5) | 343 | readonly property real threshold: units.gu(1.5) |
2169 | 344 | property bool snapIn: false | 344 | property bool snapIn: false |
2170 | 345 | 345 | ||
2171 | 346 | // returns the child index of the ListItem when not used in model driven view | ||
2172 | 347 | function childIndex() { | ||
2173 | 348 | if (styledItem.parent) { | ||
2174 | 349 | for (var i = 0; i < styledItem.parent.children.length; i++) { | ||
2175 | 350 | if (styledItem.parent.children[i] == styledItem) { | ||
2176 | 351 | return i; | ||
2177 | 352 | } | ||
2178 | 353 | } | ||
2179 | 354 | } else { | ||
2180 | 355 | return -1; | ||
2181 | 356 | } | ||
2182 | 357 | } | ||
2183 | 358 | |||
2184 | 346 | // update snap direction | 359 | // update snap direction |
2185 | 347 | function updateSnapDirection() { | 360 | function updateSnapDirection() { |
2186 | 348 | if (prevX < listItemStyle.x && (snapChangerLimit <= listItemStyle.x)) { | 361 | if (prevX < listItemStyle.x && (snapChangerLimit <= listItemStyle.x)) { |
2187 | 349 | 362 | ||
2188 | === modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/ActionBarStyle.qml' | |||
2189 | --- src/Ubuntu/Components/Themes/Ambiance/1.3/ActionBarStyle.qml 2015-05-22 10:48:49 +0000 | |||
2190 | +++ src/Ubuntu/Components/Themes/Ambiance/1.3/ActionBarStyle.qml 2015-09-08 04:09:38 +0000 | |||
2191 | @@ -87,8 +87,6 @@ | |||
2192 | 87 | id: actionsOverflowPopover | 87 | id: actionsOverflowPopover |
2193 | 88 | objectName: "actions_overflow_panel" | 88 | objectName: "actions_overflow_panel" |
2194 | 89 | 89 | ||
2195 | 90 | backgroundColor: "white" | ||
2196 | 91 | |||
2197 | 92 | // Ensure the popover closes when actions change and | 90 | // Ensure the popover closes when actions change and |
2198 | 93 | // the list item below may be destroyed before its | 91 | // the list item below may be destroyed before its |
2199 | 94 | // onClicked is executed. See bug | 92 | // onClicked is executed. See bug |
2200 | 95 | 93 | ||
2201 | === removed file 'src/Ubuntu/Components/Themes/Ambiance/1.3/HeadDividerStyle.qml' | |||
2202 | --- src/Ubuntu/Components/Themes/Ambiance/1.3/HeadDividerStyle.qml 2015-04-24 14:07:02 +0000 | |||
2203 | +++ src/Ubuntu/Components/Themes/Ambiance/1.3/HeadDividerStyle.qml 1970-01-01 00:00:00 +0000 | |||
2204 | @@ -1,56 +0,0 @@ | |||
2205 | 1 | /* | ||
2206 | 2 | * Copyright 2014 Canonical Ltd. | ||
2207 | 3 | * | ||
2208 | 4 | * This program is free software; you can redistribute it and/or modify | ||
2209 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
2210 | 6 | * the Free Software Foundation; version 3. | ||
2211 | 7 | * | ||
2212 | 8 | * This program is distributed in the hope that it will be useful, | ||
2213 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2214 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2215 | 11 | * GNU Lesser General Public License for more details. | ||
2216 | 12 | * | ||
2217 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2218 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2219 | 15 | */ | ||
2220 | 16 | import QtQuick 2.4 | ||
2221 | 17 | |||
2222 | 18 | /*! | ||
2223 | 19 | This component is DEPRECATED and no longer used. The divider is now a simple line. | ||
2224 | 20 | */ | ||
2225 | 21 | Item { | ||
2226 | 22 | id: dividerStyle | ||
2227 | 23 | |||
2228 | 24 | property color color: styledItem.backgroundColor | ||
2229 | 25 | |||
2230 | 26 | // Do not make the following two colors part of the style API as they may be deprecated soon. | ||
2231 | 27 | property color topColor: Qt.darker(color, 1.1) | ||
2232 | 28 | property color bottomColor: Qt.lighter(color, 1.2) | ||
2233 | 29 | |||
2234 | 30 | Rectangle { | ||
2235 | 31 | anchors.fill: parent | ||
2236 | 32 | color: dividerStyle.color | ||
2237 | 33 | |||
2238 | 34 | gradient: Gradient { | ||
2239 | 35 | // top shadow | ||
2240 | 36 | GradientStop { | ||
2241 | 37 | position: 0.02 | ||
2242 | 38 | color: dividerStyle.topColor | ||
2243 | 39 | } | ||
2244 | 40 | // middle (background) | ||
2245 | 41 | GradientStop { | ||
2246 | 42 | position: 0.05 | ||
2247 | 43 | color: dividerStyle.color | ||
2248 | 44 | } | ||
2249 | 45 | GradientStop { | ||
2250 | 46 | position: 0.95 | ||
2251 | 47 | color: dividerStyle.color | ||
2252 | 48 | } | ||
2253 | 49 | // bottom highlight | ||
2254 | 50 | GradientStop { | ||
2255 | 51 | position: 0.98 | ||
2256 | 52 | color: dividerStyle.bottomColor | ||
2257 | 53 | } | ||
2258 | 54 | } | ||
2259 | 55 | } | ||
2260 | 56 | } | ||
2261 | 57 | 0 | ||
2262 | === removed file 'src/Ubuntu/Components/Themes/Ambiance/1.3/HeaderStyle.qml' | |||
2263 | --- src/Ubuntu/Components/Themes/Ambiance/1.3/HeaderStyle.qml 2015-04-24 14:07:02 +0000 | |||
2264 | +++ src/Ubuntu/Components/Themes/Ambiance/1.3/HeaderStyle.qml 1970-01-01 00:00:00 +0000 | |||
2265 | @@ -1,124 +0,0 @@ | |||
2266 | 1 | /* | ||
2267 | 2 | * Copyright 2015 Canonical Ltd. | ||
2268 | 3 | * | ||
2269 | 4 | * This program is free software; you can redistribute it and/or modify | ||
2270 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
2271 | 6 | * the Free Software Foundation; version 3. | ||
2272 | 7 | * | ||
2273 | 8 | * This program is distributed in the hope that it will be useful, | ||
2274 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2275 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2276 | 11 | * GNU Lesser General Public License for more details. | ||
2277 | 12 | * | ||
2278 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2279 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2280 | 15 | */ | ||
2281 | 16 | import QtQuick 2.4 | ||
2282 | 17 | import Ubuntu.Components 1.3 | ||
2283 | 18 | |||
2284 | 19 | Item { | ||
2285 | 20 | id: headerStyle | ||
2286 | 21 | /*! | ||
2287 | 22 | The height of the headercontents, which is the full height of | ||
2288 | 23 | the header minus the separators shown at the bottom of it. | ||
2289 | 24 | */ | ||
2290 | 25 | property real contentHeight: units.gu(7.5) | ||
2291 | 26 | |||
2292 | 27 | /*! | ||
2293 | 28 | The source of the image that separates the header from the contents of a \l MainView. | ||
2294 | 29 | The separator will be drawn over the contents. | ||
2295 | 30 | */ | ||
2296 | 31 | property url separatorSource: Qt.resolvedUrl("../artwork/PageHeaderBaseDividerLight.sci") | ||
2297 | 32 | |||
2298 | 33 | /*! | ||
2299 | 34 | The source of an additional image attached to the bottom of the separator. The contents | ||
2300 | 35 | of the \l MainView will be drawn on top of the separator bottom image. | ||
2301 | 36 | */ | ||
2302 | 37 | property url separatorBottomSource: Qt.resolvedUrl("../artwork/PageHeaderBaseDividerBottom.png") | ||
2303 | 38 | |||
2304 | 39 | property int fontWeight: Font.Light | ||
2305 | 40 | property string fontSize: "x-large" | ||
2306 | 41 | property color textColor: theme.palette.selected.backgroundText | ||
2307 | 42 | property real textLeftMargin: units.gu(2) | ||
2308 | 43 | |||
2309 | 44 | implicitHeight: headerStyle.contentHeight + separator.height + separatorBottom.height | ||
2310 | 45 | |||
2311 | 46 | /*! | ||
2312 | 47 | \internal | ||
2313 | 48 | Tabs needs to call sync of the TabBar | ||
2314 | 49 | */ | ||
2315 | 50 | property TabBar __tabBar: tabBarLoader.sourceComponent ? tabBarLoader.item : null | ||
2316 | 51 | |||
2317 | 52 | BorderImage { | ||
2318 | 53 | id: separator | ||
2319 | 54 | anchors { | ||
2320 | 55 | bottom: parent.bottom | ||
2321 | 56 | left: parent.left | ||
2322 | 57 | right: parent.right | ||
2323 | 58 | } | ||
2324 | 59 | source: headerStyle.separatorSource | ||
2325 | 60 | } | ||
2326 | 61 | Image { | ||
2327 | 62 | id: separatorBottom | ||
2328 | 63 | anchors { | ||
2329 | 64 | top: separator.bottom | ||
2330 | 65 | left: parent.left | ||
2331 | 66 | right: parent.right | ||
2332 | 67 | } | ||
2333 | 68 | source: headerStyle.separatorBottomSource | ||
2334 | 69 | } | ||
2335 | 70 | |||
2336 | 71 | Item { | ||
2337 | 72 | id: foreground | ||
2338 | 73 | anchors { | ||
2339 | 74 | left: parent.left | ||
2340 | 75 | right: parent.right | ||
2341 | 76 | top: parent.top | ||
2342 | 77 | } | ||
2343 | 78 | height: headerStyle.contentHeight | ||
2344 | 79 | |||
2345 | 80 | Label { | ||
2346 | 81 | LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft | ||
2347 | 82 | |||
2348 | 83 | anchors { | ||
2349 | 84 | left: parent.left | ||
2350 | 85 | verticalCenter: parent.verticalCenter | ||
2351 | 86 | leftMargin: headerStyle.textLeftMargin | ||
2352 | 87 | } | ||
2353 | 88 | text: styledItem.title | ||
2354 | 89 | font.weight: headerStyle.fontWeight | ||
2355 | 90 | visible: !styledItem.tabsModel && !styledItem.contents | ||
2356 | 91 | fontSize: headerStyle.fontSize | ||
2357 | 92 | color: headerStyle.textColor | ||
2358 | 93 | } | ||
2359 | 94 | |||
2360 | 95 | Binding { | ||
2361 | 96 | target: styledItem.contents | ||
2362 | 97 | property: "anchors.fill" | ||
2363 | 98 | value: foreground | ||
2364 | 99 | when: styledItem.contents | ||
2365 | 100 | } | ||
2366 | 101 | Binding { | ||
2367 | 102 | target: styledItem.contents | ||
2368 | 103 | property: "parent" | ||
2369 | 104 | value: foreground | ||
2370 | 105 | when: styledItem.contents | ||
2371 | 106 | } | ||
2372 | 107 | |||
2373 | 108 | Loader { | ||
2374 | 109 | id: tabBarLoader | ||
2375 | 110 | sourceComponent: styledItem.tabsModel && !styledItem.contents ? tabBarComponent : null | ||
2376 | 111 | anchors.fill: parent | ||
2377 | 112 | } | ||
2378 | 113 | |||
2379 | 114 | Component { | ||
2380 | 115 | id: tabBarComponent | ||
2381 | 116 | TabBar { | ||
2382 | 117 | id: tabBar | ||
2383 | 118 | anchors.fill: parent | ||
2384 | 119 | model: styledItem.tabsModel | ||
2385 | 120 | animate: styledItem.animate | ||
2386 | 121 | } | ||
2387 | 122 | } | ||
2388 | 123 | } | ||
2389 | 124 | } | ||
2390 | 125 | 0 | ||
2391 | === modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/ListItemStyle.qml' | |||
2392 | --- src/Ubuntu/Components/Themes/Ambiance/1.3/ListItemStyle.qml 2015-07-22 18:57:58 +0000 | |||
2393 | +++ src/Ubuntu/Components/Themes/Ambiance/1.3/ListItemStyle.qml 2015-09-08 04:09:38 +0000 | |||
2394 | @@ -337,6 +337,7 @@ | |||
2395 | 337 | property real snapChangerLimit: 0.0 | 337 | property real snapChangerLimit: 0.0 |
2396 | 338 | readonly property real threshold: units.gu(1.5) | 338 | readonly property real threshold: units.gu(1.5) |
2397 | 339 | property bool snapIn: false | 339 | property bool snapIn: false |
2398 | 340 | property bool completed: false | ||
2399 | 340 | 341 | ||
2400 | 341 | // update snap direction | 342 | // update snap direction |
2401 | 342 | function updateSnapDirection() { | 343 | function updateSnapDirection() { |
2402 | @@ -419,4 +420,68 @@ | |||
2403 | 419 | function rebound() { | 420 | function rebound() { |
2404 | 420 | snapAnimation.snapTo(0); | 421 | snapAnimation.snapTo(0); |
2405 | 421 | } | 422 | } |
2406 | 423 | |||
2407 | 424 | // expansion | ||
2408 | 425 | Component.onCompleted: internals.completed = true | ||
2409 | 426 | state: (internals.completed && styledItem.expansion.expanded) ? (listItemStyle.flickable ? "expandedWithFlickable" : "expandedNoFlickable") : "" | ||
2410 | 427 | states: [ | ||
2411 | 428 | State { | ||
2412 | 429 | name: "expandedNoFlickable" | ||
2413 | 430 | PropertyChanges { | ||
2414 | 431 | target: styledItem | ||
2415 | 432 | height: styledItem.expansion.height | ||
2416 | 433 | } | ||
2417 | 434 | }, | ||
2418 | 435 | State { | ||
2419 | 436 | name: "expandedWithFlickable" | ||
2420 | 437 | PropertyChanges { | ||
2421 | 438 | target: styledItem | ||
2422 | 439 | height: styledItem.expansion.height | ||
2423 | 440 | } | ||
2424 | 441 | PropertyChanges { | ||
2425 | 442 | target: listItemStyle.flickable | ||
2426 | 443 | // we do not need to restore the original values | ||
2427 | 444 | restoreEntryValues: false | ||
2428 | 445 | // and we should not get any binding updates even | ||
2429 | 446 | explicit: true | ||
2430 | 447 | contentY: { | ||
2431 | 448 | var bottom = styledItem.y + styledItem.expansion.height - listItemStyle.flickable.contentY + listItemStyle.flickable.originY; | ||
2432 | 449 | var dy = bottom - listItemStyle.flickable.height; | ||
2433 | 450 | if (dy > 0) { | ||
2434 | 451 | return listItemStyle.flickable.contentY + dy - listItemStyle.flickable.originY; | ||
2435 | 452 | } else { | ||
2436 | 453 | return listItemStyle.flickable.contentY; | ||
2437 | 454 | } | ||
2438 | 455 | } | ||
2439 | 456 | } | ||
2440 | 457 | } | ||
2441 | 458 | ] | ||
2442 | 459 | transitions: [ | ||
2443 | 460 | Transition { | ||
2444 | 461 | from: "" | ||
2445 | 462 | to: "expandedWithFlickable" | ||
2446 | 463 | reversible: true | ||
2447 | 464 | enabled: listItemStyle.animatePanels | ||
2448 | 465 | ParallelAnimation { | ||
2449 | 466 | UbuntuNumberAnimation { | ||
2450 | 467 | target: listItemStyle.flickable | ||
2451 | 468 | property: "contentY" | ||
2452 | 469 | } | ||
2453 | 470 | UbuntuNumberAnimation { | ||
2454 | 471 | target: styledItem | ||
2455 | 472 | property: "height" | ||
2456 | 473 | } | ||
2457 | 474 | } | ||
2458 | 475 | }, | ||
2459 | 476 | Transition { | ||
2460 | 477 | from: "" | ||
2461 | 478 | to: "expandedNoFlickable" | ||
2462 | 479 | reversible: true | ||
2463 | 480 | enabled: listItemStyle.animatePanels | ||
2464 | 481 | UbuntuNumberAnimation { | ||
2465 | 482 | target: styledItem | ||
2466 | 483 | property: "height" | ||
2467 | 484 | } | ||
2468 | 485 | } | ||
2469 | 486 | ] | ||
2470 | 422 | } | 487 | } |
2471 | 423 | 488 | ||
2472 | === modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/OverflowPanel.qml' | |||
2473 | --- src/Ubuntu/Components/Themes/Ambiance/1.3/OverflowPanel.qml 2015-04-29 08:55:31 +0000 | |||
2474 | +++ src/Ubuntu/Components/Themes/Ambiance/1.3/OverflowPanel.qml 2015-09-08 04:09:38 +0000 | |||
2475 | @@ -32,7 +32,7 @@ | |||
2476 | 32 | /*! | 32 | /*! |
2477 | 33 | The background color of the tabs panel and the actions overflow panel. | 33 | The background color of the tabs panel and the actions overflow panel. |
2478 | 34 | */ | 34 | */ |
2480 | 35 | property color backgroundColor: styledItem.panelColor | 35 | property color backgroundColor: theme.palette.normal.background |
2481 | 36 | 36 | ||
2482 | 37 | /*! | 37 | /*! |
2483 | 38 | The background color of the tapped item in the panel. | 38 | The background color of the tapped item in the panel. |
2484 | 39 | 39 | ||
2485 | === modified file 'src/Ubuntu/Components/Themes/Ambiance/Ambiance.pro' | |||
2486 | --- src/Ubuntu/Components/Themes/Ambiance/Ambiance.pro 2015-06-18 08:03:55 +0000 | |||
2487 | +++ src/Ubuntu/Components/Themes/Ambiance/Ambiance.pro 2015-09-08 04:09:38 +0000 | |||
2488 | @@ -84,8 +84,6 @@ | |||
2489 | 84 | 1.3/DialerHandStyle.qml \ | 84 | 1.3/DialerHandStyle.qml \ |
2490 | 85 | 1.3/DialerStyle.qml \ | 85 | 1.3/DialerStyle.qml \ |
2491 | 86 | 1.3/DialogForegroundStyle.qml \ | 86 | 1.3/DialogForegroundStyle.qml \ |
2492 | 87 | 1.3/HeadDividerStyle.qml \ | ||
2493 | 88 | 1.3/HeaderStyle.qml \ | ||
2494 | 89 | 1.3/HighlightMagnifier.qml \ | 87 | 1.3/HighlightMagnifier.qml \ |
2495 | 90 | 1.3/ListItemOptionSelectorStyle.qml \ | 88 | 1.3/ListItemOptionSelectorStyle.qml \ |
2496 | 91 | 1.3/ListItemStyle.qml \ | 89 | 1.3/ListItemStyle.qml \ |
2497 | 92 | 90 | ||
2498 | === modified file 'src/Ubuntu/Components/plugin/adapters/actionsproxy_p.cpp' | |||
2499 | --- src/Ubuntu/Components/plugin/adapters/actionsproxy_p.cpp 2014-09-01 06:56:39 +0000 | |||
2500 | +++ src/Ubuntu/Components/plugin/adapters/actionsproxy_p.cpp 2015-09-08 04:09:38 +0000 | |||
2501 | @@ -90,18 +90,18 @@ | |||
2502 | 90 | } | 90 | } |
2503 | 91 | if (watch) { | 91 | if (watch) { |
2504 | 92 | // connect to action proxy | 92 | // connect to action proxy |
2507 | 93 | QObject::connect(context, SIGNAL(activeChanged(bool)), | 93 | QObject::connect(context, SIGNAL(activeChanged()), |
2508 | 94 | this, SLOT(handleContextActivation(bool)), | 94 | this, SLOT(handleContextActivation()), |
2509 | 95 | Qt::DirectConnection); | 95 | Qt::DirectConnection); |
2510 | 96 | } else { | 96 | } else { |
2511 | 97 | // disconnect | 97 | // disconnect |
2514 | 98 | QObject::disconnect(context, SIGNAL(activeChanged(bool)), | 98 | QObject::disconnect(context, SIGNAL(activeChanged()), |
2515 | 99 | this, SLOT(handleContextActivation(bool))); | 99 | this, SLOT(handleContextActivation())); |
2516 | 100 | } | 100 | } |
2517 | 101 | } | 101 | } |
2518 | 102 | 102 | ||
2519 | 103 | // handles the local context activation | 103 | // handles the local context activation |
2521 | 104 | void ActionProxy::handleContextActivation(bool active) | 104 | void ActionProxy::handleContextActivation() |
2522 | 105 | { | 105 | { |
2523 | 106 | // sender is the context changing activation | 106 | // sender is the context changing activation |
2524 | 107 | UCActionContext *context = qobject_cast<UCActionContext*>(sender()); | 107 | UCActionContext *context = qobject_cast<UCActionContext*>(sender()); |
2525 | @@ -110,7 +110,7 @@ | |||
2526 | 110 | } | 110 | } |
2527 | 111 | // deactivate the previous context if any | 111 | // deactivate the previous context if any |
2528 | 112 | if (!m_activeContext.isNull()) { | 112 | if (!m_activeContext.isNull()) { |
2530 | 113 | if (!active) { | 113 | if (!context->active()) { |
2531 | 114 | // the slot has been called due to the previous active deactivation, | 114 | // the slot has been called due to the previous active deactivation, |
2532 | 115 | // so perform system cleanup | 115 | // so perform system cleanup |
2533 | 116 | clearContextActions(m_activeContext); | 116 | clearContextActions(m_activeContext); |
2534 | @@ -124,7 +124,7 @@ | |||
2535 | 124 | m_activeContext->setActive(false); | 124 | m_activeContext->setActive(false); |
2536 | 125 | } | 125 | } |
2537 | 126 | } | 126 | } |
2539 | 127 | if (active) { | 127 | if (context->active()) { |
2540 | 128 | // publish the context's actions to the system | 128 | // publish the context's actions to the system |
2541 | 129 | publishContextActions(context); | 129 | publishContextActions(context); |
2542 | 130 | context->markActionsPublished(true); | 130 | context->markActionsPublished(true); |
2543 | 131 | 131 | ||
2544 | === modified file 'src/Ubuntu/Components/plugin/adapters/actionsproxy_p.h' | |||
2545 | --- src/Ubuntu/Components/plugin/adapters/actionsproxy_p.h 2014-09-01 06:56:39 +0000 | |||
2546 | +++ src/Ubuntu/Components/plugin/adapters/actionsproxy_p.h 2015-09-08 04:09:38 +0000 | |||
2547 | @@ -48,7 +48,7 @@ | |||
2548 | 48 | 48 | ||
2549 | 49 | protected Q_SLOTS: | 49 | protected Q_SLOTS: |
2550 | 50 | void watchContextActivation(UCActionContext *context, bool watch); | 50 | void watchContextActivation(UCActionContext *context, bool watch); |
2552 | 51 | void handleContextActivation(bool active); | 51 | void handleContextActivation(); |
2553 | 52 | virtual void clearContextActions(UCActionContext *context); | 52 | virtual void clearContextActions(UCActionContext *context); |
2554 | 53 | virtual void publishContextActions(UCActionContext *context); | 53 | virtual void publishContextActions(UCActionContext *context); |
2555 | 54 | 54 | ||
2556 | 55 | 55 | ||
2557 | === modified file 'src/Ubuntu/Components/plugin/i18n.cpp' | |||
2558 | --- src/Ubuntu/Components/plugin/i18n.cpp 2015-03-03 13:47:48 +0000 | |||
2559 | +++ src/Ubuntu/Components/plugin/i18n.cpp 2015-09-08 04:09:38 +0000 | |||
2560 | @@ -17,6 +17,7 @@ | |||
2561 | 17 | */ | 17 | */ |
2562 | 18 | 18 | ||
2563 | 19 | #include "i18n.h" | 19 | #include "i18n.h" |
2564 | 20 | #include "timeutils_p.h" | ||
2565 | 20 | #include <QtCore/QDir> | 21 | #include <QtCore/QDir> |
2566 | 21 | 22 | ||
2567 | 22 | namespace C { | 23 | namespace C { |
2568 | @@ -252,3 +253,76 @@ | |||
2569 | 252 | Q_UNUSED(context); | 253 | Q_UNUSED(context); |
2570 | 253 | return text; | 254 | return text; |
2571 | 254 | } | 255 | } |
2572 | 256 | /*! | ||
2573 | 257 | * \qmlmethod string i18n::relativeDateTime(datetime dateTime) | ||
2574 | 258 | * Translate a datetime based on proximity to current time. | ||
2575 | 259 | */ | ||
2576 | 260 | QString UbuntuI18n::relativeDateTime(const QDateTime& datetime) | ||
2577 | 261 | { | ||
2578 | 262 | QDateTime relativeTo(QDateTime::currentDateTime()); | ||
2579 | 263 | const date_proximity_t prox = getDateProximity(relativeTo, datetime); | ||
2580 | 264 | |||
2581 | 265 | switch (prox) { | ||
2582 | 266 | case DATE_PROXIMITY_NOW: | ||
2583 | 267 | /* TRANSLATORS: Time based "this is happening/happened now" */ | ||
2584 | 268 | return dtr("ubuntu-ui-toolkit", "Now"); | ||
2585 | 269 | |||
2586 | 270 | case DATE_PROXIMITY_HOUR: | ||
2587 | 271 | { | ||
2588 | 272 | qint64 diff = datetime.toMSecsSinceEpoch() - relativeTo.toMSecsSinceEpoch(); | ||
2589 | 273 | qint64 minutes = qRound(float(diff) / 60000); | ||
2590 | 274 | if (minutes < 0) { | ||
2591 | 275 | return dtr("ubuntu-ui-toolkit", "%1 minute ago", "%1 minutes ago", qAbs(minutes)).arg(qAbs(minutes)); | ||
2592 | 276 | } | ||
2593 | 277 | return dtr("ubuntu-ui-toolkit", "%1 minute", "%1 minutes", minutes).arg(minutes); | ||
2594 | 278 | } | ||
2595 | 279 | |||
2596 | 280 | case DATE_PROXIMITY_TODAY: | ||
2597 | 281 | /* en_US example: "1:00 PM" */ | ||
2598 | 282 | /* TRANSLATORS: Please translated these to your locale datetime format using the format specified by | ||
2599 | 283 | https://qt-project.org/doc/qt-5-snapshot/qdatetime.html#fromString-2 */ | ||
2600 | 284 | return datetime.toString(isLocale12h() ? dtr("ubuntu-ui-toolkit", "h:mm ap"): | ||
2601 | 285 | /* TRANSLATORS: Please translated these to your locale datetime format using the format specified by | ||
2602 | 286 | https://qt-project.org/doc/qt-5-snapshot/qdatetime.html#fromString-2 */ | ||
2603 | 287 | dtr("ubuntu-ui-toolkit", "HH:mm")); | ||
2604 | 288 | |||
2605 | 289 | case DATE_PROXIMITY_YESTERDAY: | ||
2606 | 290 | /* en_US example: "Yesterday 13:00" */ | ||
2607 | 291 | /* TRANSLATORS: Please translated these to your locale datetime format using the format specified by | ||
2608 | 292 | https://qt-project.org/doc/qt-5-snapshot/qdatetime.html#fromString-2 */ | ||
2609 | 293 | return datetime.toString(isLocale12h() ? dtr("ubuntu-ui-toolkit", "'Yesterday\u2003'h:mm ap") : | ||
2610 | 294 | /* TRANSLATORS: Please translated these to your locale datetime format using the format specified by | ||
2611 | 295 | https://qt-project.org/doc/qt-5-snapshot/qdatetime.html#fromString-2 */ | ||
2612 | 296 | dtr("ubuntu-ui-toolkit", "'Yesterday\u2003'HH:mm")); | ||
2613 | 297 | |||
2614 | 298 | case DATE_PROXIMITY_TOMORROW: | ||
2615 | 299 | /* en_US example: "Tomorrow 1:00 PM" */ | ||
2616 | 300 | /* TRANSLATORS: Please translated these to your locale datetime format using the format specified by | ||
2617 | 301 | https://qt-project.org/doc/qt-5-snapshot/qdatetime.html#fromString-2 */ | ||
2618 | 302 | return datetime.toString(isLocale12h() ? dtr("ubuntu-ui-toolkit", "'Tomorrow\u2003'h:mm ap") : | ||
2619 | 303 | /* TRANSLATORS: Please translated these to your locale datetime format using the format specified by | ||
2620 | 304 | https://qt-project.org/doc/qt-5-snapshot/qdatetime.html#fromString-2 */ | ||
2621 | 305 | dtr("ubuntu-ui-toolkit", "'Tomorrow\u2003'HH:mm")); | ||
2622 | 306 | |||
2623 | 307 | case DATE_PROXIMITY_LAST_WEEK: | ||
2624 | 308 | case DATE_PROXIMITY_NEXT_WEEK: | ||
2625 | 309 | /* en_US example: "Fri 1:00 PM" */ | ||
2626 | 310 | /* TRANSLATORS: Please translated these to your locale datetime format using the format specified by | ||
2627 | 311 | https://qt-project.org/doc/qt-5-snapshot/qdatetime.html#fromString-2 */ | ||
2628 | 312 | return datetime.toString(isLocale12h() ? dtr("ubuntu-ui-toolkit", "ddd'\u2003'h:mm ap") : | ||
2629 | 313 | /* TRANSLATORS: Please translated these to your locale datetime format using the format specified by | ||
2630 | 314 | https://qt-project.org/doc/qt-5-snapshot/qdatetime.html#fromString-2 */ | ||
2631 | 315 | dtr("ubuntu-ui-toolkit", "ddd'\u2003'HH:mm")); | ||
2632 | 316 | |||
2633 | 317 | case DATE_PROXIMITY_FAR_BACK: | ||
2634 | 318 | case DATE_PROXIMITY_FAR_FORWARD: | ||
2635 | 319 | default: | ||
2636 | 320 | /* TRANSLATORS: Please translated these to your locale datetime format using the format specified by | ||
2637 | 321 | https://qt-project.org/doc/qt-5-snapshot/qdatetime.html#fromString-2 */ | ||
2638 | 322 | return datetime.toString(isLocale12h() ? dtr("ubuntu-ui-toolkit", "ddd d MMM'\u2003'h:mm ap") : | ||
2639 | 323 | /* TRANSLATORS: Please translated these to your locale datetime format using the format specified by | ||
2640 | 324 | https://qt-project.org/doc/qt-5-snapshot/qdatetime.html#fromString-2 */ | ||
2641 | 325 | dtr("ubuntu-ui-toolkit", "ddd d MMM'\u2003'HH:mm")); | ||
2642 | 326 | } | ||
2643 | 327 | return datetime.toString(Qt::DefaultLocaleShortDate); | ||
2644 | 328 | } | ||
2645 | 255 | 329 | ||
2646 | === modified file 'src/Ubuntu/Components/plugin/i18n.h' | |||
2647 | --- src/Ubuntu/Components/plugin/i18n.h 2015-02-03 18:11:32 +0000 | |||
2648 | +++ src/Ubuntu/Components/plugin/i18n.h 2015-09-08 04:09:38 +0000 | |||
2649 | @@ -50,6 +50,7 @@ | |||
2650 | 50 | Q_INVOKABLE QString dctr(const QString& domain, const QString& context, const QString& text); | 50 | Q_INVOKABLE QString dctr(const QString& domain, const QString& context, const QString& text); |
2651 | 51 | Q_INVOKABLE QString tag(const QString& text); | 51 | Q_INVOKABLE QString tag(const QString& text); |
2652 | 52 | Q_INVOKABLE QString tag(const QString& context, const QString& text); | 52 | Q_INVOKABLE QString tag(const QString& context, const QString& text); |
2653 | 53 | Q_INVOKABLE QString relativeDateTime(const QDateTime& datetime); | ||
2654 | 53 | 54 | ||
2655 | 54 | // getter | 55 | // getter |
2656 | 55 | QString domain() const; | 56 | QString domain() const; |
2657 | 56 | 57 | ||
2658 | === modified file 'src/Ubuntu/Components/plugin/plugin.cpp' | |||
2659 | --- src/Ubuntu/Components/plugin/plugin.cpp 2015-08-12 09:54:40 +0000 | |||
2660 | +++ src/Ubuntu/Components/plugin/plugin.cpp 2015-09-08 04:09:38 +0000 | |||
2661 | @@ -62,6 +62,9 @@ | |||
2662 | 62 | #include "uclistitemstyle.h" | 62 | #include "uclistitemstyle.h" |
2663 | 63 | #include "ucserviceproperties.h" | 63 | #include "ucserviceproperties.h" |
2664 | 64 | #include "ucnamespace.h" | 64 | #include "ucnamespace.h" |
2665 | 65 | #include "ucactionitem.h" | ||
2666 | 66 | #include "uchaptics.h" | ||
2667 | 67 | #include "ucabstractbutton.h" | ||
2668 | 65 | 68 | ||
2669 | 66 | #include <sys/types.h> | 69 | #include <sys/types.h> |
2670 | 67 | #include <unistd.h> | 70 | #include <unistd.h> |
2671 | @@ -116,6 +119,14 @@ | |||
2672 | 116 | return new UCNamespaceV13(); | 119 | return new UCNamespaceV13(); |
2673 | 117 | } | 120 | } |
2674 | 118 | 121 | ||
2675 | 122 | static QObject *registerHaptics(QQmlEngine *engine, QJSEngine *scriptEngine) | ||
2676 | 123 | { | ||
2677 | 124 | Q_UNUSED(engine) | ||
2678 | 125 | Q_UNUSED(scriptEngine) | ||
2679 | 126 | |||
2680 | 127 | return new UCHaptics(); | ||
2681 | 128 | } | ||
2682 | 129 | |||
2683 | 119 | void UbuntuComponentsPlugin::initializeBaseUrl() | 130 | void UbuntuComponentsPlugin::initializeBaseUrl() |
2684 | 120 | { | 131 | { |
2685 | 121 | if (!m_baseUrl.isValid()) { | 132 | if (!m_baseUrl.isValid()) { |
2686 | @@ -174,6 +185,8 @@ | |||
2687 | 174 | qmlRegisterSingletonType<UCUriHandler>(uri, major, minor, "UriHandler", registerUriHandler); | 185 | qmlRegisterSingletonType<UCUriHandler>(uri, major, minor, "UriHandler", registerUriHandler); |
2688 | 175 | qmlRegisterType<UCMouse>(uri, major, minor, "Mouse"); | 186 | qmlRegisterType<UCMouse>(uri, major, minor, "Mouse"); |
2689 | 176 | qmlRegisterType<UCInverseMouse>(uri, major, minor, "InverseMouse"); | 187 | qmlRegisterType<UCInverseMouse>(uri, major, minor, "InverseMouse"); |
2690 | 188 | qmlRegisterType<UCActionItem>(uri, major, minor, "ActionItem"); | ||
2691 | 189 | qmlRegisterSingletonType<UCHaptics>(uri, major, minor, "Haptics", registerHaptics); | ||
2692 | 177 | } | 190 | } |
2693 | 178 | 191 | ||
2694 | 179 | void UbuntuComponentsPlugin::registerTypes(const char *uri) | 192 | void UbuntuComponentsPlugin::registerTypes(const char *uri) |
2695 | @@ -211,6 +224,8 @@ | |||
2696 | 211 | 224 | ||
2697 | 212 | // register 1.3 API | 225 | // register 1.3 API |
2698 | 213 | qmlRegisterType<UCListItem13>(uri, 1, 3, "ListItem"); | 226 | qmlRegisterType<UCListItem13>(uri, 1, 3, "ListItem"); |
2699 | 227 | qmlRegisterType<UCListItemExpansion>(); | ||
2700 | 228 | qmlRegisterUncreatableType<UCViewItemsAttached13>(uri, 1, 3, "ViewItems", "No create"); | ||
2701 | 214 | qmlRegisterType<UCTheme>(uri, 1, 3, "ThemeSettings"); | 229 | qmlRegisterType<UCTheme>(uri, 1, 3, "ThemeSettings"); |
2702 | 215 | qmlRegisterType<UCStyledItemBase, 2>(uri, 1, 3, "StyledItem"); | 230 | qmlRegisterType<UCStyledItemBase, 2>(uri, 1, 3, "StyledItem"); |
2703 | 216 | qmlRegisterSingletonType<UCNamespaceV13>(uri, 1, 3, "Ubuntu", registerUbuntuNamespace13); | 231 | qmlRegisterSingletonType<UCNamespaceV13>(uri, 1, 3, "Ubuntu", registerUbuntuNamespace13); |
2704 | @@ -220,6 +235,7 @@ | |||
2705 | 220 | qmlRegisterType<UCUbuntuShape, 2>(uri, 1, 3, "UbuntuShape"); | 235 | qmlRegisterType<UCUbuntuShape, 2>(uri, 1, 3, "UbuntuShape"); |
2706 | 221 | qmlRegisterType<UCProportionalShape>(uri, 1, 3, "ProportionalShape"); | 236 | qmlRegisterType<UCProportionalShape>(uri, 1, 3, "ProportionalShape"); |
2707 | 222 | qmlRegisterType<LiveTimer>(uri, 1, 3, "LiveTimer"); | 237 | qmlRegisterType<LiveTimer>(uri, 1, 3, "LiveTimer"); |
2708 | 238 | qmlRegisterType<UCAbstractButton>(uri, 1, 3, "AbstractButton"); | ||
2709 | 223 | } | 239 | } |
2710 | 224 | 240 | ||
2711 | 225 | void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri) | 241 | void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri) |
2712 | @@ -244,6 +260,8 @@ | |||
2713 | 244 | 260 | ||
2714 | 245 | UCDeprecatedTheme::instance().registerToContext(context); | 261 | UCDeprecatedTheme::instance().registerToContext(context); |
2715 | 246 | 262 | ||
2716 | 263 | HapticsProxy::instance().setEngine(context->engine()); | ||
2717 | 264 | |||
2718 | 247 | context->setContextProperty("i18n", &UbuntuI18n::instance()); | 265 | context->setContextProperty("i18n", &UbuntuI18n::instance()); |
2719 | 248 | ContextPropertyChangeListener *i18nChangeListener = | 266 | ContextPropertyChangeListener *i18nChangeListener = |
2720 | 249 | new ContextPropertyChangeListener(context, "i18n"); | 267 | new ContextPropertyChangeListener(context, "i18n"); |
2721 | 250 | 268 | ||
2722 | === modified file 'src/Ubuntu/Components/plugin/plugin.pri' | |||
2723 | --- src/Ubuntu/Components/plugin/plugin.pri 2015-08-18 22:14:51 +0000 | |||
2724 | +++ src/Ubuntu/Components/plugin/plugin.pri 2015-09-08 04:09:38 +0000 | |||
2725 | @@ -80,7 +80,10 @@ | |||
2726 | 80 | $$PWD/ucstylehints.h \ | 80 | $$PWD/ucstylehints.h \ |
2727 | 81 | $$PWD/livetimer.h \ | 81 | $$PWD/livetimer.h \ |
2728 | 82 | $$PWD/livetimer_p.h \ | 82 | $$PWD/livetimer_p.h \ |
2730 | 83 | $$PWD/timeutils_p.h | 83 | $$PWD/timeutils_p.h \ |
2731 | 84 | $$PWD/ucactionitem.h \ | ||
2732 | 85 | $$PWD/uchaptics.h \ | ||
2733 | 86 | $$PWD/ucabstractbutton.h | ||
2734 | 84 | 87 | ||
2735 | 85 | SOURCES += $$PWD/plugin.cpp \ | 88 | SOURCES += $$PWD/plugin.cpp \ |
2736 | 86 | $$PWD/uctheme.cpp \ | 89 | $$PWD/uctheme.cpp \ |
2737 | @@ -127,12 +130,16 @@ | |||
2738 | 127 | $$PWD/ucserviceproperties.cpp \ | 130 | $$PWD/ucserviceproperties.cpp \ |
2739 | 128 | $$PWD/privates/listitemdragarea.cpp \ | 131 | $$PWD/privates/listitemdragarea.cpp \ |
2740 | 129 | $$PWD/privates/listitemdraghandler.cpp \ | 132 | $$PWD/privates/listitemdraghandler.cpp \ |
2741 | 133 | $$PWD/privates/listitemexpansion.cpp \ | ||
2742 | 130 | $$PWD/ucnamespace.cpp \ | 134 | $$PWD/ucnamespace.cpp \ |
2743 | 131 | $$PWD/ucdeprecatedtheme.cpp \ | 135 | $$PWD/ucdeprecatedtheme.cpp \ |
2744 | 132 | $$PWD/ucdefaulttheme.cpp \ | 136 | $$PWD/ucdefaulttheme.cpp \ |
2745 | 133 | $$PWD/ucstylehints.cpp \ | 137 | $$PWD/ucstylehints.cpp \ |
2746 | 134 | $$PWD/livetimer.cpp \ | 138 | $$PWD/livetimer.cpp \ |
2748 | 135 | $$PWD/livetimer_p.cpp | 139 | $$PWD/livetimer_p.cpp \ |
2749 | 140 | $$PWD/ucactionitem.cpp \ | ||
2750 | 141 | $$PWD/uchaptics.cpp \ | ||
2751 | 142 | $$PWD/ucabstractbutton.cpp | ||
2752 | 136 | 143 | ||
2753 | 137 | # adapters | 144 | # adapters |
2754 | 138 | SOURCES += $$PWD/adapters/alarmsadapter_organizer.cpp | 145 | SOURCES += $$PWD/adapters/alarmsadapter_organizer.cpp |
2755 | 139 | 146 | ||
2756 | === modified file 'src/Ubuntu/Components/plugin/privates/listitemdragarea.cpp' | |||
2757 | --- src/Ubuntu/Components/plugin/privates/listitemdragarea.cpp 2015-04-13 11:11:59 +0000 | |||
2758 | +++ src/Ubuntu/Components/plugin/privates/listitemdragarea.cpp 2015-09-08 04:09:38 +0000 | |||
2759 | @@ -47,13 +47,12 @@ | |||
2760 | 47 | setObjectName("drag_area"); | 47 | setObjectName("drag_area"); |
2761 | 48 | } | 48 | } |
2762 | 49 | 49 | ||
2764 | 50 | void ListItemDragArea::init() | 50 | void ListItemDragArea::init(UCViewItemsAttached *viewItems) |
2765 | 51 | { | 51 | { |
2766 | 52 | setParentItem(static_cast<QQuickItem*>(parent())); | 52 | setParentItem(static_cast<QQuickItem*>(parent())); |
2767 | 53 | QQuickAnchors *anchors = QQuickItemPrivate::get(this)->anchors(); | 53 | QQuickAnchors *anchors = QQuickItemPrivate::get(this)->anchors(); |
2768 | 54 | anchors->setFill(parentItem()); | 54 | anchors->setFill(parentItem()); |
2771 | 55 | viewAttached = static_cast<UCViewItemsAttached*>( | 55 | viewAttached = viewItems; |
2770 | 56 | qmlAttachedPropertiesObject<UCViewItemsAttached>(listView)); | ||
2772 | 57 | reset(); | 56 | reset(); |
2773 | 58 | } | 57 | } |
2774 | 59 | 58 | ||
2775 | 60 | 59 | ||
2776 | === modified file 'src/Ubuntu/Components/plugin/privates/listitemdragarea.h' | |||
2777 | --- src/Ubuntu/Components/plugin/privates/listitemdragarea.h 2015-02-24 15:57:53 +0000 | |||
2778 | +++ src/Ubuntu/Components/plugin/privates/listitemdragarea.h 2015-09-08 04:09:38 +0000 | |||
2779 | @@ -27,7 +27,7 @@ | |||
2780 | 27 | Q_OBJECT | 27 | Q_OBJECT |
2781 | 28 | public: | 28 | public: |
2782 | 29 | explicit ListItemDragArea(QQuickItem *parent = 0); | 29 | explicit ListItemDragArea(QQuickItem *parent = 0); |
2784 | 30 | void init(); | 30 | void init(UCViewItemsAttached *viewItems); |
2785 | 31 | void reset(); | 31 | void reset(); |
2786 | 32 | 32 | ||
2787 | 33 | protected: | 33 | protected: |
2788 | 34 | 34 | ||
2789 | === added file 'src/Ubuntu/Components/plugin/privates/listitemexpansion.cpp' | |||
2790 | --- src/Ubuntu/Components/plugin/privates/listitemexpansion.cpp 1970-01-01 00:00:00 +0000 | |||
2791 | +++ src/Ubuntu/Components/plugin/privates/listitemexpansion.cpp 2015-09-08 04:09:38 +0000 | |||
2792 | @@ -0,0 +1,106 @@ | |||
2793 | 1 | /* | ||
2794 | 2 | * Copyright 2015 Canonical Ltd. | ||
2795 | 3 | * | ||
2796 | 4 | * This program is free software; you can redistribute it and/or modify | ||
2797 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
2798 | 6 | * the Free Software Foundation; version 3. | ||
2799 | 7 | * | ||
2800 | 8 | * This program is distributed in the hope that it will be useful, | ||
2801 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2802 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2803 | 11 | * GNU Lesser General Public License for more details. | ||
2804 | 12 | * | ||
2805 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2806 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2807 | 15 | */ | ||
2808 | 16 | |||
2809 | 17 | #include "uclistitem.h" | ||
2810 | 18 | #include "uclistitem_p.h" | ||
2811 | 19 | |||
2812 | 20 | UCListItemExpansion::UCListItemExpansion(QObject *parent) | ||
2813 | 21 | : QObject(parent) | ||
2814 | 22 | , m_listItem(static_cast<UCListItem13*>(parent)) | ||
2815 | 23 | , m_height(0.0) | ||
2816 | 24 | , m_filtering(false) | ||
2817 | 25 | { | ||
2818 | 26 | } | ||
2819 | 27 | |||
2820 | 28 | bool UCListItemExpansion::expandedLocked() | ||
2821 | 29 | { | ||
2822 | 30 | UCListItemPrivate *listItem = UCListItemPrivate::get(m_listItem); | ||
2823 | 31 | UCViewItemsAttachedPrivate *viewItems = UCViewItemsAttachedPrivate::get(listItem->parentAttached); | ||
2824 | 32 | return expanded() && !((viewItems->expansionFlags & UCViewItemsAttached::UnlockExpanded) == UCViewItemsAttached::UnlockExpanded); | ||
2825 | 33 | } | ||
2826 | 34 | |||
2827 | 35 | void UCListItemExpansion::enableClickFiltering(bool enable) | ||
2828 | 36 | { | ||
2829 | 37 | if (m_filtering == enable) { | ||
2830 | 38 | return; | ||
2831 | 39 | } | ||
2832 | 40 | m_filtering = enable; | ||
2833 | 41 | if (m_filtering) { | ||
2834 | 42 | m_listItem->window()->installEventFilter(this); | ||
2835 | 43 | } else { | ||
2836 | 44 | m_listItem->window()->removeEventFilter(this); | ||
2837 | 45 | } | ||
2838 | 46 | } | ||
2839 | 47 | |||
2840 | 48 | // event filter for external mouse presses to collapse when pressed outside | ||
2841 | 49 | bool UCListItemExpansion::eventFilter(QObject *target, QEvent *event) | ||
2842 | 50 | { | ||
2843 | 51 | if (event->type() == QEvent::MouseButtonPress) { | ||
2844 | 52 | QMouseEvent *mouse = static_cast<QMouseEvent*>(event); | ||
2845 | 53 | QQuickWindow *window = qobject_cast<QQuickWindow*>(target); | ||
2846 | 54 | if (window) { | ||
2847 | 55 | QPointF myPos(window->contentItem()->mapToItem(m_listItem, mouse->localPos())); | ||
2848 | 56 | if (!m_listItem->contains(myPos)) { | ||
2849 | 57 | UCListItemPrivate *listItem = UCListItemPrivate::get(m_listItem); | ||
2850 | 58 | UCViewItemsAttachedPrivate *viewItems = UCViewItemsAttachedPrivate::get(listItem->parentAttached); | ||
2851 | 59 | if (viewItems) { | ||
2852 | 60 | // collapse all as there can be only one expanded when the flag is set | ||
2853 | 61 | viewItems->collapseAll(); | ||
2854 | 62 | } | ||
2855 | 63 | } | ||
2856 | 64 | } | ||
2857 | 65 | } | ||
2858 | 66 | return false; | ||
2859 | 67 | } | ||
2860 | 68 | |||
2861 | 69 | |||
2862 | 70 | bool UCListItemExpansion::expanded() | ||
2863 | 71 | { | ||
2864 | 72 | UCListItemPrivate *listItem = UCListItemPrivate::get(m_listItem); | ||
2865 | 73 | UCViewItemsAttachedPrivate *viewItems = UCViewItemsAttachedPrivate::get(listItem->parentAttached); | ||
2866 | 74 | return (viewItems && viewItems->expansionList.contains(listItem->index())); | ||
2867 | 75 | } | ||
2868 | 76 | |||
2869 | 77 | void UCListItemExpansion::setExpanded(bool expanded) | ||
2870 | 78 | { | ||
2871 | 79 | if (this->expanded() == expanded) { | ||
2872 | 80 | return; | ||
2873 | 81 | } | ||
2874 | 82 | UCListItemPrivate *listItem = UCListItemPrivate::get(m_listItem); | ||
2875 | 83 | UCViewItemsAttachedPrivate *viewItems = UCViewItemsAttachedPrivate::get(listItem->parentAttached); | ||
2876 | 84 | if (viewItems) { | ||
2877 | 85 | if (viewItems->expansionFlags & UCViewItemsAttached::Exclusive) { | ||
2878 | 86 | // collapse all the expanded ones | ||
2879 | 87 | viewItems->collapseAll(); | ||
2880 | 88 | } | ||
2881 | 89 | if (expanded) { | ||
2882 | 90 | viewItems->expand(listItem->index(), m_listItem); | ||
2883 | 91 | } else { | ||
2884 | 92 | viewItems->collapse(listItem->index()); | ||
2885 | 93 | } | ||
2886 | 94 | } | ||
2887 | 95 | UCListItemPrivate::get(m_listItem)->loadStyleItem(); | ||
2888 | 96 | // no need to emit changed signal, as ViewItems.expandedIndicesChanged is connected to the change signal | ||
2889 | 97 | } | ||
2890 | 98 | |||
2891 | 99 | void UCListItemExpansion::setHeight(qreal height) | ||
2892 | 100 | { | ||
2893 | 101 | if (m_height == height) { | ||
2894 | 102 | return; | ||
2895 | 103 | } | ||
2896 | 104 | m_height = height; | ||
2897 | 105 | Q_EMIT heightChanged(); | ||
2898 | 106 | } | ||
2899 | 0 | 107 | ||
2900 | === modified file 'src/Ubuntu/Components/plugin/sortfiltermodel.cpp' | |||
2901 | --- src/Ubuntu/Components/plugin/sortfiltermodel.cpp 2015-03-03 13:47:48 +0000 | |||
2902 | +++ src/Ubuntu/Components/plugin/sortfiltermodel.cpp 2015-09-08 04:09:38 +0000 | |||
2903 | @@ -113,9 +113,12 @@ | |||
2904 | 113 | QSortFilterProxyModelQML::roleByName(const QString& roleName) const | 113 | QSortFilterProxyModelQML::roleByName(const QString& roleName) const |
2905 | 114 | { | 114 | { |
2906 | 115 | const QHash<int, QByteArray> roles = roleNames(); | 115 | const QHash<int, QByteArray> roles = roleNames(); |
2910 | 116 | for(int role = 0; role < roles.count(); role++) | 116 | QHashIterator<int, QByteArray> i(roles); |
2911 | 117 | if (roles[role] == roleName) | 117 | while (i.hasNext()) { |
2912 | 118 | return role; | 118 | i.next(); |
2913 | 119 | if (i.value() == roleName) | ||
2914 | 120 | return i.key(); | ||
2915 | 121 | } | ||
2916 | 119 | return 0; | 122 | return 0; |
2917 | 120 | } | 123 | } |
2918 | 121 | 124 | ||
2919 | 122 | 125 | ||
2920 | === modified file 'src/Ubuntu/Components/plugin/timeutils_p.h' | |||
2921 | --- src/Ubuntu/Components/plugin/timeutils_p.h 2015-07-20 15:34:32 +0000 | |||
2922 | +++ src/Ubuntu/Components/plugin/timeutils_p.h 2015-09-08 04:09:38 +0000 | |||
2923 | @@ -20,9 +20,33 @@ | |||
2924 | 20 | #include "livetimer.h" | 20 | #include "livetimer.h" |
2925 | 21 | 21 | ||
2926 | 22 | #include <QDateTime> | 22 | #include <QDateTime> |
2927 | 23 | #include <QLocale> | ||
2928 | 23 | #include <QObject> | 24 | #include <QObject> |
2929 | 24 | #include <QTimer> | 25 | #include <QTimer> |
2930 | 25 | 26 | ||
2931 | 27 | /* Check the system locale setting to see if the format is 24-hour | ||
2932 | 28 | time or 12-hour time */ | ||
2933 | 29 | inline bool isLocale12h(void) | ||
2934 | 30 | { | ||
2935 | 31 | QString strTimeFormat = QLocale::system().timeFormat(); | ||
2936 | 32 | QStringList includes; includes << "AP"; includes << "ap"; | ||
2937 | 33 | QStringList excludes; excludes << "H"; excludes << "HH"; | ||
2938 | 34 | |||
2939 | 35 | Q_FOREACH(const QString& exclude, excludes) { | ||
2940 | 36 | if (strTimeFormat.contains(exclude)) { | ||
2941 | 37 | return false; | ||
2942 | 38 | } | ||
2943 | 39 | } | ||
2944 | 40 | |||
2945 | 41 | Q_FOREACH(const QString& include, includes) { | ||
2946 | 42 | if (strTimeFormat.contains(include)) { | ||
2947 | 43 | return true; | ||
2948 | 44 | } | ||
2949 | 45 | } | ||
2950 | 46 | |||
2951 | 47 | return false; | ||
2952 | 48 | } | ||
2953 | 49 | |||
2954 | 26 | typedef enum | 50 | typedef enum |
2955 | 27 | { | 51 | { |
2956 | 28 | DATE_PROXIMITY_NOW, | 52 | DATE_PROXIMITY_NOW, |
2957 | 29 | 53 | ||
2958 | === added file 'src/Ubuntu/Components/plugin/ucabstractbutton.cpp' | |||
2959 | --- src/Ubuntu/Components/plugin/ucabstractbutton.cpp 1970-01-01 00:00:00 +0000 | |||
2960 | +++ src/Ubuntu/Components/plugin/ucabstractbutton.cpp 2015-09-08 04:09:38 +0000 | |||
2961 | @@ -0,0 +1,156 @@ | |||
2962 | 1 | /* | ||
2963 | 2 | * Copyright 2015 Canonical Ltd. | ||
2964 | 3 | * | ||
2965 | 4 | * This program is free software; you can redistribute it and/or modify | ||
2966 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
2967 | 6 | * the Free Software Foundation; version 3. | ||
2968 | 7 | * | ||
2969 | 8 | * This program is distributed in the hope that it will be useful, | ||
2970 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2971 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2972 | 11 | * GNU Lesser General Public License for more details. | ||
2973 | 12 | * | ||
2974 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2975 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2976 | 15 | */ | ||
2977 | 16 | |||
2978 | 17 | #include "ucabstractbutton.h" | ||
2979 | 18 | #include "uchaptics.h" | ||
2980 | 19 | #include <QtQuick/private/qquickitem_p.h> | ||
2981 | 20 | #include <QtQuick/private/qquickmousearea_p.h> | ||
2982 | 21 | #include <QtQml/private/qqmlglobal_p.h> | ||
2983 | 22 | |||
2984 | 23 | /*! | ||
2985 | 24 | \qmltype AbstractButton | ||
2986 | 25 | \instantiates UCAbstractButton | ||
2987 | 26 | \inqmlmodule Ubuntu.Components 1.1 | ||
2988 | 27 | \ingroup ubuntu | ||
2989 | 28 | \brief The AbstractButton class defines the behavior of the button. | ||
2990 | 29 | |||
2991 | 30 | This class defines the behavior of the button. All components deriving from | ||
2992 | 31 | this class support haptic feedback out of the box. | ||
2993 | 32 | |||
2994 | 33 | If an action is specified, the button's clicked signal will trigger the action. | ||
2995 | 34 | Subclasses of AbstractButton can use other properties of action (for example | ||
2996 | 35 | the text and iconName). | ||
2997 | 36 | */ | ||
2998 | 37 | |||
2999 | 38 | /*! | ||
3000 | 39 | * | ||
3001 | 40 | * \qmlsignal AbstractButton::clicked() | ||
3002 | 41 | * This handler is called when there is a mouse click on the button and the button | ||
3003 | 42 | * is not disabled. If \l {ActionItem::action}{action} is defined, the action will be triggered. | ||
3004 | 43 | */ | ||
3005 | 44 | |||
3006 | 45 | /*! | ||
3007 | 46 | * | ||
3008 | 47 | * \qmlsignal AbstractButton::pressAndHold() | ||
3009 | 48 | * This handler is called when there is a long press. | ||
3010 | 49 | */ | ||
3011 | 50 | |||
3012 | 51 | UCAbstractButton::UCAbstractButton(QQuickItem *parent) | ||
3013 | 52 | : UCActionItem(parent) | ||
3014 | 53 | , m_mouseArea(new QQuickMouseArea) | ||
3015 | 54 | , m_acceptEvents(true) | ||
3016 | 55 | { | ||
3017 | 56 | setActiveFocusOnPress(true); | ||
3018 | 57 | } | ||
3019 | 58 | |||
3020 | 59 | bool UCAbstractButton::isPressAndHoldConnected() | ||
3021 | 60 | { | ||
3022 | 61 | static QMetaMethod method = QMetaMethod::fromSignal(&UCAbstractButton::pressAndHold); | ||
3023 | 62 | static int signalIdx = QMetaObjectPrivate::signalIndex(method); | ||
3024 | 63 | return QObjectPrivate::get(this)->isSignalConnected(signalIdx); | ||
3025 | 64 | } | ||
3026 | 65 | |||
3027 | 66 | void UCAbstractButton::classBegin() | ||
3028 | 67 | { | ||
3029 | 68 | UCActionItem::classBegin(); | ||
3030 | 69 | |||
3031 | 70 | // make sure we have the haptics set up! | ||
3032 | 71 | HapticsProxy::instance().initialize(); | ||
3033 | 72 | |||
3034 | 73 | // set up mouse area | ||
3035 | 74 | QQml_setParent_noEvent(m_mouseArea, this); | ||
3036 | 75 | m_mouseArea->setParentItem(this); | ||
3037 | 76 | QQuickAnchors *anchors = QQuickItemPrivate::get(m_mouseArea)->anchors(); | ||
3038 | 77 | anchors->setFill(this); | ||
3039 | 78 | m_mouseArea->setHoverEnabled(true); | ||
3040 | 79 | } | ||
3041 | 80 | |||
3042 | 81 | void UCAbstractButton::componentComplete() | ||
3043 | 82 | { | ||
3044 | 83 | UCActionItem::componentComplete(); | ||
3045 | 84 | // connect to the right slot, using macros so we get the proper slot | ||
3046 | 85 | connect(this, SIGNAL(clicked()), this, SLOT(trigger())); | ||
3047 | 86 | |||
3048 | 87 | // bind mouse area | ||
3049 | 88 | connect(m_mouseArea, &QQuickMouseArea::pressedChanged, this, &UCAbstractButton::pressedChanged); | ||
3050 | 89 | connect(m_mouseArea, &QQuickMouseArea::hoveredChanged, this, &UCAbstractButton::hoveredChanged); | ||
3051 | 90 | connect(m_mouseArea, SIGNAL(clicked(QQuickMouseEvent*)), this, SLOT(_q_mouseAreaClicked())); | ||
3052 | 91 | if (isPressAndHoldConnected()) { | ||
3053 | 92 | connect(m_mouseArea, SIGNAL(pressAndHold(QQuickMouseEvent*)), this, SLOT(_q_mouseAreaPressAndHold())); | ||
3054 | 93 | } | ||
3055 | 94 | } | ||
3056 | 95 | |||
3057 | 96 | // handle mouseClicked with Haptics | ||
3058 | 97 | void UCAbstractButton::_q_mouseAreaClicked() | ||
3059 | 98 | { | ||
3060 | 99 | // required by the deprecated ListItem module | ||
3061 | 100 | if (!m_acceptEvents) { | ||
3062 | 101 | return; | ||
3063 | 102 | } | ||
3064 | 103 | // play haptics | ||
3065 | 104 | HapticsProxy::instance().play(QVariant()); | ||
3066 | 105 | Q_EMIT clicked(); | ||
3067 | 106 | } | ||
3068 | 107 | |||
3069 | 108 | // handle pressAndHold | ||
3070 | 109 | void UCAbstractButton::_q_mouseAreaPressAndHold() | ||
3071 | 110 | { | ||
3072 | 111 | // required by the deprecated ListItem module | ||
3073 | 112 | if (!m_acceptEvents) { | ||
3074 | 113 | return; | ||
3075 | 114 | } | ||
3076 | 115 | Q_EMIT pressAndHold(); | ||
3077 | 116 | } | ||
3078 | 117 | |||
3079 | 118 | // emit clicked when Enter/Return is pressed | ||
3080 | 119 | void UCAbstractButton::keyPressEvent(QKeyEvent *event) | ||
3081 | 120 | { | ||
3082 | 121 | UCActionItem::keyPressEvent(event); | ||
3083 | 122 | |||
3084 | 123 | switch (event->key()) { | ||
3085 | 124 | case Qt::Key_Enter: | ||
3086 | 125 | case Qt::Key_Return: | ||
3087 | 126 | // FIXME: space may also come here, however that depends on the button type | ||
3088 | 127 | // (i.e default Dialog btn) so we may need to add that to Button | ||
3089 | 128 | { | ||
3090 | 129 | Q_EMIT clicked(); | ||
3091 | 130 | break; | ||
3092 | 131 | } | ||
3093 | 132 | } | ||
3094 | 133 | } | ||
3095 | 134 | |||
3096 | 135 | /*! | ||
3097 | 136 | * \qmlproperty bool AbstractButton::pressed | ||
3098 | 137 | * True if the user presses a mouse button in the button's mouse area. | ||
3099 | 138 | */ | ||
3100 | 139 | bool UCAbstractButton::pressed() const | ||
3101 | 140 | { | ||
3102 | 141 | return m_mouseArea ? m_mouseArea->pressed() : false; | ||
3103 | 142 | } | ||
3104 | 143 | |||
3105 | 144 | /*! | ||
3106 | 145 | * \qmlproperty bool AbstractButton::hovered | ||
3107 | 146 | * True if the mouse cursor hovers over the button's mouse area. | ||
3108 | 147 | */ | ||
3109 | 148 | bool UCAbstractButton::hovered() const | ||
3110 | 149 | { | ||
3111 | 150 | return m_mouseArea ? m_mouseArea->hovered() : false; | ||
3112 | 151 | } | ||
3113 | 152 | |||
3114 | 153 | QQuickMouseArea *UCAbstractButton::privateMouseArea() const | ||
3115 | 154 | { | ||
3116 | 155 | return m_mouseArea; | ||
3117 | 156 | } | ||
3118 | 0 | 157 | ||
3119 | === added file 'src/Ubuntu/Components/plugin/ucabstractbutton.h' | |||
3120 | --- src/Ubuntu/Components/plugin/ucabstractbutton.h 1970-01-01 00:00:00 +0000 | |||
3121 | +++ src/Ubuntu/Components/plugin/ucabstractbutton.h 2015-09-08 04:09:38 +0000 | |||
3122 | @@ -0,0 +1,64 @@ | |||
3123 | 1 | /* | ||
3124 | 2 | * Copyright 2015 Canonical Ltd. | ||
3125 | 3 | * | ||
3126 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3127 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
3128 | 6 | * the Free Software Foundation; version 3. | ||
3129 | 7 | * | ||
3130 | 8 | * This program is distributed in the hope that it will be useful, | ||
3131 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3132 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3133 | 11 | * GNU Lesser General Public License for more details. | ||
3134 | 12 | * | ||
3135 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
3136 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3137 | 15 | */ | ||
3138 | 16 | |||
3139 | 17 | #ifndef UCABSTRACTBUTTON_H | ||
3140 | 18 | #define UCABSTRACTBUTTON_H | ||
3141 | 19 | |||
3142 | 20 | #include "ucactionitem.h" | ||
3143 | 21 | |||
3144 | 22 | class QQuickMouseArea; | ||
3145 | 23 | class UCAbstractButton : public UCActionItem | ||
3146 | 24 | { | ||
3147 | 25 | Q_OBJECT | ||
3148 | 26 | Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged) | ||
3149 | 27 | Q_PROPERTY(bool hovered READ hovered NOTIFY hoveredChanged) | ||
3150 | 28 | |||
3151 | 29 | // internal, declared to support the deprecated ListItem module | ||
3152 | 30 | Q_PROPERTY(bool __acceptEvents MEMBER m_acceptEvents) | ||
3153 | 31 | Q_PROPERTY(QQuickMouseArea *__mouseArea READ privateMouseArea CONSTANT) | ||
3154 | 32 | public: | ||
3155 | 33 | explicit UCAbstractButton(QQuickItem *parent = 0); | ||
3156 | 34 | |||
3157 | 35 | bool pressed() const; | ||
3158 | 36 | bool hovered() const; | ||
3159 | 37 | |||
3160 | 38 | bool privateAcceptEvents() const; | ||
3161 | 39 | void setPrivateAcceptEvents(bool accept); | ||
3162 | 40 | QQuickMouseArea *privateMouseArea() const; | ||
3163 | 41 | |||
3164 | 42 | protected: | ||
3165 | 43 | void classBegin(); | ||
3166 | 44 | void componentComplete(); | ||
3167 | 45 | void keyPressEvent(QKeyEvent *key); | ||
3168 | 46 | |||
3169 | 47 | Q_SIGNALS: | ||
3170 | 48 | void pressedChanged(); | ||
3171 | 49 | void hoveredChanged(); | ||
3172 | 50 | void clicked(); | ||
3173 | 51 | void pressAndHold(); | ||
3174 | 52 | |||
3175 | 53 | protected Q_SLOTS: | ||
3176 | 54 | void _q_mouseAreaClicked(); | ||
3177 | 55 | void _q_mouseAreaPressAndHold(); | ||
3178 | 56 | |||
3179 | 57 | protected: | ||
3180 | 58 | QQuickMouseArea *m_mouseArea; | ||
3181 | 59 | bool m_acceptEvents:1; | ||
3182 | 60 | |||
3183 | 61 | bool isPressAndHoldConnected(); | ||
3184 | 62 | }; | ||
3185 | 63 | |||
3186 | 64 | #endif // UCABSTRACTBUTTON_H | ||
3187 | 0 | 65 | ||
3188 | === modified file 'src/Ubuntu/Components/plugin/ucaction.cpp' | |||
3189 | --- src/Ubuntu/Components/plugin/ucaction.cpp 2015-07-03 19:16:56 +0000 | |||
3190 | +++ src/Ubuntu/Components/plugin/ucaction.cpp 2015-09-08 04:09:38 +0000 | |||
3191 | @@ -150,13 +150,12 @@ | |||
3192 | 150 | 150 | ||
3193 | 151 | UCAction::UCAction(QObject *parent) | 151 | UCAction::UCAction(QObject *parent) |
3194 | 152 | : QObject(parent) | 152 | : QObject(parent) |
3195 | 153 | , m_itemHint(Q_NULLPTR) | ||
3196 | 154 | , m_parameterType(None) | ||
3197 | 153 | , m_factoryIconSource(true) | 155 | , m_factoryIconSource(true) |
3198 | 154 | , m_enabled(true) | 156 | , m_enabled(true) |
3199 | 155 | , m_visible(true) | 157 | , m_visible(true) |
3200 | 156 | , m_published(false) | 158 | , m_published(false) |
3201 | 157 | , m_itemHint(0) | ||
3202 | 158 | , m_parameterType(None) | ||
3203 | 159 | , m_shortcut(0) | ||
3204 | 160 | { | 159 | { |
3205 | 161 | generateName(); | 160 | generateName(); |
3206 | 162 | } | 161 | } |
3207 | @@ -288,7 +287,7 @@ | |||
3208 | 288 | qmlInfo(this) << "Invalid shortcut: " << shortcut.toString(); | 287 | qmlInfo(this) << "Invalid shortcut: " << shortcut.toString(); |
3209 | 289 | 288 | ||
3210 | 290 | m_shortcut = shortcut; | 289 | m_shortcut = shortcut; |
3212 | 291 | Q_EMIT shortcutChanged(shortcut); | 290 | Q_EMIT shortcutChanged(); |
3213 | 292 | } | 291 | } |
3214 | 293 | 292 | ||
3215 | 294 | bool UCAction::event(QEvent *event) | 293 | bool UCAction::event(QEvent *event) |
3216 | @@ -302,7 +301,8 @@ | |||
3217 | 302 | return false; | 301 | return false; |
3218 | 303 | } | 302 | } |
3219 | 304 | 303 | ||
3221 | 305 | trigger(); | 304 | // do not call trigger() directly but invoke, as it may get overridden in QML |
3222 | 305 | metaObject()->invokeMethod(this, "trigger"); | ||
3223 | 306 | return true; | 306 | return true; |
3224 | 307 | } | 307 | } |
3225 | 308 | 308 | ||
3226 | 309 | 309 | ||
3227 | === modified file 'src/Ubuntu/Components/plugin/ucaction.h' | |||
3228 | --- src/Ubuntu/Components/plugin/ucaction.h 2015-07-07 13:57:50 +0000 | |||
3229 | +++ src/Ubuntu/Components/plugin/ucaction.h 2015-09-08 04:09:38 +0000 | |||
3230 | @@ -70,28 +70,29 @@ | |||
3231 | 70 | void parameterTypeChanged(); | 70 | void parameterTypeChanged(); |
3232 | 71 | void iconSourceChanged(); | 71 | void iconSourceChanged(); |
3233 | 72 | void visibleChanged(); | 72 | void visibleChanged(); |
3235 | 73 | void shortcutChanged(const QVariant& shortcut); | 73 | void shortcutChanged(); |
3236 | 74 | void triggered(const QVariant &value); | 74 | void triggered(const QVariant &value); |
3237 | 75 | 75 | ||
3238 | 76 | public Q_SLOTS: | 76 | public Q_SLOTS: |
3239 | 77 | void trigger(const QVariant &value = QVariant()); | 77 | void trigger(const QVariant &value = QVariant()); |
3240 | 78 | 78 | ||
3241 | 79 | private: | 79 | private: |
3242 | 80 | bool m_factoryIconSource:1; | ||
3243 | 81 | bool m_enabled:1; | ||
3244 | 82 | bool m_visible:1; | ||
3245 | 83 | bool m_published:1; | ||
3246 | 84 | QQmlComponent *m_itemHint; | ||
3247 | 85 | QString m_name; | 80 | QString m_name; |
3248 | 86 | QString m_text; | 81 | QString m_text; |
3249 | 87 | QString m_iconName; | 82 | QString m_iconName; |
3250 | 88 | QUrl m_iconSource; | 83 | QUrl m_iconSource; |
3251 | 89 | QString m_description; | 84 | QString m_description; |
3252 | 90 | QString m_keywords; | 85 | QString m_keywords; |
3253 | 86 | QVariant m_shortcut; | ||
3254 | 87 | QQmlComponent *m_itemHint; | ||
3255 | 91 | Type m_parameterType; | 88 | Type m_parameterType; |
3257 | 92 | QVariant m_shortcut; | 89 | bool m_factoryIconSource:1; |
3258 | 90 | bool m_enabled:1; | ||
3259 | 91 | bool m_visible:1; | ||
3260 | 92 | bool m_published:1; | ||
3261 | 93 | 93 | ||
3262 | 94 | friend class UCActionContext; | 94 | friend class UCActionContext; |
3263 | 95 | friend class UCActionItem; | ||
3264 | 95 | friend class UCListItemPrivate; | 96 | friend class UCListItemPrivate; |
3265 | 96 | friend class UCListItemAttached; | 97 | friend class UCListItemAttached; |
3266 | 97 | friend class UCListItemActionsPrivate; | 98 | friend class UCListItemActionsPrivate; |
3267 | 98 | 99 | ||
3268 | === modified file 'src/Ubuntu/Components/plugin/ucactioncontext.cpp' | |||
3269 | --- src/Ubuntu/Components/plugin/ucactioncontext.cpp 2015-07-09 17:55:03 +0000 | |||
3270 | +++ src/Ubuntu/Components/plugin/ucactioncontext.cpp 2015-09-08 04:09:38 +0000 | |||
3271 | @@ -104,6 +104,11 @@ | |||
3272 | 104 | * sufficient to manage the active local context of the manager and no additional | 104 | * sufficient to manage the active local context of the manager and no additional |
3273 | 105 | * calls are necessary to manually inactivate the other contexts. | 105 | * calls are necessary to manually inactivate the other contexts. |
3274 | 106 | */ | 106 | */ |
3275 | 107 | bool UCActionContext::active() | ||
3276 | 108 | { | ||
3277 | 109 | return m_active; | ||
3278 | 110 | } | ||
3279 | 111 | |||
3280 | 107 | void UCActionContext::setActive(bool active) | 112 | void UCActionContext::setActive(bool active) |
3281 | 108 | { | 113 | { |
3282 | 109 | if (m_active == active) { | 114 | if (m_active == active) { |
3283 | @@ -114,7 +119,7 @@ | |||
3284 | 114 | return; | 119 | return; |
3285 | 115 | } | 120 | } |
3286 | 116 | m_active = active; | 121 | m_active = active; |
3288 | 117 | Q_EMIT activeChanged(active); | 122 | Q_EMIT activeChanged(); |
3289 | 118 | } | 123 | } |
3290 | 119 | 124 | ||
3291 | 120 | /*! | 125 | /*! |
3292 | 121 | 126 | ||
3293 | === modified file 'src/Ubuntu/Components/plugin/ucactioncontext.h' | |||
3294 | --- src/Ubuntu/Components/plugin/ucactioncontext.h 2015-07-09 17:55:03 +0000 | |||
3295 | +++ src/Ubuntu/Components/plugin/ucactioncontext.h 2015-09-08 04:09:38 +0000 | |||
3296 | @@ -29,7 +29,7 @@ | |||
3297 | 29 | Q_OBJECT | 29 | Q_OBJECT |
3298 | 30 | Q_INTERFACES(QQmlParserStatus) | 30 | Q_INTERFACES(QQmlParserStatus) |
3299 | 31 | Q_PROPERTY(QQmlListProperty<UCAction> actions READ actions) | 31 | Q_PROPERTY(QQmlListProperty<UCAction> actions READ actions) |
3301 | 32 | Q_PROPERTY(bool active MEMBER m_active WRITE setActive NOTIFY activeChanged) | 32 | Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) |
3302 | 33 | Q_CLASSINFO("DefaultProperty", "actions") | 33 | Q_CLASSINFO("DefaultProperty", "actions") |
3303 | 34 | public: | 34 | public: |
3304 | 35 | explicit UCActionContext(QObject *parent = 0); | 35 | explicit UCActionContext(QObject *parent = 0); |
3305 | @@ -41,10 +41,11 @@ | |||
3306 | 41 | 41 | ||
3307 | 42 | QQmlListProperty<UCAction> actions(); | 42 | QQmlListProperty<UCAction> actions(); |
3308 | 43 | 43 | ||
3309 | 44 | bool active(); | ||
3310 | 44 | void setActive(bool active); | 45 | void setActive(bool active); |
3311 | 45 | 46 | ||
3312 | 46 | Q_SIGNALS: | 47 | Q_SIGNALS: |
3314 | 47 | void activeChanged(bool); | 48 | void activeChanged(); |
3315 | 48 | 49 | ||
3316 | 49 | public Q_SLOTS: | 50 | public Q_SLOTS: |
3317 | 50 | void addAction(UCAction *action); | 51 | void addAction(UCAction *action); |
3318 | 51 | 52 | ||
3319 | === added file 'src/Ubuntu/Components/plugin/ucactionitem.cpp' | |||
3320 | --- src/Ubuntu/Components/plugin/ucactionitem.cpp 1970-01-01 00:00:00 +0000 | |||
3321 | +++ src/Ubuntu/Components/plugin/ucactionitem.cpp 2015-09-08 04:09:38 +0000 | |||
3322 | @@ -0,0 +1,316 @@ | |||
3323 | 1 | /* | ||
3324 | 2 | * Copyright 2015 Canonical Ltd. | ||
3325 | 3 | * | ||
3326 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3327 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
3328 | 6 | * the Free Software Foundation; version 3. | ||
3329 | 7 | * | ||
3330 | 8 | * This program is distributed in the hope that it will be useful, | ||
3331 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3332 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3333 | 11 | * GNU Lesser General Public License for more details. | ||
3334 | 12 | * | ||
3335 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
3336 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3337 | 15 | */ | ||
3338 | 16 | |||
3339 | 17 | #include "ucactionitem.h" | ||
3340 | 18 | #include "ucaction.h" | ||
3341 | 19 | |||
3342 | 20 | /*! | ||
3343 | 21 | * \qmltype ActionItem | ||
3344 | 22 | * \instantiates UCActionItem | ||
3345 | 23 | * \inqmlmodule Ubuntu.Components 1.1 | ||
3346 | 24 | * \ingroup ubuntu | ||
3347 | 25 | * \brief A visual representation of an Action. The API of ActionItem is a | ||
3348 | 26 | * copy of the API of \l Action, with additional properties to define | ||
3349 | 27 | * visual aspects of the ActionItem. | ||
3350 | 28 | * | ||
3351 | 29 | * If \l action is set, the values of the other properties will by default | ||
3352 | 30 | * be identical to the \l Action's property values. Setting the other properties | ||
3353 | 31 | * will override the properties copied from the \l Action. | ||
3354 | 32 | */ | ||
3355 | 33 | |||
3356 | 34 | /*! | ||
3357 | 35 | * \qmlsignal ActionItem::triggered(var value) | ||
3358 | 36 | * Called when the actionItem is triggered. | ||
3359 | 37 | */ | ||
3360 | 38 | UCActionItem::UCActionItem(QQuickItem *parent) | ||
3361 | 39 | : UCStyledItemBase(parent) | ||
3362 | 40 | , m_action(Q_NULLPTR) | ||
3363 | 41 | , m_flags(0) | ||
3364 | 42 | { | ||
3365 | 43 | connect(this, &UCActionItem::visibleChanged, this, &UCActionItem::_q_visibleChanged); | ||
3366 | 44 | connect(this, &UCActionItem::enabledChanged, this, &UCActionItem::_q_enabledChanged); | ||
3367 | 45 | } | ||
3368 | 46 | |||
3369 | 47 | void UCActionItem::componentComplete() | ||
3370 | 48 | { | ||
3371 | 49 | UCStyledItemBase::componentComplete(); | ||
3372 | 50 | // make sure we connect to the right signals, so we detach and re-attach actions | ||
3373 | 51 | // to make sure the SLOT macro picks up the custom trigger() slot | ||
3374 | 52 | if (m_action) { | ||
3375 | 53 | attachAction(false); | ||
3376 | 54 | attachAction(true); | ||
3377 | 55 | } | ||
3378 | 56 | } | ||
3379 | 57 | |||
3380 | 58 | void UCActionItem::_q_visibleChanged() | ||
3381 | 59 | { | ||
3382 | 60 | m_flags |= CustomVisible; | ||
3383 | 61 | disconnect(this, &UCActionItem::visibleChanged, this, &UCActionItem::_q_visibleChanged); | ||
3384 | 62 | } | ||
3385 | 63 | |||
3386 | 64 | void UCActionItem::_q_enabledChanged() | ||
3387 | 65 | { | ||
3388 | 66 | m_flags |= CustomEnabled; | ||
3389 | 67 | disconnect(this, &UCActionItem::enabledChanged, this, &UCActionItem::_q_enabledChanged); | ||
3390 | 68 | } | ||
3391 | 69 | |||
3392 | 70 | // update visible property | ||
3393 | 71 | void UCActionItem::_q_updateVisible() | ||
3394 | 72 | { | ||
3395 | 73 | bool visible = m_action ? m_action->m_visible : true; | ||
3396 | 74 | setVisible(visible); | ||
3397 | 75 | // reset flag and reconnect signal handler disconnected by the | ||
3398 | 76 | m_flags &= ~CustomVisible; | ||
3399 | 77 | if (m_action) { | ||
3400 | 78 | connect(this, &UCActionItem::visibleChanged, this, &UCActionItem::_q_visibleChanged); | ||
3401 | 79 | } | ||
3402 | 80 | } | ||
3403 | 81 | |||
3404 | 82 | // update enabled property | ||
3405 | 83 | void UCActionItem::_q_updateEnabled() | ||
3406 | 84 | { | ||
3407 | 85 | bool enabled = m_action ? m_action->m_enabled : true; | ||
3408 | 86 | setEnabled(enabled); | ||
3409 | 87 | // reset flag and reconnect signal handler disconnected by the | ||
3410 | 88 | m_flags &= ~CustomEnabled; | ||
3411 | 89 | if (m_action) { | ||
3412 | 90 | connect(this, &UCActionItem::enabledChanged, this, &UCActionItem::_q_enabledChanged); | ||
3413 | 91 | } | ||
3414 | 92 | } | ||
3415 | 93 | |||
3416 | 94 | void UCActionItem::updateProperties() | ||
3417 | 95 | { | ||
3418 | 96 | if (!(m_flags & CustomText)) { | ||
3419 | 97 | Q_EMIT textChanged(); | ||
3420 | 98 | } | ||
3421 | 99 | if (!(m_flags & CustomIconSource)) { | ||
3422 | 100 | Q_EMIT iconSourceChanged(); | ||
3423 | 101 | } | ||
3424 | 102 | if (!(m_flags & CustomIconName)) { | ||
3425 | 103 | Q_EMIT iconNameChanged(); | ||
3426 | 104 | } | ||
3427 | 105 | } | ||
3428 | 106 | |||
3429 | 107 | void UCActionItem::attachAction(bool attach) | ||
3430 | 108 | { | ||
3431 | 109 | if (attach) { | ||
3432 | 110 | connect(this, SIGNAL(triggered(QVariant)), | ||
3433 | 111 | m_action, SLOT(trigger(QVariant)), Qt::DirectConnection); | ||
3434 | 112 | connect(m_action, &UCAction::visibleChanged, | ||
3435 | 113 | this, &UCActionItem::_q_updateVisible, Qt::DirectConnection); | ||
3436 | 114 | connect(m_action, &UCAction::enabledChanged, | ||
3437 | 115 | this, &UCActionItem::_q_updateEnabled, Qt::DirectConnection); | ||
3438 | 116 | if (!(m_flags & CustomText)) { | ||
3439 | 117 | connect(m_action, &UCAction::textChanged, | ||
3440 | 118 | this, &UCActionItem::textChanged, Qt::DirectConnection); | ||
3441 | 119 | } | ||
3442 | 120 | if (!(m_flags & CustomIconSource)) { | ||
3443 | 121 | connect(m_action, &UCAction::iconSourceChanged, | ||
3444 | 122 | this, &UCActionItem::iconSourceChanged, Qt::DirectConnection); | ||
3445 | 123 | } | ||
3446 | 124 | if (!(m_flags & CustomIconName)) { | ||
3447 | 125 | connect(m_action, &UCAction::iconNameChanged, | ||
3448 | 126 | this, &UCActionItem::iconNameChanged, Qt::DirectConnection); | ||
3449 | 127 | } | ||
3450 | 128 | } else { | ||
3451 | 129 | disconnect(this, SIGNAL(triggered(QVariant)), | ||
3452 | 130 | m_action, SLOT(trigger(QVariant))); | ||
3453 | 131 | disconnect(m_action, &UCAction::visibleChanged, | ||
3454 | 132 | this, &UCActionItem::_q_updateVisible); | ||
3455 | 133 | disconnect(m_action, &UCAction::enabledChanged, | ||
3456 | 134 | this, &UCActionItem::_q_updateEnabled); | ||
3457 | 135 | if (!(m_flags & CustomText)) { | ||
3458 | 136 | disconnect(m_action, &UCAction::textChanged, | ||
3459 | 137 | this, &UCActionItem::textChanged); | ||
3460 | 138 | } | ||
3461 | 139 | if (!(m_flags & CustomIconSource)) { | ||
3462 | 140 | disconnect(m_action, &UCAction::iconSourceChanged, | ||
3463 | 141 | this, &UCActionItem::iconSourceChanged); | ||
3464 | 142 | } | ||
3465 | 143 | if (!(m_flags & CustomIconName)) { | ||
3466 | 144 | disconnect(m_action, &UCAction::iconNameChanged, | ||
3467 | 145 | this, &UCActionItem::iconNameChanged); | ||
3468 | 146 | } | ||
3469 | 147 | } | ||
3470 | 148 | } | ||
3471 | 149 | |||
3472 | 150 | /*! | ||
3473 | 151 | * \qmlproperty Action ActionItem::action | ||
3474 | 152 | * The \l Action associated with this ActionItem. If action is set, the values | ||
3475 | 153 | * of the \l Action properties are copied to the values of the ActionItem | ||
3476 | 154 | * properties, unless those were previously overridden. | ||
3477 | 155 | */ | ||
3478 | 156 | void UCActionItem::setAction(UCAction *action) | ||
3479 | 157 | { | ||
3480 | 158 | if (m_action == action) { | ||
3481 | 159 | return; | ||
3482 | 160 | } | ||
3483 | 161 | if (m_action) { | ||
3484 | 162 | attachAction(false); | ||
3485 | 163 | } | ||
3486 | 164 | m_action = action; | ||
3487 | 165 | Q_EMIT actionChanged(); | ||
3488 | 166 | |||
3489 | 167 | if (m_action) { | ||
3490 | 168 | attachAction(true); | ||
3491 | 169 | } | ||
3492 | 170 | _q_updateVisible(); | ||
3493 | 171 | _q_updateEnabled(); | ||
3494 | 172 | updateProperties(); | ||
3495 | 173 | } | ||
3496 | 174 | |||
3497 | 175 | /*! | ||
3498 | 176 | * \qmlproperty string ActionItem::text | ||
3499 | 177 | * The title of the actionItem. Defaults to the \c action.text. | ||
3500 | 178 | */ | ||
3501 | 179 | QString UCActionItem::text() | ||
3502 | 180 | { | ||
3503 | 181 | if (m_flags & CustomText) { | ||
3504 | 182 | return m_text; | ||
3505 | 183 | } | ||
3506 | 184 | return m_action ? m_action->m_text : QString(); | ||
3507 | 185 | } | ||
3508 | 186 | void UCActionItem::setText(const QString &text) | ||
3509 | 187 | { | ||
3510 | 188 | if (m_text == text) { | ||
3511 | 189 | return; | ||
3512 | 190 | } | ||
3513 | 191 | m_text = text; | ||
3514 | 192 | if (m_action && !(m_flags & CustomText)) { | ||
3515 | 193 | // disconnect change signal from Action | ||
3516 | 194 | disconnect(m_action, &UCAction::textChanged, | ||
3517 | 195 | this, &UCActionItem::textChanged); | ||
3518 | 196 | } | ||
3519 | 197 | m_flags |= CustomText; | ||
3520 | 198 | Q_EMIT textChanged(); | ||
3521 | 199 | } | ||
3522 | 200 | void UCActionItem::resetText() | ||
3523 | 201 | { | ||
3524 | 202 | m_text.clear(); | ||
3525 | 203 | m_flags &= ~CustomText; | ||
3526 | 204 | if (m_action) { | ||
3527 | 205 | // re-connect change signal from Action | ||
3528 | 206 | connect(m_action, &UCAction::textChanged, | ||
3529 | 207 | this, &UCActionItem::textChanged, Qt::DirectConnection); | ||
3530 | 208 | } | ||
3531 | 209 | Q_EMIT textChanged(); | ||
3532 | 210 | } | ||
3533 | 211 | |||
3534 | 212 | /*! | ||
3535 | 213 | * \qmlproperty url ActionItem::iconSource | ||
3536 | 214 | * The image associated with the ActionItem. Defaults to \c action.iconSource. | ||
3537 | 215 | * | ||
3538 | 216 | * This is the URL of any image file. If both iconSource and \l iconName are defined, | ||
3539 | 217 | * \l iconName will be ignored. | ||
3540 | 218 | */ | ||
3541 | 219 | QUrl UCActionItem::iconSource() | ||
3542 | 220 | { | ||
3543 | 221 | if (m_flags & CustomIconSource) { | ||
3544 | 222 | return m_iconSource; | ||
3545 | 223 | } | ||
3546 | 224 | if (m_action) { | ||
3547 | 225 | return m_action->m_iconSource; | ||
3548 | 226 | } | ||
3549 | 227 | return !iconName().isEmpty() ? QUrl(QString("image://theme/%1").arg(iconName())) : QUrl(); | ||
3550 | 228 | } | ||
3551 | 229 | void UCActionItem::setIconSource(const QUrl &iconSource) | ||
3552 | 230 | { | ||
3553 | 231 | if (m_iconSource == iconSource) { | ||
3554 | 232 | return; | ||
3555 | 233 | } | ||
3556 | 234 | m_iconSource = iconSource; | ||
3557 | 235 | if (m_action && !(m_flags & CustomIconSource)) { | ||
3558 | 236 | // disconnect change signal from Action | ||
3559 | 237 | disconnect(m_action, &UCAction::iconSourceChanged, | ||
3560 | 238 | this, &UCActionItem::iconSourceChanged); | ||
3561 | 239 | } | ||
3562 | 240 | m_flags |= CustomIconSource; | ||
3563 | 241 | Q_EMIT iconSourceChanged(); | ||
3564 | 242 | } | ||
3565 | 243 | void UCActionItem::resetIconSource() | ||
3566 | 244 | { | ||
3567 | 245 | m_iconSource.clear(); | ||
3568 | 246 | m_flags &= ~CustomIconSource; | ||
3569 | 247 | if (m_action) { | ||
3570 | 248 | // re-connect change signal from Action | ||
3571 | 249 | connect(m_action, &UCAction::iconSourceChanged, | ||
3572 | 250 | this, &UCActionItem::iconSourceChanged, Qt::DirectConnection); | ||
3573 | 251 | } | ||
3574 | 252 | Q_EMIT iconSourceChanged(); | ||
3575 | 253 | } | ||
3576 | 254 | |||
3577 | 255 | /*! | ||
3578 | 256 | * \qmlproperty string ActionItem::iconName | ||
3579 | 257 | * The icon associated with the actionItem in the suru icon theme. Defaults to | ||
3580 | 258 | * \c action.iconName. | ||
3581 | 259 | * | ||
3582 | 260 | * \note The complete list of icons available in Ubuntu is not published yet. | ||
3583 | 261 | * For now please refer to the folders where the icon themes are installed: | ||
3584 | 262 | * \list | ||
3585 | 263 | * \li Ubuntu Touch: \l file:/usr/share/icons/suru | ||
3586 | 264 | * \li Ubuntu Desktop: \l file:/usr/share/icons/ubuntu-mono-dark | ||
3587 | 265 | * \endlist | ||
3588 | 266 | * These 2 separate icon themes will be merged soon. | ||
3589 | 267 | * | ||
3590 | 268 | * If both \l iconSource and iconName are defined, iconName will be ignored. | ||
3591 | 269 | */ | ||
3592 | 270 | QString UCActionItem::iconName() | ||
3593 | 271 | { | ||
3594 | 272 | if (m_flags & CustomIconName) { | ||
3595 | 273 | return m_iconName; | ||
3596 | 274 | } | ||
3597 | 275 | return m_action ? m_action->m_iconName : QString(); | ||
3598 | 276 | } | ||
3599 | 277 | void UCActionItem::setIconName(const QString &iconName) | ||
3600 | 278 | { | ||
3601 | 279 | if (m_iconName == iconName) { | ||
3602 | 280 | return; | ||
3603 | 281 | } | ||
3604 | 282 | m_iconName = iconName; | ||
3605 | 283 | if (m_action && !(m_flags & CustomIconName)) { | ||
3606 | 284 | // disconnect change signal from Action | ||
3607 | 285 | disconnect(m_action, &UCAction::iconNameChanged, | ||
3608 | 286 | this, &UCActionItem::iconNameChanged); | ||
3609 | 287 | } | ||
3610 | 288 | m_flags |= CustomIconName; | ||
3611 | 289 | Q_EMIT iconNameChanged(); | ||
3612 | 290 | // also sync iconSource if that is not a custom one or taken from action | ||
3613 | 291 | if (!m_action || (m_flags & CustomIconSource)) { | ||
3614 | 292 | Q_EMIT iconSourceChanged(); | ||
3615 | 293 | } | ||
3616 | 294 | } | ||
3617 | 295 | void UCActionItem::resetIconName() | ||
3618 | 296 | { | ||
3619 | 297 | m_iconName.clear(); | ||
3620 | 298 | m_flags &= ~CustomIconName; | ||
3621 | 299 | if (m_action) { | ||
3622 | 300 | // re-connect change signal from Action | ||
3623 | 301 | connect(m_action, &UCAction::iconNameChanged, | ||
3624 | 302 | this, &UCActionItem::iconNameChanged, Qt::DirectConnection); | ||
3625 | 303 | } | ||
3626 | 304 | Q_EMIT iconNameChanged(); | ||
3627 | 305 | } | ||
3628 | 306 | |||
3629 | 307 | /*! | ||
3630 | 308 | * \qmlmethod void ActionItem::trigger(var value) | ||
3631 | 309 | * Trigger this action item if it is enabled. | ||
3632 | 310 | */ | ||
3633 | 311 | void UCActionItem::trigger(const QVariant &value) | ||
3634 | 312 | { | ||
3635 | 313 | if (isEnabled()) { | ||
3636 | 314 | Q_EMIT triggered(value); | ||
3637 | 315 | } | ||
3638 | 316 | } | ||
3639 | 0 | 317 | ||
3640 | === added file 'src/Ubuntu/Components/plugin/ucactionitem.h' | |||
3641 | --- src/Ubuntu/Components/plugin/ucactionitem.h 1970-01-01 00:00:00 +0000 | |||
3642 | +++ src/Ubuntu/Components/plugin/ucactionitem.h 2015-09-08 04:09:38 +0000 | |||
3643 | @@ -0,0 +1,79 @@ | |||
3644 | 1 | /* | ||
3645 | 2 | * Copyright 2015 Canonical Ltd. | ||
3646 | 3 | * | ||
3647 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3648 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
3649 | 6 | * the Free Software Foundation; version 3. | ||
3650 | 7 | * | ||
3651 | 8 | * This program is distributed in the hope that it will be useful, | ||
3652 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3653 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3654 | 11 | * GNU Lesser General Public License for more details. | ||
3655 | 12 | * | ||
3656 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
3657 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3658 | 15 | */ | ||
3659 | 16 | #ifndef UCACTIONITEM_H | ||
3660 | 17 | #define UCACTIONITEM_H | ||
3661 | 18 | |||
3662 | 19 | #include "ucstyleditembase.h" | ||
3663 | 20 | |||
3664 | 21 | class UCAction; | ||
3665 | 22 | class UCActionItem : public UCStyledItemBase | ||
3666 | 23 | { | ||
3667 | 24 | Q_OBJECT | ||
3668 | 25 | Q_PROPERTY(UCAction *action MEMBER m_action WRITE setAction NOTIFY actionChanged FINAL) | ||
3669 | 26 | Q_PROPERTY(QString text READ text WRITE setText RESET resetText NOTIFY textChanged) | ||
3670 | 27 | Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource RESET resetIconSource NOTIFY iconSourceChanged) | ||
3671 | 28 | Q_PROPERTY(QString iconName READ iconName WRITE setIconName RESET resetIconName NOTIFY iconNameChanged) | ||
3672 | 29 | public: | ||
3673 | 30 | explicit UCActionItem(QQuickItem *parent = 0); | ||
3674 | 31 | |||
3675 | 32 | void setAction(UCAction *action); | ||
3676 | 33 | QString text(); | ||
3677 | 34 | void setText(const QString &text); | ||
3678 | 35 | void resetText(); | ||
3679 | 36 | QUrl iconSource(); | ||
3680 | 37 | void setIconSource(const QUrl &iconSource); | ||
3681 | 38 | void resetIconSource(); | ||
3682 | 39 | QString iconName(); | ||
3683 | 40 | void setIconName(const QString &iconName); | ||
3684 | 41 | void resetIconName(); | ||
3685 | 42 | |||
3686 | 43 | Q_SIGNALS: | ||
3687 | 44 | void actionChanged(); | ||
3688 | 45 | void textChanged(); | ||
3689 | 46 | void iconSourceChanged(); | ||
3690 | 47 | void iconNameChanged(); | ||
3691 | 48 | void triggered(const QVariant &value); | ||
3692 | 49 | |||
3693 | 50 | public Q_SLOTS: | ||
3694 | 51 | void trigger(const QVariant &value = QVariant()); | ||
3695 | 52 | |||
3696 | 53 | protected Q_SLOTS: | ||
3697 | 54 | void _q_visibleChanged(); | ||
3698 | 55 | void _q_enabledChanged(); | ||
3699 | 56 | void _q_updateVisible(); | ||
3700 | 57 | void _q_updateEnabled(); | ||
3701 | 58 | |||
3702 | 59 | protected: | ||
3703 | 60 | enum { | ||
3704 | 61 | CustomText = 0x01, | ||
3705 | 62 | CustomIconSource = 0x02, | ||
3706 | 63 | CustomIconName = 0x04, | ||
3707 | 64 | CustomVisible = 0x40, | ||
3708 | 65 | CustomEnabled = 0x80 | ||
3709 | 66 | }; | ||
3710 | 67 | QString m_text; | ||
3711 | 68 | QString m_iconName; | ||
3712 | 69 | QUrl m_iconSource; | ||
3713 | 70 | UCAction *m_action; | ||
3714 | 71 | quint8 m_flags; | ||
3715 | 72 | |||
3716 | 73 | void componentComplete(); | ||
3717 | 74 | |||
3718 | 75 | void updateProperties(); | ||
3719 | 76 | void attachAction(bool attach); | ||
3720 | 77 | }; | ||
3721 | 78 | |||
3722 | 79 | #endif // UCACTIONITEM_H | ||
3723 | 0 | 80 | ||
3724 | === added file 'src/Ubuntu/Components/plugin/uchaptics.cpp' | |||
3725 | --- src/Ubuntu/Components/plugin/uchaptics.cpp 1970-01-01 00:00:00 +0000 | |||
3726 | +++ src/Ubuntu/Components/plugin/uchaptics.cpp 2015-09-08 04:09:38 +0000 | |||
3727 | @@ -0,0 +1,179 @@ | |||
3728 | 1 | /* | ||
3729 | 2 | * Copyright 2015 Canonical Ltd. | ||
3730 | 3 | * | ||
3731 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3732 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
3733 | 6 | * the Free Software Foundation; version 3. | ||
3734 | 7 | * | ||
3735 | 8 | * This program is distributed in the hope that it will be useful, | ||
3736 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3737 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3738 | 11 | * GNU Lesser General Public License for more details. | ||
3739 | 12 | * | ||
3740 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
3741 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3742 | 15 | */ | ||
3743 | 16 | |||
3744 | 17 | #include "uchaptics.h" | ||
3745 | 18 | #include "plugin.h" | ||
3746 | 19 | #include <QtQml/QQmlComponent> | ||
3747 | 20 | #include <QtCore/QUrl> | ||
3748 | 21 | #include <QDebug> | ||
3749 | 22 | |||
3750 | 23 | /*! | ||
3751 | 24 | \qmltype Haptics | ||
3752 | 25 | \instantiates UCHaptics | ||
3753 | 26 | \inqmlmodule Ubuntu.Components 1.1 | ||
3754 | 27 | \ingroup ubuntu-services | ||
3755 | 28 | \brief Singleton defining the haptics feedback used in components, where execution | ||
3756 | 29 | of the feedback is controlled by the system settings. | ||
3757 | 30 | |||
3758 | 31 | Supports global feedback as well as custom feedback. Global feedback can be | ||
3759 | 32 | configured through its properties, and \l play function will play the default | ||
3760 | 33 | configuration, or a custom one if parameter is given. | ||
3761 | 34 | |||
3762 | 35 | Example of using Haptics: | ||
3763 | 36 | \qml | ||
3764 | 37 | import QtQuick 2.4 | ||
3765 | 38 | import Ubuntu.Components 1.3 | ||
3766 | 39 | |||
3767 | 40 | Item { | ||
3768 | 41 | implicitWidth: units.gu(20) | ||
3769 | 42 | implicitHeight: units.gu(5) | ||
3770 | 43 | |||
3771 | 44 | Label { | ||
3772 | 45 | text: "Press me" | ||
3773 | 46 | anchors.fill: parent | ||
3774 | 47 | horizontalAlignment: Text.AlignHCenter | ||
3775 | 48 | verticalAlignment: Text.AlignVCenter | ||
3776 | 49 | } | ||
3777 | 50 | MouseArea { | ||
3778 | 51 | anchors.fill: parent | ||
3779 | 52 | onClicked: Haptics.play() | ||
3780 | 53 | } | ||
3781 | 54 | } | ||
3782 | 55 | \endqml | ||
3783 | 56 | |||
3784 | 57 | Custom effects can be played as follows: | ||
3785 | 58 | \qml | ||
3786 | 59 | import QtQuick 2.4 | ||
3787 | 60 | import Ubuntu.Components 1.3 | ||
3788 | 61 | |||
3789 | 62 | Item { | ||
3790 | 63 | implicitWidth: units.gu(20) | ||
3791 | 64 | implicitHeight: units.gu(5) | ||
3792 | 65 | |||
3793 | 66 | Label { | ||
3794 | 67 | text: "Press me" | ||
3795 | 68 | anchors.fill: parent | ||
3796 | 69 | horizontalAlignment: Text.AlignHCenter | ||
3797 | 70 | verticalAlignment: Text.AlignVCenter | ||
3798 | 71 | } | ||
3799 | 72 | MouseArea { | ||
3800 | 73 | anchors.fill: parent | ||
3801 | 74 | onClicked: Haptics.play({duration: 25, attackIntensity: 0.7}) | ||
3802 | 75 | } | ||
3803 | 76 | } | ||
3804 | 77 | \endqml | ||
3805 | 78 | |||
3806 | 79 | \note Though the \l effect property exposes \c start, \c stop and \c pause | ||
3807 | 80 | functions, use those only if you want to have feedback independent from what the | ||
3808 | 81 | system setting is. | ||
3809 | 82 | */ | ||
3810 | 83 | |||
3811 | 84 | UCHaptics::UCHaptics(QObject *parent) | ||
3812 | 85 | : QObject(parent) | ||
3813 | 86 | { | ||
3814 | 87 | connect(&HapticsProxy::instance(), &HapticsProxy::enabledChanged, | ||
3815 | 88 | this, &UCHaptics::enabledChanged); | ||
3816 | 89 | } | ||
3817 | 90 | |||
3818 | 91 | /*! | ||
3819 | 92 | \qmlproperty bool Haptics::enabled | ||
3820 | 93 | \readonly | ||
3821 | 94 | The property specifies whether the haptics feedback is enabled or not by the system. | ||
3822 | 95 | */ | ||
3823 | 96 | bool UCHaptics::enabled() const | ||
3824 | 97 | { | ||
3825 | 98 | return HapticsProxy::instance().enabled(); | ||
3826 | 99 | } | ||
3827 | 100 | |||
3828 | 101 | /*! | ||
3829 | 102 | \qmlproperty HapticsEffect Haptics::effect | ||
3830 | 103 | \readonly | ||
3831 | 104 | The property defines the settings of the haptics effect used by the component. | ||
3832 | 105 | The default setting is a haptics effect with a duration of 10 milliseconds | ||
3833 | 106 | with an intensity of 1.0, having fading time of 50 millisecods and fading | ||
3834 | 107 | intensity 0.0, and attack time of 50 milliseconds and with an intensity of | ||
3835 | 108 | 0.0. | ||
3836 | 109 | */ | ||
3837 | 110 | QObject *UCHaptics::effect() const | ||
3838 | 111 | { | ||
3839 | 112 | return HapticsProxy::instance().effect(); | ||
3840 | 113 | } | ||
3841 | 114 | |||
3842 | 115 | /*! | ||
3843 | 116 | \qmlmethod void Haptics::play(var customEffect) | ||
3844 | 117 | The function plays the feedback with the configuration specified in \l effect | ||
3845 | 118 | if no parameter is given. Custom effect can be played by specifying the effect | ||
3846 | 119 | properties in a JSON object in \c customEffect. | ||
3847 | 120 | |||
3848 | 121 | The function will exit unconditionaly if playing the effects is blocked by | ||
3849 | 122 | system settings. | ||
3850 | 123 | |||
3851 | 124 | The function will not stop any ongoing haptics effect played, if that one | ||
3852 | 125 | was a default haptics effect. In case of custom effects, the previous effect | ||
3853 | 126 | will be stopped, and settings will be restored before the new haptics will | ||
3854 | 127 | be played. The custom settings properties (the ones which are required to | ||
3855 | 128 | be different from the ones defined in the \l effect) must be specified in | ||
3856 | 129 | the parameter in a JSON object. | ||
3857 | 130 | */ | ||
3858 | 131 | void UCHaptics::play(const QVariant &customEffect) | ||
3859 | 132 | { | ||
3860 | 133 | HapticsProxy::instance().play(customEffect); | ||
3861 | 134 | } | ||
3862 | 135 | |||
3863 | 136 | /********************************************************* | ||
3864 | 137 | * Proxy implementation | ||
3865 | 138 | */ | ||
3866 | 139 | bool HapticsProxy::enabled() | ||
3867 | 140 | { | ||
3868 | 141 | initialize(); | ||
3869 | 142 | return (m_proxyObject) ? m_proxyObject->property("enabled").toBool() : false; | ||
3870 | 143 | } | ||
3871 | 144 | |||
3872 | 145 | QObject *HapticsProxy::effect() | ||
3873 | 146 | { | ||
3874 | 147 | initialize(); | ||
3875 | 148 | return (m_proxyObject) ? m_proxyObject->property("effect").value<QObject*>() : Q_NULLPTR; | ||
3876 | 149 | } | ||
3877 | 150 | |||
3878 | 151 | void HapticsProxy::initialize() | ||
3879 | 152 | { | ||
3880 | 153 | if (!m_engine || m_proxyObject) { | ||
3881 | 154 | return; | ||
3882 | 155 | } | ||
3883 | 156 | // load haptics proxy from file system/qrc | ||
3884 | 157 | QUrl path = UbuntuComponentsPlugin::pluginUrl().resolved(QUrl("1.1/Haptics.qml")); | ||
3885 | 158 | QQmlComponent component(m_engine, path, QQmlComponent::PreferSynchronous); | ||
3886 | 159 | if (!component.isError()) { | ||
3887 | 160 | m_proxyObject = component.create(); | ||
3888 | 161 | if (m_proxyObject) { | ||
3889 | 162 | connect(m_proxyObject, SIGNAL(enabledChanged()), this, SIGNAL(enabledChanged())); | ||
3890 | 163 | } | ||
3891 | 164 | } else { | ||
3892 | 165 | qWarning() << qPrintable(component.errorString()); | ||
3893 | 166 | } | ||
3894 | 167 | } | ||
3895 | 168 | |||
3896 | 169 | void HapticsProxy::play(const QVariant &customEffect) | ||
3897 | 170 | { | ||
3898 | 171 | if (!m_engine) { | ||
3899 | 172 | qWarning() << "Engine not specified, haptics won't play"; | ||
3900 | 173 | } | ||
3901 | 174 | initialize(); | ||
3902 | 175 | if (m_proxyObject) { | ||
3903 | 176 | // invoke play function | ||
3904 | 177 | m_proxyObject->metaObject()->invokeMethod(m_proxyObject, "play", Q_ARG(QVariant, customEffect)); | ||
3905 | 178 | } | ||
3906 | 179 | } | ||
3907 | 0 | 180 | ||
3908 | === added file 'src/Ubuntu/Components/plugin/uchaptics.h' | |||
3909 | --- src/Ubuntu/Components/plugin/uchaptics.h 1970-01-01 00:00:00 +0000 | |||
3910 | +++ src/Ubuntu/Components/plugin/uchaptics.h 2015-09-08 04:09:38 +0000 | |||
3911 | @@ -0,0 +1,78 @@ | |||
3912 | 1 | /* | ||
3913 | 2 | * Copyright 2015 Canonical Ltd. | ||
3914 | 3 | * | ||
3915 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3916 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
3917 | 6 | * the Free Software Foundation; version 3. | ||
3918 | 7 | * | ||
3919 | 8 | * This program is distributed in the hope that it will be useful, | ||
3920 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3921 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3922 | 11 | * GNU Lesser General Public License for more details. | ||
3923 | 12 | * | ||
3924 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
3925 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3926 | 15 | */ | ||
3927 | 16 | |||
3928 | 17 | #ifndef UCHAPTICS_H | ||
3929 | 18 | #define UCHAPTICS_H | ||
3930 | 19 | |||
3931 | 20 | #include <QtCore/QObject> | ||
3932 | 21 | #include <QtCore/QVariant> | ||
3933 | 22 | |||
3934 | 23 | class UCHaptics : public QObject | ||
3935 | 24 | { | ||
3936 | 25 | Q_OBJECT | ||
3937 | 26 | Q_PROPERTY(bool enabled READ enabled NOTIFY enabledChanged) | ||
3938 | 27 | Q_PROPERTY(QObject *effect READ effect CONSTANT) | ||
3939 | 28 | public: | ||
3940 | 29 | explicit UCHaptics(QObject *parent = 0); | ||
3941 | 30 | |||
3942 | 31 | bool enabled() const; | ||
3943 | 32 | QObject *effect() const; | ||
3944 | 33 | |||
3945 | 34 | Q_SIGNALS: | ||
3946 | 35 | void enabledChanged(); | ||
3947 | 36 | |||
3948 | 37 | public Q_SLOTS: | ||
3949 | 38 | void play(const QVariant &customEffect = QVariant()); | ||
3950 | 39 | }; | ||
3951 | 40 | |||
3952 | 41 | class QQmlEngine; | ||
3953 | 42 | class HapticsProxy : public QObject | ||
3954 | 43 | { | ||
3955 | 44 | Q_OBJECT | ||
3956 | 45 | public: | ||
3957 | 46 | explicit HapticsProxy(QObject *parent = 0) | ||
3958 | 47 | : QObject(parent) | ||
3959 | 48 | , m_proxyObject(Q_NULLPTR) | ||
3960 | 49 | , m_engine(Q_NULLPTR) | ||
3961 | 50 | { | ||
3962 | 51 | } | ||
3963 | 52 | |||
3964 | 53 | static HapticsProxy &instance() | ||
3965 | 54 | { | ||
3966 | 55 | static HapticsProxy instance; | ||
3967 | 56 | return instance; | ||
3968 | 57 | } | ||
3969 | 58 | |||
3970 | 59 | void setEngine(QQmlEngine *engine) | ||
3971 | 60 | { | ||
3972 | 61 | m_engine = engine; | ||
3973 | 62 | } | ||
3974 | 63 | |||
3975 | 64 | void initialize(); | ||
3976 | 65 | |||
3977 | 66 | bool enabled(); | ||
3978 | 67 | QObject *effect(); | ||
3979 | 68 | void play(const QVariant &customEffect); | ||
3980 | 69 | |||
3981 | 70 | Q_SIGNALS: | ||
3982 | 71 | void enabledChanged(); | ||
3983 | 72 | |||
3984 | 73 | private: | ||
3985 | 74 | QObject *m_proxyObject; | ||
3986 | 75 | QQmlEngine *m_engine; | ||
3987 | 76 | }; | ||
3988 | 77 | |||
3989 | 78 | #endif // UCHAPTICS_H | ||
3990 | 0 | 79 | ||
3991 | === modified file 'src/Ubuntu/Components/plugin/uclistitem.cpp' | |||
3992 | --- src/Ubuntu/Components/plugin/uclistitem.cpp 2015-07-30 13:27:32 +0000 | |||
3993 | +++ src/Ubuntu/Components/plugin/uclistitem.cpp 2015-09-08 04:09:38 +0000 | |||
3994 | @@ -200,6 +200,7 @@ | |||
3995 | 200 | , leadingActions(0) | 200 | , leadingActions(0) |
3996 | 201 | , trailingActions(0) | 201 | , trailingActions(0) |
3997 | 202 | , mainAction(0) | 202 | , mainAction(0) |
3998 | 203 | , expansion(Q_NULLPTR) | ||
3999 | 203 | { | 204 | { |
4000 | 204 | } | 205 | } |
4001 | 205 | UCListItemPrivate::~UCListItemPrivate() | 206 | UCListItemPrivate::~UCListItemPrivate() |
4002 | @@ -325,7 +326,7 @@ | |||
4003 | 325 | bool UCListItemPrivate::loadStyleItem(bool animated) | 326 | bool UCListItemPrivate::loadStyleItem(bool animated) |
4004 | 326 | { | 327 | { |
4005 | 327 | // the style should be loaded only if one of the condition is satisfied | 328 | // the style should be loaded only if one of the condition is satisfied |
4007 | 328 | if (!swiped && !selectMode() && !dragMode()) { | 329 | if (!swiped && !selectMode() && !dragMode() && !(expansion && expansion->expanded())) { |
4008 | 329 | return false; | 330 | return false; |
4009 | 330 | } | 331 | } |
4010 | 331 | 332 | ||
4011 | @@ -339,6 +340,7 @@ | |||
4012 | 339 | preStyleChanged(); | 340 | preStyleChanged(); |
4013 | 340 | return false; | 341 | return false; |
4014 | 341 | } | 342 | } |
4015 | 343 | myStyle->updateFlickable(flickable); | ||
4016 | 342 | // bring the panels foreground | 344 | // bring the panels foreground |
4017 | 343 | styleItem->setZ(0); | 345 | styleItem->setZ(0); |
4018 | 344 | listItemStyle()->setAnimatePanels(true); | 346 | listItemStyle()->setAnimatePanels(true); |
4019 | @@ -372,23 +374,13 @@ | |||
4020 | 372 | (parentItem ? QQuickItemPrivate::get(parentItem)->childItems.indexOf(q) : -1); | 374 | (parentItem ? QQuickItemPrivate::get(parentItem)->childItems.indexOf(q) : -1); |
4021 | 373 | } | 375 | } |
4022 | 374 | 376 | ||
4025 | 375 | // returns true if the highlight is possible | 377 | // returns true if the highlight is possible; the highlight is possible if the |
4026 | 376 | bool UCListItemPrivate::canHighlight(QMouseEvent *event) | 378 | // list item has at least one action, leading/trailing actions set, onClicked |
4027 | 379 | // or onPressAndHold signal handlers set | ||
4028 | 380 | bool UCListItemPrivate::canHighlight() | ||
4029 | 377 | { | 381 | { |
4030 | 378 | // if automatic, the highlight should not happen if we clicked on an active component; | ||
4031 | 379 | // localPos is a position relative to ListItem which will give us a child from | ||
4032 | 380 | // from the original coordinates; therefore we must map the position to the contentItem | ||
4033 | 381 | Q_Q(UCListItem); | 382 | Q_Q(UCListItem); |
4044 | 382 | QPointF myPos = q->mapToItem(contentItem, event->localPos()); | 383 | return (isClickedConnected() || isPressAndHoldConnected() || mainAction || leadingActions || trailingActions); |
4035 | 383 | QQuickItem *child = contentItem->childAt(myPos.x(), myPos.y()); | ||
4036 | 384 | bool activeComponent = child && (child->acceptedMouseButtons() & event->button()) && | ||
4037 | 385 | child->isEnabled() && !qobject_cast<QQuickText*>(child); | ||
4038 | 386 | // do highlight if not pressed above the active component, and the component has either | ||
4039 | 387 | // action, leading or trailing actions list or at least an active child component declared | ||
4040 | 388 | QQuickMouseArea *ma = q->findChild<QQuickMouseArea*>(); | ||
4041 | 389 | bool activeMouseArea = ma && ma->isEnabled(); | ||
4042 | 390 | return !activeComponent && (isClickedConnected() || isPressAndHoldConnected() || | ||
4043 | 391 | mainAction || leadingActions || trailingActions || activeMouseArea); | ||
4045 | 392 | } | 384 | } |
4046 | 393 | 385 | ||
4047 | 394 | // set highlighted flag and update contentItem | 386 | // set highlighted flag and update contentItem |
4048 | @@ -876,8 +868,74 @@ | |||
4049 | 876 | * | 868 | * |
4050 | 877 | * \sa ViewItems::dragMode, ViewItems::dragUpdated | 869 | * \sa ViewItems::dragMode, ViewItems::dragUpdated |
4051 | 878 | * | 870 | * |
4052 | 871 | * \section2 Expansion | ||
4053 | 872 | * Since Ubuntu.Components 1.3, ListItem supports expansion. ListItems declared | ||
4054 | 873 | * in a view can expand exclusively, having leading and trailing panes locked | ||
4055 | 874 | * when expanded and to be collapsed when tapping outside of the expanded area. | ||
4056 | 875 | * The expansion is driven by the \l expansion group property, and the behavior | ||
4057 | 876 | * by the \l ViewItems::expansionFlags and \l ViewItems::expandedIndices | ||
4058 | 877 | * attached properties. Each ListItem which is required to expand should set a | ||
4059 | 878 | * proper height in the \l expansion.height property, which should be bigger | ||
4060 | 879 | * than the collapsed height of the ListItem is. The expansion itself is driven | ||
4061 | 880 | * by the \l expansion.expanded property, which can be set freely depending on | ||
4062 | 881 | * the use case, on click, on long press, etc. | ||
4063 | 882 | * | ||
4064 | 883 | * The default expansion behavior is set to be exclusive and locked, meaning | ||
4065 | 884 | * there can be only one ListItem expanded within a view and neither leading | ||
4066 | 885 | * nor trailing action panels cannot be swiped in. Expanding an other ListItem | ||
4067 | 886 | * will collapse the previosuly expanded one. There can be cases when tapping | ||
4068 | 887 | * outside of the expanded area of a ListItem we woudl need the expanded one | ||
4069 | 888 | * to collapse automatically. This can be achieved by setting \c ViewItems.CollapseOnOutsidePress | ||
4070 | 889 | * flag to \l ViewItems::expansionFlags. This flag will also turn on \c ViewItems.Exclusive | ||
4071 | 890 | * flag, as tapping outside practicly forbids more than one item to be expanded | ||
4072 | 891 | * at a time. | ||
4073 | 892 | * \qml | ||
4074 | 893 | * import QtQuick 2.4 | ||
4075 | 894 | * import Ubuntu.Components 1.3 | ||
4076 | 895 | * | ||
4077 | 896 | * ListView { | ||
4078 | 897 | * width: units.gu(40) | ||
4079 | 898 | * height: units.gu(71) | ||
4080 | 899 | * model: ListModel { | ||
4081 | 900 | * Component.onCompleted: { | ||
4082 | 901 | * for (var i = 0; i < 50; i++) { | ||
4083 | 902 | * append({data: i}); | ||
4084 | 903 | * } | ||
4085 | 904 | * } | ||
4086 | 905 | * } | ||
4087 | 906 | * ViewItems.expansionFlags: ViewItems.CollapseOnOutsidePress | ||
4088 | 907 | * delegate: ListItem { | ||
4089 | 908 | * Label { | ||
4090 | 909 | * text: "Model item #" + modelData | ||
4091 | 910 | * } | ||
4092 | 911 | * trailingActions: ListItemActions { | ||
4093 | 912 | * actions: [ | ||
4094 | 913 | * Action { | ||
4095 | 914 | * icon: "search" | ||
4096 | 915 | * }, | ||
4097 | 916 | * Action { | ||
4098 | 917 | * icon: "edit" | ||
4099 | 918 | * }, | ||
4100 | 919 | * Action { | ||
4101 | 920 | * icon: "copy" | ||
4102 | 921 | * } | ||
4103 | 922 | * ] | ||
4104 | 923 | * } | ||
4105 | 924 | * expansion.height: units.gu(15) | ||
4106 | 925 | * onClicked: expansion.expanded = true | ||
4107 | 926 | * } | ||
4108 | 927 | * } | ||
4109 | 928 | * \endqml | ||
4110 | 929 | * The example above collapses the expanded item whenever it is tapped or mouse | ||
4111 | 930 | * pressed outside of the expanded list item. | ||
4112 | 931 | * \note Set 0 to \l ViewItems::expansionFlags if no restrictions on expanded items | ||
4113 | 932 | * is required (i.e multiple expanded items are allowed, swiping leading/trailing | ||
4114 | 933 | * actions when expanded). | ||
4115 | 934 | * \note Do not bind \l expansion.height to the ListItem's height as is will cause | ||
4116 | 935 | * binding loops. | ||
4117 | 936 | * | ||
4118 | 879 | * \section2 Note on styling | 937 | * \section2 Note on styling |
4120 | 880 | * ListItem's styling differs from the other component sstyling, as ListItem loads | 938 | * ListItem's styling differs from the other components styling, as ListItem loads |
4121 | 881 | * the style only when either of the leadin/trailing panels are swiped, or when the | 939 | * the style only when either of the leadin/trailing panels are swiped, or when the |
4122 | 882 | * item enters in select- or drag mode. The component does not assume any visuals | 940 | * item enters in select- or drag mode. The component does not assume any visuals |
4123 | 883 | * to be present in the style. | 941 | * to be present in the style. |
4124 | @@ -914,6 +972,11 @@ | |||
4125 | 914 | { | 972 | { |
4126 | 915 | } | 973 | } |
4127 | 916 | 974 | ||
4128 | 975 | QObject *UCListItem::attachedViewItems(QObject *object, bool create) | ||
4129 | 976 | { | ||
4130 | 977 | return qmlAttachedPropertiesObject<UCViewItemsAttached>(object, create); | ||
4131 | 978 | } | ||
4132 | 979 | |||
4133 | 917 | void UCListItem::classBegin() | 980 | void UCListItem::classBegin() |
4134 | 918 | { | 981 | { |
4135 | 919 | UCStyledItemBase::classBegin(); | 982 | UCStyledItemBase::classBegin(); |
4136 | @@ -966,7 +1029,7 @@ | |||
4137 | 966 | this, SLOT(_q_syncDragMode())); | 1029 | this, SLOT(_q_syncDragMode())); |
4138 | 967 | 1030 | ||
4139 | 968 | // if selection or drag mode is on, initialize style, with animations turned off | 1031 | // if selection or drag mode is on, initialize style, with animations turned off |
4141 | 969 | if (d->parentAttached->selectMode() || d->parentAttached->dragMode()) { | 1032 | if (d->parentAttached->selectMode() || d->parentAttached->dragMode() || (d->expansion && d->expansion->expanded())) { |
4142 | 970 | d->loadStyleItem(false); | 1033 | d->loadStyleItem(false); |
4143 | 971 | } | 1034 | } |
4144 | 972 | // set the object name for testing purposes | 1035 | // set the object name for testing purposes |
4145 | @@ -996,10 +1059,10 @@ | |||
4146 | 996 | QQuickItem *parentAttachee = data.item; | 1059 | QQuickItem *parentAttachee = data.item; |
4147 | 997 | if (d->flickable && d->flickable->inherits("QQuickListView")) { | 1060 | if (d->flickable && d->flickable->inherits("QQuickListView")) { |
4148 | 998 | // attach to ListView | 1061 | // attach to ListView |
4150 | 999 | d->parentAttached = static_cast<UCViewItemsAttached*>(qmlAttachedPropertiesObject<UCViewItemsAttached>(d->flickable)); | 1062 | d->parentAttached = static_cast<UCViewItemsAttached*>(attachedViewItems(d->flickable, true)); |
4151 | 1000 | parentAttachee = d->flickable; | 1063 | parentAttachee = d->flickable; |
4152 | 1001 | } else if (data.item) { | 1064 | } else if (data.item) { |
4154 | 1002 | d->parentAttached = static_cast<UCViewItemsAttached*>(qmlAttachedPropertiesObject<UCViewItemsAttached>(data.item)); | 1065 | d->parentAttached = static_cast<UCViewItemsAttached*>(attachedViewItems(data.item, true)); |
4155 | 1003 | } else { | 1066 | } else { |
4156 | 1004 | // mark as not ready, so no action should be performed which depends on readyness | 1067 | // mark as not ready, so no action should be performed which depends on readyness |
4157 | 1005 | d->ready = false; | 1068 | d->ready = false; |
4158 | @@ -1007,6 +1070,11 @@ | |||
4159 | 1007 | d->parentAttached = 0; | 1070 | d->parentAttached = 0; |
4160 | 1008 | } | 1071 | } |
4161 | 1009 | 1072 | ||
4162 | 1073 | if (d->styleItem) { | ||
4163 | 1074 | UCListItemStyle * myStyle = static_cast<UCListItemStyle*>(d->styleItem); | ||
4164 | 1075 | myStyle->updateFlickable(d->flickable); | ||
4165 | 1076 | } | ||
4166 | 1077 | |||
4167 | 1010 | if (parentAttachee) { | 1078 | if (parentAttachee) { |
4168 | 1011 | QObject::connect(parentAttachee, SIGNAL(widthChanged()), this, SLOT(_q_updateSize()), Qt::DirectConnection); | 1079 | QObject::connect(parentAttachee, SIGNAL(widthChanged()), this, SLOT(_q_updateSize()), Qt::DirectConnection); |
4169 | 1012 | // update size | 1080 | // update size |
4170 | @@ -1081,7 +1149,7 @@ | |||
4171 | 1081 | // while moving, we cannot select any items | 1149 | // while moving, we cannot select any items |
4172 | 1082 | return; | 1150 | return; |
4173 | 1083 | } | 1151 | } |
4175 | 1084 | if (d->canHighlight(event) && !d->highlighted && event->button() == Qt::LeftButton) { | 1152 | if (d->canHighlight() && !d->highlighted && event->button() == Qt::LeftButton) { |
4176 | 1085 | d->grabLeftButtonEvents(event); | 1153 | d->grabLeftButtonEvents(event); |
4177 | 1086 | } | 1154 | } |
4178 | 1087 | // accept the event so we get the rest of the events as well | 1155 | // accept the event so we get the rest of the events as well |
4179 | @@ -1194,7 +1262,7 @@ | |||
4180 | 1194 | Q_D(UCListItem); | 1262 | Q_D(UCListItem); |
4181 | 1195 | UCStyledItemBase::mouseMoveEvent(event); | 1263 | UCStyledItemBase::mouseMoveEvent(event); |
4182 | 1196 | 1264 | ||
4184 | 1197 | if (d->selectMode() || d->dragMode()) { | 1265 | if (d->selectMode() || d->dragMode() || (d->expansion && d->expansion->expandedLocked())) { |
4185 | 1198 | // no move is allowed while selectable mode is on | 1266 | // no move is allowed while selectable mode is on |
4186 | 1199 | return; | 1267 | return; |
4187 | 1200 | } | 1268 | } |
4188 | @@ -1672,4 +1740,48 @@ | |||
4189 | 1672 | d->defaultThemeVersion = BUILD_VERSION(1, 3); | 1740 | d->defaultThemeVersion = BUILD_VERSION(1, 3); |
4190 | 1673 | } | 1741 | } |
4191 | 1674 | 1742 | ||
4192 | 1743 | QObject *UCListItem13::attachedViewItems(QObject *object, bool create) | ||
4193 | 1744 | { | ||
4194 | 1745 | return qmlAttachedPropertiesObject<UCViewItemsAttached13>(object, create); | ||
4195 | 1746 | } | ||
4196 | 1747 | |||
4197 | 1748 | void UCListItem13::itemChange(ItemChange change, const ItemChangeData &data) | ||
4198 | 1749 | { | ||
4199 | 1750 | UCListItem::itemChange(change, data); | ||
4200 | 1751 | |||
4201 | 1752 | Q_D(UCListItem); | ||
4202 | 1753 | // ViewItems drives expansion | ||
4203 | 1754 | if (d->parentAttached) { | ||
4204 | 1755 | connect(d->parentAttached.data(), SIGNAL(expandedIndicesChanged(QList<int>)), | ||
4205 | 1756 | this, SLOT(_q_updateExpansion(QList<int>)), Qt::UniqueConnection); | ||
4206 | 1757 | } | ||
4207 | 1758 | } | ||
4208 | 1759 | |||
4209 | 1760 | /*! | ||
4210 | 1761 | * \qmlpropertygroup ::ListItem::expansion | ||
4211 | 1762 | * \qmlproperty bool ListItem::expansion.expanded | ||
4212 | 1763 | * \qmlproperty real ListItem::expansion.height | ||
4213 | 1764 | * \since Ubuntu.Components 1.3 | ||
4214 | 1765 | * The group drefines the expansion state of the ListItem. | ||
4215 | 1766 | */ | ||
4216 | 1767 | UCListItemExpansion *UCListItem13::expansion() | ||
4217 | 1768 | { | ||
4218 | 1769 | Q_D(UCListItem); | ||
4219 | 1770 | if (!d->expansion) { | ||
4220 | 1771 | d->expansion = new UCListItemExpansion(this); | ||
4221 | 1772 | } | ||
4222 | 1773 | return d->expansion; | ||
4223 | 1774 | } | ||
4224 | 1775 | |||
4225 | 1776 | void UCListItem13::_q_updateExpansion(const QList<int> &indices) | ||
4226 | 1777 | { | ||
4227 | 1778 | Q_UNUSED(indices); | ||
4228 | 1779 | Q_D(UCListItem); | ||
4229 | 1780 | Q_EMIT expansion()->expandedChanged(); | ||
4230 | 1781 | // make sure the style is loaded | ||
4231 | 1782 | if (indices.contains(d->index())) { | ||
4232 | 1783 | d->loadStyleItem(); | ||
4233 | 1784 | } | ||
4234 | 1785 | } | ||
4235 | 1786 | |||
4236 | 1675 | #include "moc_uclistitem.cpp" | 1787 | #include "moc_uclistitem.cpp" |
4237 | 1676 | 1788 | ||
4238 | === modified file 'src/Ubuntu/Components/plugin/uclistitem.h' | |||
4239 | --- src/Ubuntu/Components/plugin/uclistitem.h 2015-07-28 19:29:19 +0000 | |||
4240 | +++ src/Ubuntu/Components/plugin/uclistitem.h 2015-09-08 04:09:38 +0000 | |||
4241 | @@ -62,6 +62,7 @@ | |||
4242 | 62 | void resetHighlightColor(); | 62 | void resetHighlightColor(); |
4243 | 63 | 63 | ||
4244 | 64 | protected: | 64 | protected: |
4245 | 65 | virtual QObject *attachedViewItems(QObject *object, bool create); | ||
4246 | 65 | void classBegin(); | 66 | void classBegin(); |
4247 | 66 | void componentComplete(); | 67 | void componentComplete(); |
4248 | 67 | QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data); | 68 | QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data); |
4249 | @@ -109,17 +110,24 @@ | |||
4250 | 109 | Q_PRIVATE_SLOT(d_func(), void _q_syncDragMode()) | 110 | Q_PRIVATE_SLOT(d_func(), void _q_syncDragMode()) |
4251 | 110 | }; | 111 | }; |
4252 | 111 | 112 | ||
4253 | 113 | class UCListItemExpansion; | ||
4254 | 112 | class UCListItem13 : public UCListItem | 114 | class UCListItem13 : public UCListItem |
4255 | 113 | { | 115 | { |
4256 | 114 | Q_OBJECT | 116 | Q_OBJECT |
4257 | 117 | Q_PROPERTY(UCListItemExpansion* expansion READ expansion CONSTANT) | ||
4258 | 115 | protected: | 118 | protected: |
4259 | 119 | virtual QObject *attachedViewItems(QObject *object, bool create); | ||
4260 | 120 | void itemChange(ItemChange change, const ItemChangeData &data); | ||
4261 | 116 | void mousePressEvent(QMouseEvent *event); | 121 | void mousePressEvent(QMouseEvent *event); |
4262 | 117 | void mouseReleaseEvent(QMouseEvent *event); | 122 | void mouseReleaseEvent(QMouseEvent *event); |
4263 | 118 | private: | 123 | private: |
4264 | 124 | Q_SLOT void _q_updateExpansion(const QList<int> &indices); | ||
4265 | 119 | bool shouldShowContextMenu(QMouseEvent *event); | 125 | bool shouldShowContextMenu(QMouseEvent *event); |
4266 | 120 | void popoverClosed(); | 126 | void popoverClosed(); |
4267 | 121 | public: | 127 | public: |
4268 | 122 | explicit UCListItem13(QQuickItem *parent = 0); | 128 | explicit UCListItem13(QQuickItem *parent = 0); |
4269 | 129 | |||
4270 | 130 | UCListItemExpansion *expansion(); | ||
4271 | 123 | }; | 131 | }; |
4272 | 124 | 132 | ||
4273 | 125 | class UCListItemDividerPrivate; | 133 | class UCListItemDividerPrivate; |
4274 | @@ -158,8 +166,15 @@ | |||
4275 | 158 | Q_PROPERTY(bool selectMode READ selectMode WRITE setSelectMode NOTIFY selectModeChanged) | 166 | Q_PROPERTY(bool selectMode READ selectMode WRITE setSelectMode NOTIFY selectModeChanged) |
4276 | 159 | Q_PROPERTY(QList<int> selectedIndices READ selectedIndices WRITE setSelectedIndices NOTIFY selectedIndicesChanged) | 167 | Q_PROPERTY(QList<int> selectedIndices READ selectedIndices WRITE setSelectedIndices NOTIFY selectedIndicesChanged) |
4277 | 160 | Q_PROPERTY(bool dragMode READ dragMode WRITE setDragMode NOTIFY dragModeChanged) | 168 | Q_PROPERTY(bool dragMode READ dragMode WRITE setDragMode NOTIFY dragModeChanged) |
4278 | 169 | Q_ENUMS(ExpansionFlag) | ||
4279 | 161 | public: | 170 | public: |
4281 | 162 | explicit UCViewItemsAttached(QObject *owner); | 171 | enum ExpansionFlag { |
4282 | 172 | Exclusive = 0x01, | ||
4283 | 173 | UnlockExpanded = 0x02, | ||
4284 | 174 | CollapseOnOutsidePress = Exclusive | 0x04 | ||
4285 | 175 | }; | ||
4286 | 176 | Q_DECLARE_FLAGS(ExpansionFlags, ExpansionFlag) | ||
4287 | 177 | explicit UCViewItemsAttached(QObject *owner = 0); | ||
4288 | 163 | ~UCViewItemsAttached(); | 178 | ~UCViewItemsAttached(); |
4289 | 164 | 179 | ||
4290 | 165 | static UCViewItemsAttached *qmlAttachedProperties(QObject *owner); | 180 | static UCViewItemsAttached *qmlAttachedProperties(QObject *owner); |
4291 | @@ -191,8 +206,68 @@ | |||
4292 | 191 | private: | 206 | private: |
4293 | 192 | Q_DECLARE_PRIVATE(UCViewItemsAttached) | 207 | Q_DECLARE_PRIVATE(UCViewItemsAttached) |
4294 | 193 | }; | 208 | }; |
4295 | 209 | Q_DECLARE_OPERATORS_FOR_FLAGS(UCViewItemsAttached::ExpansionFlags) | ||
4296 | 194 | QML_DECLARE_TYPEINFO(UCViewItemsAttached, QML_HAS_ATTACHED_PROPERTIES) | 210 | QML_DECLARE_TYPEINFO(UCViewItemsAttached, QML_HAS_ATTACHED_PROPERTIES) |
4297 | 195 | 211 | ||
4298 | 212 | // FIXME keep the 1.3 properties in a separate class, workaround for bug | ||
4299 | 213 | // https://bugs.launchpad.net/ubuntu/+source/qtdeclarative-opensource-src/+bug/1389721 | ||
4300 | 214 | // enums and flag are added to UCViewItemsAttached like normal | ||
4301 | 215 | class UCViewItemsAttached13 : public UCViewItemsAttached | ||
4302 | 216 | { | ||
4303 | 217 | Q_OBJECT | ||
4304 | 218 | Q_PROPERTY(QList<int> expandedIndices READ expandedIndices WRITE setExpandedIndices NOTIFY expandedIndicesChanged) | ||
4305 | 219 | Q_PROPERTY(int expansionFlags READ expansionFlags WRITE setExpansionFlags NOTIFY expansionFlagsChanged) | ||
4306 | 220 | public: | ||
4307 | 221 | explicit UCViewItemsAttached13(QObject *owner = 0); | ||
4308 | 222 | static UCViewItemsAttached13 *qmlAttachedProperties(QObject *owner); | ||
4309 | 223 | |||
4310 | 224 | QList<int> expandedIndices() const; | ||
4311 | 225 | void setExpandedIndices(QList<int> indices); | ||
4312 | 226 | int expansionFlags() const; | ||
4313 | 227 | void setExpansionFlags(int flags); | ||
4314 | 228 | |||
4315 | 229 | Q_SIGNALS: | ||
4316 | 230 | void expandedIndicesChanged(const QList<int> &indices); | ||
4317 | 231 | void expansionFlagsChanged(); | ||
4318 | 232 | |||
4319 | 233 | private: | ||
4320 | 234 | UCViewItemsAttachedPrivate *d_ptr; | ||
4321 | 235 | Q_DECLARE_PRIVATE_D(d_ptr, UCViewItemsAttached) | ||
4322 | 236 | }; | ||
4323 | 237 | QML_DECLARE_TYPEINFO(UCViewItemsAttached13, QML_HAS_ATTACHED_PROPERTIES) | ||
4324 | 238 | |||
4325 | 239 | class UCListItemExpansion : public QObject | ||
4326 | 240 | { | ||
4327 | 241 | Q_OBJECT | ||
4328 | 242 | Q_PROPERTY(bool expanded READ expanded WRITE setExpanded NOTIFY expandedChanged) | ||
4329 | 243 | Q_PROPERTY(qreal height MEMBER m_height WRITE setHeight NOTIFY heightChanged) | ||
4330 | 244 | public: | ||
4331 | 245 | explicit UCListItemExpansion(QObject *parent = 0); | ||
4332 | 246 | |||
4333 | 247 | bool expandedLocked(); | ||
4334 | 248 | void enableClickFiltering(bool enable); | ||
4335 | 249 | |||
4336 | 250 | bool expanded(); | ||
4337 | 251 | void setExpanded(bool expanded); | ||
4338 | 252 | void setHeight(qreal height); | ||
4339 | 253 | |||
4340 | 254 | Q_SIGNALS: | ||
4341 | 255 | void expandedChanged(); | ||
4342 | 256 | void heightChanged(); | ||
4343 | 257 | |||
4344 | 258 | protected: | ||
4345 | 259 | bool eventFilter(QObject *, QEvent *); | ||
4346 | 260 | |||
4347 | 261 | private: | ||
4348 | 262 | UCListItem13 *m_listItem; | ||
4349 | 263 | qreal m_height; | ||
4350 | 264 | bool m_filtering:1; | ||
4351 | 265 | |||
4352 | 266 | friend class UCListItem; | ||
4353 | 267 | friend class UCListItem13; | ||
4354 | 268 | friend class UCListItemPrivate; | ||
4355 | 269 | }; | ||
4356 | 270 | |||
4357 | 196 | class UCDragEvent : public QObject | 271 | class UCDragEvent : public QObject |
4358 | 197 | { | 272 | { |
4359 | 198 | Q_OBJECT | 273 | Q_OBJECT |
4360 | 199 | 274 | ||
4361 | === modified file 'src/Ubuntu/Components/plugin/uclistitem_p.h' | |||
4362 | --- src/Ubuntu/Components/plugin/uclistitem_p.h 2015-07-30 13:27:32 +0000 | |||
4363 | +++ src/Ubuntu/Components/plugin/uclistitem_p.h 2015-09-08 04:09:38 +0000 | |||
4364 | @@ -60,7 +60,7 @@ | |||
4365 | 60 | void _q_syncSelectMode(); | 60 | void _q_syncSelectMode(); |
4366 | 61 | void _q_syncDragMode(); | 61 | void _q_syncDragMode(); |
4367 | 62 | int index(); | 62 | int index(); |
4369 | 63 | bool canHighlight(QMouseEvent *event); | 63 | bool canHighlight(); |
4370 | 64 | void setHighlighted(bool pressed); | 64 | void setHighlighted(bool pressed); |
4371 | 65 | void listenToRebind(bool listen); | 65 | void listenToRebind(bool listen); |
4372 | 66 | void lockContentItem(bool lock); | 66 | void lockContentItem(bool lock); |
4373 | @@ -95,6 +95,7 @@ | |||
4374 | 95 | UCListItemActions *leadingActions; | 95 | UCListItemActions *leadingActions; |
4375 | 96 | UCListItemActions *trailingActions; | 96 | UCListItemActions *trailingActions; |
4376 | 97 | UCAction *mainAction; | 97 | UCAction *mainAction; |
4377 | 98 | UCListItemExpansion *expansion; | ||
4378 | 98 | 99 | ||
4379 | 99 | // getters/setters | 100 | // getters/setters |
4380 | 100 | QQmlListProperty<QObject> data(); | 101 | QQmlListProperty<QObject> data(); |
4381 | @@ -147,17 +148,25 @@ | |||
4382 | 147 | bool isDragUpdatedConnected(); | 148 | bool isDragUpdatedConnected(); |
4383 | 148 | void updateSelectedIndices(int fromIndex, int toIndex); | 149 | void updateSelectedIndices(int fromIndex, int toIndex); |
4384 | 149 | 150 | ||
4385 | 151 | // expansion | ||
4386 | 152 | void expand(int index, UCListItem13 *listItem, bool emitChangeSignal = true); | ||
4387 | 153 | void collapse(int index, bool emitChangeSignal = true); | ||
4388 | 154 | void collapseAll(); | ||
4389 | 155 | void toggleExpansionFlags(bool enable); | ||
4390 | 156 | |||
4391 | 157 | QSet<int> selectedList; | ||
4392 | 158 | QMap<int, QPointer<UCListItem13> > expansionList; | ||
4393 | 159 | QList< QPointer<QQuickFlickable> > flickables; | ||
4394 | 160 | QList< PropertyChange* > changes; | ||
4395 | 161 | QPointer<UCListItem> boundItem; | ||
4396 | 162 | QPointer<UCListItem> disablerItem; | ||
4397 | 150 | QQuickFlickable *listView; | 163 | QQuickFlickable *listView; |
4398 | 151 | ListItemDragArea *dragArea; | 164 | ListItemDragArea *dragArea; |
4399 | 165 | UCViewItemsAttached::ExpansionFlags expansionFlags; | ||
4400 | 152 | bool globalDisabled:1; | 166 | bool globalDisabled:1; |
4401 | 153 | bool selectable:1; | 167 | bool selectable:1; |
4402 | 154 | bool draggable:1; | 168 | bool draggable:1; |
4403 | 155 | bool ready:1; | 169 | bool ready:1; |
4404 | 156 | QSet<int> selectedList; | ||
4405 | 157 | QList< QPointer<QQuickFlickable> > flickables; | ||
4406 | 158 | QList< PropertyChange* > changes; | ||
4407 | 159 | QPointer<UCListItem> boundItem; | ||
4408 | 160 | QPointer<UCListItem> disablerItem; | ||
4409 | 161 | }; | 170 | }; |
4410 | 162 | 171 | ||
4411 | 163 | #endif // UCVIEWITEM_P_H | 172 | #endif // UCVIEWITEM_P_H |
4412 | 164 | 173 | ||
4413 | === modified file 'src/Ubuntu/Components/plugin/uclistitemstyle.cpp' | |||
4414 | --- src/Ubuntu/Components/plugin/uclistitemstyle.cpp 2015-04-13 13:42:03 +0000 | |||
4415 | +++ src/Ubuntu/Components/plugin/uclistitemstyle.cpp 2015-09-08 04:09:38 +0000 | |||
4416 | @@ -21,6 +21,7 @@ | |||
4417 | 21 | #include <QtQml/QQmlContext> | 21 | #include <QtQml/QQmlContext> |
4418 | 22 | #include <QtQml/QQmlInfo> | 22 | #include <QtQml/QQmlInfo> |
4419 | 23 | #include <QtQuick/private/qquickanimation_p.h> | 23 | #include <QtQuick/private/qquickanimation_p.h> |
4420 | 24 | #include <QtQuick/private/qquickflickable_p.h> | ||
4421 | 24 | 25 | ||
4422 | 25 | /*! | 26 | /*! |
4423 | 26 | * \qmltype ListItemStyle | 27 | * \qmltype ListItemStyle |
4424 | @@ -41,6 +42,7 @@ | |||
4425 | 41 | , m_snapAnimation(0) | 42 | , m_snapAnimation(0) |
4426 | 42 | , m_dropAnimation(0) | 43 | , m_dropAnimation(0) |
4427 | 43 | , m_dragPanel(0) | 44 | , m_dragPanel(0) |
4428 | 45 | , m_flickable(Q_NULLPTR) | ||
4429 | 44 | , m_animatePanels(true) | 46 | , m_animatePanels(true) |
4430 | 45 | { | 47 | { |
4431 | 46 | } | 48 | } |
4432 | @@ -54,21 +56,29 @@ | |||
4433 | 54 | setAnimatePanels(context->contextProperty("animated").toBool()); | 56 | setAnimatePanels(context->contextProperty("animated").toBool()); |
4434 | 55 | } | 57 | } |
4435 | 56 | m_listItem = qmlContext(this)->contextProperty("styledItem").value<UCListItem*>(); | 58 | m_listItem = qmlContext(this)->contextProperty("styledItem").value<UCListItem*>(); |
4436 | 59 | // get the flickable value | ||
4437 | 60 | if (m_listItem) { | ||
4438 | 61 | m_flickable = UCListItemPrivate::get(m_listItem)->flickable.data(); | ||
4439 | 62 | } | ||
4440 | 57 | } | 63 | } |
4441 | 58 | 64 | ||
4442 | 59 | void UCListItemStyle::componentComplete() | 65 | void UCListItemStyle::componentComplete() |
4443 | 60 | { | 66 | { |
4444 | 61 | QQuickItem::componentComplete(); | 67 | QQuickItem::componentComplete(); |
4445 | 62 | 68 | ||
4455 | 63 | // look for overridden slots | 69 | // look for overridden slots, indexOfMethod returns th elast index of the overridden method |
4456 | 64 | for (int i = metaObject()->methodOffset(); i < metaObject()->methodCount(); i++) { | 70 | m_rebound = metaObject()->method(metaObject()->indexOfMethod("rebound()")); |
4457 | 65 | const QMetaMethod method = metaObject()->method(i); | 71 | m_swipeEvent = metaObject()->method(metaObject()->indexOfMethod("swipeEvent(QVariant)")); |
4458 | 66 | if (method.name() == QByteArrayLiteral("swipeEvent")) { | 72 | // qDebug() << m_rebound.isValid() << m_swipeEvent.isValid(); |
4459 | 67 | m_swipeEvent = method; | 73 | // for (int i = metaObject()->methodOffset(); i < metaObject()->methodCount(); i++) { |
4460 | 68 | } else if (method.name() == QByteArrayLiteral("rebound")) { | 74 | // const QMetaMethod method = metaObject()->method(i); |
4461 | 69 | m_rebound = method; | 75 | // if (method.name() == QByteArrayLiteral("swipeEvent")) { |
4462 | 70 | } | 76 | // qDebug() << method.methodSignature(); |
4463 | 71 | } | 77 | // m_swipeEvent = method; |
4464 | 78 | // } else if (method.name() == QByteArrayLiteral("rebound")) { | ||
4465 | 79 | // m_rebound = method; | ||
4466 | 80 | // } | ||
4467 | 81 | // } | ||
4468 | 72 | 82 | ||
4469 | 73 | // connect snapAnimation's stopped() and the owning ListItem's contentMovementeEnded() signals | 83 | // connect snapAnimation's stopped() and the owning ListItem's contentMovementeEnded() signals |
4470 | 74 | if (m_listItem && m_snapAnimation) { | 84 | if (m_listItem && m_snapAnimation) { |
4471 | @@ -92,6 +102,25 @@ | |||
4472 | 92 | } | 102 | } |
4473 | 93 | 103 | ||
4474 | 94 | /*! | 104 | /*! |
4475 | 105 | * \qmlproperty Flickable ListItemStyle::flickable | ||
4476 | 106 | * \readonly | ||
4477 | 107 | * \since Ubuntu.Components.Styles 1.3 | ||
4478 | 108 | * The property holds the Flickable (or ListView) holding the ListItem styled. | ||
4479 | 109 | */ | ||
4480 | 110 | QQuickFlickable *UCListItemStyle::flickable() | ||
4481 | 111 | { | ||
4482 | 112 | return m_flickable; | ||
4483 | 113 | } | ||
4484 | 114 | void UCListItemStyle::updateFlickable(QQuickFlickable *flickable) | ||
4485 | 115 | { | ||
4486 | 116 | if (m_flickable == flickable) { | ||
4487 | 117 | return; | ||
4488 | 118 | } | ||
4489 | 119 | m_flickable = flickable; | ||
4490 | 120 | Q_EMIT flickableChanged(); | ||
4491 | 121 | } | ||
4492 | 122 | |||
4493 | 123 | /*! | ||
4494 | 95 | * \qmlmethod ListItemStyle::swipeEvent(SwipeEvent event) | 124 | * \qmlmethod ListItemStyle::swipeEvent(SwipeEvent event) |
4495 | 96 | * The function is called by the ListItem when a swipe action is performed, i.e. | 125 | * The function is called by the ListItem when a swipe action is performed, i.e. |
4496 | 97 | * when the swipe is started, the position is updated or the swipe ends. The | 126 | * when the swipe is started, the position is updated or the swipe ends. The |
4497 | 98 | 127 | ||
4498 | === modified file 'src/Ubuntu/Components/plugin/uclistitemstyle.h' | |||
4499 | --- src/Ubuntu/Components/plugin/uclistitemstyle.h 2015-04-13 13:42:03 +0000 | |||
4500 | +++ src/Ubuntu/Components/plugin/uclistitemstyle.h 2015-09-08 04:09:38 +0000 | |||
4501 | @@ -62,6 +62,7 @@ | |||
4502 | 62 | class QQuickPropertyAnimation; | 62 | class QQuickPropertyAnimation; |
4503 | 63 | class QQuickBehavior; | 63 | class QQuickBehavior; |
4504 | 64 | class UCListItem; | 64 | class UCListItem; |
4505 | 65 | class QQuickFlickable; | ||
4506 | 65 | class UCListItemStyle : public QQuickItem | 66 | class UCListItemStyle : public QQuickItem |
4507 | 66 | { | 67 | { |
4508 | 67 | Q_OBJECT | 68 | Q_OBJECT |
4509 | @@ -70,6 +71,7 @@ | |||
4510 | 70 | Q_PROPERTY(bool animatePanels READ animatePanels NOTIFY animatePanelsChanged) | 71 | Q_PROPERTY(bool animatePanels READ animatePanels NOTIFY animatePanelsChanged) |
4511 | 71 | Q_PROPERTY(QQuickItem *dragPanel MEMBER m_dragPanel NOTIFY dragPanelChanged) | 72 | Q_PROPERTY(QQuickItem *dragPanel MEMBER m_dragPanel NOTIFY dragPanelChanged) |
4512 | 72 | Q_PROPERTY(int listItemIndex READ index NOTIFY listItemIndexChanged FINAL REVISION 1) | 73 | Q_PROPERTY(int listItemIndex READ index NOTIFY listItemIndexChanged FINAL REVISION 1) |
4513 | 74 | Q_PROPERTY(QQuickFlickable *flickable READ flickable NOTIFY flickableChanged REVISION 1) | ||
4514 | 73 | public: | 75 | public: |
4515 | 74 | explicit UCListItemStyle(QQuickItem *parent = 0); | 76 | explicit UCListItemStyle(QQuickItem *parent = 0); |
4516 | 75 | 77 | ||
4517 | @@ -78,6 +80,8 @@ | |||
4518 | 78 | bool animatePanels() const; | 80 | bool animatePanels() const; |
4519 | 79 | void setAnimatePanels(bool animate); | 81 | void setAnimatePanels(bool animate); |
4520 | 80 | int index(); | 82 | int index(); |
4521 | 83 | QQuickFlickable *flickable(); | ||
4522 | 84 | void updateFlickable(QQuickFlickable *flickable); | ||
4523 | 81 | 85 | ||
4524 | 82 | Q_SIGNALS: | 86 | Q_SIGNALS: |
4525 | 83 | void snapAnimationChanged(); | 87 | void snapAnimationChanged(); |
4526 | @@ -85,6 +89,7 @@ | |||
4527 | 85 | void animatePanelsChanged(); | 89 | void animatePanelsChanged(); |
4528 | 86 | void dragPanelChanged(); | 90 | void dragPanelChanged(); |
4529 | 87 | Q_REVISION(1) void listItemIndexChanged(); | 91 | Q_REVISION(1) void listItemIndexChanged(); |
4530 | 92 | Q_REVISION(1) void flickableChanged(); | ||
4531 | 88 | 93 | ||
4532 | 89 | public Q_SLOTS: | 94 | public Q_SLOTS: |
4533 | 90 | void swipeEvent(UCSwipeEvent *event); | 95 | void swipeEvent(UCSwipeEvent *event); |
4534 | @@ -102,6 +107,7 @@ | |||
4535 | 102 | QQuickAbstractAnimation *m_snapAnimation; | 107 | QQuickAbstractAnimation *m_snapAnimation; |
4536 | 103 | QQuickPropertyAnimation *m_dropAnimation; | 108 | QQuickPropertyAnimation *m_dropAnimation; |
4537 | 104 | QQuickItem *m_dragPanel; | 109 | QQuickItem *m_dragPanel; |
4538 | 110 | QQuickFlickable *m_flickable; | ||
4539 | 105 | bool m_animatePanels:1; | 111 | bool m_animatePanels:1; |
4540 | 106 | 112 | ||
4541 | 107 | friend class UCListItemPrivate; | 113 | friend class UCListItemPrivate; |
4542 | 108 | 114 | ||
4543 | === modified file 'src/Ubuntu/Components/plugin/ucqquickimageextension.cpp' | |||
4544 | --- src/Ubuntu/Components/plugin/ucqquickimageextension.cpp 2014-11-24 13:14:35 +0000 | |||
4545 | +++ src/Ubuntu/Components/plugin/ucqquickimageextension.cpp 2015-09-08 04:09:38 +0000 | |||
4546 | @@ -19,6 +19,7 @@ | |||
4547 | 19 | #include <QtCore/QFile> | 19 | #include <QtCore/QFile> |
4548 | 20 | #include <QtCore/QFileInfo> | 20 | #include <QtCore/QFileInfo> |
4549 | 21 | #include <QtCore/QDir> | 21 | #include <QtCore/QDir> |
4550 | 22 | #include <QtGui/QGuiApplication> | ||
4551 | 22 | #include <QtQuick/private/qquickimagebase_p.h> | 23 | #include <QtQuick/private/qquickimagebase_p.h> |
4552 | 23 | 24 | ||
4553 | 24 | #include "ucqquickimageextension.h" | 25 | #include "ucqquickimageextension.h" |
4554 | @@ -78,8 +79,18 @@ | |||
4555 | 78 | QString selectedFilePath = resolved.mid(separatorPosition+1); | 79 | QString selectedFilePath = resolved.mid(separatorPosition+1); |
4556 | 79 | 80 | ||
4557 | 80 | if (scaleFactor == "1") { | 81 | if (scaleFactor == "1") { |
4560 | 81 | // No scaling. Just pass the file as is. | 82 | if (qFuzzyCompare(qGuiApp->devicePixelRatio(), (qreal)1.0) |
4561 | 82 | m_image->setSource(QUrl::fromLocalFile(selectedFilePath)); | 83 | || selectedFilePath.endsWith(".svg") || selectedFilePath.endsWith(".svgz")) { |
4562 | 84 | // No scaling necessary. Just pass the file as is. | ||
4563 | 85 | m_image->setSource(QUrl::fromLocalFile(selectedFilePath)); | ||
4564 | 86 | } else { | ||
4565 | 87 | // Need to scale the pixel-based image to suit the devicePixelRatio setting ourselves. | ||
4566 | 88 | // If we let Qt do it, Qt will not choose the UITK-supported "@gu" scaled images. | ||
4567 | 89 | m_image->setSource(QUrl("image://scaling/1/" + selectedFilePath)); | ||
4568 | 90 | // explicitly set the source size in the QQuickImageBase, this persuades it that the | ||
4569 | 91 | // supplied image is suitable for the current devicePixelRatio. | ||
4570 | 92 | m_image->setSourceSize(m_image->sourceSize()); | ||
4571 | 93 | } | ||
4572 | 83 | } else { | 94 | } else { |
4573 | 84 | // Prepend "image://scaling" for the image to be loaded by UCScalingImageProvider. | 95 | // Prepend "image://scaling" for the image to be loaded by UCScalingImageProvider. |
4574 | 85 | if (!m_source.path().endsWith(".sci")) { | 96 | if (!m_source.path().endsWith(".sci")) { |
4575 | @@ -100,7 +111,13 @@ | |||
4576 | 100 | rewrittenSciFile->setFileTemplate(QDir::tempPath() + QDir::separator() + "XXXXXX.sci"); | 111 | rewrittenSciFile->setFileTemplate(QDir::tempPath() + QDir::separator() + "XXXXXX.sci"); |
4577 | 101 | rewrittenSciFile->open(); | 112 | rewrittenSciFile->open(); |
4578 | 102 | QTextStream output(rewrittenSciFile); | 113 | QTextStream output(rewrittenSciFile); |
4580 | 103 | rewritten = rewriteSciFile(selectedFilePath, scaleFactor, output); | 114 | |
4581 | 115 | if (qFuzzyCompare(qGuiApp->devicePixelRatio(), (qreal)1.0)) { | ||
4582 | 116 | rewritten = rewriteSciFile(selectedFilePath, scaleFactor, output); | ||
4583 | 117 | } else { | ||
4584 | 118 | QString scaleFactorInDevicePixels = QString::number(scaleFactor.toFloat() / qGuiApp->devicePixelRatio()); | ||
4585 | 119 | rewritten = rewriteSciFile(selectedFilePath, scaleFactorInDevicePixels, output); | ||
4586 | 120 | } | ||
4587 | 104 | rewrittenSciFile->close(); | 121 | rewrittenSciFile->close(); |
4588 | 105 | 122 | ||
4589 | 106 | s_rewrittenSciFiles.insert(m_source, QSharedPointer<QTemporaryFile>(rewrittenSciFile)); | 123 | s_rewrittenSciFiles.insert(m_source, QSharedPointer<QTemporaryFile>(rewrittenSciFile)); |
4590 | @@ -112,6 +129,9 @@ | |||
4591 | 112 | m_image->setSource(m_source); | 129 | m_image->setSource(m_source); |
4592 | 113 | } | 130 | } |
4593 | 114 | } | 131 | } |
4594 | 132 | // explicitly set the source size in the QQuickImageBase, this persuades it that the | ||
4595 | 133 | // supplied image is suitable for the current devicePixelRatio. | ||
4596 | 134 | m_image->setSourceSize(m_image->sourceSize()); | ||
4597 | 115 | } | 135 | } |
4598 | 116 | } | 136 | } |
4599 | 117 | 137 | ||
4600 | 118 | 138 | ||
4601 | === modified file 'src/Ubuntu/Components/plugin/ucstatesaver.cpp' | |||
4602 | --- src/Ubuntu/Components/plugin/ucstatesaver.cpp 2015-07-22 14:35:48 +0000 | |||
4603 | +++ src/Ubuntu/Components/plugin/ucstatesaver.cpp 2015-09-08 04:09:38 +0000 | |||
4604 | @@ -147,7 +147,7 @@ | |||
4605 | 147 | * \instantiates UCStateSaverAttached | 147 | * \instantiates UCStateSaverAttached |
4606 | 148 | * \inqmlmodule Ubuntu.Components 1.1 | 148 | * \inqmlmodule Ubuntu.Components 1.1 |
4607 | 149 | * \ingroup ubuntu-services | 149 | * \ingroup ubuntu-services |
4609 | 150 | * \brief Attached propertyes to save component property states. | 150 | * \brief Attached properties to save component property states. |
4610 | 151 | * | 151 | * |
4611 | 152 | * StateSaver attached object provides the ability to save component property values | 152 | * StateSaver attached object provides the ability to save component property values |
4612 | 153 | * that can be restored after an inproper application close. The properties subject | 153 | * that can be restored after an inproper application close. The properties subject |
4613 | @@ -297,7 +297,7 @@ | |||
4614 | 297 | * List of properties to be serialized, separated with commas. Properties must be | 297 | * List of properties to be serialized, separated with commas. Properties must be |
4615 | 298 | * writable and can only be \l{http://qt-project.org/doc/qt-5.0/qtqml/qtqml-typesystem-basictypes.html}{QML base types}. | 298 | * writable and can only be \l{http://qt-project.org/doc/qt-5.0/qtqml/qtqml-typesystem-basictypes.html}{QML base types}. |
4616 | 299 | * | 299 | * |
4618 | 300 | * A custom singl eline input which saves the text, polaceholderText, font and color would look as follows: | 300 | * A custom single line input which saves the text, placeholderText, font and color would look as follows: |
4619 | 301 | * \qml | 301 | * \qml |
4620 | 302 | * TextField { | 302 | * TextField { |
4621 | 303 | * id: input | 303 | * id: input |
4622 | 304 | 304 | ||
4623 | === modified file 'src/Ubuntu/Components/plugin/ucubuntushape.cpp' | |||
4624 | --- src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-08-24 20:49:41 +0000 | |||
4625 | +++ src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-09-08 04:09:38 +0000 | |||
4626 | @@ -318,10 +318,7 @@ | |||
4627 | 318 | setFlag(ItemHasContents); | 318 | setFlag(ItemHasContents); |
4628 | 319 | QObject::connect(&UCUnits::instance(), SIGNAL(gridUnitChanged()), this, | 319 | QObject::connect(&UCUnits::instance(), SIGNAL(gridUnitChanged()), this, |
4629 | 320 | SLOT(_q_gridUnitChanged())); | 320 | SLOT(_q_gridUnitChanged())); |
4634 | 321 | const float gridUnit = UCUnits::instance().gridUnit(); | 321 | _q_gridUnitChanged(); |
4631 | 322 | setImplicitWidth(implicitWidthGU * gridUnit); | ||
4632 | 323 | setImplicitHeight(implicitHeightGU * gridUnit); | ||
4633 | 324 | update(); | ||
4635 | 325 | } | 322 | } |
4636 | 326 | 323 | ||
4637 | 327 | /*! \qmlproperty string UbuntuShape::radius | 324 | /*! \qmlproperty string UbuntuShape::radius |
4638 | @@ -803,9 +800,11 @@ | |||
4639 | 803 | */ | 800 | */ |
4640 | 804 | void UCUbuntuShape::setColor(const QColor& color) | 801 | void UCUbuntuShape::setColor(const QColor& color) |
4641 | 805 | { | 802 | { |
4645 | 806 | if (QuickUtils::showDeprecationWarnings()) { | 803 | static bool loggedOnce = false; |
4646 | 807 | qmlInfo(this) << "'color' is deprecated. Use 'backgroundColor', 'secondaryBackgroundColor' and " | 804 | if (!loggedOnce) { |
4647 | 808 | "'backgroundMode' instead."; | 805 | loggedOnce = true; |
4648 | 806 | qmlInfo(this) << "'color' is deprecated. Use 'backgroundColor', 'secondaryBackgroundColor' " | ||
4649 | 807 | "and 'backgroundMode' instead."; | ||
4650 | 809 | } | 808 | } |
4651 | 810 | 809 | ||
4652 | 811 | if (!(m_flags & BackgroundApiSet)) { | 810 | if (!(m_flags & BackgroundApiSet)) { |
4653 | @@ -834,7 +833,9 @@ | |||
4654 | 834 | */ | 833 | */ |
4655 | 835 | void UCUbuntuShape::setGradientColor(const QColor& gradientColor) | 834 | void UCUbuntuShape::setGradientColor(const QColor& gradientColor) |
4656 | 836 | { | 835 | { |
4658 | 837 | if (QuickUtils::showDeprecationWarnings()) { | 836 | static bool loggedOnce = false; |
4659 | 837 | if (!loggedOnce) { | ||
4660 | 838 | loggedOnce = true; | ||
4661 | 838 | qmlInfo(this) << "'gradientColor' is deprecated. Use 'backgroundColor', " | 839 | qmlInfo(this) << "'gradientColor' is deprecated. Use 'backgroundColor', " |
4662 | 839 | "'secondaryBackgroundColor' and 'backgroundMode' instead."; | 840 | "'secondaryBackgroundColor' and 'backgroundMode' instead."; |
4663 | 840 | } | 841 | } |
4664 | @@ -863,7 +864,9 @@ | |||
4665 | 863 | */ | 864 | */ |
4666 | 864 | void UCUbuntuShape::setImage(const QVariant& image) | 865 | void UCUbuntuShape::setImage(const QVariant& image) |
4667 | 865 | { | 866 | { |
4669 | 866 | if (QuickUtils::showDeprecationWarnings()) { | 867 | static bool loggedOnce = false; |
4670 | 868 | if (!loggedOnce) { | ||
4671 | 869 | loggedOnce = true; | ||
4672 | 867 | qmlInfo(this) << "'image' is deprecated. Use 'source' instead."; | 870 | qmlInfo(this) << "'image' is deprecated. Use 'source' instead."; |
4673 | 868 | } | 871 | } |
4674 | 869 | 872 | ||
4675 | @@ -894,7 +897,9 @@ | |||
4676 | 894 | // maintain it for a while for compatibility reasons. | 897 | // maintain it for a while for compatibility reasons. |
4677 | 895 | void UCUbuntuShape::setStretched(bool stretched) | 898 | void UCUbuntuShape::setStretched(bool stretched) |
4678 | 896 | { | 899 | { |
4680 | 897 | if (QuickUtils::showDeprecationWarnings()) { | 900 | static bool loggedOnce = false; |
4681 | 901 | if (!loggedOnce) { | ||
4682 | 902 | loggedOnce = true; | ||
4683 | 898 | qmlInfo(this) << "'stretched' is deprecated. Use 'sourceFillMode' instead"; | 903 | qmlInfo(this) << "'stretched' is deprecated. Use 'sourceFillMode' instead"; |
4684 | 899 | } | 904 | } |
4685 | 900 | 905 | ||
4686 | @@ -915,8 +920,11 @@ | |||
4687 | 915 | // Deprecation layer. Same comment as setStretched(). | 920 | // Deprecation layer. Same comment as setStretched(). |
4688 | 916 | void UCUbuntuShape::setHorizontalAlignment(HAlignment horizontalAlignment) | 921 | void UCUbuntuShape::setHorizontalAlignment(HAlignment horizontalAlignment) |
4689 | 917 | { | 922 | { |
4692 | 918 | if (QuickUtils::showDeprecationWarnings()) { | 923 | static bool loggedOnce = false; |
4693 | 919 | qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceHorizontalAlignment' instead"; | 924 | if (!loggedOnce) { |
4694 | 925 | loggedOnce = true; | ||
4695 | 926 | qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceHorizontalAlignment' " | ||
4696 | 927 | "instead"; | ||
4697 | 920 | } | 928 | } |
4698 | 921 | 929 | ||
4699 | 922 | if (!(m_flags & SourceApiSet)) { | 930 | if (!(m_flags & SourceApiSet)) { |
4700 | @@ -932,8 +940,11 @@ | |||
4701 | 932 | // Deprecation layer. Same comment as setStretched(). | 940 | // Deprecation layer. Same comment as setStretched(). |
4702 | 933 | void UCUbuntuShape::setVerticalAlignment(VAlignment verticalAlignment) | 941 | void UCUbuntuShape::setVerticalAlignment(VAlignment verticalAlignment) |
4703 | 934 | { | 942 | { |
4706 | 935 | if (QuickUtils::showDeprecationWarnings()) { | 943 | static bool loggedOnce = false; |
4707 | 936 | qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceVerticalAlignment' instead"; | 944 | if (!loggedOnce) { |
4708 | 945 | loggedOnce = true; | ||
4709 | 946 | qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceVerticalAlignment' " | ||
4710 | 947 | "instead"; | ||
4711 | 937 | } | 948 | } |
4712 | 938 | 949 | ||
4713 | 939 | if (!(m_flags & SourceApiSet)) { | 950 | if (!(m_flags & SourceApiSet)) { |
4714 | @@ -1009,20 +1020,11 @@ | |||
4715 | 1009 | updateFromImageProperties(qobject_cast<QQuickItem*>(sender())); | 1020 | updateFromImageProperties(qobject_cast<QQuickItem*>(sender())); |
4716 | 1010 | } | 1021 | } |
4717 | 1011 | 1022 | ||
4718 | 1012 | void UCUbuntuShape::_q_openglContextDestroyed() | ||
4719 | 1013 | { | ||
4720 | 1014 | // Delete the shape textures that are stored per context and shared by all the shape items. | ||
4721 | 1015 | const int index = getShapeTexturesIndex(qobject_cast<QOpenGLContext*>(sender())); | ||
4722 | 1016 | Q_ASSERT(index >= 0); | ||
4723 | 1017 | shapeTextures[index].openglContext = NULL; | ||
4724 | 1018 | glDeleteTextures(shapeTextureCount, shapeTextures[index].textureId); | ||
4725 | 1019 | } | ||
4726 | 1020 | |||
4727 | 1021 | void UCUbuntuShape::_q_gridUnitChanged() | 1023 | void UCUbuntuShape::_q_gridUnitChanged() |
4728 | 1022 | { | 1024 | { |
4732 | 1023 | const float gridUnit = UCUnits::instance().gridUnit(); | 1025 | const float gridUnitInDevicePixels = UCUnits::instance().gridUnit() / qGuiApp->devicePixelRatio(); |
4733 | 1024 | setImplicitWidth(implicitWidthGU * gridUnit); | 1026 | setImplicitWidth(implicitWidthGU * gridUnitInDevicePixels); |
4734 | 1025 | setImplicitHeight(implicitHeightGU * gridUnit); | 1027 | setImplicitHeight(implicitHeightGU * gridUnitInDevicePixels); |
4735 | 1026 | update(); | 1028 | update(); |
4736 | 1027 | } | 1029 | } |
4737 | 1028 | 1030 | ||
4738 | @@ -1170,8 +1172,10 @@ | |||
4739 | 1170 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, shapeTextureSize, shapeTextureSize, 0, GL_RGBA, | 1172 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, shapeTextureSize, shapeTextureSize, 0, GL_RGBA, |
4740 | 1171 | GL_UNSIGNED_BYTE, shapeTextureData[i]); | 1173 | GL_UNSIGNED_BYTE, shapeTextureData[i]); |
4741 | 1172 | } | 1174 | } |
4744 | 1173 | QObject::connect(openglContext, SIGNAL(aboutToBeDestroyed()), this, | 1175 | connect(openglContext, &QOpenGLContext::aboutToBeDestroyed, [index] { |
4745 | 1174 | SLOT(_q_openglContextDestroyed()), Qt::DirectConnection); | 1176 | shapeTextures[index].openglContext = NULL; |
4746 | 1177 | glDeleteTextures(shapeTextureCount, shapeTextures[index].textureId); | ||
4747 | 1178 | } ); | ||
4748 | 1175 | } | 1179 | } |
4749 | 1176 | const quint32 shapeTextureId = shapeTextures[index].textureId[m_aspect != DropShadow ? 0 : 1]; | 1180 | const quint32 shapeTextureId = shapeTextures[index].textureId[m_aspect != DropShadow ? 0 : 1]; |
4750 | 1177 | 1181 | ||
4751 | @@ -1184,13 +1188,15 @@ | |||
4752 | 1184 | sourceTextureRect = sourceTexture->normalizedTextureSubRect(); | 1188 | sourceTextureRect = sourceTexture->normalizedTextureSubRect(); |
4753 | 1185 | } | 1189 | } |
4754 | 1186 | if (m_flags & DirtySourceTransform) { | 1190 | if (m_flags & DirtySourceTransform) { |
4755 | 1191 | const float dpr = qGuiApp->devicePixelRatio(); | ||
4756 | 1192 | |||
4757 | 1187 | if (m_flags & SourceApiSet) { | 1193 | if (m_flags & SourceApiSet) { |
4759 | 1188 | updateSourceTransform(itemSize.width(), itemSize.height(), m_sourceFillMode, | 1194 | updateSourceTransform(itemSize.width() * dpr, itemSize.height() * dpr, m_sourceFillMode, |
4760 | 1189 | m_sourceHorizontalAlignment, m_sourceVerticalAlignment, | 1195 | m_sourceHorizontalAlignment, m_sourceVerticalAlignment, |
4761 | 1190 | sourceTexture->textureSize()); | 1196 | sourceTexture->textureSize()); |
4762 | 1191 | } else { | 1197 | } else { |
4763 | 1192 | FillMode imageFillMode = (m_flags & Stretched) ? Stretch : PreserveAspectCrop; | 1198 | FillMode imageFillMode = (m_flags & Stretched) ? Stretch : PreserveAspectCrop; |
4765 | 1193 | updateSourceTransform(itemSize.width(), itemSize.height(), imageFillMode, | 1199 | updateSourceTransform(itemSize.width() * dpr, itemSize.height() * dpr, imageFillMode, |
4766 | 1194 | m_imageHorizontalAlignment, m_imageVerticalAlignment, | 1200 | m_imageHorizontalAlignment, m_imageVerticalAlignment, |
4767 | 1195 | sourceTexture->textureSize()); | 1201 | sourceTexture->textureSize()); |
4768 | 1196 | } | 1202 | } |
4769 | @@ -1220,13 +1226,15 @@ | |||
4770 | 1220 | // accordingly. The shape was using a fixed image for the corner before switching to a | 1226 | // accordingly. The shape was using a fixed image for the corner before switching to a |
4771 | 1221 | // distance field, since the corner wasn't taking the whole image (ending at ~80%) we need | 1227 | // distance field, since the corner wasn't taking the whole image (ending at ~80%) we need |
4772 | 1222 | // to take that into account when the size is scaled down. | 1228 | // to take that into account when the size is scaled down. |
4774 | 1223 | radius = UCUnits::instance().gridUnit() * radiusGuMap[m_radius]; | 1229 | radius = UCUnits::instance().gridUnit() * radiusGuMap[m_radius] |
4775 | 1230 | / qGuiApp->devicePixelRatio(); | ||
4776 | 1224 | const float scaledDownRadius = qMin(itemSize.width(), itemSize.height()) * 0.5f * 0.8f; | 1231 | const float scaledDownRadius = qMin(itemSize.width(), itemSize.height()) * 0.5f * 0.8f; |
4777 | 1225 | if (radius > scaledDownRadius) { | 1232 | if (radius > scaledDownRadius) { |
4778 | 1226 | radius = scaledDownRadius; | 1233 | radius = scaledDownRadius; |
4779 | 1227 | } | 1234 | } |
4780 | 1228 | } else { | 1235 | } else { |
4782 | 1229 | radius = qMin(itemSize.width(), itemSize.height()) * 0.5f * (m_relativeRadius * 0.01f); | 1236 | radius = qMin(itemSize.width(), itemSize.height()) * 0.5f * (m_relativeRadius * 0.01f) |
4783 | 1237 | / qGuiApp->devicePixelRatio(); | ||
4784 | 1230 | } | 1238 | } |
4785 | 1231 | 1239 | ||
4786 | 1232 | updateMaterial(node, radius, shapeTextureId, sourceTexture && m_sourceOpacity); | 1240 | updateMaterial(node, radius, shapeTextureId, sourceTexture && m_sourceOpacity); |
4787 | @@ -1306,16 +1314,19 @@ | |||
4788 | 1306 | materialData->sourceOpacity = 0; | 1314 | materialData->sourceOpacity = 0; |
4789 | 1307 | } | 1315 | } |
4790 | 1308 | 1316 | ||
4791 | 1317 | const float physicalRadius = radius * qGuiApp->devicePixelRatio(); | ||
4792 | 1318 | |||
4793 | 1309 | // Mapping of radius size range from [0, 4] to [0, 1] with clamping, plus quantization. | 1319 | // Mapping of radius size range from [0, 4] to [0, 1] with clamping, plus quantization. |
4794 | 1310 | const float start = 0.0f + radiusSizeOffset; | 1320 | const float start = 0.0f + radiusSizeOffset; |
4795 | 1311 | const float end = 4.0f + radiusSizeOffset; | 1321 | const float end = 4.0f + radiusSizeOffset; |
4796 | 1322 | |||
4797 | 1312 | materialData->distanceAAFactor = | 1323 | materialData->distanceAAFactor = |
4799 | 1313 | qMin((radius / (end - start)) - (start / (end - start)), 1.0f) * 255.0f; | 1324 | qMin((physicalRadius / (end - start)) - (start / (end - start)), 1.0f) * 255.0f; |
4800 | 1314 | 1325 | ||
4801 | 1315 | // When the radius is equal to radiusSizeOffset (which means radius size is 0), no aspect is | 1326 | // When the radius is equal to radiusSizeOffset (which means radius size is 0), no aspect is |
4802 | 1316 | // flagged so that a dedicated (statically flow controlled) shaved off shader can be used for | 1327 | // flagged so that a dedicated (statically flow controlled) shaved off shader can be used for |
4803 | 1317 | // optimal performance. | 1328 | // optimal performance. |
4805 | 1318 | if (radius > radiusSizeOffset) { | 1329 | if (physicalRadius > radiusSizeOffset) { |
4806 | 1319 | const quint8 aspectFlags[] = { | 1330 | const quint8 aspectFlags[] = { |
4807 | 1320 | ShapeMaterial::Data::Flat, ShapeMaterial::Data::Inset, ShapeMaterial::Data::DropShadow, | 1331 | ShapeMaterial::Data::Flat, ShapeMaterial::Data::Inset, ShapeMaterial::Data::DropShadow, |
4808 | 1321 | ShapeMaterial::Data::Inset | ShapeMaterial::Data::Pressed | 1332 | ShapeMaterial::Data::Inset | ShapeMaterial::Data::Pressed |
4809 | 1322 | 1333 | ||
4810 | === modified file 'src/Ubuntu/Components/plugin/ucubuntushape.h' | |||
4811 | --- src/Ubuntu/Components/plugin/ucubuntushape.h 2015-08-06 13:16:24 +0000 | |||
4812 | +++ src/Ubuntu/Components/plugin/ucubuntushape.h 2015-09-08 04:09:38 +0000 | |||
4813 | @@ -296,7 +296,6 @@ | |||
4814 | 296 | 296 | ||
4815 | 297 | private Q_SLOTS: | 297 | private Q_SLOTS: |
4816 | 298 | void _q_imagePropertiesChanged(); | 298 | void _q_imagePropertiesChanged(); |
4817 | 299 | void _q_openglContextDestroyed(); | ||
4818 | 300 | void _q_gridUnitChanged(); | 299 | void _q_gridUnitChanged(); |
4819 | 301 | void _q_providerDestroyed(QObject* object=0); | 300 | void _q_providerDestroyed(QObject* object=0); |
4820 | 302 | void _q_textureChanged(); | 301 | void _q_textureChanged(); |
4821 | 303 | 302 | ||
4822 | === modified file 'src/Ubuntu/Components/plugin/ucunits.cpp' | |||
4823 | --- src/Ubuntu/Components/plugin/ucunits.cpp 2015-03-03 13:47:48 +0000 | |||
4824 | +++ src/Ubuntu/Components/plugin/ucunits.cpp 2015-09-08 04:09:38 +0000 | |||
4825 | @@ -24,6 +24,8 @@ | |||
4826 | 24 | #include <QtCore/QDir> | 24 | #include <QtCore/QDir> |
4827 | 25 | #include <QtCore/QRegularExpression> | 25 | #include <QtCore/QRegularExpression> |
4828 | 26 | #include <QtCore/qmath.h> | 26 | #include <QtCore/qmath.h> |
4829 | 27 | #include <QtGui/QGuiApplication> | ||
4830 | 28 | #include <QtGui/QScreen> | ||
4831 | 27 | 29 | ||
4832 | 28 | #define ENV_GRID_UNIT_PX "GRID_UNIT_PX" | 30 | #define ENV_GRID_UNIT_PX "GRID_UNIT_PX" |
4833 | 29 | #define DEFAULT_GRID_UNIT_PX 8 | 31 | #define DEFAULT_GRID_UNIT_PX 8 |
4834 | @@ -62,10 +64,46 @@ | |||
4835 | 62 | 64 | ||
4836 | 63 | \sa {Resolution Independence} | 65 | \sa {Resolution Independence} |
4837 | 64 | */ | 66 | */ |
4838 | 67 | |||
4839 | 68 | /* | ||
4840 | 69 | * Note on the interaction between GRID_UNIT_PX and QT_DEVICE_PIXEL_RATIO | ||
4841 | 70 | * | ||
4842 | 71 | * In Qt5.4 there is a single means to scale the UI: the QT_DEVICE_PIXEL_RATIO environment | ||
4843 | 72 | * variable. This accepts only integer values, thus allowing a x2 or x3 scaling of any | ||
4844 | 73 | * Qt-based UI, that includes QWidget as well as any QML UI. | ||
4845 | 74 | * | ||
4846 | 75 | * Setting QT_DEVICE_PIXEL_RATIO=2 implies one density-independent pixel corresponds to 2 | ||
4847 | 76 | * physical pixels. Developers describe their UI in terms of density-independent pixels. | ||
4848 | 77 | * Qt scales accordingly. | ||
4849 | 78 | * | ||
4850 | 79 | * The Ubuntu UI Toolkit has solved the scaling problem with the GRID_UNIT_PX variable. | ||
4851 | 80 | * It offers more flexibility, but only scales QML applications written to use the UITK | ||
4852 | 81 | * (since it uses this Units class) as it is built on top of QML. | ||
4853 | 82 | * | ||
4854 | 83 | * There are additional areas in Qt where QT_DEVICE_PIXEL_RATIO causes correct scaling which | ||
4855 | 84 | * GRID_UNIT_PX cannot, for example: | ||
4856 | 85 | * 1. cacheBuffer for ListView/GridViews - specified in density-independent pixels | ||
4857 | 86 | * 2. gesture recognition matches what is on screen better, as it is density-independent | ||
4858 | 87 | * pixel aware | ||
4859 | 88 | * | ||
4860 | 89 | * In order to get the best of both worlds, Ubuntu will set both GRID_UNIT_PX and | ||
4861 | 90 | * QT_DEVICE_PIXEL_RATIO. Thus all Qt apps will scale reasonably well, with UITK-based apps | ||
4862 | 91 | * scaling perfectly for any desired scale (i.e. non-integer scales). | ||
4863 | 92 | * | ||
4864 | 93 | * However UITK developers can just use this Units class as usual, and will be almost totally | ||
4865 | 94 | * isolated from Qt's own scaling concept. | ||
4866 | 95 | */ | ||
4867 | 96 | |||
4868 | 65 | UCUnits::UCUnits(QObject *parent) : | 97 | UCUnits::UCUnits(QObject *parent) : |
4870 | 66 | QObject(parent) | 98 | QObject(parent), |
4871 | 99 | m_devicePixelRatio(qGuiApp->devicePixelRatio()) | ||
4872 | 67 | { | 100 | { |
4874 | 68 | m_gridUnit = getenvFloat(ENV_GRID_UNIT_PX, DEFAULT_GRID_UNIT_PX); | 101 | // If GRID_UNIT_PX set, always use it. If not, 1GU := DEFAULT_GRID_UNIT_PX * m_devicePixelRatio |
4875 | 102 | if (qEnvironmentVariableIsSet(ENV_GRID_UNIT_PX)) { | ||
4876 | 103 | m_gridUnit = getenvFloat(ENV_GRID_UNIT_PX, DEFAULT_GRID_UNIT_PX); | ||
4877 | 104 | } else { | ||
4878 | 105 | m_gridUnit = DEFAULT_GRID_UNIT_PX * m_devicePixelRatio; | ||
4879 | 106 | } | ||
4880 | 69 | } | 107 | } |
4881 | 70 | 108 | ||
4882 | 71 | /*! | 109 | /*! |
4883 | @@ -89,14 +127,15 @@ | |||
4884 | 89 | 127 | ||
4885 | 90 | Returns the number of pixels \a value density independent pixels correspond to. | 128 | Returns the number of pixels \a value density independent pixels correspond to. |
4886 | 91 | */ | 129 | */ |
4887 | 130 | // Density-independent pixels (and not physical pixels) because Qt sizes in terms of density-independent pixels. | ||
4888 | 92 | float UCUnits::dp(float value) | 131 | float UCUnits::dp(float value) |
4889 | 93 | { | 132 | { |
4890 | 94 | const float ratio = m_gridUnit / DEFAULT_GRID_UNIT_PX; | 133 | const float ratio = m_gridUnit / DEFAULT_GRID_UNIT_PX; |
4891 | 95 | if (value <= 2.0) { | 134 | if (value <= 2.0) { |
4892 | 96 | // for values under 2dp, return only multiples of the value | 135 | // for values under 2dp, return only multiples of the value |
4894 | 97 | return qRound(value * qFloor(ratio)); | 136 | return qRound(value * qFloor(ratio)) / m_devicePixelRatio; |
4895 | 98 | } else { | 137 | } else { |
4897 | 99 | return qRound(value * ratio); | 138 | return qRound(value * ratio) / m_devicePixelRatio; |
4898 | 100 | } | 139 | } |
4899 | 101 | } | 140 | } |
4900 | 102 | 141 | ||
4901 | @@ -105,9 +144,11 @@ | |||
4902 | 105 | 144 | ||
4903 | 106 | Returns the number of pixels \a value grid units correspond to. | 145 | Returns the number of pixels \a value grid units correspond to. |
4904 | 107 | */ | 146 | */ |
4905 | 147 | // Density-independent pixels (and not physical pixels) because Qt sizes in terms of density-independent pixels. | ||
4906 | 148 | |||
4907 | 108 | float UCUnits::gu(float value) | 149 | float UCUnits::gu(float value) |
4908 | 109 | { | 150 | { |
4910 | 110 | return qRound(value * m_gridUnit); | 151 | return qRound(value * m_gridUnit) / m_devicePixelRatio; |
4911 | 111 | } | 152 | } |
4912 | 112 | 153 | ||
4913 | 113 | QString UCUnits::resolveResource(const QUrl& url) | 154 | QString UCUnits::resolveResource(const QUrl& url) |
4914 | 114 | 155 | ||
4915 | === modified file 'src/Ubuntu/Components/plugin/ucunits.h' | |||
4916 | --- src/Ubuntu/Components/plugin/ucunits.h 2013-10-18 08:56:39 +0000 | |||
4917 | +++ src/Ubuntu/Components/plugin/ucunits.h 2015-09-08 04:09:38 +0000 | |||
4918 | @@ -53,6 +53,7 @@ | |||
4919 | 53 | float gridUnitSuffixFromFileName(const QString &fileName); | 53 | float gridUnitSuffixFromFileName(const QString &fileName); |
4920 | 54 | 54 | ||
4921 | 55 | private: | 55 | private: |
4922 | 56 | float m_devicePixelRatio; | ||
4923 | 56 | float m_gridUnit; | 57 | float m_gridUnit; |
4924 | 57 | }; | 58 | }; |
4925 | 58 | 59 | ||
4926 | 59 | 60 | ||
4927 | === modified file 'src/Ubuntu/Components/plugin/ucviewitemsattached.cpp' | |||
4928 | --- src/Ubuntu/Components/plugin/ucviewitemsattached.cpp 2015-03-17 16:48:59 +0000 | |||
4929 | +++ src/Ubuntu/Components/plugin/ucviewitemsattached.cpp 2015-09-08 04:09:38 +0000 | |||
4930 | @@ -104,6 +104,7 @@ | |||
4931 | 104 | : QObjectPrivate() | 104 | : QObjectPrivate() |
4932 | 105 | , listView(0) | 105 | , listView(0) |
4933 | 106 | , dragArea(0) | 106 | , dragArea(0) |
4934 | 107 | , expansionFlags(UCViewItemsAttached::Exclusive) | ||
4935 | 107 | , globalDisabled(false) | 108 | , globalDisabled(false) |
4936 | 108 | , selectable(false) | 109 | , selectable(false) |
4937 | 109 | , draggable(false) | 110 | , draggable(false) |
4938 | @@ -556,7 +557,7 @@ | |||
4939 | 556 | return; | 557 | return; |
4940 | 557 | } | 558 | } |
4941 | 558 | dragArea = new ListItemDragArea(listView); | 559 | dragArea = new ListItemDragArea(listView); |
4943 | 559 | dragArea->init(); | 560 | dragArea->init(q_func()); |
4944 | 560 | } | 561 | } |
4945 | 561 | 562 | ||
4946 | 562 | void UCViewItemsAttachedPrivate::leaveDragMode() | 563 | void UCViewItemsAttachedPrivate::leaveDragMode() |
4947 | @@ -611,3 +612,142 @@ | |||
4948 | 611 | Q_EMIT q->selectedIndicesChanged(); | 612 | Q_EMIT q->selectedIndicesChanged(); |
4949 | 612 | } | 613 | } |
4950 | 613 | } | 614 | } |
4951 | 615 | |||
4952 | 616 | |||
4953 | 617 | UCViewItemsAttached13::UCViewItemsAttached13(QObject *owner) | ||
4954 | 618 | : UCViewItemsAttached(owner) | ||
4955 | 619 | { | ||
4956 | 620 | d_ptr = UCViewItemsAttachedPrivate::get(this); | ||
4957 | 621 | } | ||
4958 | 622 | |||
4959 | 623 | UCViewItemsAttached13 *UCViewItemsAttached13::qmlAttachedProperties(QObject *owner) | ||
4960 | 624 | { | ||
4961 | 625 | return new UCViewItemsAttached13(owner); | ||
4962 | 626 | } | ||
4963 | 627 | |||
4964 | 628 | /*! | ||
4965 | 629 | * \qmlattachedproperty list<int> ViewItems::expandedIndices | ||
4966 | 630 | * \since Ubuntu.Components 1.3 | ||
4967 | 631 | * The property contains the indexes of the ListItems marked as expanded. The | ||
4968 | 632 | * indexes are model indexes when used in ListView, and child indexes in other | ||
4969 | 633 | * components. The property being writable, initial expansion configuration | ||
4970 | 634 | * can be provided for a view, and provides ability to save the expansion state. | ||
4971 | 635 | * \note If the \l ViewItems::expansionFlags is having \c ViewItems.Exclusive | ||
4972 | 636 | * flags set, only the last item from the list will be considered and set as | ||
4973 | 637 | * expanded. | ||
4974 | 638 | */ | ||
4975 | 639 | QList<int> UCViewItemsAttached13::expandedIndices() const | ||
4976 | 640 | { | ||
4977 | 641 | Q_D(const UCViewItemsAttached); | ||
4978 | 642 | return d->expansionList.keys(); | ||
4979 | 643 | } | ||
4980 | 644 | void UCViewItemsAttached13::setExpandedIndices(QList<int> indices) | ||
4981 | 645 | { | ||
4982 | 646 | Q_UNUSED(indices); | ||
4983 | 647 | Q_D(UCViewItemsAttached); | ||
4984 | 648 | d->collapseAll(); | ||
4985 | 649 | if (indices.size() > 0) { | ||
4986 | 650 | if (d->expansionFlags & UCViewItemsAttached::Exclusive) { | ||
4987 | 651 | // take only the last one from the list | ||
4988 | 652 | d->expand(indices.last(), QPointer<UCListItem13>(), false); | ||
4989 | 653 | } else { | ||
4990 | 654 | for (int i = 0; i < indices.size(); i++) { | ||
4991 | 655 | d->expand(indices[i], QPointer<UCListItem13>(), false); | ||
4992 | 656 | } | ||
4993 | 657 | } | ||
4994 | 658 | } | ||
4995 | 659 | Q_EMIT expandedIndicesChanged(d->expansionList.keys()); | ||
4996 | 660 | } | ||
4997 | 661 | |||
4998 | 662 | // insert listItem into the expanded indices map | ||
4999 | 663 | void UCViewItemsAttachedPrivate::expand(int index, UCListItem13 *listItem, bool emitChangeSignal) | ||
5000 | 664 | { |
The diff has been truncated for viewing.