Merge lp:~bzoltan/ubuntu-ui-toolkit/landing-2015-09-04 into lp:ubuntu-ui-toolkit

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
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
=== modified file '.bzrignore'
--- .bzrignore 2015-05-20 14:47:16 +0000
+++ .bzrignore 2015-09-08 04:09:38 +0000
@@ -1,25 +1,25 @@
1.obj
2.pch
3.qmake.cache
4.rcc
5qml
6
1Makefile*7Makefile*
2src/Makefile*
3src/Ubuntu/Components/Makefile*
4src/Ubuntu/Components/plugin/Makefile*
5src/Ubuntu/Components/plugin/qrc_plugin.cpp
6src/Ubuntu/Components/Themes/Makefile*
7src/Ubuntu/Components/Layouts/Makefile*
8src/Ubuntu/Components/PerformanceMetrics/Makefile*
9src/Ubuntu/Test/Makefile*
10documentation/html/*8documentation/html/*
11*.moc9*.moc
12moc_*.cpp10moc_*.cpp
13qrc_tst_*.cpp11qrc_tst_*.cpp
14tests/test_tst_*.xml12tests/test_tst_*.xml
15tests/tst_*.qml.xml13tests/tst_*.qml.xml
16tests/unit*/tst_*/tst_[^.]*14tests/unit*/tst_*/tst_*
15tests/unit/tst_*/tst_*/tst_*
17tests/unit*/testparser/testparser16tests/unit*/testparser/testparser
18plugins.qmltypes17plugins.qmltypes
19po/*.mo18po/*.mo
20examples/ubuntu-ui-toolkit-gallery/po/*.mo19examples/ubuntu-ui-toolkit-gallery/po/*.mo
21tests/unit/tst_i18n/locale/en/LC_MESSAGES/*.mo20tests/unit/tst_i18n/tst_*/*/share/locale/en/LC_MESSAGES/*.mo
21tests/unit/tst_i18n/*/share/locale/en/LC_MESSAGES/*.mo
22tests/unit/tst_units/dpr*/dpr*
22tests/apicheck/apicheck23tests/apicheck/apicheck
23tests/launcher/launcher24tests/launcher/launcher
24build_paths.inc25build_paths.inc
25tests/unit/tst_i18n/localizedApp/share/locale/en/LC_MESSAGES/localizedApp.mo
2626
=== modified file '.qmake.conf'
--- .qmake.conf 2015-05-18 09:53:55 +0000
+++ .qmake.conf 2015-09-08 04:09:38 +0000
@@ -12,3 +12,7 @@
1212
13ROOT_SOURCE_DIR=$$PWD13ROOT_SOURCE_DIR=$$PWD
14ROOT_BUILD_DIR=$$shadowed($$PWD)14ROOT_BUILD_DIR=$$shadowed($$PWD)
15
16exists($$PWD/../qt.pro) {
17 CONFIG += build_with_qt
18}
1519
=== modified file 'components.api'
--- components.api 2015-08-12 09:55:50 +0000
+++ components.api 2015-09-08 04:09:38 +0000
@@ -4,10 +4,10 @@
4 signal pressAndHold()4 signal pressAndHold()
5 property bool pressed5 property bool pressed
6Ubuntu.Components.AbstractButton 1.3: ActionItem6Ubuntu.Components.AbstractButton 1.3: ActionItem
7 property bool hovered7 readonly property bool hovered
8 signal clicked()8 signal clicked()
9 signal pressAndHold()9 signal pressAndHold()
10 property bool pressed10 readonly property bool pressed
11Ubuntu.Components.Action 1.3 1.0 0.1: QtObject11Ubuntu.Components.Action 1.3 1.0 0.1: QtObject
12 property string description12 property string description
13 property bool enabled13 property bool enabled
@@ -43,14 +43,8 @@
43 property string iconName43 property string iconName
44 property url iconSource44 property url iconSource
45 signal triggered(var value)45 signal triggered(var value)
46 function var trigger(var value)46 function trigger(var value)
47 property string text47 function trigger()
48Ubuntu.Components.ActionItem 1.3: StyledItem
49 property Action action
50 property string iconName
51 property url iconSource
52 signal triggered(var value)
53 function var trigger(var value)
54 property string text48 property string text
55Ubuntu.Components.ActionList 1.0 0.1: QtObject49Ubuntu.Components.ActionList 1.0 0.1: QtObject
56 readonly property Action actions50 readonly property Action actions
@@ -82,6 +76,8 @@
82 property bool onScreen76 property bool onScreen
83 property bool running77 property bool running
84Ubuntu.Components.AdaptivePageLayout 1.3: PageTreeNode78Ubuntu.Components.AdaptivePageLayout 1.3: PageTreeNode
79 readonly property int columns
80 readonly property PageColumnsLayout layouts
85 function var addPageToCurrentColumn(var sourcePage, var page, var properties)81 function var addPageToCurrentColumn(var sourcePage, var page, var properties)
86 function var addPageToNextColumn(var sourcePage, var page, var properties)82 function var addPageToNextColumn(var sourcePage, var page, var properties)
87 function var removePages(var page)83 function var removePages(var page)
@@ -92,6 +88,7 @@
92 property bool enabled88 property bool enabled
93 readonly property int error89 readonly property int error
94 property string message90 property string message
91 signal statusChanged(Operation operation)
95 function save()92 function save()
96 function cancel()93 function cancel()
97 function reset()94 function reset()
@@ -305,6 +302,9 @@
305Ubuntu.Components.ListItems.Divider 1.0 0.1: QQuickImageBase302Ubuntu.Components.ListItems.Divider 1.0 0.1: QQuickImageBase
306 property FillMode fillMode303 property FillMode fillMode
307 property HAlignment horizontalAlignment304 property HAlignment horizontalAlignment
305 signal horizontalAlignmentChanged(HAlignment alignment)
306 signal verticalAlignmentChanged(VAlignment alignment)
307 signal mipmapChanged(bool )
308 property bool mipmap308 property bool mipmap
309 readonly property double paintedHeight309 readonly property double paintedHeight
310 readonly property double paintedWidth310 readonly property double paintedWidth
@@ -312,6 +312,9 @@
312Ubuntu.Components.ListItems.Divider 1.3: QQuickImageBase312Ubuntu.Components.ListItems.Divider 1.3: QQuickImageBase
313 property FillMode fillMode313 property FillMode fillMode
314 property HAlignment horizontalAlignment314 property HAlignment horizontalAlignment
315 signal horizontalAlignmentChanged(HAlignment alignment)
316 signal verticalAlignmentChanged(VAlignment alignment)
317 signal mipmapChanged(bool )
315 property bool mipmap318 property bool mipmap
316 readonly property double paintedHeight319 readonly property double paintedHeight
317 readonly property double paintedWidth320 readonly property double paintedWidth
@@ -361,10 +364,11 @@
361Ubuntu.Components.FilterBehavior 1.1: QtObject364Ubuntu.Components.FilterBehavior 1.1: QtObject
362 property QRegExp pattern365 property QRegExp pattern
363 property string property366 property string property
364Ubuntu.Components.Haptics 1.0 0.1: Object singleton367Ubuntu.Components.Haptics 1.0 0.1: QtObject singleton
365 readonly property HapticsEffect effect368 readonly property QtObject effect
366 readonly property bool enabled369 readonly property bool enabled
367 function var play(var customEffect)370 function play(var customEffect)
371 function play()
368Ubuntu.Components.ListItems.Header 1.0 0.1: Item372Ubuntu.Components.ListItems.Header 1.0 0.1: Item
369 property string text373 property string text
370Ubuntu.Components.Header 1.0 0.1: AppHeader374Ubuntu.Components.Header 1.0 0.1: AppHeader
@@ -385,22 +389,6 @@
385 property bool useDeprecatedToolbar389 property bool useDeprecatedToolbar
386Ubuntu.Components.ListItems.Header 1.3: Item390Ubuntu.Components.ListItems.Header 1.3: Item
387 property string text391 property string text
388Ubuntu.Components.Header 1.3: AppHeader
389 property string _for_autopilot
390 property var actions
391 property bool animate
392 property QtObject config
393 property Item contents
394 property color dividerColor
395 property Flickable flickable
396 function var show()
397 function var hide()
398 readonly property bool moving
399 property var pageStack
400 property color panelColor
401 property var tabsModel
402 property string title
403 property bool useDeprecatedToolbar
404Ubuntu.Components.Icon 1.0 0.1: Item392Ubuntu.Components.Icon 1.0 0.1: Item
405 property color color393 property color color
406 property color keyColor394 property color keyColor
@@ -466,6 +454,7 @@
466 property bool selected454 property bool selected
467 property ListItemActions trailingActions455 property ListItemActions trailingActions
468Ubuntu.Components.ListItem 1.3: ListItem456Ubuntu.Components.ListItem 1.3: ListItem
457 readonly property UCListItemExpansion expansion
469Ubuntu.Components.ListItemActions 1.2: QtObject458Ubuntu.Components.ListItemActions 1.2: QtObject
470 readonly property Action actions459 readonly property Action actions
471 default readonly property QtObject data460 default readonly property QtObject data
@@ -485,6 +474,7 @@
485 readonly property bool animatePanels474 readonly property bool animatePanels
486 property Item dragPanel475 property Item dragPanel
487 property PropertyAnimation dropAnimation476 property PropertyAnimation dropAnimation
477 readonly property Flickable flickable 1.3
488 readonly property int listItemIndex 1.3478 readonly property int listItemIndex 1.3
489 function swipeEvent(SwipeEvent event)479 function swipeEvent(SwipeEvent event)
490 function rebound()480 function rebound()
@@ -528,6 +518,7 @@
528 signal clicked(QQuickMouseEvent mouse, Item host)518 signal clicked(QQuickMouseEvent mouse, Item host)
529 signal pressAndHold(QQuickMouseEvent mouse, Item host)519 signal pressAndHold(QQuickMouseEvent mouse, Item host)
530 signal doubleClicked(QQuickMouseEvent mouse, Item host)520 signal doubleClicked(QQuickMouseEvent mouse, Item host)
521 signal positionChanged(QQuickMouseEvent mouse, Item host)
531 signal entered(QQuickMouseEvent event, Item host)522 signal entered(QQuickMouseEvent event, Item host)
532 signal exited(QQuickMouseEvent event, Item host)523 signal exited(QQuickMouseEvent event, Item host)
533 property Priority priority524 property Priority priority
@@ -603,6 +594,14 @@
603 property Flickable flickable594 property Flickable flickable
604 readonly property PageHeadConfiguration head595 readonly property PageHeadConfiguration head
605 property string title596 property string title
597Ubuntu.Components.PageColumn 1.3: QtObject
598 property bool fillWidth
599 property double maximumWidth
600 property double minimumWidth
601 property double preferredWidth
602Ubuntu.Components.PageColumnsLayout 1.3: QtObject
603 default readonly property PageColumn data
604 property bool when
606Ubuntu.Components.PageHeadConfiguration 1.1: Object605Ubuntu.Components.PageHeadConfiguration 1.1: Object
607 readonly property Action actions606 readonly property Action actions
608 property Action backAction607 property Action backAction
@@ -1222,14 +1221,16 @@
1222 property string iconName1221 property string iconName
1223 property url iconSource1222 property url iconSource
1224 signal triggered(var value)1223 signal triggered(var value)
1225 function var trigger(var value)1224 function trigger(var value)
1225 function trigger()
1226 property string text1226 property string text
1227Ubuntu.Components.ToolbarButton 1.3: StyledItem1227Ubuntu.Components.ToolbarButton 1.3: StyledItem
1228 property Action action1228 property Action action
1229 property string iconName1229 property string iconName
1230 property url iconSource1230 property url iconSource
1231 signal triggered(var value)1231 signal triggered(var value)
1232 function var trigger(var value)1232 function trigger(var value)
1233 function trigger()
1233 property string text1234 property string text
1234Ubuntu.Components.ToolbarItems 1.0 0.1: Item1235Ubuntu.Components.ToolbarItems 1.0 0.1: Item
1235 property Item back1236 property Item back
@@ -1246,6 +1247,9 @@
1246UCListItemDivider: Item1247UCListItemDivider: Item
1247 property color colorFrom1248 property color colorFrom
1248 property color colorTo1249 property color colorTo
1250UCListItemExpansion: QtObject
1251 property bool expanded
1252 property double height
1249UCStateSaverAttached: QtObject1253UCStateSaverAttached: QtObject
1250 property bool enabled1254 property bool enabled
1251 property string properties1255 property string properties
@@ -1393,6 +1397,14 @@
1393 signal dragUpdated(ListItemDrag event)1397 signal dragUpdated(ListItemDrag event)
1394 property bool selectMode1398 property bool selectMode
1395 property QList<int> selectedIndices1399 property QList<int> selectedIndices
1400Ubuntu.Components.ViewItems 1.3: ViewItems
1401 property QList<int> expandedIndices
1402 property int expansionFlags
1403 signal expandedIndicesChanged(QList<int> indices)
1404Ubuntu.Components.ViewItems.ExpansionFlag: Enum
1405 CollapseOnOutsidePress
1406 Exclusive
1407 UnlockExpanded
1396Ubuntu.Components.i18n 1.0 0.1: QtObject1408Ubuntu.Components.i18n 1.0 0.1: QtObject
1397 property string domain1409 property string domain
1398 property string language1410 property string language
@@ -1405,3 +1417,4 @@
1405 function string dctr(string domain, string context, string text)1417 function string dctr(string domain, string context, string text)
1406 function string tag(string text)1418 function string tag(string text)
1407 function string tag(string context, string text)1419 function string tag(string context, string text)
1420 function string relativeDateTime(QDateTime datetime)
14081421
=== modified file 'debian/changelog'
--- debian/changelog 2015-08-24 20:49:45 +0000
+++ debian/changelog 2015-09-08 04:09:38 +0000
@@ -1,3 +1,61 @@
1ubuntu-ui-toolkit (1.3.1627+15.10.20150904-0ubuntu1) UNRELEASED; urgency=medium
2
3 [ Zsombor Egri ]
4 * Implement list item expansion.
5 * Turn AdaptivePageLayout page creation to be asynchronous.
6 * Fix ListItem swipe handling when gesture is initiated over an overlay
7 MouseArea which does not accept pressed event. Fixes LP: #1484545
8 * AbstractButton to C++. Fixes LP: #1365471, LP: #1458028
9 * Haptics singleton moved to C++.
10 * ActionItem moved to C++.
11 * Making columns resizable in an AdaptivePageLayout.
12 * Introducing column configuration into AdaptivePageLayout.
13
14 [ Benjamin Zeller ]
15 * Fix build inside qt and shadowbuild.
16
17 [ Tim Peeters ]
18 * Remove old and unused header-related files, and update unit test filenames.
19 * Don't unset the subheader style when Page.head changes because that unsets
20 the parent of Page.head.contents. Fixes LP: #1488922
21 * Fix the theming of the MainView.
22 * Fix the background color of the overflow panel.
23
24 [ Christian Dywan ]
25 * Include change signals with arguments in .api.
26 * A public QML type with no version is an error. Rather than silently breaking
27 as QML does normally at least apicheck can make this fatal.
28 * UbuntuShape shouldn't emit redundant deprecation warnings. Fixes LP: #1481791
29 * Update .bzrignore to new upstream style layout. Fixes LP: #1433308
30 * Revert unnecessary change of Popover minimumWidth. Fixes LP: #1483708
31
32 [ Ken VanDine ]
33 * Fixed a few typos in the api docs for StateSaver.
34
35 [ Olivier Tilloy ]
36 * Take custom key indexes into account to allow sorting on custom roles.
37 Fixes LP: #1485674
38
39 [ Albert Astals Cid ]
40 * Properly free shapeTextures[index] The old code assumes that the UbuntuShape
41 will still be around when the opengl context is destroyed, but that seldom
42 happens so connect the signal to a lambda that will be there and does the
43 cleanup properly. Without this patch testDirectionalDragArea from unity8 was
44 hitting the qFatal because it ran out of space in shapeTextures.
45
46 [ Richard Huddie ]
47 * Remove all usage of the autopilot simulated keyboard when the OSK is being
48 used. Fixes LP: 31483668
49
50 [ Gerry Boland ]
51 * Compensate for Qt's device pixel ratio multiplier.
52 Fixes: LP: #1207270, LP: #1275748, LP: #1468402
53
54 [ Nick Dedekind ]
55 * Added relative date time i18n.
56
57 -- Zoltán Balogh <zoltan@bakter.hu> Fri, 04 Sep 2015 19:25:03 +0300
58
1ubuntu-ui-toolkit (1.3.1603+15.10.20150824.1-0ubuntu1) wily; urgency=medium59ubuntu-ui-toolkit (1.3.1603+15.10.20150824.1-0ubuntu1) wily; urgency=medium
260
3 [ CI Train Bot ]61 [ CI Train Bot ]
462
=== modified file 'debian/control'
--- debian/control 2015-07-10 05:40:21 +0000
+++ debian/control 2015-09-08 04:09:38 +0000
@@ -45,6 +45,11 @@
45 suru-icon-theme,45 suru-icon-theme,
46 uuid-runtime,46 uuid-runtime,
47 python3-sphinx,47 python3-sphinx,
48 libfontconfig1-dev,
49 libfreetype6-dev,
50 libmtdev-dev,
51 libudev-dev,
52 libxrender-dev
48Standards-Version: 3.9.453Standards-Version: 3.9.4
49Homepage: https://launchpad.net/ubuntu-ui-toolkit54Homepage: https://launchpad.net/ubuntu-ui-toolkit
50# If you aren't a member of ~ubuntu-sdk-team but need to upload packaging55# If you aren't a member of ~ubuntu-sdk-team but need to upload packaging
5156
=== modified file 'documentation/documentation.pro'
--- documentation/documentation.pro 2015-06-02 15:47:45 +0000
+++ documentation/documentation.pro 2015-09-08 04:09:38 +0000
@@ -17,7 +17,7 @@
17generate_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_PATH17generate_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
1818
19#install the online docs only when building outside of Qt19#install the online docs only when building outside of Qt
20force_independent: {20!build_with_qt{
21 install_docs.files = $$shadowed($$ROOT_SOURCE_DIR)/documentation/html21 install_docs.files = $$shadowed($$ROOT_SOURCE_DIR)/documentation/html
22 install_docs.path = /usr/share/ubuntu-ui-toolkit/doc22 install_docs.path = /usr/share/ubuntu-ui-toolkit/doc
23 install_docs.CONFIG += no_check_exist directory no_build23 install_docs.CONFIG += no_check_exist directory no_build
2424
=== modified file 'documentation/ubuntu-ui-toolkit-common.qdocconf'
--- documentation/ubuntu-ui-toolkit-common.qdocconf 2015-07-24 18:00:54 +0000
+++ documentation/ubuntu-ui-toolkit-common.qdocconf 2015-09-08 04:09:38 +0000
@@ -26,7 +26,7 @@
26sources.fileextensions = "*.qml *.qdoc *.cpp *.js"26sources.fileextensions = "*.qml *.qdoc *.cpp *.js"
27headers.fileextensions = "*.h"27headers.fileextensions = "*.h"
28# exclude qml files that have the component documented in a separate qdoc file28# exclude qml files that have the component documented in a separate qdoc file
29excludefiles = $BLD/../src/Ubuntu/Components/MainView.qml29excludefiles += $BLD/../src/Ubuntu/Components/1.3/PageWrapperUtils.js
30outputdir = $BLD/html30outputdir = $BLD/html
31outputformats = HTML31outputformats = HTML
32version = 1.232version = 1.2
3333
=== modified file 'examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.qml'
--- examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.qml 2015-08-07 13:48:39 +0000
+++ examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.qml 2015-09-08 04:09:38 +0000
@@ -37,6 +37,28 @@
37 anchors.fill: parent37 anchors.fill: parent
38 primaryPage: mainPage38 primaryPage: mainPage
3939
40 layouts: [
41 PageColumnsLayout {
42 when: layout.width > units.gu(80)
43 PageColumn {
44 minimumWidth: units.gu(30)
45 maximumWidth: units.gu(50)
46 preferredWidth: units.gu(40)
47 }
48 PageColumn {
49 fillWidth: true
50 }
51 },
52 // configure single column mode so we can only size it to minimum 20 GU
53 PageColumnsLayout {
54 when: true
55 PageColumn {
56 minimumWidth: units.gu(20)
57 fillWidth: true
58 }
59 }
60 ]
61
40 Page {62 Page {
41 id: mainPage63 id: mainPage
42 title: "Ubuntu UI Toolkit"64 title: "Ubuntu UI Toolkit"
@@ -74,9 +96,8 @@
74 selected: index === widgetList.currentIndex96 selected: index === widgetList.currentIndex
75 onClicked: {97 onClicked: {
76 var source = Qt.resolvedUrl(model.source);98 var source = Qt.resolvedUrl(model.source);
77 var newPage = layout.addPageToNextColumn(mainPage, source);99 layout.addPageToNextColumn(mainPage, source, {title: model.label});
78100
79 newPage.title = model.label;
80 widgetList.currentIndex = index;101 widgetList.currentIndex = index;
81 }102 }
82 }103 }
83104
=== modified file 'features/ubuntu_enable_testing.prf'
--- features/ubuntu_enable_testing.prf 2015-05-19 07:55:27 +0000
+++ features/ubuntu_enable_testing.prf 2015-09-08 04:09:38 +0000
@@ -1,6 +1,6 @@
1instbase = $$ROOT_BUILD_DIR/qml1instbase = $$ROOT_BUILD_DIR/qml
22
3force_independent: {3!build_with_qt {
4 # These bizarre rules copy the files to the build directory4 # These bizarre rules copy the files to the build directory
55
6 defineReplace(qmlModStripSrcDir) {6 defineReplace(qmlModStripSrcDir) {
77
=== modified file 'features/ubuntu_qml_plugin.prf'
--- features/ubuntu_qml_plugin.prf 2015-07-30 13:47:23 +0000
+++ features/ubuntu_qml_plugin.prf 2015-09-08 04:09:38 +0000
@@ -1,64 +1,65 @@
1load(qml_plugin)1load(qml_plugin)
2CONFIG -= hide_symbols2CONFIG -= hide_symbols
33
4
5load(ubuntu_enable_testing)4load(ubuntu_enable_testing)
65
7#hacky hacks to build the qmltypes6#hacky hacks to build the qmltypes
87
9#should be already set by the qml_plugin.prf, but lets be safe8!build_with_qt{
10isEmpty(IMPORT_VERSION): error("Must set IMPORT_VERSION")9 #should be already set by the qml_plugin.prf, but lets be safe
1110 isEmpty(IMPORT_VERSION): error("Must set IMPORT_VERSION")
12load(resolve_target)11
1312 load(resolve_target)
14qml1_target {13
15 qmlplugindump = qml1plugindump14 qml1_target {
16 importpath.name = QML_IMPORT_PATH15 qmlplugindump = qml1plugindump
17} else {16 importpath.name = QML_IMPORT_PATH
18 qmlplugindump = qmlplugindump17 } else {
19 importpath.name = QML2_IMPORT_PATH18 qmlplugindump = qmlplugindump
20}19 importpath.name = QML2_IMPORT_PATH
2120 }
22qtPrepareTool(QMLPLUGINDUMP, $$qmlplugindump)21
23importpath.value =22 qtPrepareTool(QMLPLUGINDUMP, $$qmlplugindump)
24for(qmod, QTREPOS) {23 importpath.value =
25 qml1_target: \24 for(qmod, QTREPOS) {
26 qmod = $$qmod/imports25 qml1_target: \
27 else: \26 qmod = $$qmod/imports
28 qmod = $$qmod/qml27 else: \
29 exists($$qmod): importpath.value += $$shell_path($$qmod)28 qmod = $$qmod/qml
30}29 exists($$qmod): importpath.value += $$shell_path($$qmod)
3130 }
32#add our path, somehow its not added automatically31
33importpath.value += $$shell_path($$instbase)32 #add our path, somehow its not added automatically
34importpath.value = $$unique(importpath.value)33 importpath.value += $$shell_path($$instbase)
3534 importpath.value = $$unique(importpath.value)
36membackend.name = ALARM_BACKEND35
37membackend.value = memory36 membackend.name = ALARM_BACKEND
3837 membackend.value = memory
39qtAddToolEnv(QMLPLUGINDUMP, importpath)38
40qtAddToolEnv(QMLPLUGINDUMP, membackend)39 qtAddToolEnv(QMLPLUGINDUMP, importpath)
4140 qtAddToolEnv(QMLPLUGINDUMP, membackend)
42TARGETPATHBASE = $$replace(TARGETPATH, \\.\\d+\$, )41
4342 TARGETPATHBASE = $$replace(TARGETPATH, \\.\\d+\$, )
44QMLTYPEFILE = $$instbase/$$TARGETPATH/plugins.qmltypes43
45autobld_qmltypes.target = $$QMLTYPEFILE44 QMLTYPEFILE = $$instbase/$$TARGETPATH/plugins.qmltypes
46autobld_qmltypes.commands = $$QMLPLUGINDUMP -nonrelocatable $$replace(TARGETPATHBASE, /, .) $$IMPORT_VERSION > $$QMLTYPEFILE45 autobld_qmltypes.target = $$QMLTYPEFILE
47autobld_qmltypes.commands += && sed -i \'s?-1.-1\"?0.1\"?\' $$QMLTYPEFILE46 autobld_qmltypes.commands = $$QMLPLUGINDUMP -nonrelocatable $$replace(TARGETPATHBASE, /, .) $$IMPORT_VERSION > $$QMLTYPEFILE
48autobld_qmltypes.commands += && sed -i \'s?exportMetaObjectRevisions: \\[-1\\]?exportMetaObjectRevisions: [0,0]?\' $$QMLTYPEFILE47 autobld_qmltypes.commands += && sed -i \'s?-1.-1\"?0.1\"?\' $$QMLTYPEFILE
49autobld_qmltypes.depends = $$QMAKE_RESOLVED_TARGET48 autobld_qmltypes.commands += && sed -i \'s?exportMetaObjectRevisions: \\[-1\\]?exportMetaObjectRevisions: [0,0]?\' $$QMLTYPEFILE
5049 autobld_qmltypes.depends = $$QMAKE_RESOLVED_TARGET
51autobld_install_qmltypes.files = $$QMLTYPEFILE50
52autobld_install_qmltypes.depends = $$QMLTYPEFILE51 autobld_install_qmltypes.files = $$QMLTYPEFILE
53autobld_install_qmltypes.path = $$[QT_INSTALL_QML]/$$TARGETPATH52 autobld_install_qmltypes.depends = $$QMLTYPEFILE
54autobld_install_qmltypes.CONFIG += no_check_exist53 autobld_install_qmltypes.path = $$[QT_INSTALL_QML]/$$TARGETPATH
5554 autobld_install_qmltypes.CONFIG += no_check_exist
56INSTALLS+=autobld_install_qmltypes55
57QMAKE_EXTRA_TARGETS += autobld_qmltypes56 INSTALLS+=autobld_install_qmltypes
57 QMAKE_EXTRA_TARGETS += autobld_qmltypes
58}
5859
59# when building against the system Qt we pick up the CXX_FLAGS for a release build60# when building against the system Qt we pick up the CXX_FLAGS for a release build
60# reset them to the default debug build flags61# reset them to the default debug build flags
61force_independent: {62!build_with_qt: {
62 CONFIG(debug, debug|release) {63 CONFIG(debug, debug|release) {
63 QMAKE_CFLAGS = $$QMAKE_CFLAGS_DEBUG64 QMAKE_CFLAGS = $$QMAKE_CFLAGS_DEBUG
64 QMAKE_CXXFLAGS = $$QMAKE_CXXFLAGS_DEBUG65 QMAKE_CXXFLAGS = $$QMAKE_CXXFLAGS_DEBUG
6566
=== modified file 'po/po.pro'
--- po/po.pro 2014-12-02 09:00:30 +0000
+++ po/po.pro 2015-09-08 04:09:38 +0000
@@ -30,7 +30,7 @@
30 mo_file = $$replace(po_file,.po,.mo)30 mo_file = $$replace(po_file,.po,.mo)
31 system(msgfmt $$po_file -o $$mo_file)31 system(msgfmt $$po_file -o $$mo_file)
32 mo_name = $$replace(mo_file,.mo,)32 mo_name = $$replace(mo_file,.mo,)
33 mo_targetpath = $(INSTALL_ROOT)/usr/share/locale/$${mo_name}/LC_MESSAGES33 mo_targetpath = $(INSTALL_ROOT)$$[QT_INSTALL_PREFIX]/share/locale/$${mo_name}/LC_MESSAGES
34 mo_target = $${mo_targetpath}/ubuntu-ui-toolkit.mo34 mo_target = $${mo_targetpath}/ubuntu-ui-toolkit.mo
35 !isEmpty(install_mo_commands): install_mo_commands += &&35 !isEmpty(install_mo_commands): install_mo_commands += &&
36 install_mo_commands += test -d $$mo_targetpath || mkdir -p $$mo_targetpath36 install_mo_commands += test -d $$mo_targetpath || mkdir -p $$mo_targetpath
3737
=== modified file 'src/Ubuntu/Components/1.1/Haptics.qml'
--- src/Ubuntu/Components/1.1/Haptics.qml 2015-07-24 09:54:03 +0000
+++ src/Ubuntu/Components/1.1/Haptics.qml 2015-09-08 04:09:38 +0000
@@ -14,105 +14,14 @@
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/>.
15 */15 */
1616
17pragma Singleton
18import QtQuick 2.417import QtQuick 2.4
19import QtFeedback 5.018import QtFeedback 5.0
20import Ubuntu.Components 1.119import Ubuntu.Components 1.1
2120
22/*!
23 \qmltype Haptics
24 \inqmlmodule Ubuntu.Components 1.1
25 \ingroup ubuntu-services
26 \brief Singleton defining the haptics feedback used in components, where execution
27 of the feedback is controlled by the system settings.
28
29 Supports global feedback as well as custom feedback. Global feedback can be
30 configured through its properties, and \l play function will play the default
31 configuration, or a custom one if parameter is given.
32
33 Example of using Haptics:
34 \qml
35 import QtQuick 2.4
36 import Ubuntu.Components 1.2
37
38 Item {
39 implicitWidth: units.gu(20)
40 implicitHeight: units.gu(5)
41
42 Label {
43 text: "Press me"
44 anchors.fill: parent
45 horizontalAlignment: Text.AlignHCenter
46 verticalAlignment: Text.AlignVCenter
47 }
48 MouseArea {
49 anchors.fill: parent
50 onClicked: Haptics.play()
51 }
52 }
53 \endqml
54
55 Custom effects can be played as follows:
56 \qml
57 import QtQuick 2.4
58 import Ubuntu.Components 1.2
59
60 Item {
61 implicitWidth: units.gu(20)
62 implicitHeight: units.gu(5)
63
64 Label {
65 text: "Press me"
66 anchors.fill: parent
67 horizontalAlignment: Text.AlignHCenter
68 verticalAlignment: Text.AlignVCenter
69 }
70 MouseArea {
71 anchors.fill: parent
72 onClicked: Haptics.play({duration: 25, attackIntensity: 0.7})
73 }
74 }
75 \endqml
76
77 \note Though the \l effect property exposes \c start, \c stop and \c pause
78 functions, use those only if you want to have feedback independent on what the
79 system setting is.
80 */
81Object {21Object {
82
83 /*!
84 \qmlproperty bool enabled
85 \readonly
86 The property specifies whether the haptics feedback is enabled or not by the system.
87 */
88 readonly property alias enabled: vibra.otherVibrate22 readonly property alias enabled: vibra.otherVibrate
89
90 /*!
91 \qmlproperty HapticsEffect effect
92 The property defines the settings of the haptics effect used by the component.
93 The default setting is a haptics effect with a duration of 10 milliseconds
94 with an intensity of 1.0, having fading time of 50 millisecods and fading
95 intensity 0.0, and attack time of 50 milliseconds and with an intensity of
96 0.0.
97 */
98 property alias effect: effect23 property alias effect: effect
9924
100 /*!
101 \qmlmethod play([customEffect])
102 The function plays the feedback with the configuration specified in \l effect
103 if no parameter is given. Custom effect can be played by specifying the effect
104 properties in a JSON object in \c customEffect.
105
106 The function will exit unconditionaly if playing the effects is blocked by
107 system settings.
108
109 The function will not stop any ongoing haptics effect played, if that one
110 was a default haptics effect. In case of custom effects, the previous effect
111 will be stopped, and settings will be restored before the new haptics will
112 be played. The custom settings properties (the ones which are required to
113 be different from the ones defined in the \l effect) must be specified in
114 the parameter in a JSON object.
115 */
116 function play(customEffect) {25 function play(customEffect) {
117 if (!vibra.otherVibrate) {26 if (!vibra.otherVibrate) {
118 return;27 return;
11928
=== removed file 'src/Ubuntu/Components/1.2/ActionItem.qml'
--- src/Ubuntu/Components/1.2/ActionItem.qml 2015-04-30 08:32:44 +0000
+++ src/Ubuntu/Components/1.2/ActionItem.qml 1970-01-01 00:00:00 +0000
@@ -1,96 +0,0 @@
1/*
2 * Copyright 2012 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18import Ubuntu.Components 1.2
19
20/*!
21 \qmlabstract ActionItem
22 \inqmlmodule Ubuntu.Components 1.1
23 \ingroup ubuntu
24 \brief A visual representation of an Action. The API of ActionItem is a
25 copy of the API of \l Action, with additional properties to define
26 visual aspects of the ActionItem.
27
28 If \l action is set, the values of the other properties will by default
29 be identical to the \l Action's property values. Setting the other properties
30 will override the properties copied from the \l Action.
31
32 See \l ToolbarItems for examples of how to use \l ToolbarButton or other ActionItems
33 in a toolbar.
34*/
35StyledItem {
36 id: actionItem
37
38 /*!
39 The \l Action associated with this ActionItem. If action is set,
40 the values of the Action properties are copied to the values of
41 the ActionItem properties.
42 */
43 property Action action: null
44
45 visible: action ? action.visible : true
46 enabled: action ? action.enabled : true
47
48 /*!
49 The title of the actionItem.
50 Default value: action.text
51 */
52 property string text: action ? action.text : ""
53
54 /*!
55 The image associated with the actionItem.
56 Default value: action.iconSource.
57
58 This is the URL of any image file
59 If both iconSource and iconName are defined, iconName will be ignored.
60 */
61 property url iconSource: action ? action.iconSource : (iconName ? "image://theme/" + iconName : "")
62
63 /*!
64 The icon associated with the actionItem in the suru icon theme.
65 Default value: action.iconName.
66
67 \note The complete list of icons available in Ubuntu is not published yet.
68 For now please refer to the folders where the icon themes are installed:
69 \list
70 \li Ubuntu Touch: \l file:/usr/share/icons/suru
71 \li Ubuntu Desktop: \l file:/usr/share/icons/ubuntu-mono-dark
72 \endlist
73 These 2 separate icon themes will be merged soon.
74
75 If both iconSource and iconName are defined, iconName will be ignored.
76 */
77 property string iconName: action ? action.iconName : ""
78
79 /*!
80 Called when the actionItem is triggered.
81 */
82 signal triggered(var value)
83
84 /*!
85 If \l action is set, this will trigger it.
86 */
87 onTriggered: if (action) action.trigger(value)
88
89 /*!
90 Trigger this action item if it is enabled.
91 */
92 function trigger(value) {
93 var passingValue = value ? value : null
94 if (actionItem.enabled) actionItem.triggered(passingValue);
95 }
96}
970
=== modified file 'src/Ubuntu/Components/1.2/TextField.qml'
--- src/Ubuntu/Components/1.2/TextField.qml 2015-05-01 19:38:57 +0000
+++ src/Ubuntu/Components/1.2/TextField.qml 2015-09-08 04:09:38 +0000
@@ -99,7 +99,7 @@
99 \note During text selection all interactive parent Flickables are turned off.99 \note During text selection all interactive parent Flickables are turned off.
100*/100*/
101101
102ActionItem {102Ubuntu.ActionItem {
103 id: control103 id: control
104104
105 implicitWidth: units.gu(25)105 implicitWidth: units.gu(25)
106106
=== modified file 'src/Ubuntu/Components/1.2/TextInputPopover.qml'
--- src/Ubuntu/Components/1.2/TextInputPopover.qml 2015-07-02 23:33:22 +0000
+++ src/Ubuntu/Components/1.2/TextInputPopover.qml 2015-09-08 04:09:38 +0000
@@ -88,6 +88,7 @@
88 action.text so we can get the proper button by text, action being not88 action.text so we can get the proper button by text, action being not
89 accessible. https://bugs.launchpad.net/autopilot/+bug/133459989 accessible. https://bugs.launchpad.net/autopilot/+bug/1334599
90 */90 */
91 // FIXME: AbstractButton has text property, which is getting the action.text, so no need to override!
91 property string text: action.text92 property string text: action.text
92 width: Math.max(units.gu(5), implicitWidth) + units.gu(2)93 width: Math.max(units.gu(5), implicitWidth) + units.gu(2)
93 height: units.gu(6)94 height: units.gu(6)
9495
=== modified file 'src/Ubuntu/Components/1.2/ToolbarButton.qml'
--- src/Ubuntu/Components/1.2/ToolbarButton.qml 2015-04-30 08:32:44 +0000
+++ src/Ubuntu/Components/1.2/ToolbarButton.qml 2015-09-08 04:09:38 +0000
@@ -15,6 +15,7 @@
15 */15 */
1616
17import QtQuick 2.417import QtQuick 2.4
18import Ubuntu.Components 1.2
1819
19/*!20/*!
20 \qmltype ToolbarButton21 \qmltype ToolbarButton
2122
=== removed file 'src/Ubuntu/Components/1.3/AbstractButton.qml'
--- src/Ubuntu/Components/1.3/AbstractButton.qml 2015-04-25 08:54:58 +0000
+++ src/Ubuntu/Components/1.3/AbstractButton.qml 1970-01-01 00:00:00 +0000
@@ -1,109 +0,0 @@
1/*
2 * Copyright 2012 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19
20/*!
21 \qmlabstract AbstractButton
22 \inqmlmodule Ubuntu.Components 1.1
23 \ingroup ubuntu
24 \brief The AbstractButton class defines the behavior of the button.
25
26 This class defines the behavior of the button: it defines the MouseArea
27 and the states.
28 All components deriving from this class support haptic feedback out of the box.
29*/
30ActionItem {
31 id: button
32
33 /*!
34 If an action is specified, the button's clicked signal will trigger the action.
35 Subclasses of AbstractButton can use other properties of action (for example
36 the text and iconName).
37 \qmlproperty Action action
38 */
39
40 /*!
41 This handler is called when there is a mouse click on the button
42 and the button is not disabled. If \b action is defined,
43 the action will be triggered.
44 */
45 signal clicked()
46
47 /*!
48 If a button is clicked, its triggered() signal will automatically be called.
49 */
50 onClicked: button.trigger()
51
52 Keys.onEnterPressed: clicked()
53 Keys.onReturnPressed: clicked()
54
55 /*!
56 This handler is called when there is a long press.
57 */
58 signal pressAndHold()
59
60 /*!
61 True if the user presses a mouse button in the button's mouse area.
62 */
63 property bool pressed: mouseArea.pressed
64
65 /*!
66 True if the mouse cursor hovers over the button's mouse area.
67 */
68 property bool hovered: __acceptEvents && mouseArea.containsMouse
69
70 /*!
71 \internal
72 Disable or enable signal emition by default.
73 Some classes want to emit the signal by themselves (ListItem.Standard)
74 */
75 property bool __acceptEvents: true
76
77 /*!
78 \internal
79 To get the properties of the mouse area in subclasses.
80 */
81 property alias __mouseArea: mouseArea
82
83 activeFocusOnPress: true
84
85 MouseArea {
86 id: mouseArea
87 anchors.fill: parent
88 // if mouseArea is given a new value, disable defaultMouseArea
89 // as it might occlude the newly assigned mouse area.
90 hoverEnabled: true
91
92 // invoke Haptics singleton earlier than we press the button,
93 // so we give some time for the singleton to sync settings with the service
94 property bool hapticsEnabled: Haptics.enabled
95
96 onClicked: {
97 if (button.__acceptEvents) {
98 // FIXME (Vivid) call this in the style rather than from AbstractButton
99 Haptics.play();
100 button.clicked()
101 }
102 }
103 onPressAndHold: {
104 if (button.__acceptEvents) {
105 button.pressAndHold()
106 }
107 }
108 }
109}
1100
=== removed file 'src/Ubuntu/Components/1.3/ActionItem.qml'
--- src/Ubuntu/Components/1.3/ActionItem.qml 2015-04-25 08:54:58 +0000
+++ src/Ubuntu/Components/1.3/ActionItem.qml 1970-01-01 00:00:00 +0000
@@ -1,96 +0,0 @@
1/*
2 * Copyright 2012 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19
20/*!
21 \qmlabstract ActionItem
22 \inqmlmodule Ubuntu.Components 1.1
23 \ingroup ubuntu
24 \brief A visual representation of an Action. The API of ActionItem is a
25 copy of the API of \l Action, with additional properties to define
26 visual aspects of the ActionItem.
27
28 If \l action is set, the values of the other properties will by default
29 be identical to the \l Action's property values. Setting the other properties
30 will override the properties copied from the \l Action.
31
32 See \l ToolbarItems for examples of how to use \l ToolbarButton or other ActionItems
33 in a toolbar.
34*/
35StyledItem {
36 id: actionItem
37
38 /*!
39 The \l Action associated with this ActionItem. If action is set,
40 the values of the Action properties are copied to the values of
41 the ActionItem properties.
42 */
43 property Action action: null
44
45 visible: action ? action.visible : true
46 enabled: action ? action.enabled : true
47
48 /*!
49 The title of the actionItem.
50 Default value: action.text
51 */
52 property string text: action ? action.text : ""
53
54 /*!
55 The image associated with the actionItem.
56 Default value: action.iconSource.
57
58 This is the URL of any image file
59 If both iconSource and iconName are defined, iconName will be ignored.
60 */
61 property url iconSource: action ? action.iconSource : (iconName ? "image://theme/" + iconName : "")
62
63 /*!
64 The icon associated with the actionItem in the suru icon theme.
65 Default value: action.iconName.
66
67 \note The complete list of icons available in Ubuntu is not published yet.
68 For now please refer to the folders where the icon themes are installed:
69 \list
70 \li Ubuntu Touch: \l file:/usr/share/icons/suru
71 \li Ubuntu Desktop: \l file:/usr/share/icons/ubuntu-mono-dark
72 \endlist
73 These 2 separate icon themes will be merged soon.
74
75 If both iconSource and iconName are defined, iconName will be ignored.
76 */
77 property string iconName: action ? action.iconName : ""
78
79 /*!
80 Called when the actionItem is triggered.
81 */
82 signal triggered(var value)
83
84 /*!
85 If \l action is set, this will trigger it.
86 */
87 onTriggered: if (action) action.trigger(value)
88
89 /*!
90 Trigger this action item if it is enabled.
91 */
92 function trigger(value) {
93 var passingValue = value ? value : null
94 if (actionItem.enabled) actionItem.triggered(passingValue);
95 }
96}
970
=== modified file 'src/Ubuntu/Components/1.3/AdaptivePageLayout.qml'
--- src/Ubuntu/Components/1.3/AdaptivePageLayout.qml 2015-07-28 15:04:07 +0000
+++ src/Ubuntu/Components/1.3/AdaptivePageLayout.qml 2015-09-08 04:09:38 +0000
@@ -83,10 +83,85 @@
83 }83 }
84 \endqml84 \endqml
8585
86 \note Observe the use of the \c Page::pageStack property in the example above.
87 The same property is used to share the AdaptivePageLayout instance the Page is
88 used in, therefore the same page can be used in a PageStack or in an AdaptivePageLayout.
89 However implementations must make sure the desired PageStack or AdaptivePageLayout
90 function exists in the instance before using it.
91
86 AdaptivePageLayout supports adaptive column handling. When the number of columns changes at92 AdaptivePageLayout supports adaptive column handling. When the number of columns changes at
87 runtime the pages are automatically rearranged.93 runtime the pages are automatically rearranged.
8894
89 \sa PageStack95 By default the component splits the layout in two columns when the width of the
96 layout exceeds 80 grid units. The first column is sized to 40 grid unit width and
97 the second one to fill the rest of the remaining space. When the 80 grid unit breakpoint
98 is reached, the component will switch from one column to two, and vice versa.
99 These defaults can be overridden through the \l layouts property by defining the
100 possible layouts, their column sizing and the breakpoints when the layouts should
101 be activated. PageColumn configurations must appear in the same order (from left
102 to right) as the columns appear in the layout. If none of the layouts condition
103 is met, a one column layout will be used.
104
105 \qml
106 import QtQuick 2.4
107 import Ubuntu.Components 1.3
108
109 MainView {
110 width: units.gu(100)
111 height: units.gu(60)
112
113 AdaptivePageLayout {
114 anchors.fill: parent
115 primaryPage: page1
116 layouts: PageColumnsLayout {
117 when: width > units.gu(80)
118 // column #0
119 PageColumn {
120 minimumWidth: units.gu(30)
121 maximumWidth: units.gu(60)
122 preferredWidth: units.gu(40)
123 }
124 // column #1
125 PageColumn {
126 fillWidth: true
127 }
128 }
129
130 Page {
131 id: page1
132 title: "Main page"
133 Column {
134 Button {
135 text: "Add Page2 above " + page1.title
136 onClicked: page1.pageStack.addPageToCurrentColumn(page1, page2)
137 }
138 Button {
139 text: "Add Page3 next to " + page1.title
140 onClicked: page1.pageStack.addPageToNextColumn(page1, page3)
141 }
142 }
143 }
144 Page {
145 id: page2
146 title: "Page #2"
147 }
148 Page {
149 id: page3
150 title: "Page #3"
151 }
152 }
153 }
154 \endqml
155
156 A column is considered to be resizable if the \l PageColumn::minimumWidth and
157 \l PageColumn::maximumWidth configuration differs. This implies that if a column
158 is not meant to be resized, it should have \l PageColumn::minimumWidth and
159 \l PageColumn::maximumWidth set to the same value. In the example above, the
160 first column can be resized to a minimum of 30, and a maximum of 60 grid units,
161 and the preferred width is set to 40 grid units. This width is set every time
162 the layout is activated.
163
164 \sa PageStack, PageColumnsLayout, PageColumn
90*/165*/
91166
92PageTreeNode {167PageTreeNode {
@@ -113,12 +188,86 @@
113 property Page primaryPage188 property Page primaryPage
114189
115 /*!190 /*!
116 \qmlmethod Item addPageToCurrentColumn(Item sourcePage, var page[, var properties])191 \qmlproperty int columns
192 \readonly
193 The property holds the number of columns shown in the layout.
194 */
195 readonly property alias columns: d.columns
196
197 /*!
198 The property holds the different layout configurations overriding the default
199 configurations. Defaults to an empty list.
200 \sa PageColumnsLayout
201 */
202 property list<PageColumnsLayout> layouts
203
204 /*!
205 \qmlmethod object addPageToCurrentColumn(Item sourcePage, var page[, var properties])
117 Adds a \c page to the column the \c sourcePage resides in and removes all pages206 Adds a \c page to the column the \c sourcePage resides in and removes all pages
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.
119 \c properties is a JSON object containing properties208 \c properties is a JSON object containing properties to be set when page
120 to be set when page is created. \c sourcePage must be active. Returns the209 is created. \c sourcePage must be active.
121 instance of the page created.210
211 The function creates the new page asynchronously if the new \c page to be
212 added is a Component or a QML document. In this case the function returns
213 an incubator which can be used to track the page creation.For more about
214 incubation in QML and creating components asynchronously, see
215 \l {http://doc.qt.io/qt-5/qml-qtqml-component.html#incubateObject-method}
216 {Component.incubateObject()}.
217 The following example removes an element from the list model whenever the
218 page opened in the second column is closed. Note, the example must be run
219 on desktop or on a device with at least 90 grid units screen width.
220 \qml
221 import QtQuick 2.4
222 import Ubuntu.Components 1.3
223
224 MainView {
225 width: units.gu(90)
226 height: units.gu(70)
227
228 Component {
229 id: page2Component
230 Page {
231 title: "Second Page"
232 Button {
233 text: "Close me"
234 onClicked: pageStack.removePages(pageStack.primaryPage);
235 }
236 }
237 }
238
239 AdaptivePageLayout {
240 id: pageLayout
241 anchors.fill: parent
242 primaryPage: Page {
243 title: "Primary Page"
244 ListView {
245 id: listView
246 anchors.fill: parent
247 model: 10
248 delegate: ListItem {
249 Label { text: modelData }
250 onClicked: {
251 var incubator = pageLayout.addPageToNextColumn(pageLayout.primaryPage, page2Component);
252 if (incubator && incubator.status == Component.Loading) {
253 incubator.onStatusChanged = function(status) {
254 if (status == Component.Ready) {
255 // connect page's destruction to decrement model
256 incubator.object.Component.destruction.connect(function() {
257 listView.model--;
258 });
259 }
260 }
261 }
262 }
263 }
264 }
265 }
266 }
267 }
268 \endqml
269
270 \sa {http://doc.qt.io/qt-5/qml-qtqml-component.html#incubateObject-method}{Component.incubateObject}
122 */271 */
123 function addPageToCurrentColumn(sourcePage, page, properties) {272 function addPageToCurrentColumn(sourcePage, page, properties) {
124 var nextColumn = d.columnForPage(sourcePage) + 1;273 var nextColumn = d.columnForPage(sourcePage) + 1;
@@ -138,6 +287,7 @@
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.
139 If \c sourcePage is located in the288 If \c sourcePage is located in the
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.
290 The return value is the same as in \l addPageToCurrentColumn case.
141 */291 */
142 function addPageToNextColumn(sourcePage, page, properties) {292 function addPageToNextColumn(sourcePage, page, properties) {
143 var nextColumn = d.columnForPage(sourcePage) + 1;293 var nextColumn = d.columnForPage(sourcePage) + 1;
@@ -168,7 +318,12 @@
168 */318 */
169319
170 Component.onCompleted: {320 Component.onCompleted: {
171 d.relayout();321 // check layout configuration
322 if (layouts.length > 0) {
323 d.prepareLayouts();
324 } else {
325 d.relayout();
326 }
172 d.completed = true;327 d.completed = true;
173 if (primaryPage) {328 if (primaryPage) {
174 var wrapper = d.createWrapper(primaryPage);329 var wrapper = d.createWrapper(primaryPage);
@@ -183,6 +338,13 @@
183 return;338 return;
184 }339 }
185 }340 }
341 onLayoutsChanged: {
342 if (d.completed) {
343 // only deal with this if the layouts array changes after completion
344 // to avoid unnecessary rendering
345 d.prepareLayouts();
346 }
347 }
186348
187 QtObject {349 QtObject {
188 id: d350 id: d
@@ -190,7 +352,12 @@
190 property bool completed: false352 property bool completed: false
191 property var tree: new Tree.Tree()353 property var tree: new Tree.Tree()
192354
193 property int columns: layout.width >= units.gu(80) ? 2 : 1355 property int columns: !layout.layouts.length ?
356 (layout.width >= units.gu(80) ? 2 : 1) :
357 (activeLayout ? activeLayout.data.length : 1)
358 property PageColumnsLayout activeLayout: null
359 property list<PageColumnsLayout> prevLayouts
360
194 /*! internal */361 /*! internal */
195 onColumnsChanged: {362 onColumnsChanged: {
196 if (columns <= 0) {363 if (columns <= 0) {
@@ -201,11 +368,10 @@
201 }368 }
202 property real defaultColumnWidth: units.gu(40)369 property real defaultColumnWidth: units.gu(40)
203 onDefaultColumnWidthChanged: body.applyMetrics()370 onDefaultColumnWidthChanged: body.applyMetrics()
204 property list<ColumnMetrics> columnMetrics
205371
206 function createWrapper(page, properties) {372 function createWrapper(page, properties) {
207 var wrapperComponent = Qt.createComponent("PageWrapper.qml");373 var wrapperComponent = Qt.createComponent("PageWrapper.qml");
208 var wrapperObject = wrapperComponent.createObject(hiddenPages);374 var wrapperObject = wrapperComponent.createObject(hiddenPages, {synchronous: false});
209 wrapperObject.pageStack = layout;375 wrapperObject.pageStack = layout;
210 wrapperObject.properties = properties;376 wrapperObject.properties = properties;
211 // set reference last because it will trigger creation of the object377 // set reference last because it will trigger creation of the object
@@ -221,7 +387,14 @@
221 // replace page holder's child387 // replace page holder's child
222 var holder = body.children[targetColumn];388 var holder = body.children[targetColumn];
223 holder.detachCurrentPage();389 holder.detachCurrentPage();
224 holder.attachPage(pageWrapper)390 if ((pageWrapper.incubator && pageWrapper.incubator.status == Component.Ready) || pageWrapper.object) {
391 holder.attachPage(pageWrapper);
392 } else {
393 // asynchronous, connect to page load completion and attach when page is available
394 pageWrapper.pageLoaded.connect(function () {
395 holder.attachPage(pageWrapper);
396 });
397 }
225 }398 }
226399
227 function getWrapper(page) {400 function getWrapper(page) {
@@ -279,7 +452,7 @@
279 newWrapper.parentPage = sourcePage;452 newWrapper.parentPage = sourcePage;
280 newWrapper.column = column;453 newWrapper.column = column;
281 d.addWrappedPage(newWrapper);454 d.addWrappedPage(newWrapper);
282 return newWrapper.object;455 return newWrapper.incubator;
283 }456 }
284457
285 // update the page for the specified column458 // update the page for the specified column
@@ -301,6 +474,33 @@
301 }474 }
302 }475 }
303476
477 // prepares layout management, listens on layout condition changes and performs re-layouting
478 function prepareLayouts() {
479 // disconnect from the previous layouts
480 for (var i = 0; i < prevLayouts.length; i++) {
481 prevLayouts[i].whenChanged.disconnect(updateLayout);
482 }
483 prevLayouts = layouts;
484 for (var i = 0; i < layouts.length; i++) {
485 layouts[i].whenChanged.connect(updateLayout);
486 }
487 // first time evaluation
488 updateLayout();
489 }
490
491 // function called when one of the layout condition is satisfied
492 function updateLayout() {
493 var newLayout = null;
494 for (var i = 0; i < layouts.length; i++) {
495 // get the first affirmative condition
496 if (layouts[i].when) {
497 newLayout = layouts[i];
498 break;
499 }
500 }
501 d.activeLayout = newLayout;
502 }
503
304 // relayouts when column count changes504 // relayouts when column count changes
305 function relayout() {505 function relayout() {
306 if (body.children.length == d.columns) return;506 if (body.children.length == d.columns) return;
@@ -357,8 +557,8 @@
357 // default metrics557 // default metrics
358 Component {558 Component {
359 id: defaultMetrics559 id: defaultMetrics
360 ColumnMetrics {560 PageColumn {
361 fillWidth: column == d.columns561 fillWidth: __column == d.columns
362 minimumWidth: d.defaultColumnWidth562 minimumWidth: d.defaultColumnWidth
363 }563 }
364 }564 }
@@ -376,13 +576,12 @@
376 property PageWrapper pageWrapper576 property PageWrapper pageWrapper
377 property int column577 property int column
378 property alias config: subHeader.config578 property alias config: subHeader.config
379 property ColumnMetrics metrics: setDefaultMetrics()579 property PageColumn metrics: getDefaultMetrics()
580 readonly property real dividerThickness: units.dp(1)
380581
381 Layout.fillWidth: metrics.fillWidth582 Layout.fillWidth: metrics.fillWidth
382 Layout.fillHeight: true583 Layout.fillHeight: true
383 Layout.preferredWidth: metrics.maximumWidth > 0 ?584 Layout.preferredWidth: MathUtils.clamp(metrics.preferredWidth, metrics.minimumWidth, metrics.maximumWidth)
384 MathUtils.clamp(d.defaultColumnWidth, metrics.minimumWidth, metrics.maximumWidth) :
385 d.defaultColumnWidth
386 Layout.minimumWidth: metrics.minimumWidth585 Layout.minimumWidth: metrics.minimumWidth
387 Layout.maximumWidth: metrics.maximumWidth586 Layout.maximumWidth: metrics.maximumWidth
388587
@@ -396,7 +595,7 @@
396 bottom: parent.bottom595 bottom: parent.bottom
397 left: parent.left596 left: parent.left
398 right: parent.right597 right: parent.right
399 rightMargin: verticalDivider.width598 rightMargin: dividerThickness
400 }599 }
401 // we need to clip because the header does not have a background600 // we need to clip because the header does not have a background
402 clip: true601 clip: true
@@ -412,7 +611,7 @@
412 }611 }
413 height: body.headerHeight612 height: body.headerHeight
414613
415 styleName: config ? "PageHeadStyle" : ""614 styleName: "PageHeadStyle"
416 theme.version: Ubuntu.toolkitVersion615 theme.version: Ubuntu.toolkitVersion
417 objectName: "Header" + column616 objectName: "Header" + column
418617
@@ -457,9 +656,52 @@
457 top: parent.top656 top: parent.top
458 bottom: parent.bottom657 bottom: parent.bottom
459 right: parent.right658 right: parent.right
659 rightMargin: dividerThickness
460 }660 }
461 width: (column == (d.columns - 1)) || !pageWrapper ? 0 : units.dp(1)661 width: (column == (d.columns - 1)) || !pageWrapper ? 0 : units.dp(1)
462 color: subHeader.dividerColor662 color: theme.palette.selected.background
663 MouseArea {
664 id: resizerSensing
665 objectName: "Divider"
666 enabled: verticalDivider.width > 0
667 anchors {
668 fill: parent
669 leftMargin: enabled ? -units.gu(1) : 0
670 rightMargin: enabled ? -units.gu(1) : 0
671 }
672 cursorShape: Qt.SizeHorCursor
673 drag {
674 axis: Drag.XAxis
675 target: resizer
676 smoothed: false
677 minimumX: holder.Layout.minimumWidth
678 maximumX: holder.Layout.maximumWidth
679 }
680 onPressed: resizer.x = holder.Layout.preferredWidth
681 }
682 states: State {
683 name: "active"
684 when: resizerSensing.pressed
685 PropertyChanges {
686 target: verticalDivider
687 color: Qt.darker(theme.palette.normal.background, 1.5)
688 }
689 }
690 transitions: Transition {
691 from: ""
692 to: "*"
693 reversible: true
694 ColorAnimation {
695 target: verticalDivider
696 property: "color"
697 duration: UbuntuAnimation.SlowDuration
698 }
699 }
700 }
701 Item {
702 id: resizer
703 height: parent.height
704 onXChanged: holder.Layout.preferredWidth = x
463 }705 }
464706
465 function attachPage(page) {707 function attachPage(page) {
@@ -488,9 +730,9 @@
488 return wrapper;730 return wrapper;
489 }731 }
490732
491 function setDefaultMetrics() {733 function getDefaultMetrics() {
492 var result = defaultMetrics.createObject(holder);734 var result = defaultMetrics.createObject(holder);
493 result.column = Qt.binding(function() { return holder.column + 1; });735 result.__column = Qt.binding(function() { return holder.column + 1; });
494 return result;736 return result;
495 }737 }
496 }738 }
@@ -545,15 +787,9 @@
545 for (var i = 0; i < children.length; i++) {787 for (var i = 0; i < children.length; i++) {
546 var holder = children[i];788 var holder = children[i];
547 // search for the column metrics789 // search for the column metrics
548 var metrics = null;790 var metrics = d.activeLayout ? d.activeLayout.data[i] : null;
549 for (var j = 0; j < d.columnMetrics.length; j++) {
550 if (d.columnMetrics[j].column == (i + 1)) {
551 metrics = d.columnMetrics[j];
552 break;
553 }
554 }
555 if (!metrics) {791 if (!metrics) {
556 metrics = holder.setDefaultMetrics();792 metrics = holder.getDefaultMetrics();
557 }793 }
558 holder.metrics = metrics;794 holder.metrics = metrics;
559 updateHeaderHeight(0);795 updateHeaderHeight(0);
560796
=== modified file 'src/Ubuntu/Components/1.3/AppHeader.qml'
--- src/Ubuntu/Components/1.3/AppHeader.qml 2015-08-03 15:02:42 +0000
+++ src/Ubuntu/Components/1.3/AppHeader.qml 2015-09-08 04:09:38 +0000
@@ -184,11 +184,6 @@
184 }184 }
185185
186 /*!186 /*!
187 Set by \l MainView
188 */
189 property bool useDeprecatedToolbar: true
190
191 /*!
192 Configuration of the header.187 Configuration of the header.
193 FIXME: Must be of type PageHeadConfiguration. Setting that as the property type188 FIXME: Must be of type PageHeadConfiguration. Setting that as the property type
194 however will use the latest version (1.3) and a Page that uses an older189 however will use the latest version (1.3) and a Page that uses an older
@@ -355,5 +350,5 @@
355 }350 }
356351
357 theme.version: Components.Ubuntu.toolkitVersion352 theme.version: Components.Ubuntu.toolkitVersion
358 styleName: header.useDeprecatedToolbar ? "HeaderStyle" : "PageHeadStyle"353 styleName: "PageHeadStyle"
359}354}
360355
=== modified file 'src/Ubuntu/Components/1.3/Button.qml'
--- src/Ubuntu/Components/1.3/Button.qml 2015-05-26 15:05:46 +0000
+++ src/Ubuntu/Components/1.3/Button.qml 2015-09-08 04:09:38 +0000
@@ -105,7 +105,7 @@
105 /*!105 /*!
106 The font used for the button's text.106 The font used for the button's text.
107 */107 */
108 property font font: __styleInstance ? __styleInstance.defaultFont : Qt.font({family: "Ubuntu", pixelSize: FontUtils.sizeToPixels("medium")})108 property font font: __styleInstance.defaultFont
109109
110 /*!110 /*!
111 The position of the icon relative to the text. Options111 The position of the icon relative to the text. Options
112112
=== modified file 'src/Ubuntu/Components/1.3/ComboButton.qml'
--- src/Ubuntu/Components/1.3/ComboButton.qml 2015-05-21 10:50:35 +0000
+++ src/Ubuntu/Components/1.3/ComboButton.qml 2015-09-08 04:09:38 +0000
@@ -15,6 +15,7 @@
15 */15 */
1616
17import QtQuick 2.417import QtQuick 2.4
18import Ubuntu.Components 1.3
18import Ubuntu.Components.Popups 1.319import Ubuntu.Components.Popups 1.3
1920
20/*!21/*!
2122
=== removed file 'src/Ubuntu/Components/1.3/Header.qml'
--- src/Ubuntu/Components/1.3/Header.qml 2015-04-25 08:54:58 +0000
+++ src/Ubuntu/Components/1.3/Header.qml 1970-01-01 00:00:00 +0000
@@ -1,39 +0,0 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18
19/*!
20 \qmltype Header
21 \internal
22 \deprecated
23*/
24AppHeader {
25
26 /*!
27 \internal
28 We need this property so QML exposes this class as Header instead of
29 AppHeader. This way autopilot can select the deprecated header.
30 */
31 property string _for_autopilot
32
33 Component.onCompleted: {
34 print("WARNING: Header is an internal component of Ubuntu.Components and" +
35 "its API may change or be removed at any moment." +
36 "Please use MainView and Page instead."
37 );
38 }
39}
400
=== modified file 'src/Ubuntu/Components/1.3/MainView.qml'
--- src/Ubuntu/Components/1.3/MainView.qml 2015-08-10 15:35:04 +0000
+++ src/Ubuntu/Components/1.3/MainView.qml 2015-09-08 04:09:38 +0000
@@ -191,9 +191,6 @@
191 window.title = headerItem.title191 window.title = headerItem.title
192 }192 }
193 }193 }
194
195 // Use of the deprecated toolbar is no longer supported in MainView 1.2.
196 useDeprecatedToolbar: false
197 }194 }
198195
199 Connections {196 Connections {
200197
=== modified file 'src/Ubuntu/Components/1.3/MainViewBase.qml'
--- src/Ubuntu/Components/1.3/MainViewBase.qml 2015-08-06 22:32:02 +0000
+++ src/Ubuntu/Components/1.3/MainViewBase.qml 2015-09-08 04:09:38 +0000
@@ -28,6 +28,8 @@
28*/28*/
29PageTreeNode {29PageTreeNode {
30 id: mainView30 id: mainView
31 styleName: "MainViewStyle"
32
31 /*!33 /*!
32 The property holds the application's name, which must be the same as the34 The property holds the application's name, which must be the same as the
33 desktop file's name.35 desktop file's name.
@@ -53,7 +55,7 @@
5355
54 \sa backgroundColor, footerColor56 \sa backgroundColor, footerColor
55 */57 */
56 property alias headerColor: background.headerColor58 property color headerColor: backgroundColor
5759
58 /*!60 /*!
59 \qmlproperty color MainView::backgroundColor61 \qmlproperty color MainView::backgroundColor
@@ -80,7 +82,7 @@
8082
81 \sa footerColor, headerColor83 \sa footerColor, headerColor
82 */84 */
83 property alias backgroundColor: background.backgroundColor85 property color backgroundColor: theme.palette.normal.background
8486
85 /*!87 /*!
86 \qmlproperty color MainView::footerColor88 \qmlproperty color MainView::footerColor
@@ -88,22 +90,12 @@
8890
89 \sa backgroundColor, headerColor91 \sa backgroundColor, headerColor
90 */92 */
91 property alias footerColor: background.footerColor93 property color footerColor: backgroundColor
9294
93 // FIXME: Make sure that the theming is only in the background, and the style95 Toolkit.Object {
94 // should not occlude contents of the MainView. When making changes here, make96 id: autoTheme
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
96 Toolkit.StyledItem {98 // in MainViewBase. That removes the need for auto-theming.
97 id: background
98 anchors.fill: parent
99 // theme is inherited from PageTreeNode, no need to update versioning
100 styleName: "MainViewStyle"
101
102 // FIXME: Define the colors in MainViewStyle and get rid of the properties
103 // in MainViewBase.
104 property color headerColor: backgroundColor
105 property color backgroundColor: theme.palette.normal.background
106 property color footerColor: backgroundColor
10799
108 /*100 /*
109 As we don't know the order the property bindings and onXXXChanged signals are evaluated101 As we don't know the order the property bindings and onXXXChanged signals are evaluated
@@ -113,18 +105,23 @@
113 Qt bug: https://bugreports.qt-project.org/browse/QTBUG-11712105 Qt bug: https://bugreports.qt-project.org/browse/QTBUG-11712
114 */106 */
115107
116 onBackgroundColorChanged: {108 Connections {
117 if (backgroundColor != theme.palette.normal.background) {109 target: mainView
118 // custom color, proceed with auto-theming110
119 autoThemeName = (ColorUtils.luminance(backgroundColor) >= 0.85) ?111 onBackgroundColorChanged: {
120 "Ambiance" : "SuruDark";112 if (mainView.backgroundColor != theme.palette.normal.background) {
113 // custom color, proceed with auto-theming
114 autoTheme.themeName = (ColorUtils.luminance(backgroundColor) >= 0.85) ?
115 "Ambiance" : "SuruDark";
116 }
121 }117 }
122 }118 }
123 property string autoThemeName119
124 onAutoThemeNameChanged: {120 property string themeName
121 onThemeNameChanged: {
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.
126 if (autoThemeName !== "" && (theme.name.search("Ubuntu.Components.Themes") == 0)) {123 if (themeName !== "" && (theme.name.search("Ubuntu.Components.Themes") == 0)) {
127 mainView.theme.name = "Ubuntu.Components.Themes.%1".arg(autoThemeName);124 mainView.theme.name = "Ubuntu.Components.Themes.%1".arg(themeName);
128 }125 }
129 }126 }
130 }127 }
131128
=== renamed file 'src/Ubuntu/Components/1.3/ColumnMetrics.qml' => 'src/Ubuntu/Components/1.3/PageColumn.qml'
--- src/Ubuntu/Components/1.3/ColumnMetrics.qml 2015-06-24 16:16:13 +0000
+++ src/Ubuntu/Components/1.3/PageColumn.qml 2015-09-08 04:09:38 +0000
@@ -17,37 +17,42 @@
17import QtQuick 2.417import QtQuick 2.4
1818
19/*!19/*!
20 \qmltype ColumnMetrics20 \qmltype PageColumn
21 \inqmlmodule Ubuntu.Components 1.321 \inqmlmodule Ubuntu.Components 1.3
22 \since Ubuntu.Components 1.322 \since Ubuntu.Components 1.3
23 \ingroup ubuntu23 \ingroup ubuntu
24 \brief Component configuring the metrics of a column in MultiColumnView.24 \brief Component configuring the metrics of a column in AdaptivePageLayout.
25 \internal
2625
27 */26 */
28QtObject {27QtObject {
29 /*!28 /*!
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.
30 \internal
31 */31 */
32 property int column32 property int __column
3333
34 /*!34 /*!
35 Specifies whether the width of the column should fill the available space35 Specifies whether the width of the column should fill the available space
36 of the MultiColumnView column or not. Defaults to \a false.36 of the AdaptivePageLayout column or not. Defaults to \a false.
37 */37 */
38 property bool fillWidth: false38 property bool fillWidth: false
3939
40 /*!40 /*!
41 Specifies the minimum width of the column. If the value is greater than41 Specifies the minimum width of the column. Defaults to 0.
42 \b MultiColumnView::defaultColumnWidth, the value will be set as width for
43 the column.
44 */42 */
45 property real minimumWidth: 043 property real minimumWidth: 0
4644
47 /*!45 /*!
48 Specifies the maximum width of the column. If the value is smaller than46 Specifies the maximum width of the column. A maximum value of 0 will be ignored.
49 \b MultiColumnView::defaultColumnWidth, the value will be set as width for47 Defaults to the maximum positive value.
50 the column. A maximum value of 0 will be ignored.
51 */48 */
52 property real maximumWidth: Number.POSITIVE_INFINITY49 property real maximumWidth: Number.POSITIVE_INFINITY
50
51 /*!
52 Specifies the preferred width of the column when the layout is initialized.
53 Defaults to 0. AdaptivePageLayout clamps the given value between \l minimumWidth
54 and \l maximumWidth. The value must be set if the \l fillWidth and \l minimumWidth
55 are not set.
56 */
57 property real preferredWidth: 0
53}58}
5459
=== added file 'src/Ubuntu/Components/1.3/PageColumnsLayout.qml'
--- src/Ubuntu/Components/1.3/PageColumnsLayout.qml 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/Components/1.3/PageColumnsLayout.qml 2015-09-08 04:09:38 +0000
@@ -0,0 +1,115 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18
19/*!
20 \qmltype PageColumnsLayout
21 \inqmlmodule Ubuntu.Components 1.3
22 \since Ubuntu.Components 1.3
23 \ingroup ubuntu
24 \brief Component configuring a layout in an AdaptivePageLayout component.
25
26 The component specifies the column configuration of a specific layout. The layout
27 will have as many columns as many PageColumn elements will be declared. The layout
28 will be activated when the \l when property evaluates to \c true. There can be
29 many layouts evaluated to true, only the first one evaluated to true in the
30 \l AdaptivePageLayout::layouts list will be activated.
31
32 \qml
33 import QtQuick 2.4
34 import Ubuntu.Components 1.3
35
36 MainView {
37 width: units.gu(100)
38 height: units.gu(60)
39
40 AdaptivePageLayout {
41 anchors.fill: parent
42 primaryPage: page1
43 layouts: [
44 PageColumnsLayout {
45 when: width > units.gu(80)
46 // column #0
47 PageColumn {
48 minimumWidth: units.gu(30)
49 maximumWidth: units.gu(60)
50 preferredWidth: units.gu(40)
51 }
52 // column #1
53 PageColumn {
54 fillWidth: true
55 }
56 },
57 PageColumnsLayout {
58 when: true
59 PageColumn {
60 fillWidth: true
61 minimumWidth: units.gu(10)
62 }
63 }
64 ]
65
66 Page {
67 id: page1
68 title: "Main page"
69 Column {
70 Button {
71 text: "Add Page2 above " + page1.title
72 onClicked: page1.pageStack.addPageToCurrentColumn(page1, page2)
73 }
74 Button {
75 text: "Add Page3 next to " + page1.title
76 onClicked: page1.pageStack.addPageToNextColumn(page1, page3)
77 }
78 }
79 }
80 Page {
81 id: page2
82 title: "Page #2"
83 }
84 Page {
85 id: page3
86 title: "Page #3"
87 }
88 }
89 }
90 \endqml
91 In the example above the second PageColumnLayout's condition is always set to
92 true, which means that that the layout will be always active unless the first
93 layout's condition evaluates to true. The layout overrides the single column
94 minimumWidth default value. Note that \l PageColumn::fillWidth must be also set.
95
96 \note When none of the conditions is met, a single column layout will be used.
97
98 \sa PageColumn
99 */
100QtObject {
101 id: layout
102
103 /*!
104 Condition activating the layout. Defaults to false.
105 */
106 property bool when: false
107
108 /*!
109 \qmlproperty list<PageColumn> data
110 \default
111 Default property holding the PageColumn elements configuring each column.
112 */
113 default property alias data: layout.__data
114 property list<PageColumn> __data
115}
0116
=== modified file 'src/Ubuntu/Components/1.3/PageWrapper.qml'
--- src/Ubuntu/Components/1.3/PageWrapper.qml 2015-06-15 07:45:34 +0000
+++ src/Ubuntu/Components/1.3/PageWrapper.qml 2015-09-08 04:09:38 +0000
@@ -15,7 +15,7 @@
15 */15 */
1616
17import QtQuick 2.417import QtQuick 2.4
18import "../1.2/PageWrapperUtils.js" as Utils18import "PageWrapperUtils.js" as Utils
1919
20/*!20/*!
21 \internal21 \internal
@@ -66,6 +66,22 @@
66 property Item pageHolder66 property Item pageHolder
6767
68 /*!68 /*!
69 Instructs to load the page synchronously or not. Used by AdaptivePageLayout.
70 True by default to keep PageStack integrity.
71 */
72 property bool synchronous: true
73
74 /*!
75 Incubator for the asynchronous page creation
76 */
77 property var incubator: null
78
79 /*!
80 Signal emitted when incubator completes page loading.
81 */
82 signal pageLoaded()
83
84 /*!
69 Returns true if the current PageWrapper is a child of the given page85 Returns true if the current PageWrapper is a child of the given page
70 */86 */
71 function childOf(page) {87 function childOf(page) {
@@ -114,7 +130,14 @@
114 if (pageWrapper.object) pageWrapper.object = null;130 if (pageWrapper.object) pageWrapper.object = null;
115 Utils.initPage(pageWrapper);131 Utils.initPage(pageWrapper);
116 if (pageWrapper.active && reference) {132 if (pageWrapper.active && reference) {
117 Utils.activate(pageWrapper);133 if ((pageWrapper.incubator && pageWrapper.incubator.status == Component.Ready) || pageWrapper.object) {
134 Utils.activate(pageWrapper);
135 } else {
136 // asynchronous, connect page activation
137 pageLoaded.connect(function () {
138 Utils.activate(pageWrapper);
139 });
140 }
118 }141 }
119 }142 }
120143
121144
=== added file 'src/Ubuntu/Components/1.3/PageWrapperUtils.js'
--- src/Ubuntu/Components/1.3/PageWrapperUtils.js 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/Components/1.3/PageWrapperUtils.js 2015-09-08 04:09:38 +0000
@@ -0,0 +1,167 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17//.pragma library // FIXME: cannot refer to Component.Error if I use this.
18// FIXME: ideally we would make this a stateless library, but that breaks applications
19// that rely on accessing context variables in pages that were pushed on a PageStack
20// by url (PageStack.push("FileName.qml")) because of a Qt bug:
21// https://bugreports.qt-project.org/browse/QTBUG-31347
22
23/*!
24 \internal
25 Incubator wrapper object. Used when page is loaded asynchronously.
26 */
27
28function Incubator(pageWrapper, pageComponent) {
29 // private variable for QmlIncubatorObject
30 var incubator = null;
31
32 // public API
33 this.status = Component.Ready;
34 this.object = null;
35 this.onStatusChanged = null;
36 this.forceCompletion = function () {
37 if (incubator) {
38 incubator.forceCompletion();
39 }
40 }
41
42 // internal function to catch status changes
43 function incubatorStatusChanged(status) {
44 // update wrapper incubator fields
45 pageWrapper.incubator.status = status;
46 pageWrapper.incubator.object = pageWrapper.object = incubator.object;
47
48 // emit pageWrapper's pageLoaded signal to complete page activation and loading
49 if (status === Component.Ready) {
50 pageWrapper.pageLoaded();
51 }
52
53 // forward state change to the user
54 if (pageWrapper.incubator.onStatusChanged) {
55 // call onStatusChanged
56 pageWrapper.incubator.onStatusChanged(status);
57 }
58
59 // cleanup of ready or error
60 if (status !== Component.Loading) {
61 pageWrapper.incubator = null;
62 incubator = null;
63 }
64 }
65
66 if (pageWrapper.properties) {
67 incubator = pageComponent.incubateObject(pageWrapper, pageWrapper.properties);
68 } else {
69 incubator = pageComponent.incubateObject(pageWrapper);
70 }
71
72 this.status = incubator.status;
73 if (incubator.status != Component.Ready) {
74 incubator.onStatusChanged = incubatorStatusChanged;
75 } else {
76 incubatorStatusChanged(incubator.status);
77 }
78}
79
80/*******************************************************
81 *
82 */
83/*!
84 \internal
85 Initialize pageWrapper.object.
86 */
87function initPage(pageWrapper) {
88 var pageComponent;
89
90 if (pageWrapper.reference.createObject) {
91 // page reference is a component
92 pageComponent = pageWrapper.reference;
93 } else if (typeof pageWrapper.reference == "string") {
94 // page reference is a string (url)
95 pageComponent = Qt.createComponent(pageWrapper.reference);
96 }
97
98 // PageWrapper can override the synchronous loading
99 var synchronous = pageWrapper.hasOwnProperty("synchronous") ? pageWrapper.synchronous : true;
100
101 if (pageComponent) {
102 if (pageComponent.status === Component.Error) {
103 throw new Error("Error while loading page: " + pageComponent.errorString());
104 } else {
105 // create the object
106 pageWrapper.incubator = new Incubator(pageWrapper, pageComponent);
107 if (synchronous) {
108 pageWrapper.incubator.forceCompletion();
109 }
110 pageWrapper.canDestroy = true;
111 }
112 } else {
113 // page reference is an object
114 pageWrapper.object = pageWrapper.reference;
115 pageWrapper.object.parent = pageWrapper;
116 pageWrapper.canDestroy = false;
117
118 // copy the properties to the page object
119 for (var prop in pageWrapper.properties) {
120 if (pageWrapper.properties.hasOwnProperty(prop)) {
121 pageWrapper.object[prop] = pageWrapper.properties[prop];
122 }
123 }
124 }
125
126 return pageWrapper.object;
127}
128
129/*!
130 \internal
131 Create the page object if needed, and make the page object visible.
132 */
133function activate(pageWrapper) {
134 if (!pageWrapper.object) {
135 initPage(pageWrapper);
136 }
137
138 // Having the same page pushed multiple times on a stack changes
139 // the parent of the page object. Change it back here.
140 pageWrapper.object.parent = pageWrapper;
141
142 // Some page objects are invisible initially. Make visible.
143
144 pageWrapper.object.visible = true;
145 pageWrapper.active = true;
146}
147
148/*!
149 \internal
150 Hide page object.
151 */
152function deactivate(pageWrapper) {
153 pageWrapper.active = false;
154}
155
156/*!
157 \internal
158 Destroy the page object if pageWrapper.canDestroy is true.
159 Do nothing if pageWrapper.canDestroy is false.
160 */
161function destroyObject(pageWrapper) {
162 if (pageWrapper.canDestroy) {
163 pageWrapper.object.destroy();
164 pageWrapper.object = null;
165 pageWrapper.canDestroy = false;
166 }
167}
0168
=== modified file 'src/Ubuntu/Components/1.3/TextField.qml'
--- src/Ubuntu/Components/1.3/TextField.qml 2015-08-11 17:15:59 +0000
+++ src/Ubuntu/Components/1.3/TextField.qml 2015-09-08 04:09:38 +0000
@@ -99,7 +99,7 @@
99 \note During text selection all interactive parent Flickables are turned off.99 \note During text selection all interactive parent Flickables are turned off.
100*/100*/
101101
102ActionItem {102Ubuntu.ActionItem {
103 id: control103 id: control
104104
105 implicitWidth: units.gu(25)105 implicitWidth: units.gu(25)
@@ -896,7 +896,7 @@
896 }896 }
897 }897 }
898898
899 AbstractButton {899 Ubuntu.AbstractButton {
900 id: clearButton900 id: clearButton
901 objectName: "clear_button"901 objectName: "clear_button"
902 activeFocusOnPress: false902 activeFocusOnPress: false
903903
=== modified file 'src/Ubuntu/Components/ComponentModule.pro'
--- src/Ubuntu/Components/ComponentModule.pro 2015-07-29 10:12:07 +0000
+++ src/Ubuntu/Components/ComponentModule.pro 2015-09-08 04:09:38 +0000
@@ -25,7 +25,6 @@
2525
26#1.226#1.2
27QML_FILES += 1.2/AbstractButton.qml \27QML_FILES += 1.2/AbstractButton.qml \
28 1.2/ActionItem.qml \
29 1.2/ActionList.qml \28 1.2/ActionList.qml \
30 1.2/ActivityIndicator.qml \29 1.2/ActivityIndicator.qml \
31 1.2/AnimatedItem.qml \30 1.2/AnimatedItem.qml \
@@ -81,9 +80,7 @@
81 1.2/UbuntuNumberAnimation.qml80 1.2/UbuntuNumberAnimation.qml
8281
83#1.382#1.3
84QML_FILES += 1.3/AbstractButton.qml \83QML_FILES += 1.3/ActionBar.qml \
85 1.3/ActionBar.qml \
86 1.3/ActionItem.qml \
87 1.3/ActionList.qml \84 1.3/ActionList.qml \
88 1.3/ActivityIndicator.qml \85 1.3/ActivityIndicator.qml \
89 1.3/AdaptivePageLayout.qml \86 1.3/AdaptivePageLayout.qml \
@@ -92,12 +89,10 @@
92 1.3/Button.qml \89 1.3/Button.qml \
93 1.3/Captions.qml \90 1.3/Captions.qml \
94 1.3/CheckBox.qml \91 1.3/CheckBox.qml \
95 1.3/ColumnMetrics.qml \
96 1.3/ComboButton.qml \92 1.3/ComboButton.qml \
97 1.3/CrossFadeImage.qml \93 1.3/CrossFadeImage.qml \
98 1.3/dateUtils.js \94 1.3/dateUtils.js \
99 1.3/DraggingArea.qml \95 1.3/DraggingArea.qml \
100 1.3/Header.qml \
101 1.3/InputHandler.qml \96 1.3/InputHandler.qml \
102 1.3/Label.qml \97 1.3/Label.qml \
103 1.3/MainViewBase.qml \98 1.3/MainViewBase.qml \
@@ -114,6 +109,7 @@
114 1.3/PageTreeNode.qml \109 1.3/PageTreeNode.qml \
115 1.3/pageUtils.js \110 1.3/pageUtils.js \
116 1.3/PageWrapper.qml \111 1.3/PageWrapper.qml \
112 1.3/PageWrapperUtils.js \
117 1.3/Panel.qml \113 1.3/Panel.qml \
118 1.3/ProgressBar.qml \114 1.3/ProgressBar.qml \
119 1.3/PullToRefresh.qml \115 1.3/PullToRefresh.qml \
@@ -137,9 +133,12 @@
137 1.3/UbuntuListView.qml \133 1.3/UbuntuListView.qml \
138 1.3/UbuntuNumberAnimation.qml \134 1.3/UbuntuNumberAnimation.qml \
139 1.3/ListItemPopover.qml \135 1.3/ListItemPopover.qml \
140 1.3/BottomEdgeHint.qml136 1.3/BottomEdgeHint.qml \
137 1.3/PageColumn.qml \
138 1.3/PageColumnsLayout.qml
141139
142OTHER_FILES+= 1.3/CrossFadeImage.qdoc \140OTHER_FILES+= qmldir \
141 1.3/CrossFadeImage.qdoc \
143 1.3/UbuntuListView11.qdoc \142 1.3/UbuntuListView11.qdoc \
144 1.3/Page.qdoc \143 1.3/Page.qdoc \
145 1.3/PageHeadConfiguration.qdoc \144 1.3/PageHeadConfiguration.qdoc \
146145
=== modified file 'src/Ubuntu/Components/ListItems/1.3/SingleControl.qml'
--- src/Ubuntu/Components/ListItems/1.3/SingleControl.qml 2015-04-29 07:21:29 +0000
+++ src/Ubuntu/Components/ListItems/1.3/SingleControl.qml 2015-09-08 04:09:38 +0000
@@ -54,7 +54,8 @@
5454
55 /*! \internal */55 /*! \internal */
56 onClicked: if (control && control.enabled && control.hasOwnProperty("clicked")) control.clicked()56 onClicked: if (control && control.enabled && control.hasOwnProperty("clicked")) control.clicked()
57 pressed: __mouseArea.pressed || (control && control.hasOwnProperty("pressed") && control.pressed)57 /*! \internal */
58 property bool pressed: __mouseArea.pressed || (control && control.hasOwnProperty("pressed") && control.pressed)
58 /*! \internal */59 /*! \internal */
59 onPressedChanged: if (control && control.enabled && control.hasOwnProperty("pressed")) control.pressed = singleControlListItem.pressed60 onPressedChanged: if (control && control.enabled && control.hasOwnProperty("pressed")) control.pressed = singleControlListItem.pressed
6061
6162
=== modified file 'src/Ubuntu/Components/Popups/1.3/Popover.qml'
--- src/Ubuntu/Components/Popups/1.3/Popover.qml 2015-07-19 17:54:49 +0000
+++ src/Ubuntu/Components/Popups/1.3/Popover.qml 2015-09-08 04:09:38 +0000
@@ -210,7 +210,7 @@
210 objectName: "popover_foreground"210 objectName: "popover_foreground"
211211
212 //styling properties212 //styling properties
213 property real minimumWidth: units.gu(25)213 property real minimumWidth: units.gu(40)
214214
215 property real maxWidth: dismissArea ? (internal.portrait ? dismissArea.width : dismissArea.width * 3/4) : 0.0215 property real maxWidth: dismissArea ? (internal.portrait ? dismissArea.width : dismissArea.width * 3/4) : 0.0
216 property real maxHeight: dismissArea ? (internal.portrait ? dismissArea.height * 3/4 : dismissArea.height) : 0.0216 property real maxHeight: dismissArea ? (internal.portrait ? dismissArea.height * 3/4 : dismissArea.height) : 0.0
217217
=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.2/ListItemStyle.qml'
--- src/Ubuntu/Components/Themes/Ambiance/1.2/ListItemStyle.qml 2015-07-22 18:57:58 +0000
+++ src/Ubuntu/Components/Themes/Ambiance/1.2/ListItemStyle.qml 2015-09-08 04:09:38 +0000
@@ -25,7 +25,7 @@
25 * Take over the ListItem's index context property as repeater used in panel25 * Take over the ListItem's index context property as repeater used in panel
26 * overrides the property.26 * overrides the property.
27 */27 */
28 readonly property int listItemIndex: index28 readonly property int listItemIndex: (typeof index !== "undefined") ? index : internals.childIndex()
2929
30 /*30 /*
31 * Coloring properties31 * Coloring properties
@@ -343,6 +343,19 @@
343 readonly property real threshold: units.gu(1.5)343 readonly property real threshold: units.gu(1.5)
344 property bool snapIn: false344 property bool snapIn: false
345345
346 // returns the child index of the ListItem when not used in model driven view
347 function childIndex() {
348 if (styledItem.parent) {
349 for (var i = 0; i < styledItem.parent.children.length; i++) {
350 if (styledItem.parent.children[i] == styledItem) {
351 return i;
352 }
353 }
354 } else {
355 return -1;
356 }
357 }
358
346 // update snap direction359 // update snap direction
347 function updateSnapDirection() {360 function updateSnapDirection() {
348 if (prevX < listItemStyle.x && (snapChangerLimit <= listItemStyle.x)) {361 if (prevX < listItemStyle.x && (snapChangerLimit <= listItemStyle.x)) {
349362
=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/ActionBarStyle.qml'
--- src/Ubuntu/Components/Themes/Ambiance/1.3/ActionBarStyle.qml 2015-05-22 10:48:49 +0000
+++ src/Ubuntu/Components/Themes/Ambiance/1.3/ActionBarStyle.qml 2015-09-08 04:09:38 +0000
@@ -87,8 +87,6 @@
87 id: actionsOverflowPopover87 id: actionsOverflowPopover
88 objectName: "actions_overflow_panel"88 objectName: "actions_overflow_panel"
8989
90 backgroundColor: "white"
91
92 // Ensure the popover closes when actions change and90 // Ensure the popover closes when actions change and
93 // the list item below may be destroyed before its91 // the list item below may be destroyed before its
94 // onClicked is executed. See bug92 // onClicked is executed. See bug
9593
=== removed file 'src/Ubuntu/Components/Themes/Ambiance/1.3/HeadDividerStyle.qml'
--- src/Ubuntu/Components/Themes/Ambiance/1.3/HeadDividerStyle.qml 2015-04-24 14:07:02 +0000
+++ src/Ubuntu/Components/Themes/Ambiance/1.3/HeadDividerStyle.qml 1970-01-01 00:00:00 +0000
@@ -1,56 +0,0 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16import QtQuick 2.4
17
18/*!
19 This component is DEPRECATED and no longer used. The divider is now a simple line.
20 */
21Item {
22 id: dividerStyle
23
24 property color color: styledItem.backgroundColor
25
26 // Do not make the following two colors part of the style API as they may be deprecated soon.
27 property color topColor: Qt.darker(color, 1.1)
28 property color bottomColor: Qt.lighter(color, 1.2)
29
30 Rectangle {
31 anchors.fill: parent
32 color: dividerStyle.color
33
34 gradient: Gradient {
35 // top shadow
36 GradientStop {
37 position: 0.02
38 color: dividerStyle.topColor
39 }
40 // middle (background)
41 GradientStop {
42 position: 0.05
43 color: dividerStyle.color
44 }
45 GradientStop {
46 position: 0.95
47 color: dividerStyle.color
48 }
49 // bottom highlight
50 GradientStop {
51 position: 0.98
52 color: dividerStyle.bottomColor
53 }
54 }
55 }
56}
570
=== removed file 'src/Ubuntu/Components/Themes/Ambiance/1.3/HeaderStyle.qml'
--- src/Ubuntu/Components/Themes/Ambiance/1.3/HeaderStyle.qml 2015-04-24 14:07:02 +0000
+++ src/Ubuntu/Components/Themes/Ambiance/1.3/HeaderStyle.qml 1970-01-01 00:00:00 +0000
@@ -1,124 +0,0 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16import QtQuick 2.4
17import Ubuntu.Components 1.3
18
19Item {
20 id: headerStyle
21 /*!
22 The height of the headercontents, which is the full height of
23 the header minus the separators shown at the bottom of it.
24 */
25 property real contentHeight: units.gu(7.5)
26
27 /*!
28 The source of the image that separates the header from the contents of a \l MainView.
29 The separator will be drawn over the contents.
30 */
31 property url separatorSource: Qt.resolvedUrl("../artwork/PageHeaderBaseDividerLight.sci")
32
33 /*!
34 The source of an additional image attached to the bottom of the separator. The contents
35 of the \l MainView will be drawn on top of the separator bottom image.
36 */
37 property url separatorBottomSource: Qt.resolvedUrl("../artwork/PageHeaderBaseDividerBottom.png")
38
39 property int fontWeight: Font.Light
40 property string fontSize: "x-large"
41 property color textColor: theme.palette.selected.backgroundText
42 property real textLeftMargin: units.gu(2)
43
44 implicitHeight: headerStyle.contentHeight + separator.height + separatorBottom.height
45
46 /*!
47 \internal
48 Tabs needs to call sync of the TabBar
49 */
50 property TabBar __tabBar: tabBarLoader.sourceComponent ? tabBarLoader.item : null
51
52 BorderImage {
53 id: separator
54 anchors {
55 bottom: parent.bottom
56 left: parent.left
57 right: parent.right
58 }
59 source: headerStyle.separatorSource
60 }
61 Image {
62 id: separatorBottom
63 anchors {
64 top: separator.bottom
65 left: parent.left
66 right: parent.right
67 }
68 source: headerStyle.separatorBottomSource
69 }
70
71 Item {
72 id: foreground
73 anchors {
74 left: parent.left
75 right: parent.right
76 top: parent.top
77 }
78 height: headerStyle.contentHeight
79
80 Label {
81 LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft
82
83 anchors {
84 left: parent.left
85 verticalCenter: parent.verticalCenter
86 leftMargin: headerStyle.textLeftMargin
87 }
88 text: styledItem.title
89 font.weight: headerStyle.fontWeight
90 visible: !styledItem.tabsModel && !styledItem.contents
91 fontSize: headerStyle.fontSize
92 color: headerStyle.textColor
93 }
94
95 Binding {
96 target: styledItem.contents
97 property: "anchors.fill"
98 value: foreground
99 when: styledItem.contents
100 }
101 Binding {
102 target: styledItem.contents
103 property: "parent"
104 value: foreground
105 when: styledItem.contents
106 }
107
108 Loader {
109 id: tabBarLoader
110 sourceComponent: styledItem.tabsModel && !styledItem.contents ? tabBarComponent : null
111 anchors.fill: parent
112 }
113
114 Component {
115 id: tabBarComponent
116 TabBar {
117 id: tabBar
118 anchors.fill: parent
119 model: styledItem.tabsModel
120 animate: styledItem.animate
121 }
122 }
123 }
124}
1250
=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/ListItemStyle.qml'
--- src/Ubuntu/Components/Themes/Ambiance/1.3/ListItemStyle.qml 2015-07-22 18:57:58 +0000
+++ src/Ubuntu/Components/Themes/Ambiance/1.3/ListItemStyle.qml 2015-09-08 04:09:38 +0000
@@ -337,6 +337,7 @@
337 property real snapChangerLimit: 0.0337 property real snapChangerLimit: 0.0
338 readonly property real threshold: units.gu(1.5)338 readonly property real threshold: units.gu(1.5)
339 property bool snapIn: false339 property bool snapIn: false
340 property bool completed: false
340341
341 // update snap direction342 // update snap direction
342 function updateSnapDirection() {343 function updateSnapDirection() {
@@ -419,4 +420,68 @@
419 function rebound() {420 function rebound() {
420 snapAnimation.snapTo(0);421 snapAnimation.snapTo(0);
421 }422 }
423
424 // expansion
425 Component.onCompleted: internals.completed = true
426 state: (internals.completed && styledItem.expansion.expanded) ? (listItemStyle.flickable ? "expandedWithFlickable" : "expandedNoFlickable") : ""
427 states: [
428 State {
429 name: "expandedNoFlickable"
430 PropertyChanges {
431 target: styledItem
432 height: styledItem.expansion.height
433 }
434 },
435 State {
436 name: "expandedWithFlickable"
437 PropertyChanges {
438 target: styledItem
439 height: styledItem.expansion.height
440 }
441 PropertyChanges {
442 target: listItemStyle.flickable
443 // we do not need to restore the original values
444 restoreEntryValues: false
445 // and we should not get any binding updates even
446 explicit: true
447 contentY: {
448 var bottom = styledItem.y + styledItem.expansion.height - listItemStyle.flickable.contentY + listItemStyle.flickable.originY;
449 var dy = bottom - listItemStyle.flickable.height;
450 if (dy > 0) {
451 return listItemStyle.flickable.contentY + dy - listItemStyle.flickable.originY;
452 } else {
453 return listItemStyle.flickable.contentY;
454 }
455 }
456 }
457 }
458 ]
459 transitions: [
460 Transition {
461 from: ""
462 to: "expandedWithFlickable"
463 reversible: true
464 enabled: listItemStyle.animatePanels
465 ParallelAnimation {
466 UbuntuNumberAnimation {
467 target: listItemStyle.flickable
468 property: "contentY"
469 }
470 UbuntuNumberAnimation {
471 target: styledItem
472 property: "height"
473 }
474 }
475 },
476 Transition {
477 from: ""
478 to: "expandedNoFlickable"
479 reversible: true
480 enabled: listItemStyle.animatePanels
481 UbuntuNumberAnimation {
482 target: styledItem
483 property: "height"
484 }
485 }
486 ]
422}487}
423488
=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/OverflowPanel.qml'
--- src/Ubuntu/Components/Themes/Ambiance/1.3/OverflowPanel.qml 2015-04-29 08:55:31 +0000
+++ src/Ubuntu/Components/Themes/Ambiance/1.3/OverflowPanel.qml 2015-09-08 04:09:38 +0000
@@ -32,7 +32,7 @@
32 /*!32 /*!
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.
34 */34 */
35 property color backgroundColor: styledItem.panelColor35 property color backgroundColor: theme.palette.normal.background
3636
37 /*!37 /*!
38 The background color of the tapped item in the panel.38 The background color of the tapped item in the panel.
3939
=== modified file 'src/Ubuntu/Components/Themes/Ambiance/Ambiance.pro'
--- src/Ubuntu/Components/Themes/Ambiance/Ambiance.pro 2015-06-18 08:03:55 +0000
+++ src/Ubuntu/Components/Themes/Ambiance/Ambiance.pro 2015-09-08 04:09:38 +0000
@@ -84,8 +84,6 @@
84 1.3/DialerHandStyle.qml \84 1.3/DialerHandStyle.qml \
85 1.3/DialerStyle.qml \85 1.3/DialerStyle.qml \
86 1.3/DialogForegroundStyle.qml \86 1.3/DialogForegroundStyle.qml \
87 1.3/HeadDividerStyle.qml \
88 1.3/HeaderStyle.qml \
89 1.3/HighlightMagnifier.qml \87 1.3/HighlightMagnifier.qml \
90 1.3/ListItemOptionSelectorStyle.qml \88 1.3/ListItemOptionSelectorStyle.qml \
91 1.3/ListItemStyle.qml \89 1.3/ListItemStyle.qml \
9290
=== modified file 'src/Ubuntu/Components/plugin/adapters/actionsproxy_p.cpp'
--- src/Ubuntu/Components/plugin/adapters/actionsproxy_p.cpp 2014-09-01 06:56:39 +0000
+++ src/Ubuntu/Components/plugin/adapters/actionsproxy_p.cpp 2015-09-08 04:09:38 +0000
@@ -90,18 +90,18 @@
90 }90 }
91 if (watch) {91 if (watch) {
92 // connect to action proxy92 // connect to action proxy
93 QObject::connect(context, SIGNAL(activeChanged(bool)),93 QObject::connect(context, SIGNAL(activeChanged()),
94 this, SLOT(handleContextActivation(bool)),94 this, SLOT(handleContextActivation()),
95 Qt::DirectConnection);95 Qt::DirectConnection);
96 } else {96 } else {
97 // disconnect97 // disconnect
98 QObject::disconnect(context, SIGNAL(activeChanged(bool)),98 QObject::disconnect(context, SIGNAL(activeChanged()),
99 this, SLOT(handleContextActivation(bool)));99 this, SLOT(handleContextActivation()));
100 }100 }
101}101}
102102
103// handles the local context activation103// handles the local context activation
104void ActionProxy::handleContextActivation(bool active)104void ActionProxy::handleContextActivation()
105{105{
106 // sender is the context changing activation106 // sender is the context changing activation
107 UCActionContext *context = qobject_cast<UCActionContext*>(sender());107 UCActionContext *context = qobject_cast<UCActionContext*>(sender());
@@ -110,7 +110,7 @@
110 }110 }
111 // deactivate the previous context if any111 // deactivate the previous context if any
112 if (!m_activeContext.isNull()) {112 if (!m_activeContext.isNull()) {
113 if (!active) {113 if (!context->active()) {
114 // the slot has been called due to the previous active deactivation,114 // the slot has been called due to the previous active deactivation,
115 // so perform system cleanup115 // so perform system cleanup
116 clearContextActions(m_activeContext);116 clearContextActions(m_activeContext);
@@ -124,7 +124,7 @@
124 m_activeContext->setActive(false);124 m_activeContext->setActive(false);
125 }125 }
126 }126 }
127 if (active) {127 if (context->active()) {
128 // publish the context's actions to the system128 // publish the context's actions to the system
129 publishContextActions(context);129 publishContextActions(context);
130 context->markActionsPublished(true);130 context->markActionsPublished(true);
131131
=== modified file 'src/Ubuntu/Components/plugin/adapters/actionsproxy_p.h'
--- src/Ubuntu/Components/plugin/adapters/actionsproxy_p.h 2014-09-01 06:56:39 +0000
+++ src/Ubuntu/Components/plugin/adapters/actionsproxy_p.h 2015-09-08 04:09:38 +0000
@@ -48,7 +48,7 @@
4848
49protected Q_SLOTS:49protected Q_SLOTS:
50 void watchContextActivation(UCActionContext *context, bool watch);50 void watchContextActivation(UCActionContext *context, bool watch);
51 void handleContextActivation(bool active);51 void handleContextActivation();
52 virtual void clearContextActions(UCActionContext *context);52 virtual void clearContextActions(UCActionContext *context);
53 virtual void publishContextActions(UCActionContext *context);53 virtual void publishContextActions(UCActionContext *context);
5454
5555
=== modified file 'src/Ubuntu/Components/plugin/i18n.cpp'
--- src/Ubuntu/Components/plugin/i18n.cpp 2015-03-03 13:47:48 +0000
+++ src/Ubuntu/Components/plugin/i18n.cpp 2015-09-08 04:09:38 +0000
@@ -17,6 +17,7 @@
17 */17 */
1818
19#include "i18n.h"19#include "i18n.h"
20#include "timeutils_p.h"
20#include <QtCore/QDir>21#include <QtCore/QDir>
2122
22namespace C {23namespace C {
@@ -252,3 +253,76 @@
252 Q_UNUSED(context);253 Q_UNUSED(context);
253 return text;254 return text;
254}255}
256/*!
257 * \qmlmethod string i18n::relativeDateTime(datetime dateTime)
258 * Translate a datetime based on proximity to current time.
259 */
260QString UbuntuI18n::relativeDateTime(const QDateTime& datetime)
261{
262 QDateTime relativeTo(QDateTime::currentDateTime());
263 const date_proximity_t prox = getDateProximity(relativeTo, datetime);
264
265 switch (prox) {
266 case DATE_PROXIMITY_NOW:
267 /* TRANSLATORS: Time based "this is happening/happened now" */
268 return dtr("ubuntu-ui-toolkit", "Now");
269
270 case DATE_PROXIMITY_HOUR:
271 {
272 qint64 diff = datetime.toMSecsSinceEpoch() - relativeTo.toMSecsSinceEpoch();
273 qint64 minutes = qRound(float(diff) / 60000);
274 if (minutes < 0) {
275 return dtr("ubuntu-ui-toolkit", "%1 minute ago", "%1 minutes ago", qAbs(minutes)).arg(qAbs(minutes));
276 }
277 return dtr("ubuntu-ui-toolkit", "%1 minute", "%1 minutes", minutes).arg(minutes);
278 }
279
280 case DATE_PROXIMITY_TODAY:
281 /* en_US example: "1:00 PM" */
282 /* TRANSLATORS: Please translated these to your locale datetime format using the format specified by
283 https://qt-project.org/doc/qt-5-snapshot/qdatetime.html#fromString-2 */
284 return datetime.toString(isLocale12h() ? dtr("ubuntu-ui-toolkit", "h:mm ap"):
285 /* TRANSLATORS: Please translated these to your locale datetime format using the format specified by
286 https://qt-project.org/doc/qt-5-snapshot/qdatetime.html#fromString-2 */
287 dtr("ubuntu-ui-toolkit", "HH:mm"));
288
289 case DATE_PROXIMITY_YESTERDAY:
290 /* en_US example: "Yesterday 13:00" */
291 /* TRANSLATORS: Please translated these to your locale datetime format using the format specified by
292 https://qt-project.org/doc/qt-5-snapshot/qdatetime.html#fromString-2 */
293 return datetime.toString(isLocale12h() ? dtr("ubuntu-ui-toolkit", "'Yesterday\u2003'h:mm ap") :
294 /* TRANSLATORS: Please translated these to your locale datetime format using the format specified by
295 https://qt-project.org/doc/qt-5-snapshot/qdatetime.html#fromString-2 */
296 dtr("ubuntu-ui-toolkit", "'Yesterday\u2003'HH:mm"));
297
298 case DATE_PROXIMITY_TOMORROW:
299 /* en_US example: "Tomorrow 1:00 PM" */
300 /* TRANSLATORS: Please translated these to your locale datetime format using the format specified by
301 https://qt-project.org/doc/qt-5-snapshot/qdatetime.html#fromString-2 */
302 return datetime.toString(isLocale12h() ? dtr("ubuntu-ui-toolkit", "'Tomorrow\u2003'h:mm ap") :
303 /* TRANSLATORS: Please translated these to your locale datetime format using the format specified by
304 https://qt-project.org/doc/qt-5-snapshot/qdatetime.html#fromString-2 */
305 dtr("ubuntu-ui-toolkit", "'Tomorrow\u2003'HH:mm"));
306
307 case DATE_PROXIMITY_LAST_WEEK:
308 case DATE_PROXIMITY_NEXT_WEEK:
309 /* en_US example: "Fri 1:00 PM" */
310 /* TRANSLATORS: Please translated these to your locale datetime format using the format specified by
311 https://qt-project.org/doc/qt-5-snapshot/qdatetime.html#fromString-2 */
312 return datetime.toString(isLocale12h() ? dtr("ubuntu-ui-toolkit", "ddd'\u2003'h:mm ap") :
313 /* TRANSLATORS: Please translated these to your locale datetime format using the format specified by
314 https://qt-project.org/doc/qt-5-snapshot/qdatetime.html#fromString-2 */
315 dtr("ubuntu-ui-toolkit", "ddd'\u2003'HH:mm"));
316
317 case DATE_PROXIMITY_FAR_BACK:
318 case DATE_PROXIMITY_FAR_FORWARD:
319 default:
320 /* TRANSLATORS: Please translated these to your locale datetime format using the format specified by
321 https://qt-project.org/doc/qt-5-snapshot/qdatetime.html#fromString-2 */
322 return datetime.toString(isLocale12h() ? dtr("ubuntu-ui-toolkit", "ddd d MMM'\u2003'h:mm ap") :
323 /* TRANSLATORS: Please translated these to your locale datetime format using the format specified by
324 https://qt-project.org/doc/qt-5-snapshot/qdatetime.html#fromString-2 */
325 dtr("ubuntu-ui-toolkit", "ddd d MMM'\u2003'HH:mm"));
326 }
327 return datetime.toString(Qt::DefaultLocaleShortDate);
328}
255329
=== modified file 'src/Ubuntu/Components/plugin/i18n.h'
--- src/Ubuntu/Components/plugin/i18n.h 2015-02-03 18:11:32 +0000
+++ src/Ubuntu/Components/plugin/i18n.h 2015-09-08 04:09:38 +0000
@@ -50,6 +50,7 @@
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);
51 Q_INVOKABLE QString tag(const QString& text);51 Q_INVOKABLE QString tag(const QString& text);
52 Q_INVOKABLE QString tag(const QString& context, const QString& text);52 Q_INVOKABLE QString tag(const QString& context, const QString& text);
53 Q_INVOKABLE QString relativeDateTime(const QDateTime& datetime);
5354
54 // getter55 // getter
55 QString domain() const;56 QString domain() const;
5657
=== modified file 'src/Ubuntu/Components/plugin/plugin.cpp'
--- src/Ubuntu/Components/plugin/plugin.cpp 2015-08-12 09:54:40 +0000
+++ src/Ubuntu/Components/plugin/plugin.cpp 2015-09-08 04:09:38 +0000
@@ -62,6 +62,9 @@
62#include "uclistitemstyle.h"62#include "uclistitemstyle.h"
63#include "ucserviceproperties.h"63#include "ucserviceproperties.h"
64#include "ucnamespace.h"64#include "ucnamespace.h"
65#include "ucactionitem.h"
66#include "uchaptics.h"
67#include "ucabstractbutton.h"
6568
66#include <sys/types.h>69#include <sys/types.h>
67#include <unistd.h>70#include <unistd.h>
@@ -116,6 +119,14 @@
116 return new UCNamespaceV13();119 return new UCNamespaceV13();
117}120}
118121
122static QObject *registerHaptics(QQmlEngine *engine, QJSEngine *scriptEngine)
123{
124 Q_UNUSED(engine)
125 Q_UNUSED(scriptEngine)
126
127 return new UCHaptics();
128}
129
119void UbuntuComponentsPlugin::initializeBaseUrl()130void UbuntuComponentsPlugin::initializeBaseUrl()
120{131{
121 if (!m_baseUrl.isValid()) {132 if (!m_baseUrl.isValid()) {
@@ -174,6 +185,8 @@
174 qmlRegisterSingletonType<UCUriHandler>(uri, major, minor, "UriHandler", registerUriHandler);185 qmlRegisterSingletonType<UCUriHandler>(uri, major, minor, "UriHandler", registerUriHandler);
175 qmlRegisterType<UCMouse>(uri, major, minor, "Mouse");186 qmlRegisterType<UCMouse>(uri, major, minor, "Mouse");
176 qmlRegisterType<UCInverseMouse>(uri, major, minor, "InverseMouse");187 qmlRegisterType<UCInverseMouse>(uri, major, minor, "InverseMouse");
188 qmlRegisterType<UCActionItem>(uri, major, minor, "ActionItem");
189 qmlRegisterSingletonType<UCHaptics>(uri, major, minor, "Haptics", registerHaptics);
177}190}
178191
179void UbuntuComponentsPlugin::registerTypes(const char *uri)192void UbuntuComponentsPlugin::registerTypes(const char *uri)
@@ -211,6 +224,8 @@
211224
212 // register 1.3 API225 // register 1.3 API
213 qmlRegisterType<UCListItem13>(uri, 1, 3, "ListItem");226 qmlRegisterType<UCListItem13>(uri, 1, 3, "ListItem");
227 qmlRegisterType<UCListItemExpansion>();
228 qmlRegisterUncreatableType<UCViewItemsAttached13>(uri, 1, 3, "ViewItems", "No create");
214 qmlRegisterType<UCTheme>(uri, 1, 3, "ThemeSettings");229 qmlRegisterType<UCTheme>(uri, 1, 3, "ThemeSettings");
215 qmlRegisterType<UCStyledItemBase, 2>(uri, 1, 3, "StyledItem");230 qmlRegisterType<UCStyledItemBase, 2>(uri, 1, 3, "StyledItem");
216 qmlRegisterSingletonType<UCNamespaceV13>(uri, 1, 3, "Ubuntu", registerUbuntuNamespace13);231 qmlRegisterSingletonType<UCNamespaceV13>(uri, 1, 3, "Ubuntu", registerUbuntuNamespace13);
@@ -220,6 +235,7 @@
220 qmlRegisterType<UCUbuntuShape, 2>(uri, 1, 3, "UbuntuShape");235 qmlRegisterType<UCUbuntuShape, 2>(uri, 1, 3, "UbuntuShape");
221 qmlRegisterType<UCProportionalShape>(uri, 1, 3, "ProportionalShape");236 qmlRegisterType<UCProportionalShape>(uri, 1, 3, "ProportionalShape");
222 qmlRegisterType<LiveTimer>(uri, 1, 3, "LiveTimer");237 qmlRegisterType<LiveTimer>(uri, 1, 3, "LiveTimer");
238 qmlRegisterType<UCAbstractButton>(uri, 1, 3, "AbstractButton");
223}239}
224240
225void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)241void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
@@ -244,6 +260,8 @@
244260
245 UCDeprecatedTheme::instance().registerToContext(context);261 UCDeprecatedTheme::instance().registerToContext(context);
246262
263 HapticsProxy::instance().setEngine(context->engine());
264
247 context->setContextProperty("i18n", &UbuntuI18n::instance());265 context->setContextProperty("i18n", &UbuntuI18n::instance());
248 ContextPropertyChangeListener *i18nChangeListener =266 ContextPropertyChangeListener *i18nChangeListener =
249 new ContextPropertyChangeListener(context, "i18n");267 new ContextPropertyChangeListener(context, "i18n");
250268
=== modified file 'src/Ubuntu/Components/plugin/plugin.pri'
--- src/Ubuntu/Components/plugin/plugin.pri 2015-08-18 22:14:51 +0000
+++ src/Ubuntu/Components/plugin/plugin.pri 2015-09-08 04:09:38 +0000
@@ -80,7 +80,10 @@
80 $$PWD/ucstylehints.h \80 $$PWD/ucstylehints.h \
81 $$PWD/livetimer.h \81 $$PWD/livetimer.h \
82 $$PWD/livetimer_p.h \82 $$PWD/livetimer_p.h \
83 $$PWD/timeutils_p.h83 $$PWD/timeutils_p.h \
84 $$PWD/ucactionitem.h \
85 $$PWD/uchaptics.h \
86 $$PWD/ucabstractbutton.h
8487
85SOURCES += $$PWD/plugin.cpp \88SOURCES += $$PWD/plugin.cpp \
86 $$PWD/uctheme.cpp \89 $$PWD/uctheme.cpp \
@@ -127,12 +130,16 @@
127 $$PWD/ucserviceproperties.cpp \130 $$PWD/ucserviceproperties.cpp \
128 $$PWD/privates/listitemdragarea.cpp \131 $$PWD/privates/listitemdragarea.cpp \
129 $$PWD/privates/listitemdraghandler.cpp \132 $$PWD/privates/listitemdraghandler.cpp \
133 $$PWD/privates/listitemexpansion.cpp \
130 $$PWD/ucnamespace.cpp \134 $$PWD/ucnamespace.cpp \
131 $$PWD/ucdeprecatedtheme.cpp \135 $$PWD/ucdeprecatedtheme.cpp \
132 $$PWD/ucdefaulttheme.cpp \136 $$PWD/ucdefaulttheme.cpp \
133 $$PWD/ucstylehints.cpp \137 $$PWD/ucstylehints.cpp \
134 $$PWD/livetimer.cpp \138 $$PWD/livetimer.cpp \
135 $$PWD/livetimer_p.cpp139 $$PWD/livetimer_p.cpp \
140 $$PWD/ucactionitem.cpp \
141 $$PWD/uchaptics.cpp \
142 $$PWD/ucabstractbutton.cpp
136143
137# adapters144# adapters
138SOURCES += $$PWD/adapters/alarmsadapter_organizer.cpp145SOURCES += $$PWD/adapters/alarmsadapter_organizer.cpp
139146
=== modified file 'src/Ubuntu/Components/plugin/privates/listitemdragarea.cpp'
--- src/Ubuntu/Components/plugin/privates/listitemdragarea.cpp 2015-04-13 11:11:59 +0000
+++ src/Ubuntu/Components/plugin/privates/listitemdragarea.cpp 2015-09-08 04:09:38 +0000
@@ -47,13 +47,12 @@
47 setObjectName("drag_area");47 setObjectName("drag_area");
48}48}
4949
50void ListItemDragArea::init()50void ListItemDragArea::init(UCViewItemsAttached *viewItems)
51{51{
52 setParentItem(static_cast<QQuickItem*>(parent()));52 setParentItem(static_cast<QQuickItem*>(parent()));
53 QQuickAnchors *anchors = QQuickItemPrivate::get(this)->anchors();53 QQuickAnchors *anchors = QQuickItemPrivate::get(this)->anchors();
54 anchors->setFill(parentItem());54 anchors->setFill(parentItem());
55 viewAttached = static_cast<UCViewItemsAttached*>(55 viewAttached = viewItems;
56 qmlAttachedPropertiesObject<UCViewItemsAttached>(listView));
57 reset();56 reset();
58}57}
5958
6059
=== modified file 'src/Ubuntu/Components/plugin/privates/listitemdragarea.h'
--- src/Ubuntu/Components/plugin/privates/listitemdragarea.h 2015-02-24 15:57:53 +0000
+++ src/Ubuntu/Components/plugin/privates/listitemdragarea.h 2015-09-08 04:09:38 +0000
@@ -27,7 +27,7 @@
27 Q_OBJECT27 Q_OBJECT
28public:28public:
29 explicit ListItemDragArea(QQuickItem *parent = 0);29 explicit ListItemDragArea(QQuickItem *parent = 0);
30 void init();30 void init(UCViewItemsAttached *viewItems);
31 void reset();31 void reset();
3232
33protected:33protected:
3434
=== added file 'src/Ubuntu/Components/plugin/privates/listitemexpansion.cpp'
--- src/Ubuntu/Components/plugin/privates/listitemexpansion.cpp 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/Components/plugin/privates/listitemexpansion.cpp 2015-09-08 04:09:38 +0000
@@ -0,0 +1,106 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "uclistitem.h"
18#include "uclistitem_p.h"
19
20UCListItemExpansion::UCListItemExpansion(QObject *parent)
21 : QObject(parent)
22 , m_listItem(static_cast<UCListItem13*>(parent))
23 , m_height(0.0)
24 , m_filtering(false)
25{
26}
27
28bool UCListItemExpansion::expandedLocked()
29{
30 UCListItemPrivate *listItem = UCListItemPrivate::get(m_listItem);
31 UCViewItemsAttachedPrivate *viewItems = UCViewItemsAttachedPrivate::get(listItem->parentAttached);
32 return expanded() && !((viewItems->expansionFlags & UCViewItemsAttached::UnlockExpanded) == UCViewItemsAttached::UnlockExpanded);
33}
34
35void UCListItemExpansion::enableClickFiltering(bool enable)
36{
37 if (m_filtering == enable) {
38 return;
39 }
40 m_filtering = enable;
41 if (m_filtering) {
42 m_listItem->window()->installEventFilter(this);
43 } else {
44 m_listItem->window()->removeEventFilter(this);
45 }
46}
47
48// event filter for external mouse presses to collapse when pressed outside
49bool UCListItemExpansion::eventFilter(QObject *target, QEvent *event)
50{
51 if (event->type() == QEvent::MouseButtonPress) {
52 QMouseEvent *mouse = static_cast<QMouseEvent*>(event);
53 QQuickWindow *window = qobject_cast<QQuickWindow*>(target);
54 if (window) {
55 QPointF myPos(window->contentItem()->mapToItem(m_listItem, mouse->localPos()));
56 if (!m_listItem->contains(myPos)) {
57 UCListItemPrivate *listItem = UCListItemPrivate::get(m_listItem);
58 UCViewItemsAttachedPrivate *viewItems = UCViewItemsAttachedPrivate::get(listItem->parentAttached);
59 if (viewItems) {
60 // collapse all as there can be only one expanded when the flag is set
61 viewItems->collapseAll();
62 }
63 }
64 }
65 }
66 return false;
67}
68
69
70bool UCListItemExpansion::expanded()
71{
72 UCListItemPrivate *listItem = UCListItemPrivate::get(m_listItem);
73 UCViewItemsAttachedPrivate *viewItems = UCViewItemsAttachedPrivate::get(listItem->parentAttached);
74 return (viewItems && viewItems->expansionList.contains(listItem->index()));
75}
76
77void UCListItemExpansion::setExpanded(bool expanded)
78{
79 if (this->expanded() == expanded) {
80 return;
81 }
82 UCListItemPrivate *listItem = UCListItemPrivate::get(m_listItem);
83 UCViewItemsAttachedPrivate *viewItems = UCViewItemsAttachedPrivate::get(listItem->parentAttached);
84 if (viewItems) {
85 if (viewItems->expansionFlags & UCViewItemsAttached::Exclusive) {
86 // collapse all the expanded ones
87 viewItems->collapseAll();
88 }
89 if (expanded) {
90 viewItems->expand(listItem->index(), m_listItem);
91 } else {
92 viewItems->collapse(listItem->index());
93 }
94 }
95 UCListItemPrivate::get(m_listItem)->loadStyleItem();
96 // no need to emit changed signal, as ViewItems.expandedIndicesChanged is connected to the change signal
97}
98
99void UCListItemExpansion::setHeight(qreal height)
100{
101 if (m_height == height) {
102 return;
103 }
104 m_height = height;
105 Q_EMIT heightChanged();
106}
0107
=== modified file 'src/Ubuntu/Components/plugin/sortfiltermodel.cpp'
--- src/Ubuntu/Components/plugin/sortfiltermodel.cpp 2015-03-03 13:47:48 +0000
+++ src/Ubuntu/Components/plugin/sortfiltermodel.cpp 2015-09-08 04:09:38 +0000
@@ -113,9 +113,12 @@
113QSortFilterProxyModelQML::roleByName(const QString& roleName) const113QSortFilterProxyModelQML::roleByName(const QString& roleName) const
114{114{
115 const QHash<int, QByteArray> roles = roleNames();115 const QHash<int, QByteArray> roles = roleNames();
116 for(int role = 0; role < roles.count(); role++)116 QHashIterator<int, QByteArray> i(roles);
117 if (roles[role] == roleName)117 while (i.hasNext()) {
118 return role;118 i.next();
119 if (i.value() == roleName)
120 return i.key();
121 }
119 return 0;122 return 0;
120}123}
121124
122125
=== modified file 'src/Ubuntu/Components/plugin/timeutils_p.h'
--- src/Ubuntu/Components/plugin/timeutils_p.h 2015-07-20 15:34:32 +0000
+++ src/Ubuntu/Components/plugin/timeutils_p.h 2015-09-08 04:09:38 +0000
@@ -20,9 +20,33 @@
20#include "livetimer.h"20#include "livetimer.h"
2121
22#include <QDateTime>22#include <QDateTime>
23#include <QLocale>
23#include <QObject>24#include <QObject>
24#include <QTimer>25#include <QTimer>
2526
27/* Check the system locale setting to see if the format is 24-hour
28 time or 12-hour time */
29inline bool isLocale12h(void)
30{
31 QString strTimeFormat = QLocale::system().timeFormat();
32 QStringList includes; includes << "AP"; includes << "ap";
33 QStringList excludes; excludes << "H"; excludes << "HH";
34
35 Q_FOREACH(const QString& exclude, excludes) {
36 if (strTimeFormat.contains(exclude)) {
37 return false;
38 }
39 }
40
41 Q_FOREACH(const QString& include, includes) {
42 if (strTimeFormat.contains(include)) {
43 return true;
44 }
45 }
46
47 return false;
48}
49
26typedef enum50typedef enum
27{51{
28 DATE_PROXIMITY_NOW,52 DATE_PROXIMITY_NOW,
2953
=== added file 'src/Ubuntu/Components/plugin/ucabstractbutton.cpp'
--- src/Ubuntu/Components/plugin/ucabstractbutton.cpp 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/Components/plugin/ucabstractbutton.cpp 2015-09-08 04:09:38 +0000
@@ -0,0 +1,156 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "ucabstractbutton.h"
18#include "uchaptics.h"
19#include <QtQuick/private/qquickitem_p.h>
20#include <QtQuick/private/qquickmousearea_p.h>
21#include <QtQml/private/qqmlglobal_p.h>
22
23/*!
24 \qmltype AbstractButton
25 \instantiates UCAbstractButton
26 \inqmlmodule Ubuntu.Components 1.1
27 \ingroup ubuntu
28 \brief The AbstractButton class defines the behavior of the button.
29
30 This class defines the behavior of the button. All components deriving from
31 this class support haptic feedback out of the box.
32
33 If an action is specified, the button's clicked signal will trigger the action.
34 Subclasses of AbstractButton can use other properties of action (for example
35 the text and iconName).
36*/
37
38/*!
39 *
40 * \qmlsignal AbstractButton::clicked()
41 * This handler is called when there is a mouse click on the button and the button
42 * is not disabled. If \l {ActionItem::action}{action} is defined, the action will be triggered.
43 */
44
45/*!
46 *
47 * \qmlsignal AbstractButton::pressAndHold()
48 * This handler is called when there is a long press.
49 */
50
51UCAbstractButton::UCAbstractButton(QQuickItem *parent)
52 : UCActionItem(parent)
53 , m_mouseArea(new QQuickMouseArea)
54 , m_acceptEvents(true)
55{
56 setActiveFocusOnPress(true);
57}
58
59bool UCAbstractButton::isPressAndHoldConnected()
60{
61 static QMetaMethod method = QMetaMethod::fromSignal(&UCAbstractButton::pressAndHold);
62 static int signalIdx = QMetaObjectPrivate::signalIndex(method);
63 return QObjectPrivate::get(this)->isSignalConnected(signalIdx);
64}
65
66void UCAbstractButton::classBegin()
67{
68 UCActionItem::classBegin();
69
70 // make sure we have the haptics set up!
71 HapticsProxy::instance().initialize();
72
73 // set up mouse area
74 QQml_setParent_noEvent(m_mouseArea, this);
75 m_mouseArea->setParentItem(this);
76 QQuickAnchors *anchors = QQuickItemPrivate::get(m_mouseArea)->anchors();
77 anchors->setFill(this);
78 m_mouseArea->setHoverEnabled(true);
79}
80
81void UCAbstractButton::componentComplete()
82{
83 UCActionItem::componentComplete();
84 // connect to the right slot, using macros so we get the proper slot
85 connect(this, SIGNAL(clicked()), this, SLOT(trigger()));
86
87 // bind mouse area
88 connect(m_mouseArea, &QQuickMouseArea::pressedChanged, this, &UCAbstractButton::pressedChanged);
89 connect(m_mouseArea, &QQuickMouseArea::hoveredChanged, this, &UCAbstractButton::hoveredChanged);
90 connect(m_mouseArea, SIGNAL(clicked(QQuickMouseEvent*)), this, SLOT(_q_mouseAreaClicked()));
91 if (isPressAndHoldConnected()) {
92 connect(m_mouseArea, SIGNAL(pressAndHold(QQuickMouseEvent*)), this, SLOT(_q_mouseAreaPressAndHold()));
93 }
94}
95
96// handle mouseClicked with Haptics
97void UCAbstractButton::_q_mouseAreaClicked()
98{
99 // required by the deprecated ListItem module
100 if (!m_acceptEvents) {
101 return;
102 }
103 // play haptics
104 HapticsProxy::instance().play(QVariant());
105 Q_EMIT clicked();
106}
107
108// handle pressAndHold
109void UCAbstractButton::_q_mouseAreaPressAndHold()
110{
111 // required by the deprecated ListItem module
112 if (!m_acceptEvents) {
113 return;
114 }
115 Q_EMIT pressAndHold();
116}
117
118// emit clicked when Enter/Return is pressed
119void UCAbstractButton::keyPressEvent(QKeyEvent *event)
120{
121 UCActionItem::keyPressEvent(event);
122
123 switch (event->key()) {
124 case Qt::Key_Enter:
125 case Qt::Key_Return:
126 // FIXME: space may also come here, however that depends on the button type
127 // (i.e default Dialog btn) so we may need to add that to Button
128 {
129 Q_EMIT clicked();
130 break;
131 }
132 }
133}
134
135/*!
136 * \qmlproperty bool AbstractButton::pressed
137 * True if the user presses a mouse button in the button's mouse area.
138 */
139bool UCAbstractButton::pressed() const
140{
141 return m_mouseArea ? m_mouseArea->pressed() : false;
142}
143
144/*!
145 * \qmlproperty bool AbstractButton::hovered
146 * True if the mouse cursor hovers over the button's mouse area.
147 */
148bool UCAbstractButton::hovered() const
149{
150 return m_mouseArea ? m_mouseArea->hovered() : false;
151}
152
153QQuickMouseArea *UCAbstractButton::privateMouseArea() const
154{
155 return m_mouseArea;
156}
0157
=== added file 'src/Ubuntu/Components/plugin/ucabstractbutton.h'
--- src/Ubuntu/Components/plugin/ucabstractbutton.h 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/Components/plugin/ucabstractbutton.h 2015-09-08 04:09:38 +0000
@@ -0,0 +1,64 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef UCABSTRACTBUTTON_H
18#define UCABSTRACTBUTTON_H
19
20#include "ucactionitem.h"
21
22class QQuickMouseArea;
23class UCAbstractButton : public UCActionItem
24{
25 Q_OBJECT
26 Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
27 Q_PROPERTY(bool hovered READ hovered NOTIFY hoveredChanged)
28
29 // internal, declared to support the deprecated ListItem module
30 Q_PROPERTY(bool __acceptEvents MEMBER m_acceptEvents)
31 Q_PROPERTY(QQuickMouseArea *__mouseArea READ privateMouseArea CONSTANT)
32public:
33 explicit UCAbstractButton(QQuickItem *parent = 0);
34
35 bool pressed() const;
36 bool hovered() const;
37
38 bool privateAcceptEvents() const;
39 void setPrivateAcceptEvents(bool accept);
40 QQuickMouseArea *privateMouseArea() const;
41
42protected:
43 void classBegin();
44 void componentComplete();
45 void keyPressEvent(QKeyEvent *key);
46
47Q_SIGNALS:
48 void pressedChanged();
49 void hoveredChanged();
50 void clicked();
51 void pressAndHold();
52
53protected Q_SLOTS:
54 void _q_mouseAreaClicked();
55 void _q_mouseAreaPressAndHold();
56
57protected:
58 QQuickMouseArea *m_mouseArea;
59 bool m_acceptEvents:1;
60
61 bool isPressAndHoldConnected();
62};
63
64#endif // UCABSTRACTBUTTON_H
065
=== modified file 'src/Ubuntu/Components/plugin/ucaction.cpp'
--- src/Ubuntu/Components/plugin/ucaction.cpp 2015-07-03 19:16:56 +0000
+++ src/Ubuntu/Components/plugin/ucaction.cpp 2015-09-08 04:09:38 +0000
@@ -150,13 +150,12 @@
150150
151UCAction::UCAction(QObject *parent)151UCAction::UCAction(QObject *parent)
152 : QObject(parent)152 : QObject(parent)
153 , m_itemHint(Q_NULLPTR)
154 , m_parameterType(None)
153 , m_factoryIconSource(true)155 , m_factoryIconSource(true)
154 , m_enabled(true)156 , m_enabled(true)
155 , m_visible(true)157 , m_visible(true)
156 , m_published(false)158 , m_published(false)
157 , m_itemHint(0)
158 , m_parameterType(None)
159 , m_shortcut(0)
160{159{
161 generateName();160 generateName();
162}161}
@@ -288,7 +287,7 @@
288 qmlInfo(this) << "Invalid shortcut: " << shortcut.toString();287 qmlInfo(this) << "Invalid shortcut: " << shortcut.toString();
289288
290 m_shortcut = shortcut;289 m_shortcut = shortcut;
291 Q_EMIT shortcutChanged(shortcut);290 Q_EMIT shortcutChanged();
292}291}
293292
294bool UCAction::event(QEvent *event)293bool UCAction::event(QEvent *event)
@@ -302,7 +301,8 @@
302 return false;301 return false;
303 }302 }
304303
305 trigger();304 // do not call trigger() directly but invoke, as it may get overridden in QML
305 metaObject()->invokeMethod(this, "trigger");
306 return true;306 return true;
307}307}
308308
309309
=== modified file 'src/Ubuntu/Components/plugin/ucaction.h'
--- src/Ubuntu/Components/plugin/ucaction.h 2015-07-07 13:57:50 +0000
+++ src/Ubuntu/Components/plugin/ucaction.h 2015-09-08 04:09:38 +0000
@@ -70,28 +70,29 @@
70 void parameterTypeChanged();70 void parameterTypeChanged();
71 void iconSourceChanged();71 void iconSourceChanged();
72 void visibleChanged();72 void visibleChanged();
73 void shortcutChanged(const QVariant& shortcut);73 void shortcutChanged();
74 void triggered(const QVariant &value);74 void triggered(const QVariant &value);
7575
76public Q_SLOTS:76public Q_SLOTS:
77 void trigger(const QVariant &value = QVariant());77 void trigger(const QVariant &value = QVariant());
7878
79private:79private:
80 bool m_factoryIconSource:1;
81 bool m_enabled:1;
82 bool m_visible:1;
83 bool m_published:1;
84 QQmlComponent *m_itemHint;
85 QString m_name;80 QString m_name;
86 QString m_text;81 QString m_text;
87 QString m_iconName;82 QString m_iconName;
88 QUrl m_iconSource;83 QUrl m_iconSource;
89 QString m_description;84 QString m_description;
90 QString m_keywords;85 QString m_keywords;
86 QVariant m_shortcut;
87 QQmlComponent *m_itemHint;
91 Type m_parameterType;88 Type m_parameterType;
92 QVariant m_shortcut;89 bool m_factoryIconSource:1;
90 bool m_enabled:1;
91 bool m_visible:1;
92 bool m_published:1;
9393
94 friend class UCActionContext;94 friend class UCActionContext;
95 friend class UCActionItem;
95 friend class UCListItemPrivate;96 friend class UCListItemPrivate;
96 friend class UCListItemAttached;97 friend class UCListItemAttached;
97 friend class UCListItemActionsPrivate;98 friend class UCListItemActionsPrivate;
9899
=== modified file 'src/Ubuntu/Components/plugin/ucactioncontext.cpp'
--- src/Ubuntu/Components/plugin/ucactioncontext.cpp 2015-07-09 17:55:03 +0000
+++ src/Ubuntu/Components/plugin/ucactioncontext.cpp 2015-09-08 04:09:38 +0000
@@ -104,6 +104,11 @@
104 * sufficient to manage the active local context of the manager and no additional104 * sufficient to manage the active local context of the manager and no additional
105 * calls are necessary to manually inactivate the other contexts.105 * calls are necessary to manually inactivate the other contexts.
106 */106 */
107bool UCActionContext::active()
108{
109 return m_active;
110}
111
107void UCActionContext::setActive(bool active)112void UCActionContext::setActive(bool active)
108{113{
109 if (m_active == active) {114 if (m_active == active) {
@@ -114,7 +119,7 @@
114 return;119 return;
115 }120 }
116 m_active = active;121 m_active = active;
117 Q_EMIT activeChanged(active);122 Q_EMIT activeChanged();
118}123}
119124
120/*!125/*!
121126
=== modified file 'src/Ubuntu/Components/plugin/ucactioncontext.h'
--- src/Ubuntu/Components/plugin/ucactioncontext.h 2015-07-09 17:55:03 +0000
+++ src/Ubuntu/Components/plugin/ucactioncontext.h 2015-09-08 04:09:38 +0000
@@ -29,7 +29,7 @@
29 Q_OBJECT29 Q_OBJECT
30 Q_INTERFACES(QQmlParserStatus)30 Q_INTERFACES(QQmlParserStatus)
31 Q_PROPERTY(QQmlListProperty<UCAction> actions READ actions)31 Q_PROPERTY(QQmlListProperty<UCAction> actions READ actions)
32 Q_PROPERTY(bool active MEMBER m_active WRITE setActive NOTIFY activeChanged)32 Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
33 Q_CLASSINFO("DefaultProperty", "actions")33 Q_CLASSINFO("DefaultProperty", "actions")
34public:34public:
35 explicit UCActionContext(QObject *parent = 0);35 explicit UCActionContext(QObject *parent = 0);
@@ -41,10 +41,11 @@
4141
42 QQmlListProperty<UCAction> actions();42 QQmlListProperty<UCAction> actions();
4343
44 bool active();
44 void setActive(bool active);45 void setActive(bool active);
4546
46Q_SIGNALS:47Q_SIGNALS:
47 void activeChanged(bool);48 void activeChanged();
4849
49public Q_SLOTS:50public Q_SLOTS:
50 void addAction(UCAction *action);51 void addAction(UCAction *action);
5152
=== added file 'src/Ubuntu/Components/plugin/ucactionitem.cpp'
--- src/Ubuntu/Components/plugin/ucactionitem.cpp 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/Components/plugin/ucactionitem.cpp 2015-09-08 04:09:38 +0000
@@ -0,0 +1,316 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "ucactionitem.h"
18#include "ucaction.h"
19
20/*!
21 * \qmltype ActionItem
22 * \instantiates UCActionItem
23 * \inqmlmodule Ubuntu.Components 1.1
24 * \ingroup ubuntu
25 * \brief A visual representation of an Action. The API of ActionItem is a
26 * copy of the API of \l Action, with additional properties to define
27 * visual aspects of the ActionItem.
28 *
29 * If \l action is set, the values of the other properties will by default
30 * be identical to the \l Action's property values. Setting the other properties
31 * will override the properties copied from the \l Action.
32 */
33
34/*!
35 * \qmlsignal ActionItem::triggered(var value)
36 * Called when the actionItem is triggered.
37 */
38UCActionItem::UCActionItem(QQuickItem *parent)
39 : UCStyledItemBase(parent)
40 , m_action(Q_NULLPTR)
41 , m_flags(0)
42{
43 connect(this, &UCActionItem::visibleChanged, this, &UCActionItem::_q_visibleChanged);
44 connect(this, &UCActionItem::enabledChanged, this, &UCActionItem::_q_enabledChanged);
45}
46
47void UCActionItem::componentComplete()
48{
49 UCStyledItemBase::componentComplete();
50 // make sure we connect to the right signals, so we detach and re-attach actions
51 // to make sure the SLOT macro picks up the custom trigger() slot
52 if (m_action) {
53 attachAction(false);
54 attachAction(true);
55 }
56}
57
58void UCActionItem::_q_visibleChanged()
59{
60 m_flags |= CustomVisible;
61 disconnect(this, &UCActionItem::visibleChanged, this, &UCActionItem::_q_visibleChanged);
62}
63
64void UCActionItem::_q_enabledChanged()
65{
66 m_flags |= CustomEnabled;
67 disconnect(this, &UCActionItem::enabledChanged, this, &UCActionItem::_q_enabledChanged);
68}
69
70// update visible property
71void UCActionItem::_q_updateVisible()
72{
73 bool visible = m_action ? m_action->m_visible : true;
74 setVisible(visible);
75 // reset flag and reconnect signal handler disconnected by the
76 m_flags &= ~CustomVisible;
77 if (m_action) {
78 connect(this, &UCActionItem::visibleChanged, this, &UCActionItem::_q_visibleChanged);
79 }
80}
81
82// update enabled property
83void UCActionItem::_q_updateEnabled()
84{
85 bool enabled = m_action ? m_action->m_enabled : true;
86 setEnabled(enabled);
87 // reset flag and reconnect signal handler disconnected by the
88 m_flags &= ~CustomEnabled;
89 if (m_action) {
90 connect(this, &UCActionItem::enabledChanged, this, &UCActionItem::_q_enabledChanged);
91 }
92}
93
94void UCActionItem::updateProperties()
95{
96 if (!(m_flags & CustomText)) {
97 Q_EMIT textChanged();
98 }
99 if (!(m_flags & CustomIconSource)) {
100 Q_EMIT iconSourceChanged();
101 }
102 if (!(m_flags & CustomIconName)) {
103 Q_EMIT iconNameChanged();
104 }
105}
106
107void UCActionItem::attachAction(bool attach)
108{
109 if (attach) {
110 connect(this, SIGNAL(triggered(QVariant)),
111 m_action, SLOT(trigger(QVariant)), Qt::DirectConnection);
112 connect(m_action, &UCAction::visibleChanged,
113 this, &UCActionItem::_q_updateVisible, Qt::DirectConnection);
114 connect(m_action, &UCAction::enabledChanged,
115 this, &UCActionItem::_q_updateEnabled, Qt::DirectConnection);
116 if (!(m_flags & CustomText)) {
117 connect(m_action, &UCAction::textChanged,
118 this, &UCActionItem::textChanged, Qt::DirectConnection);
119 }
120 if (!(m_flags & CustomIconSource)) {
121 connect(m_action, &UCAction::iconSourceChanged,
122 this, &UCActionItem::iconSourceChanged, Qt::DirectConnection);
123 }
124 if (!(m_flags & CustomIconName)) {
125 connect(m_action, &UCAction::iconNameChanged,
126 this, &UCActionItem::iconNameChanged, Qt::DirectConnection);
127 }
128 } else {
129 disconnect(this, SIGNAL(triggered(QVariant)),
130 m_action, SLOT(trigger(QVariant)));
131 disconnect(m_action, &UCAction::visibleChanged,
132 this, &UCActionItem::_q_updateVisible);
133 disconnect(m_action, &UCAction::enabledChanged,
134 this, &UCActionItem::_q_updateEnabled);
135 if (!(m_flags & CustomText)) {
136 disconnect(m_action, &UCAction::textChanged,
137 this, &UCActionItem::textChanged);
138 }
139 if (!(m_flags & CustomIconSource)) {
140 disconnect(m_action, &UCAction::iconSourceChanged,
141 this, &UCActionItem::iconSourceChanged);
142 }
143 if (!(m_flags & CustomIconName)) {
144 disconnect(m_action, &UCAction::iconNameChanged,
145 this, &UCActionItem::iconNameChanged);
146 }
147 }
148}
149
150/*!
151 * \qmlproperty Action ActionItem::action
152 * The \l Action associated with this ActionItem. If action is set, the values
153 * of the \l Action properties are copied to the values of the ActionItem
154 * properties, unless those were previously overridden.
155 */
156void UCActionItem::setAction(UCAction *action)
157{
158 if (m_action == action) {
159 return;
160 }
161 if (m_action) {
162 attachAction(false);
163 }
164 m_action = action;
165 Q_EMIT actionChanged();
166
167 if (m_action) {
168 attachAction(true);
169 }
170 _q_updateVisible();
171 _q_updateEnabled();
172 updateProperties();
173}
174
175/*!
176 * \qmlproperty string ActionItem::text
177 * The title of the actionItem. Defaults to the \c action.text.
178 */
179QString UCActionItem::text()
180{
181 if (m_flags & CustomText) {
182 return m_text;
183 }
184 return m_action ? m_action->m_text : QString();
185}
186void UCActionItem::setText(const QString &text)
187{
188 if (m_text == text) {
189 return;
190 }
191 m_text = text;
192 if (m_action && !(m_flags & CustomText)) {
193 // disconnect change signal from Action
194 disconnect(m_action, &UCAction::textChanged,
195 this, &UCActionItem::textChanged);
196 }
197 m_flags |= CustomText;
198 Q_EMIT textChanged();
199}
200void UCActionItem::resetText()
201{
202 m_text.clear();
203 m_flags &= ~CustomText;
204 if (m_action) {
205 // re-connect change signal from Action
206 connect(m_action, &UCAction::textChanged,
207 this, &UCActionItem::textChanged, Qt::DirectConnection);
208 }
209 Q_EMIT textChanged();
210}
211
212/*!
213 * \qmlproperty url ActionItem::iconSource
214 * The image associated with the ActionItem. Defaults to \c action.iconSource.
215 *
216 * This is the URL of any image file. If both iconSource and \l iconName are defined,
217 * \l iconName will be ignored.
218 */
219QUrl UCActionItem::iconSource()
220{
221 if (m_flags & CustomIconSource) {
222 return m_iconSource;
223 }
224 if (m_action) {
225 return m_action->m_iconSource;
226 }
227 return !iconName().isEmpty() ? QUrl(QString("image://theme/%1").arg(iconName())) : QUrl();
228}
229void UCActionItem::setIconSource(const QUrl &iconSource)
230{
231 if (m_iconSource == iconSource) {
232 return;
233 }
234 m_iconSource = iconSource;
235 if (m_action && !(m_flags & CustomIconSource)) {
236 // disconnect change signal from Action
237 disconnect(m_action, &UCAction::iconSourceChanged,
238 this, &UCActionItem::iconSourceChanged);
239 }
240 m_flags |= CustomIconSource;
241 Q_EMIT iconSourceChanged();
242}
243void UCActionItem::resetIconSource()
244{
245 m_iconSource.clear();
246 m_flags &= ~CustomIconSource;
247 if (m_action) {
248 // re-connect change signal from Action
249 connect(m_action, &UCAction::iconSourceChanged,
250 this, &UCActionItem::iconSourceChanged, Qt::DirectConnection);
251 }
252 Q_EMIT iconSourceChanged();
253}
254
255/*!
256 * \qmlproperty string ActionItem::iconName
257 * The icon associated with the actionItem in the suru icon theme. Defaults to
258 * \c action.iconName.
259 *
260 * \note The complete list of icons available in Ubuntu is not published yet.
261 * For now please refer to the folders where the icon themes are installed:
262 * \list
263 * \li Ubuntu Touch: \l file:/usr/share/icons/suru
264 * \li Ubuntu Desktop: \l file:/usr/share/icons/ubuntu-mono-dark
265 * \endlist
266 * These 2 separate icon themes will be merged soon.
267 *
268 * If both \l iconSource and iconName are defined, iconName will be ignored.
269 */
270QString UCActionItem::iconName()
271{
272 if (m_flags & CustomIconName) {
273 return m_iconName;
274 }
275 return m_action ? m_action->m_iconName : QString();
276}
277void UCActionItem::setIconName(const QString &iconName)
278{
279 if (m_iconName == iconName) {
280 return;
281 }
282 m_iconName = iconName;
283 if (m_action && !(m_flags & CustomIconName)) {
284 // disconnect change signal from Action
285 disconnect(m_action, &UCAction::iconNameChanged,
286 this, &UCActionItem::iconNameChanged);
287 }
288 m_flags |= CustomIconName;
289 Q_EMIT iconNameChanged();
290 // also sync iconSource if that is not a custom one or taken from action
291 if (!m_action || (m_flags & CustomIconSource)) {
292 Q_EMIT iconSourceChanged();
293 }
294}
295void UCActionItem::resetIconName()
296{
297 m_iconName.clear();
298 m_flags &= ~CustomIconName;
299 if (m_action) {
300 // re-connect change signal from Action
301 connect(m_action, &UCAction::iconNameChanged,
302 this, &UCActionItem::iconNameChanged, Qt::DirectConnection);
303 }
304 Q_EMIT iconNameChanged();
305}
306
307/*!
308 * \qmlmethod void ActionItem::trigger(var value)
309 * Trigger this action item if it is enabled.
310 */
311void UCActionItem::trigger(const QVariant &value)
312{
313 if (isEnabled()) {
314 Q_EMIT triggered(value);
315 }
316}
0317
=== added file 'src/Ubuntu/Components/plugin/ucactionitem.h'
--- src/Ubuntu/Components/plugin/ucactionitem.h 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/Components/plugin/ucactionitem.h 2015-09-08 04:09:38 +0000
@@ -0,0 +1,79 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#ifndef UCACTIONITEM_H
17#define UCACTIONITEM_H
18
19#include "ucstyleditembase.h"
20
21class UCAction;
22class UCActionItem : public UCStyledItemBase
23{
24 Q_OBJECT
25 Q_PROPERTY(UCAction *action MEMBER m_action WRITE setAction NOTIFY actionChanged FINAL)
26 Q_PROPERTY(QString text READ text WRITE setText RESET resetText NOTIFY textChanged)
27 Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource RESET resetIconSource NOTIFY iconSourceChanged)
28 Q_PROPERTY(QString iconName READ iconName WRITE setIconName RESET resetIconName NOTIFY iconNameChanged)
29public:
30 explicit UCActionItem(QQuickItem *parent = 0);
31
32 void setAction(UCAction *action);
33 QString text();
34 void setText(const QString &text);
35 void resetText();
36 QUrl iconSource();
37 void setIconSource(const QUrl &iconSource);
38 void resetIconSource();
39 QString iconName();
40 void setIconName(const QString &iconName);
41 void resetIconName();
42
43Q_SIGNALS:
44 void actionChanged();
45 void textChanged();
46 void iconSourceChanged();
47 void iconNameChanged();
48 void triggered(const QVariant &value);
49
50public Q_SLOTS:
51 void trigger(const QVariant &value = QVariant());
52
53protected Q_SLOTS:
54 void _q_visibleChanged();
55 void _q_enabledChanged();
56 void _q_updateVisible();
57 void _q_updateEnabled();
58
59protected:
60 enum {
61 CustomText = 0x01,
62 CustomIconSource = 0x02,
63 CustomIconName = 0x04,
64 CustomVisible = 0x40,
65 CustomEnabled = 0x80
66 };
67 QString m_text;
68 QString m_iconName;
69 QUrl m_iconSource;
70 UCAction *m_action;
71 quint8 m_flags;
72
73 void componentComplete();
74
75 void updateProperties();
76 void attachAction(bool attach);
77};
78
79#endif // UCACTIONITEM_H
080
=== added file 'src/Ubuntu/Components/plugin/uchaptics.cpp'
--- src/Ubuntu/Components/plugin/uchaptics.cpp 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/Components/plugin/uchaptics.cpp 2015-09-08 04:09:38 +0000
@@ -0,0 +1,179 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "uchaptics.h"
18#include "plugin.h"
19#include <QtQml/QQmlComponent>
20#include <QtCore/QUrl>
21#include <QDebug>
22
23/*!
24 \qmltype Haptics
25 \instantiates UCHaptics
26 \inqmlmodule Ubuntu.Components 1.1
27 \ingroup ubuntu-services
28 \brief Singleton defining the haptics feedback used in components, where execution
29 of the feedback is controlled by the system settings.
30
31 Supports global feedback as well as custom feedback. Global feedback can be
32 configured through its properties, and \l play function will play the default
33 configuration, or a custom one if parameter is given.
34
35 Example of using Haptics:
36 \qml
37 import QtQuick 2.4
38 import Ubuntu.Components 1.3
39
40 Item {
41 implicitWidth: units.gu(20)
42 implicitHeight: units.gu(5)
43
44 Label {
45 text: "Press me"
46 anchors.fill: parent
47 horizontalAlignment: Text.AlignHCenter
48 verticalAlignment: Text.AlignVCenter
49 }
50 MouseArea {
51 anchors.fill: parent
52 onClicked: Haptics.play()
53 }
54 }
55 \endqml
56
57 Custom effects can be played as follows:
58 \qml
59 import QtQuick 2.4
60 import Ubuntu.Components 1.3
61
62 Item {
63 implicitWidth: units.gu(20)
64 implicitHeight: units.gu(5)
65
66 Label {
67 text: "Press me"
68 anchors.fill: parent
69 horizontalAlignment: Text.AlignHCenter
70 verticalAlignment: Text.AlignVCenter
71 }
72 MouseArea {
73 anchors.fill: parent
74 onClicked: Haptics.play({duration: 25, attackIntensity: 0.7})
75 }
76 }
77 \endqml
78
79 \note Though the \l effect property exposes \c start, \c stop and \c pause
80 functions, use those only if you want to have feedback independent from what the
81 system setting is.
82 */
83
84UCHaptics::UCHaptics(QObject *parent)
85 : QObject(parent)
86{
87 connect(&HapticsProxy::instance(), &HapticsProxy::enabledChanged,
88 this, &UCHaptics::enabledChanged);
89}
90
91/*!
92 \qmlproperty bool Haptics::enabled
93 \readonly
94 The property specifies whether the haptics feedback is enabled or not by the system.
95 */
96bool UCHaptics::enabled() const
97{
98 return HapticsProxy::instance().enabled();
99}
100
101/*!
102 \qmlproperty HapticsEffect Haptics::effect
103 \readonly
104 The property defines the settings of the haptics effect used by the component.
105 The default setting is a haptics effect with a duration of 10 milliseconds
106 with an intensity of 1.0, having fading time of 50 millisecods and fading
107 intensity 0.0, and attack time of 50 milliseconds and with an intensity of
108 0.0.
109 */
110QObject *UCHaptics::effect() const
111{
112 return HapticsProxy::instance().effect();
113}
114
115/*!
116 \qmlmethod void Haptics::play(var customEffect)
117 The function plays the feedback with the configuration specified in \l effect
118 if no parameter is given. Custom effect can be played by specifying the effect
119 properties in a JSON object in \c customEffect.
120
121 The function will exit unconditionaly if playing the effects is blocked by
122 system settings.
123
124 The function will not stop any ongoing haptics effect played, if that one
125 was a default haptics effect. In case of custom effects, the previous effect
126 will be stopped, and settings will be restored before the new haptics will
127 be played. The custom settings properties (the ones which are required to
128 be different from the ones defined in the \l effect) must be specified in
129 the parameter in a JSON object.
130 */
131void UCHaptics::play(const QVariant &customEffect)
132{
133 HapticsProxy::instance().play(customEffect);
134}
135
136/*********************************************************
137 * Proxy implementation
138 */
139bool HapticsProxy::enabled()
140{
141 initialize();
142 return (m_proxyObject) ? m_proxyObject->property("enabled").toBool() : false;
143}
144
145QObject *HapticsProxy::effect()
146{
147 initialize();
148 return (m_proxyObject) ? m_proxyObject->property("effect").value<QObject*>() : Q_NULLPTR;
149}
150
151void HapticsProxy::initialize()
152{
153 if (!m_engine || m_proxyObject) {
154 return;
155 }
156 // load haptics proxy from file system/qrc
157 QUrl path = UbuntuComponentsPlugin::pluginUrl().resolved(QUrl("1.1/Haptics.qml"));
158 QQmlComponent component(m_engine, path, QQmlComponent::PreferSynchronous);
159 if (!component.isError()) {
160 m_proxyObject = component.create();
161 if (m_proxyObject) {
162 connect(m_proxyObject, SIGNAL(enabledChanged()), this, SIGNAL(enabledChanged()));
163 }
164 } else {
165 qWarning() << qPrintable(component.errorString());
166 }
167}
168
169void HapticsProxy::play(const QVariant &customEffect)
170{
171 if (!m_engine) {
172 qWarning() << "Engine not specified, haptics won't play";
173 }
174 initialize();
175 if (m_proxyObject) {
176 // invoke play function
177 m_proxyObject->metaObject()->invokeMethod(m_proxyObject, "play", Q_ARG(QVariant, customEffect));
178 }
179}
0180
=== added file 'src/Ubuntu/Components/plugin/uchaptics.h'
--- src/Ubuntu/Components/plugin/uchaptics.h 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/Components/plugin/uchaptics.h 2015-09-08 04:09:38 +0000
@@ -0,0 +1,78 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef UCHAPTICS_H
18#define UCHAPTICS_H
19
20#include <QtCore/QObject>
21#include <QtCore/QVariant>
22
23class UCHaptics : public QObject
24{
25 Q_OBJECT
26 Q_PROPERTY(bool enabled READ enabled NOTIFY enabledChanged)
27 Q_PROPERTY(QObject *effect READ effect CONSTANT)
28public:
29 explicit UCHaptics(QObject *parent = 0);
30
31 bool enabled() const;
32 QObject *effect() const;
33
34Q_SIGNALS:
35 void enabledChanged();
36
37public Q_SLOTS:
38 void play(const QVariant &customEffect = QVariant());
39};
40
41class QQmlEngine;
42class HapticsProxy : public QObject
43{
44 Q_OBJECT
45public:
46 explicit HapticsProxy(QObject *parent = 0)
47 : QObject(parent)
48 , m_proxyObject(Q_NULLPTR)
49 , m_engine(Q_NULLPTR)
50 {
51 }
52
53 static HapticsProxy &instance()
54 {
55 static HapticsProxy instance;
56 return instance;
57 }
58
59 void setEngine(QQmlEngine *engine)
60 {
61 m_engine = engine;
62 }
63
64 void initialize();
65
66 bool enabled();
67 QObject *effect();
68 void play(const QVariant &customEffect);
69
70Q_SIGNALS:
71 void enabledChanged();
72
73private:
74 QObject *m_proxyObject;
75 QQmlEngine *m_engine;
76};
77
78#endif // UCHAPTICS_H
079
=== modified file 'src/Ubuntu/Components/plugin/uclistitem.cpp'
--- src/Ubuntu/Components/plugin/uclistitem.cpp 2015-07-30 13:27:32 +0000
+++ src/Ubuntu/Components/plugin/uclistitem.cpp 2015-09-08 04:09:38 +0000
@@ -200,6 +200,7 @@
200 , leadingActions(0)200 , leadingActions(0)
201 , trailingActions(0)201 , trailingActions(0)
202 , mainAction(0)202 , mainAction(0)
203 , expansion(Q_NULLPTR)
203{204{
204}205}
205UCListItemPrivate::~UCListItemPrivate()206UCListItemPrivate::~UCListItemPrivate()
@@ -325,7 +326,7 @@
325bool UCListItemPrivate::loadStyleItem(bool animated)326bool UCListItemPrivate::loadStyleItem(bool animated)
326{327{
327 // the style should be loaded only if one of the condition is satisfied328 // the style should be loaded only if one of the condition is satisfied
328 if (!swiped && !selectMode() && !dragMode()) {329 if (!swiped && !selectMode() && !dragMode() && !(expansion && expansion->expanded())) {
329 return false;330 return false;
330 }331 }
331332
@@ -339,6 +340,7 @@
339 preStyleChanged();340 preStyleChanged();
340 return false;341 return false;
341 }342 }
343 myStyle->updateFlickable(flickable);
342 // bring the panels foreground344 // bring the panels foreground
343 styleItem->setZ(0);345 styleItem->setZ(0);
344 listItemStyle()->setAnimatePanels(true);346 listItemStyle()->setAnimatePanels(true);
@@ -372,23 +374,13 @@
372 (parentItem ? QQuickItemPrivate::get(parentItem)->childItems.indexOf(q) : -1);374 (parentItem ? QQuickItemPrivate::get(parentItem)->childItems.indexOf(q) : -1);
373}375}
374376
375// returns true if the highlight is possible377// returns true if the highlight is possible; the highlight is possible if the
376bool UCListItemPrivate::canHighlight(QMouseEvent *event)378// list item has at least one action, leading/trailing actions set, onClicked
379// or onPressAndHold signal handlers set
380bool UCListItemPrivate::canHighlight()
377{381{
378 // if automatic, the highlight should not happen if we clicked on an active component;
379 // localPos is a position relative to ListItem which will give us a child from
380 // from the original coordinates; therefore we must map the position to the contentItem
381 Q_Q(UCListItem);382 Q_Q(UCListItem);
382 QPointF myPos = q->mapToItem(contentItem, event->localPos());383 return (isClickedConnected() || isPressAndHoldConnected() || mainAction || leadingActions || trailingActions);
383 QQuickItem *child = contentItem->childAt(myPos.x(), myPos.y());
384 bool activeComponent = child && (child->acceptedMouseButtons() & event->button()) &&
385 child->isEnabled() && !qobject_cast<QQuickText*>(child);
386 // do highlight if not pressed above the active component, and the component has either
387 // action, leading or trailing actions list or at least an active child component declared
388 QQuickMouseArea *ma = q->findChild<QQuickMouseArea*>();
389 bool activeMouseArea = ma && ma->isEnabled();
390 return !activeComponent && (isClickedConnected() || isPressAndHoldConnected() ||
391 mainAction || leadingActions || trailingActions || activeMouseArea);
392}384}
393385
394// set highlighted flag and update contentItem386// set highlighted flag and update contentItem
@@ -876,8 +868,74 @@
876 *868 *
877 * \sa ViewItems::dragMode, ViewItems::dragUpdated869 * \sa ViewItems::dragMode, ViewItems::dragUpdated
878 *870 *
871 * \section2 Expansion
872 * Since Ubuntu.Components 1.3, ListItem supports expansion. ListItems declared
873 * in a view can expand exclusively, having leading and trailing panes locked
874 * when expanded and to be collapsed when tapping outside of the expanded area.
875 * The expansion is driven by the \l expansion group property, and the behavior
876 * by the \l ViewItems::expansionFlags and \l ViewItems::expandedIndices
877 * attached properties. Each ListItem which is required to expand should set a
878 * proper height in the \l expansion.height property, which should be bigger
879 * than the collapsed height of the ListItem is. The expansion itself is driven
880 * by the \l expansion.expanded property, which can be set freely depending on
881 * the use case, on click, on long press, etc.
882 *
883 * The default expansion behavior is set to be exclusive and locked, meaning
884 * there can be only one ListItem expanded within a view and neither leading
885 * nor trailing action panels cannot be swiped in. Expanding an other ListItem
886 * will collapse the previosuly expanded one. There can be cases when tapping
887 * outside of the expanded area of a ListItem we woudl need the expanded one
888 * to collapse automatically. This can be achieved by setting \c ViewItems.CollapseOnOutsidePress
889 * flag to \l ViewItems::expansionFlags. This flag will also turn on \c ViewItems.Exclusive
890 * flag, as tapping outside practicly forbids more than one item to be expanded
891 * at a time.
892 * \qml
893 * import QtQuick 2.4
894 * import Ubuntu.Components 1.3
895 *
896 * ListView {
897 * width: units.gu(40)
898 * height: units.gu(71)
899 * model: ListModel {
900 * Component.onCompleted: {
901 * for (var i = 0; i < 50; i++) {
902 * append({data: i});
903 * }
904 * }
905 * }
906 * ViewItems.expansionFlags: ViewItems.CollapseOnOutsidePress
907 * delegate: ListItem {
908 * Label {
909 * text: "Model item #" + modelData
910 * }
911 * trailingActions: ListItemActions {
912 * actions: [
913 * Action {
914 * icon: "search"
915 * },
916 * Action {
917 * icon: "edit"
918 * },
919 * Action {
920 * icon: "copy"
921 * }
922 * ]
923 * }
924 * expansion.height: units.gu(15)
925 * onClicked: expansion.expanded = true
926 * }
927 * }
928 * \endqml
929 * The example above collapses the expanded item whenever it is tapped or mouse
930 * pressed outside of the expanded list item.
931 * \note Set 0 to \l ViewItems::expansionFlags if no restrictions on expanded items
932 * is required (i.e multiple expanded items are allowed, swiping leading/trailing
933 * actions when expanded).
934 * \note Do not bind \l expansion.height to the ListItem's height as is will cause
935 * binding loops.
936 *
879 * \section2 Note on styling937 * \section2 Note on styling
880 * ListItem's styling differs from the other component sstyling, as ListItem loads938 * ListItem's styling differs from the other components styling, as ListItem loads
881 * the style only when either of the leadin/trailing panels are swiped, or when the939 * the style only when either of the leadin/trailing panels are swiped, or when the
882 * item enters in select- or drag mode. The component does not assume any visuals940 * item enters in select- or drag mode. The component does not assume any visuals
883 * to be present in the style.941 * to be present in the style.
@@ -914,6 +972,11 @@
914{972{
915}973}
916974
975QObject *UCListItem::attachedViewItems(QObject *object, bool create)
976{
977 return qmlAttachedPropertiesObject<UCViewItemsAttached>(object, create);
978}
979
917void UCListItem::classBegin()980void UCListItem::classBegin()
918{981{
919 UCStyledItemBase::classBegin();982 UCStyledItemBase::classBegin();
@@ -966,7 +1029,7 @@
966 this, SLOT(_q_syncDragMode()));1029 this, SLOT(_q_syncDragMode()));
9671030
968 // if selection or drag mode is on, initialize style, with animations turned off1031 // if selection or drag mode is on, initialize style, with animations turned off
969 if (d->parentAttached->selectMode() || d->parentAttached->dragMode()) {1032 if (d->parentAttached->selectMode() || d->parentAttached->dragMode() || (d->expansion && d->expansion->expanded())) {
970 d->loadStyleItem(false);1033 d->loadStyleItem(false);
971 }1034 }
972 // set the object name for testing purposes1035 // set the object name for testing purposes
@@ -996,10 +1059,10 @@
996 QQuickItem *parentAttachee = data.item;1059 QQuickItem *parentAttachee = data.item;
997 if (d->flickable && d->flickable->inherits("QQuickListView")) {1060 if (d->flickable && d->flickable->inherits("QQuickListView")) {
998 // attach to ListView1061 // attach to ListView
999 d->parentAttached = static_cast<UCViewItemsAttached*>(qmlAttachedPropertiesObject<UCViewItemsAttached>(d->flickable));1062 d->parentAttached = static_cast<UCViewItemsAttached*>(attachedViewItems(d->flickable, true));
1000 parentAttachee = d->flickable;1063 parentAttachee = d->flickable;
1001 } else if (data.item) {1064 } else if (data.item) {
1002 d->parentAttached = static_cast<UCViewItemsAttached*>(qmlAttachedPropertiesObject<UCViewItemsAttached>(data.item));1065 d->parentAttached = static_cast<UCViewItemsAttached*>(attachedViewItems(data.item, true));
1003 } else {1066 } else {
1004 // mark as not ready, so no action should be performed which depends on readyness1067 // mark as not ready, so no action should be performed which depends on readyness
1005 d->ready = false;1068 d->ready = false;
@@ -1007,6 +1070,11 @@
1007 d->parentAttached = 0;1070 d->parentAttached = 0;
1008 }1071 }
10091072
1073 if (d->styleItem) {
1074 UCListItemStyle * myStyle = static_cast<UCListItemStyle*>(d->styleItem);
1075 myStyle->updateFlickable(d->flickable);
1076 }
1077
1010 if (parentAttachee) {1078 if (parentAttachee) {
1011 QObject::connect(parentAttachee, SIGNAL(widthChanged()), this, SLOT(_q_updateSize()), Qt::DirectConnection);1079 QObject::connect(parentAttachee, SIGNAL(widthChanged()), this, SLOT(_q_updateSize()), Qt::DirectConnection);
1012 // update size1080 // update size
@@ -1081,7 +1149,7 @@
1081 // while moving, we cannot select any items1149 // while moving, we cannot select any items
1082 return;1150 return;
1083 }1151 }
1084 if (d->canHighlight(event) && !d->highlighted && event->button() == Qt::LeftButton) {1152 if (d->canHighlight() && !d->highlighted && event->button() == Qt::LeftButton) {
1085 d->grabLeftButtonEvents(event);1153 d->grabLeftButtonEvents(event);
1086 }1154 }
1087 // accept the event so we get the rest of the events as well1155 // accept the event so we get the rest of the events as well
@@ -1194,7 +1262,7 @@
1194 Q_D(UCListItem);1262 Q_D(UCListItem);
1195 UCStyledItemBase::mouseMoveEvent(event);1263 UCStyledItemBase::mouseMoveEvent(event);
11961264
1197 if (d->selectMode() || d->dragMode()) {1265 if (d->selectMode() || d->dragMode() || (d->expansion && d->expansion->expandedLocked())) {
1198 // no move is allowed while selectable mode is on1266 // no move is allowed while selectable mode is on
1199 return;1267 return;
1200 }1268 }
@@ -1672,4 +1740,48 @@
1672 d->defaultThemeVersion = BUILD_VERSION(1, 3);1740 d->defaultThemeVersion = BUILD_VERSION(1, 3);
1673}1741}
16741742
1743QObject *UCListItem13::attachedViewItems(QObject *object, bool create)
1744{
1745 return qmlAttachedPropertiesObject<UCViewItemsAttached13>(object, create);
1746}
1747
1748void UCListItem13::itemChange(ItemChange change, const ItemChangeData &data)
1749{
1750 UCListItem::itemChange(change, data);
1751
1752 Q_D(UCListItem);
1753 // ViewItems drives expansion
1754 if (d->parentAttached) {
1755 connect(d->parentAttached.data(), SIGNAL(expandedIndicesChanged(QList<int>)),
1756 this, SLOT(_q_updateExpansion(QList<int>)), Qt::UniqueConnection);
1757 }
1758}
1759
1760/*!
1761 * \qmlpropertygroup ::ListItem::expansion
1762 * \qmlproperty bool ListItem::expansion.expanded
1763 * \qmlproperty real ListItem::expansion.height
1764 * \since Ubuntu.Components 1.3
1765 * The group drefines the expansion state of the ListItem.
1766 */
1767UCListItemExpansion *UCListItem13::expansion()
1768{
1769 Q_D(UCListItem);
1770 if (!d->expansion) {
1771 d->expansion = new UCListItemExpansion(this);
1772 }
1773 return d->expansion;
1774}
1775
1776void UCListItem13::_q_updateExpansion(const QList<int> &indices)
1777{
1778 Q_UNUSED(indices);
1779 Q_D(UCListItem);
1780 Q_EMIT expansion()->expandedChanged();
1781 // make sure the style is loaded
1782 if (indices.contains(d->index())) {
1783 d->loadStyleItem();
1784 }
1785}
1786
1675#include "moc_uclistitem.cpp"1787#include "moc_uclistitem.cpp"
16761788
=== modified file 'src/Ubuntu/Components/plugin/uclistitem.h'
--- src/Ubuntu/Components/plugin/uclistitem.h 2015-07-28 19:29:19 +0000
+++ src/Ubuntu/Components/plugin/uclistitem.h 2015-09-08 04:09:38 +0000
@@ -62,6 +62,7 @@
62 void resetHighlightColor();62 void resetHighlightColor();
6363
64protected:64protected:
65 virtual QObject *attachedViewItems(QObject *object, bool create);
65 void classBegin();66 void classBegin();
66 void componentComplete();67 void componentComplete();
67 QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data);68 QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data);
@@ -109,17 +110,24 @@
109 Q_PRIVATE_SLOT(d_func(), void _q_syncDragMode())110 Q_PRIVATE_SLOT(d_func(), void _q_syncDragMode())
110};111};
111112
113class UCListItemExpansion;
112class UCListItem13 : public UCListItem114class UCListItem13 : public UCListItem
113{115{
114 Q_OBJECT116 Q_OBJECT
117 Q_PROPERTY(UCListItemExpansion* expansion READ expansion CONSTANT)
115protected:118protected:
119 virtual QObject *attachedViewItems(QObject *object, bool create);
120 void itemChange(ItemChange change, const ItemChangeData &data);
116 void mousePressEvent(QMouseEvent *event);121 void mousePressEvent(QMouseEvent *event);
117 void mouseReleaseEvent(QMouseEvent *event);122 void mouseReleaseEvent(QMouseEvent *event);
118private:123private:
124 Q_SLOT void _q_updateExpansion(const QList<int> &indices);
119 bool shouldShowContextMenu(QMouseEvent *event);125 bool shouldShowContextMenu(QMouseEvent *event);
120 void popoverClosed();126 void popoverClosed();
121public:127public:
122 explicit UCListItem13(QQuickItem *parent = 0);128 explicit UCListItem13(QQuickItem *parent = 0);
129
130 UCListItemExpansion *expansion();
123};131};
124132
125class UCListItemDividerPrivate;133class UCListItemDividerPrivate;
@@ -158,8 +166,15 @@
158 Q_PROPERTY(bool selectMode READ selectMode WRITE setSelectMode NOTIFY selectModeChanged)166 Q_PROPERTY(bool selectMode READ selectMode WRITE setSelectMode NOTIFY selectModeChanged)
159 Q_PROPERTY(QList<int> selectedIndices READ selectedIndices WRITE setSelectedIndices NOTIFY selectedIndicesChanged)167 Q_PROPERTY(QList<int> selectedIndices READ selectedIndices WRITE setSelectedIndices NOTIFY selectedIndicesChanged)
160 Q_PROPERTY(bool dragMode READ dragMode WRITE setDragMode NOTIFY dragModeChanged)168 Q_PROPERTY(bool dragMode READ dragMode WRITE setDragMode NOTIFY dragModeChanged)
169 Q_ENUMS(ExpansionFlag)
161public:170public:
162 explicit UCViewItemsAttached(QObject *owner);171 enum ExpansionFlag {
172 Exclusive = 0x01,
173 UnlockExpanded = 0x02,
174 CollapseOnOutsidePress = Exclusive | 0x04
175 };
176 Q_DECLARE_FLAGS(ExpansionFlags, ExpansionFlag)
177 explicit UCViewItemsAttached(QObject *owner = 0);
163 ~UCViewItemsAttached();178 ~UCViewItemsAttached();
164179
165 static UCViewItemsAttached *qmlAttachedProperties(QObject *owner);180 static UCViewItemsAttached *qmlAttachedProperties(QObject *owner);
@@ -191,8 +206,68 @@
191private:206private:
192 Q_DECLARE_PRIVATE(UCViewItemsAttached)207 Q_DECLARE_PRIVATE(UCViewItemsAttached)
193};208};
209Q_DECLARE_OPERATORS_FOR_FLAGS(UCViewItemsAttached::ExpansionFlags)
194QML_DECLARE_TYPEINFO(UCViewItemsAttached, QML_HAS_ATTACHED_PROPERTIES)210QML_DECLARE_TYPEINFO(UCViewItemsAttached, QML_HAS_ATTACHED_PROPERTIES)
195211
212// FIXME keep the 1.3 properties in a separate class, workaround for bug
213// https://bugs.launchpad.net/ubuntu/+source/qtdeclarative-opensource-src/+bug/1389721
214// enums and flag are added to UCViewItemsAttached like normal
215class UCViewItemsAttached13 : public UCViewItemsAttached
216{
217 Q_OBJECT
218 Q_PROPERTY(QList<int> expandedIndices READ expandedIndices WRITE setExpandedIndices NOTIFY expandedIndicesChanged)
219 Q_PROPERTY(int expansionFlags READ expansionFlags WRITE setExpansionFlags NOTIFY expansionFlagsChanged)
220public:
221 explicit UCViewItemsAttached13(QObject *owner = 0);
222 static UCViewItemsAttached13 *qmlAttachedProperties(QObject *owner);
223
224 QList<int> expandedIndices() const;
225 void setExpandedIndices(QList<int> indices);
226 int expansionFlags() const;
227 void setExpansionFlags(int flags);
228
229Q_SIGNALS:
230 void expandedIndicesChanged(const QList<int> &indices);
231 void expansionFlagsChanged();
232
233private:
234 UCViewItemsAttachedPrivate *d_ptr;
235 Q_DECLARE_PRIVATE_D(d_ptr, UCViewItemsAttached)
236};
237QML_DECLARE_TYPEINFO(UCViewItemsAttached13, QML_HAS_ATTACHED_PROPERTIES)
238
239class UCListItemExpansion : public QObject
240{
241 Q_OBJECT
242 Q_PROPERTY(bool expanded READ expanded WRITE setExpanded NOTIFY expandedChanged)
243 Q_PROPERTY(qreal height MEMBER m_height WRITE setHeight NOTIFY heightChanged)
244public:
245 explicit UCListItemExpansion(QObject *parent = 0);
246
247 bool expandedLocked();
248 void enableClickFiltering(bool enable);
249
250 bool expanded();
251 void setExpanded(bool expanded);
252 void setHeight(qreal height);
253
254Q_SIGNALS:
255 void expandedChanged();
256 void heightChanged();
257
258protected:
259 bool eventFilter(QObject *, QEvent *);
260
261private:
262 UCListItem13 *m_listItem;
263 qreal m_height;
264 bool m_filtering:1;
265
266 friend class UCListItem;
267 friend class UCListItem13;
268 friend class UCListItemPrivate;
269};
270
196class UCDragEvent : public QObject271class UCDragEvent : public QObject
197{272{
198 Q_OBJECT273 Q_OBJECT
199274
=== modified file 'src/Ubuntu/Components/plugin/uclistitem_p.h'
--- src/Ubuntu/Components/plugin/uclistitem_p.h 2015-07-30 13:27:32 +0000
+++ src/Ubuntu/Components/plugin/uclistitem_p.h 2015-09-08 04:09:38 +0000
@@ -60,7 +60,7 @@
60 void _q_syncSelectMode();60 void _q_syncSelectMode();
61 void _q_syncDragMode();61 void _q_syncDragMode();
62 int index();62 int index();
63 bool canHighlight(QMouseEvent *event);63 bool canHighlight();
64 void setHighlighted(bool pressed);64 void setHighlighted(bool pressed);
65 void listenToRebind(bool listen);65 void listenToRebind(bool listen);
66 void lockContentItem(bool lock);66 void lockContentItem(bool lock);
@@ -95,6 +95,7 @@
95 UCListItemActions *leadingActions;95 UCListItemActions *leadingActions;
96 UCListItemActions *trailingActions;96 UCListItemActions *trailingActions;
97 UCAction *mainAction;97 UCAction *mainAction;
98 UCListItemExpansion *expansion;
9899
99 // getters/setters100 // getters/setters
100 QQmlListProperty<QObject> data();101 QQmlListProperty<QObject> data();
@@ -147,17 +148,25 @@
147 bool isDragUpdatedConnected();148 bool isDragUpdatedConnected();
148 void updateSelectedIndices(int fromIndex, int toIndex);149 void updateSelectedIndices(int fromIndex, int toIndex);
149150
151 // expansion
152 void expand(int index, UCListItem13 *listItem, bool emitChangeSignal = true);
153 void collapse(int index, bool emitChangeSignal = true);
154 void collapseAll();
155 void toggleExpansionFlags(bool enable);
156
157 QSet<int> selectedList;
158 QMap<int, QPointer<UCListItem13> > expansionList;
159 QList< QPointer<QQuickFlickable> > flickables;
160 QList< PropertyChange* > changes;
161 QPointer<UCListItem> boundItem;
162 QPointer<UCListItem> disablerItem;
150 QQuickFlickable *listView;163 QQuickFlickable *listView;
151 ListItemDragArea *dragArea;164 ListItemDragArea *dragArea;
165 UCViewItemsAttached::ExpansionFlags expansionFlags;
152 bool globalDisabled:1;166 bool globalDisabled:1;
153 bool selectable:1;167 bool selectable:1;
154 bool draggable:1;168 bool draggable:1;
155 bool ready:1;169 bool ready:1;
156 QSet<int> selectedList;
157 QList< QPointer<QQuickFlickable> > flickables;
158 QList< PropertyChange* > changes;
159 QPointer<UCListItem> boundItem;
160 QPointer<UCListItem> disablerItem;
161};170};
162171
163#endif // UCVIEWITEM_P_H172#endif // UCVIEWITEM_P_H
164173
=== modified file 'src/Ubuntu/Components/plugin/uclistitemstyle.cpp'
--- src/Ubuntu/Components/plugin/uclistitemstyle.cpp 2015-04-13 13:42:03 +0000
+++ src/Ubuntu/Components/plugin/uclistitemstyle.cpp 2015-09-08 04:09:38 +0000
@@ -21,6 +21,7 @@
21#include <QtQml/QQmlContext>21#include <QtQml/QQmlContext>
22#include <QtQml/QQmlInfo>22#include <QtQml/QQmlInfo>
23#include <QtQuick/private/qquickanimation_p.h>23#include <QtQuick/private/qquickanimation_p.h>
24#include <QtQuick/private/qquickflickable_p.h>
2425
25/*!26/*!
26 * \qmltype ListItemStyle27 * \qmltype ListItemStyle
@@ -41,6 +42,7 @@
41 , m_snapAnimation(0)42 , m_snapAnimation(0)
42 , m_dropAnimation(0)43 , m_dropAnimation(0)
43 , m_dragPanel(0)44 , m_dragPanel(0)
45 , m_flickable(Q_NULLPTR)
44 , m_animatePanels(true)46 , m_animatePanels(true)
45{47{
46}48}
@@ -54,21 +56,29 @@
54 setAnimatePanels(context->contextProperty("animated").toBool());56 setAnimatePanels(context->contextProperty("animated").toBool());
55 }57 }
56 m_listItem = qmlContext(this)->contextProperty("styledItem").value<UCListItem*>();58 m_listItem = qmlContext(this)->contextProperty("styledItem").value<UCListItem*>();
59 // get the flickable value
60 if (m_listItem) {
61 m_flickable = UCListItemPrivate::get(m_listItem)->flickable.data();
62 }
57}63}
5864
59void UCListItemStyle::componentComplete()65void UCListItemStyle::componentComplete()
60{66{
61 QQuickItem::componentComplete();67 QQuickItem::componentComplete();
6268
63 // look for overridden slots69 // look for overridden slots, indexOfMethod returns th elast index of the overridden method
64 for (int i = metaObject()->methodOffset(); i < metaObject()->methodCount(); i++) {70 m_rebound = metaObject()->method(metaObject()->indexOfMethod("rebound()"));
65 const QMetaMethod method = metaObject()->method(i);71 m_swipeEvent = metaObject()->method(metaObject()->indexOfMethod("swipeEvent(QVariant)"));
66 if (method.name() == QByteArrayLiteral("swipeEvent")) {72// qDebug() << m_rebound.isValid() << m_swipeEvent.isValid();
67 m_swipeEvent = method;73// for (int i = metaObject()->methodOffset(); i < metaObject()->methodCount(); i++) {
68 } else if (method.name() == QByteArrayLiteral("rebound")) {74// const QMetaMethod method = metaObject()->method(i);
69 m_rebound = method;75// if (method.name() == QByteArrayLiteral("swipeEvent")) {
70 }76// qDebug() << method.methodSignature();
71 }77// m_swipeEvent = method;
78// } else if (method.name() == QByteArrayLiteral("rebound")) {
79// m_rebound = method;
80// }
81// }
7282
73 // connect snapAnimation's stopped() and the owning ListItem's contentMovementeEnded() signals83 // connect snapAnimation's stopped() and the owning ListItem's contentMovementeEnded() signals
74 if (m_listItem && m_snapAnimation) {84 if (m_listItem && m_snapAnimation) {
@@ -92,6 +102,25 @@
92}102}
93103
94/*!104/*!
105 * \qmlproperty Flickable ListItemStyle::flickable
106 * \readonly
107 * \since Ubuntu.Components.Styles 1.3
108 * The property holds the Flickable (or ListView) holding the ListItem styled.
109 */
110QQuickFlickable *UCListItemStyle::flickable()
111{
112 return m_flickable;
113}
114void UCListItemStyle::updateFlickable(QQuickFlickable *flickable)
115{
116 if (m_flickable == flickable) {
117 return;
118 }
119 m_flickable = flickable;
120 Q_EMIT flickableChanged();
121}
122
123/*!
95 * \qmlmethod ListItemStyle::swipeEvent(SwipeEvent event)124 * \qmlmethod ListItemStyle::swipeEvent(SwipeEvent event)
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.
97 * when the swipe is started, the position is updated or the swipe ends. The126 * when the swipe is started, the position is updated or the swipe ends. The
98127
=== modified file 'src/Ubuntu/Components/plugin/uclistitemstyle.h'
--- src/Ubuntu/Components/plugin/uclistitemstyle.h 2015-04-13 13:42:03 +0000
+++ src/Ubuntu/Components/plugin/uclistitemstyle.h 2015-09-08 04:09:38 +0000
@@ -62,6 +62,7 @@
62class QQuickPropertyAnimation;62class QQuickPropertyAnimation;
63class QQuickBehavior;63class QQuickBehavior;
64class UCListItem;64class UCListItem;
65class QQuickFlickable;
65class UCListItemStyle : public QQuickItem66class UCListItemStyle : public QQuickItem
66{67{
67 Q_OBJECT68 Q_OBJECT
@@ -70,6 +71,7 @@
70 Q_PROPERTY(bool animatePanels READ animatePanels NOTIFY animatePanelsChanged)71 Q_PROPERTY(bool animatePanels READ animatePanels NOTIFY animatePanelsChanged)
71 Q_PROPERTY(QQuickItem *dragPanel MEMBER m_dragPanel NOTIFY dragPanelChanged)72 Q_PROPERTY(QQuickItem *dragPanel MEMBER m_dragPanel NOTIFY dragPanelChanged)
72 Q_PROPERTY(int listItemIndex READ index NOTIFY listItemIndexChanged FINAL REVISION 1)73 Q_PROPERTY(int listItemIndex READ index NOTIFY listItemIndexChanged FINAL REVISION 1)
74 Q_PROPERTY(QQuickFlickable *flickable READ flickable NOTIFY flickableChanged REVISION 1)
73public:75public:
74 explicit UCListItemStyle(QQuickItem *parent = 0);76 explicit UCListItemStyle(QQuickItem *parent = 0);
7577
@@ -78,6 +80,8 @@
78 bool animatePanels() const;80 bool animatePanels() const;
79 void setAnimatePanels(bool animate);81 void setAnimatePanels(bool animate);
80 int index();82 int index();
83 QQuickFlickable *flickable();
84 void updateFlickable(QQuickFlickable *flickable);
8185
82Q_SIGNALS:86Q_SIGNALS:
83 void snapAnimationChanged();87 void snapAnimationChanged();
@@ -85,6 +89,7 @@
85 void animatePanelsChanged();89 void animatePanelsChanged();
86 void dragPanelChanged();90 void dragPanelChanged();
87 Q_REVISION(1) void listItemIndexChanged();91 Q_REVISION(1) void listItemIndexChanged();
92 Q_REVISION(1) void flickableChanged();
8893
89public Q_SLOTS:94public Q_SLOTS:
90 void swipeEvent(UCSwipeEvent *event);95 void swipeEvent(UCSwipeEvent *event);
@@ -102,6 +107,7 @@
102 QQuickAbstractAnimation *m_snapAnimation;107 QQuickAbstractAnimation *m_snapAnimation;
103 QQuickPropertyAnimation *m_dropAnimation;108 QQuickPropertyAnimation *m_dropAnimation;
104 QQuickItem *m_dragPanel;109 QQuickItem *m_dragPanel;
110 QQuickFlickable *m_flickable;
105 bool m_animatePanels:1;111 bool m_animatePanels:1;
106112
107 friend class UCListItemPrivate;113 friend class UCListItemPrivate;
108114
=== modified file 'src/Ubuntu/Components/plugin/ucqquickimageextension.cpp'
--- src/Ubuntu/Components/plugin/ucqquickimageextension.cpp 2014-11-24 13:14:35 +0000
+++ src/Ubuntu/Components/plugin/ucqquickimageextension.cpp 2015-09-08 04:09:38 +0000
@@ -19,6 +19,7 @@
19#include <QtCore/QFile>19#include <QtCore/QFile>
20#include <QtCore/QFileInfo>20#include <QtCore/QFileInfo>
21#include <QtCore/QDir>21#include <QtCore/QDir>
22#include <QtGui/QGuiApplication>
22#include <QtQuick/private/qquickimagebase_p.h>23#include <QtQuick/private/qquickimagebase_p.h>
2324
24#include "ucqquickimageextension.h"25#include "ucqquickimageextension.h"
@@ -78,8 +79,18 @@
78 QString selectedFilePath = resolved.mid(separatorPosition+1);79 QString selectedFilePath = resolved.mid(separatorPosition+1);
7980
80 if (scaleFactor == "1") {81 if (scaleFactor == "1") {
81 // No scaling. Just pass the file as is.82 if (qFuzzyCompare(qGuiApp->devicePixelRatio(), (qreal)1.0)
82 m_image->setSource(QUrl::fromLocalFile(selectedFilePath));83 || selectedFilePath.endsWith(".svg") || selectedFilePath.endsWith(".svgz")) {
84 // No scaling necessary. Just pass the file as is.
85 m_image->setSource(QUrl::fromLocalFile(selectedFilePath));
86 } else {
87 // Need to scale the pixel-based image to suit the devicePixelRatio setting ourselves.
88 // If we let Qt do it, Qt will not choose the UITK-supported "@gu" scaled images.
89 m_image->setSource(QUrl("image://scaling/1/" + selectedFilePath));
90 // explicitly set the source size in the QQuickImageBase, this persuades it that the
91 // supplied image is suitable for the current devicePixelRatio.
92 m_image->setSourceSize(m_image->sourceSize());
93 }
83 } else {94 } else {
84 // Prepend "image://scaling" for the image to be loaded by UCScalingImageProvider.95 // Prepend "image://scaling" for the image to be loaded by UCScalingImageProvider.
85 if (!m_source.path().endsWith(".sci")) {96 if (!m_source.path().endsWith(".sci")) {
@@ -100,7 +111,13 @@
100 rewrittenSciFile->setFileTemplate(QDir::tempPath() + QDir::separator() + "XXXXXX.sci");111 rewrittenSciFile->setFileTemplate(QDir::tempPath() + QDir::separator() + "XXXXXX.sci");
101 rewrittenSciFile->open();112 rewrittenSciFile->open();
102 QTextStream output(rewrittenSciFile);113 QTextStream output(rewrittenSciFile);
103 rewritten = rewriteSciFile(selectedFilePath, scaleFactor, output);114
115 if (qFuzzyCompare(qGuiApp->devicePixelRatio(), (qreal)1.0)) {
116 rewritten = rewriteSciFile(selectedFilePath, scaleFactor, output);
117 } else {
118 QString scaleFactorInDevicePixels = QString::number(scaleFactor.toFloat() / qGuiApp->devicePixelRatio());
119 rewritten = rewriteSciFile(selectedFilePath, scaleFactorInDevicePixels, output);
120 }
104 rewrittenSciFile->close();121 rewrittenSciFile->close();
105122
106 s_rewrittenSciFiles.insert(m_source, QSharedPointer<QTemporaryFile>(rewrittenSciFile));123 s_rewrittenSciFiles.insert(m_source, QSharedPointer<QTemporaryFile>(rewrittenSciFile));
@@ -112,6 +129,9 @@
112 m_image->setSource(m_source);129 m_image->setSource(m_source);
113 }130 }
114 }131 }
132 // explicitly set the source size in the QQuickImageBase, this persuades it that the
133 // supplied image is suitable for the current devicePixelRatio.
134 m_image->setSourceSize(m_image->sourceSize());
115 }135 }
116}136}
117137
118138
=== modified file 'src/Ubuntu/Components/plugin/ucstatesaver.cpp'
--- src/Ubuntu/Components/plugin/ucstatesaver.cpp 2015-07-22 14:35:48 +0000
+++ src/Ubuntu/Components/plugin/ucstatesaver.cpp 2015-09-08 04:09:38 +0000
@@ -147,7 +147,7 @@
147 * \instantiates UCStateSaverAttached147 * \instantiates UCStateSaverAttached
148 * \inqmlmodule Ubuntu.Components 1.1148 * \inqmlmodule Ubuntu.Components 1.1
149 * \ingroup ubuntu-services149 * \ingroup ubuntu-services
150 * \brief Attached propertyes to save component property states.150 * \brief Attached properties to save component property states.
151 *151 *
152 * StateSaver attached object provides the ability to save component property values152 * StateSaver attached object provides the ability to save component property values
153 * that can be restored after an inproper application close. The properties subject153 * that can be restored after an inproper application close. The properties subject
@@ -297,7 +297,7 @@
297 * List of properties to be serialized, separated with commas. Properties must be297 * List of properties to be serialized, separated with commas. Properties must be
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}.
299 *299 *
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:
301 * \qml301 * \qml
302 * TextField {302 * TextField {
303 * id: input303 * id: input
304304
=== modified file 'src/Ubuntu/Components/plugin/ucubuntushape.cpp'
--- src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-08-24 20:49:41 +0000
+++ src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-09-08 04:09:38 +0000
@@ -318,10 +318,7 @@
318 setFlag(ItemHasContents);318 setFlag(ItemHasContents);
319 QObject::connect(&UCUnits::instance(), SIGNAL(gridUnitChanged()), this,319 QObject::connect(&UCUnits::instance(), SIGNAL(gridUnitChanged()), this,
320 SLOT(_q_gridUnitChanged()));320 SLOT(_q_gridUnitChanged()));
321 const float gridUnit = UCUnits::instance().gridUnit();321 _q_gridUnitChanged();
322 setImplicitWidth(implicitWidthGU * gridUnit);
323 setImplicitHeight(implicitHeightGU * gridUnit);
324 update();
325}322}
326323
327/*! \qmlproperty string UbuntuShape::radius324/*! \qmlproperty string UbuntuShape::radius
@@ -803,9 +800,11 @@
803*/800*/
804void UCUbuntuShape::setColor(const QColor& color)801void UCUbuntuShape::setColor(const QColor& color)
805{802{
806 if (QuickUtils::showDeprecationWarnings()) {803 static bool loggedOnce = false;
807 qmlInfo(this) << "'color' is deprecated. Use 'backgroundColor', 'secondaryBackgroundColor' and "804 if (!loggedOnce) {
808 "'backgroundMode' instead.";805 loggedOnce = true;
806 qmlInfo(this) << "'color' is deprecated. Use 'backgroundColor', 'secondaryBackgroundColor' "
807 "and 'backgroundMode' instead.";
809 }808 }
810809
811 if (!(m_flags & BackgroundApiSet)) {810 if (!(m_flags & BackgroundApiSet)) {
@@ -834,7 +833,9 @@
834*/833*/
835void UCUbuntuShape::setGradientColor(const QColor& gradientColor)834void UCUbuntuShape::setGradientColor(const QColor& gradientColor)
836{835{
837 if (QuickUtils::showDeprecationWarnings()) {836 static bool loggedOnce = false;
837 if (!loggedOnce) {
838 loggedOnce = true;
838 qmlInfo(this) << "'gradientColor' is deprecated. Use 'backgroundColor', "839 qmlInfo(this) << "'gradientColor' is deprecated. Use 'backgroundColor', "
839 "'secondaryBackgroundColor' and 'backgroundMode' instead.";840 "'secondaryBackgroundColor' and 'backgroundMode' instead.";
840 }841 }
@@ -863,7 +864,9 @@
863*/864*/
864void UCUbuntuShape::setImage(const QVariant& image)865void UCUbuntuShape::setImage(const QVariant& image)
865{866{
866 if (QuickUtils::showDeprecationWarnings()) {867 static bool loggedOnce = false;
868 if (!loggedOnce) {
869 loggedOnce = true;
867 qmlInfo(this) << "'image' is deprecated. Use 'source' instead.";870 qmlInfo(this) << "'image' is deprecated. Use 'source' instead.";
868 }871 }
869872
@@ -894,7 +897,9 @@
894// maintain it for a while for compatibility reasons.897// maintain it for a while for compatibility reasons.
895void UCUbuntuShape::setStretched(bool stretched)898void UCUbuntuShape::setStretched(bool stretched)
896{899{
897 if (QuickUtils::showDeprecationWarnings()) {900 static bool loggedOnce = false;
901 if (!loggedOnce) {
902 loggedOnce = true;
898 qmlInfo(this) << "'stretched' is deprecated. Use 'sourceFillMode' instead";903 qmlInfo(this) << "'stretched' is deprecated. Use 'sourceFillMode' instead";
899 }904 }
900905
@@ -915,8 +920,11 @@
915// Deprecation layer. Same comment as setStretched().920// Deprecation layer. Same comment as setStretched().
916void UCUbuntuShape::setHorizontalAlignment(HAlignment horizontalAlignment)921void UCUbuntuShape::setHorizontalAlignment(HAlignment horizontalAlignment)
917{922{
918 if (QuickUtils::showDeprecationWarnings()) {923 static bool loggedOnce = false;
919 qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceHorizontalAlignment' instead";924 if (!loggedOnce) {
925 loggedOnce = true;
926 qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceHorizontalAlignment' "
927 "instead";
920 }928 }
921929
922 if (!(m_flags & SourceApiSet)) {930 if (!(m_flags & SourceApiSet)) {
@@ -932,8 +940,11 @@
932// Deprecation layer. Same comment as setStretched().940// Deprecation layer. Same comment as setStretched().
933void UCUbuntuShape::setVerticalAlignment(VAlignment verticalAlignment)941void UCUbuntuShape::setVerticalAlignment(VAlignment verticalAlignment)
934{942{
935 if (QuickUtils::showDeprecationWarnings()) {943 static bool loggedOnce = false;
936 qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceVerticalAlignment' instead";944 if (!loggedOnce) {
945 loggedOnce = true;
946 qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceVerticalAlignment' "
947 "instead";
937 }948 }
938949
939 if (!(m_flags & SourceApiSet)) {950 if (!(m_flags & SourceApiSet)) {
@@ -1009,20 +1020,11 @@
1009 updateFromImageProperties(qobject_cast<QQuickItem*>(sender()));1020 updateFromImageProperties(qobject_cast<QQuickItem*>(sender()));
1010}1021}
10111022
1012void UCUbuntuShape::_q_openglContextDestroyed()
1013{
1014 // Delete the shape textures that are stored per context and shared by all the shape items.
1015 const int index = getShapeTexturesIndex(qobject_cast<QOpenGLContext*>(sender()));
1016 Q_ASSERT(index >= 0);
1017 shapeTextures[index].openglContext = NULL;
1018 glDeleteTextures(shapeTextureCount, shapeTextures[index].textureId);
1019}
1020
1021void UCUbuntuShape::_q_gridUnitChanged()1023void UCUbuntuShape::_q_gridUnitChanged()
1022{1024{
1023 const float gridUnit = UCUnits::instance().gridUnit();1025 const float gridUnitInDevicePixels = UCUnits::instance().gridUnit() / qGuiApp->devicePixelRatio();
1024 setImplicitWidth(implicitWidthGU * gridUnit);1026 setImplicitWidth(implicitWidthGU * gridUnitInDevicePixels);
1025 setImplicitHeight(implicitHeightGU * gridUnit);1027 setImplicitHeight(implicitHeightGU * gridUnitInDevicePixels);
1026 update();1028 update();
1027}1029}
10281030
@@ -1170,8 +1172,10 @@
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,
1171 GL_UNSIGNED_BYTE, shapeTextureData[i]);1173 GL_UNSIGNED_BYTE, shapeTextureData[i]);
1172 }1174 }
1173 QObject::connect(openglContext, SIGNAL(aboutToBeDestroyed()), this,1175 connect(openglContext, &QOpenGLContext::aboutToBeDestroyed, [index] {
1174 SLOT(_q_openglContextDestroyed()), Qt::DirectConnection);1176 shapeTextures[index].openglContext = NULL;
1177 glDeleteTextures(shapeTextureCount, shapeTextures[index].textureId);
1178 } );
1175 }1179 }
1176 const quint32 shapeTextureId = shapeTextures[index].textureId[m_aspect != DropShadow ? 0 : 1];1180 const quint32 shapeTextureId = shapeTextures[index].textureId[m_aspect != DropShadow ? 0 : 1];
11771181
@@ -1184,13 +1188,15 @@
1184 sourceTextureRect = sourceTexture->normalizedTextureSubRect();1188 sourceTextureRect = sourceTexture->normalizedTextureSubRect();
1185 }1189 }
1186 if (m_flags & DirtySourceTransform) {1190 if (m_flags & DirtySourceTransform) {
1191 const float dpr = qGuiApp->devicePixelRatio();
1192
1187 if (m_flags & SourceApiSet) {1193 if (m_flags & SourceApiSet) {
1188 updateSourceTransform(itemSize.width(), itemSize.height(), m_sourceFillMode,1194 updateSourceTransform(itemSize.width() * dpr, itemSize.height() * dpr, m_sourceFillMode,
1189 m_sourceHorizontalAlignment, m_sourceVerticalAlignment,1195 m_sourceHorizontalAlignment, m_sourceVerticalAlignment,
1190 sourceTexture->textureSize());1196 sourceTexture->textureSize());
1191 } else {1197 } else {
1192 FillMode imageFillMode = (m_flags & Stretched) ? Stretch : PreserveAspectCrop;1198 FillMode imageFillMode = (m_flags & Stretched) ? Stretch : PreserveAspectCrop;
1193 updateSourceTransform(itemSize.width(), itemSize.height(), imageFillMode,1199 updateSourceTransform(itemSize.width() * dpr, itemSize.height() * dpr, imageFillMode,
1194 m_imageHorizontalAlignment, m_imageVerticalAlignment,1200 m_imageHorizontalAlignment, m_imageVerticalAlignment,
1195 sourceTexture->textureSize());1201 sourceTexture->textureSize());
1196 }1202 }
@@ -1220,13 +1226,15 @@
1220 // accordingly. The shape was using a fixed image for the corner before switching to a1226 // accordingly. The shape was using a fixed image for the corner before switching to a
1221 // distance field, since the corner wasn't taking the whole image (ending at ~80%) we need1227 // distance field, since the corner wasn't taking the whole image (ending at ~80%) we need
1222 // to take that into account when the size is scaled down.1228 // to take that into account when the size is scaled down.
1223 radius = UCUnits::instance().gridUnit() * radiusGuMap[m_radius];1229 radius = UCUnits::instance().gridUnit() * radiusGuMap[m_radius]
1230 / qGuiApp->devicePixelRatio();
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;
1225 if (radius > scaledDownRadius) {1232 if (radius > scaledDownRadius) {
1226 radius = scaledDownRadius;1233 radius = scaledDownRadius;
1227 }1234 }
1228 } else {1235 } else {
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)
1237 / qGuiApp->devicePixelRatio();
1230 }1238 }
12311239
1232 updateMaterial(node, radius, shapeTextureId, sourceTexture && m_sourceOpacity);1240 updateMaterial(node, radius, shapeTextureId, sourceTexture && m_sourceOpacity);
@@ -1306,16 +1314,19 @@
1306 materialData->sourceOpacity = 0;1314 materialData->sourceOpacity = 0;
1307 }1315 }
13081316
1317 const float physicalRadius = radius * qGuiApp->devicePixelRatio();
1318
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.
1310 const float start = 0.0f + radiusSizeOffset;1320 const float start = 0.0f + radiusSizeOffset;
1311 const float end = 4.0f + radiusSizeOffset;1321 const float end = 4.0f + radiusSizeOffset;
1322
1312 materialData->distanceAAFactor =1323 materialData->distanceAAFactor =
1313 qMin((radius / (end - start)) - (start / (end - start)), 1.0f) * 255.0f;1324 qMin((physicalRadius / (end - start)) - (start / (end - start)), 1.0f) * 255.0f;
13141325
1315 // When the radius is equal to radiusSizeOffset (which means radius size is 0), no aspect is1326 // When the radius is equal to radiusSizeOffset (which means radius size is 0), no aspect is
1316 // flagged so that a dedicated (statically flow controlled) shaved off shader can be used for1327 // flagged so that a dedicated (statically flow controlled) shaved off shader can be used for
1317 // optimal performance.1328 // optimal performance.
1318 if (radius > radiusSizeOffset) {1329 if (physicalRadius > radiusSizeOffset) {
1319 const quint8 aspectFlags[] = {1330 const quint8 aspectFlags[] = {
1320 ShapeMaterial::Data::Flat, ShapeMaterial::Data::Inset, ShapeMaterial::Data::DropShadow,1331 ShapeMaterial::Data::Flat, ShapeMaterial::Data::Inset, ShapeMaterial::Data::DropShadow,
1321 ShapeMaterial::Data::Inset | ShapeMaterial::Data::Pressed1332 ShapeMaterial::Data::Inset | ShapeMaterial::Data::Pressed
13221333
=== modified file 'src/Ubuntu/Components/plugin/ucubuntushape.h'
--- src/Ubuntu/Components/plugin/ucubuntushape.h 2015-08-06 13:16:24 +0000
+++ src/Ubuntu/Components/plugin/ucubuntushape.h 2015-09-08 04:09:38 +0000
@@ -296,7 +296,6 @@
296296
297private Q_SLOTS:297private Q_SLOTS:
298 void _q_imagePropertiesChanged();298 void _q_imagePropertiesChanged();
299 void _q_openglContextDestroyed();
300 void _q_gridUnitChanged();299 void _q_gridUnitChanged();
301 void _q_providerDestroyed(QObject* object=0);300 void _q_providerDestroyed(QObject* object=0);
302 void _q_textureChanged();301 void _q_textureChanged();
303302
=== modified file 'src/Ubuntu/Components/plugin/ucunits.cpp'
--- src/Ubuntu/Components/plugin/ucunits.cpp 2015-03-03 13:47:48 +0000
+++ src/Ubuntu/Components/plugin/ucunits.cpp 2015-09-08 04:09:38 +0000
@@ -24,6 +24,8 @@
24#include <QtCore/QDir>24#include <QtCore/QDir>
25#include <QtCore/QRegularExpression>25#include <QtCore/QRegularExpression>
26#include <QtCore/qmath.h>26#include <QtCore/qmath.h>
27#include <QtGui/QGuiApplication>
28#include <QtGui/QScreen>
2729
28#define ENV_GRID_UNIT_PX "GRID_UNIT_PX"30#define ENV_GRID_UNIT_PX "GRID_UNIT_PX"
29#define DEFAULT_GRID_UNIT_PX 831#define DEFAULT_GRID_UNIT_PX 8
@@ -62,10 +64,46 @@
6264
63 \sa {Resolution Independence}65 \sa {Resolution Independence}
64*/66*/
67
68/*
69 * Note on the interaction between GRID_UNIT_PX and QT_DEVICE_PIXEL_RATIO
70 *
71 * In Qt5.4 there is a single means to scale the UI: the QT_DEVICE_PIXEL_RATIO environment
72 * variable. This accepts only integer values, thus allowing a x2 or x3 scaling of any
73 * Qt-based UI, that includes QWidget as well as any QML UI.
74 *
75 * Setting QT_DEVICE_PIXEL_RATIO=2 implies one density-independent pixel corresponds to 2
76 * physical pixels. Developers describe their UI in terms of density-independent pixels.
77 * Qt scales accordingly.
78 *
79 * The Ubuntu UI Toolkit has solved the scaling problem with the GRID_UNIT_PX variable.
80 * It offers more flexibility, but only scales QML applications written to use the UITK
81 * (since it uses this Units class) as it is built on top of QML.
82 *
83 * There are additional areas in Qt where QT_DEVICE_PIXEL_RATIO causes correct scaling which
84 * GRID_UNIT_PX cannot, for example:
85 * 1. cacheBuffer for ListView/GridViews - specified in density-independent pixels
86 * 2. gesture recognition matches what is on screen better, as it is density-independent
87 * pixel aware
88 *
89 * In order to get the best of both worlds, Ubuntu will set both GRID_UNIT_PX and
90 * QT_DEVICE_PIXEL_RATIO. Thus all Qt apps will scale reasonably well, with UITK-based apps
91 * scaling perfectly for any desired scale (i.e. non-integer scales).
92 *
93 * However UITK developers can just use this Units class as usual, and will be almost totally
94 * isolated from Qt's own scaling concept.
95 */
96
65UCUnits::UCUnits(QObject *parent) :97UCUnits::UCUnits(QObject *parent) :
66 QObject(parent)98 QObject(parent),
99 m_devicePixelRatio(qGuiApp->devicePixelRatio())
67{100{
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
102 if (qEnvironmentVariableIsSet(ENV_GRID_UNIT_PX)) {
103 m_gridUnit = getenvFloat(ENV_GRID_UNIT_PX, DEFAULT_GRID_UNIT_PX);
104 } else {
105 m_gridUnit = DEFAULT_GRID_UNIT_PX * m_devicePixelRatio;
106 }
69}107}
70108
71/*!109/*!
@@ -89,14 +127,15 @@
89127
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.
91*/129*/
130// Density-independent pixels (and not physical pixels) because Qt sizes in terms of density-independent pixels.
92float UCUnits::dp(float value)131float UCUnits::dp(float value)
93{132{
94 const float ratio = m_gridUnit / DEFAULT_GRID_UNIT_PX;133 const float ratio = m_gridUnit / DEFAULT_GRID_UNIT_PX;
95 if (value <= 2.0) {134 if (value <= 2.0) {
96 // for values under 2dp, return only multiples of the value135 // for values under 2dp, return only multiples of the value
97 return qRound(value * qFloor(ratio));136 return qRound(value * qFloor(ratio)) / m_devicePixelRatio;
98 } else {137 } else {
99 return qRound(value * ratio);138 return qRound(value * ratio) / m_devicePixelRatio;
100 }139 }
101}140}
102141
@@ -105,9 +144,11 @@
105144
106 Returns the number of pixels \a value grid units correspond to.145 Returns the number of pixels \a value grid units correspond to.
107*/146*/
147// Density-independent pixels (and not physical pixels) because Qt sizes in terms of density-independent pixels.
148
108float UCUnits::gu(float value)149float UCUnits::gu(float value)
109{150{
110 return qRound(value * m_gridUnit);151 return qRound(value * m_gridUnit) / m_devicePixelRatio;
111}152}
112153
113QString UCUnits::resolveResource(const QUrl& url)154QString UCUnits::resolveResource(const QUrl& url)
114155
=== modified file 'src/Ubuntu/Components/plugin/ucunits.h'
--- src/Ubuntu/Components/plugin/ucunits.h 2013-10-18 08:56:39 +0000
+++ src/Ubuntu/Components/plugin/ucunits.h 2015-09-08 04:09:38 +0000
@@ -53,6 +53,7 @@
53 float gridUnitSuffixFromFileName(const QString &fileName);53 float gridUnitSuffixFromFileName(const QString &fileName);
5454
55private:55private:
56 float m_devicePixelRatio;
56 float m_gridUnit;57 float m_gridUnit;
57};58};
5859
5960
=== modified file 'src/Ubuntu/Components/plugin/ucviewitemsattached.cpp'
--- src/Ubuntu/Components/plugin/ucviewitemsattached.cpp 2015-03-17 16:48:59 +0000
+++ src/Ubuntu/Components/plugin/ucviewitemsattached.cpp 2015-09-08 04:09:38 +0000
@@ -104,6 +104,7 @@
104 : QObjectPrivate()104 : QObjectPrivate()
105 , listView(0)105 , listView(0)
106 , dragArea(0)106 , dragArea(0)
107 , expansionFlags(UCViewItemsAttached::Exclusive)
107 , globalDisabled(false)108 , globalDisabled(false)
108 , selectable(false)109 , selectable(false)
109 , draggable(false)110 , draggable(false)
@@ -556,7 +557,7 @@
556 return;557 return;
557 }558 }
558 dragArea = new ListItemDragArea(listView);559 dragArea = new ListItemDragArea(listView);
559 dragArea->init();560 dragArea->init(q_func());
560}561}
561562
562void UCViewItemsAttachedPrivate::leaveDragMode()563void UCViewItemsAttachedPrivate::leaveDragMode()
@@ -611,3 +612,142 @@
611 Q_EMIT q->selectedIndicesChanged();612 Q_EMIT q->selectedIndicesChanged();
612 }613 }
613}614}
615
616
617UCViewItemsAttached13::UCViewItemsAttached13(QObject *owner)
618 : UCViewItemsAttached(owner)
619{
620 d_ptr = UCViewItemsAttachedPrivate::get(this);
621}
622
623UCViewItemsAttached13 *UCViewItemsAttached13::qmlAttachedProperties(QObject *owner)
624{
625 return new UCViewItemsAttached13(owner);
626}
627
628/*!
629 * \qmlattachedproperty list<int> ViewItems::expandedIndices
630 * \since Ubuntu.Components 1.3
631 * The property contains the indexes of the ListItems marked as expanded. The
632 * indexes are model indexes when used in ListView, and child indexes in other
633 * components. The property being writable, initial expansion configuration
634 * can be provided for a view, and provides ability to save the expansion state.
635 * \note If the \l ViewItems::expansionFlags is having \c ViewItems.Exclusive
636 * flags set, only the last item from the list will be considered and set as
637 * expanded.
638 */
639QList<int> UCViewItemsAttached13::expandedIndices() const
640{
641 Q_D(const UCViewItemsAttached);
642 return d->expansionList.keys();
643}
644void UCViewItemsAttached13::setExpandedIndices(QList<int> indices)
645{
646 Q_UNUSED(indices);
647 Q_D(UCViewItemsAttached);
648 d->collapseAll();
649 if (indices.size() > 0) {
650 if (d->expansionFlags & UCViewItemsAttached::Exclusive) {
651 // take only the last one from the list
652 d->expand(indices.last(), QPointer<UCListItem13>(), false);
653 } else {
654 for (int i = 0; i < indices.size(); i++) {
655 d->expand(indices[i], QPointer<UCListItem13>(), false);
656 }
657 }
658 }
659 Q_EMIT expandedIndicesChanged(d->expansionList.keys());
660}
661
662// insert listItem into the expanded indices map
663void UCViewItemsAttachedPrivate::expand(int index, UCListItem13 *listItem, bool emitChangeSignal)
664{
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to status/vote changes: