on xenial help sign in
Purge dash and scopes dependency.
commit64cd6a3f3856acf19f1c69f06be8a4e6059bbff0 authorRodney Dawes <dobey.pwns@gmail.com> dateSat 6 Oct 2018, 14:46 (8 years ago) parent3e105e0
309 files changed+17−37156
CMakeLists.txt−2 data/CMakeLists.txt−9 data/unity8-dash.desktop.in−8 data/unity8-dash.png data/unity8-dash.svg−326 data/unity8-dash.url-dispatcher−6 debian/control+3−18 debian/rules−4 debian/unity-scope-tool.install−2 debian/unity8-common.install−1 debian/unity8-private.install−1 debian/unity8-tests.install−1 debian/unity8.install−4 debian/usr.bin.unity8-dash−21 plugins/CMakeLists.txt−1 plugins/Dash/AudioProgressBar.qml−54 plugins/Dash/CardAttributes.qml−71 plugins/Dash/CardAudioProgress.qml−59 plugins/Dash/CardCreator.js−999 plugins/Dash/CardCreatorCache.qml−40 plugins/Dash/CardSocialActions.qml−94 plugins/Dash/CroppedImageMinimumSourceSize.qml−38 plugins/Dash/DashAudioPlayer.qml−120 plugins/Dash/ScopeStyle.qml−102 plugins/Dash/abstractdashview.cpp−359 plugins/Dash/abstractdashview.h−128 plugins/Dash/graphics/music_progress_bg.png plugins/Dash/horizontaljournal.cpp−239 plugins/Dash/horizontaljournal.h−63 plugins/Dash/listviewwithpageheader.cpp−1396 plugins/Dash/listviewwithpageheader.h−218 plugins/Dash/organicgrid.cpp−259 plugins/Dash/organicgrid.h−91 plugins/Dash/plugin.cpp−70 plugins/Dash/plugin.h−33 plugins/Dash/qmldir−11 plugins/Dash/verticaljournal.cpp−281 plugins/Dash/verticaljournal.h−103 plugins/Unity/CMakeLists.txt−1 plugins/Unity/DashCommunicator/dashcommunicator.cpp−58 plugins/Unity/DashCommunicator/dashcommunicator.h−45 plugins/Unity/DashCommunicator/dashcommunicatorservice.cpp−30 plugins/Unity/DashCommunicator/dashcommunicatorservice.h−38 plugins/Unity/DashCommunicator/dashconnection.cpp−66 plugins/Unity/DashCommunicator/dashconnection.h−37 plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.cpp−35 plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.h−39 plugins/Unity/DashCommunicator/plugin.cpp−32 plugins/Unity/DashCommunicator/plugin.h−34 plugins/Unity/DashCommunicator/qmldir−3 plugins/Unity/Launcher/launchermodel.cpp−5 plugins/Wizard/System.cpp+1−4 qml/CMakeLists.txt−1 qml/Components/Background.qml+1−1 qml/Components/ResponsiveVerticalJournal.qml−81 qml/Dash/CardCarousel.qml−74 qml/Dash/CardGrid.qml−83 qml/Dash/CardHorizontalList.qml−66 qml/Dash/CardTool.qml−274 qml/Dash/CardVerticalJournal.qml−85 qml/Dash/Dash.qml−381 qml/Dash/DashApplication.qml−39 qml/Dash/DashBackground.qml−36 qml/Dash/DashCategoryBase.qml−54 qml/Dash/DashContent.qml−211 qml/Dash/DashContentTabBarStyle.qml−24 qml/Dash/DashNavigation.qml−199 qml/Dash/DashNavigationHeader.qml−73 qml/Dash/DashNavigationList.qml−118 qml/Dash/DashPageHeader.qml−448 qml/Dash/DashRenderer.qml−66 qml/Dash/DashSectionHeader.qml−64 qml/Dash/Filters/FilterExpandableWidget.qml−97 qml/Dash/Filters/FilterOptionSelector.qml−97 qml/Dash/Filters/FilterRangeInput.qml−136 qml/Dash/Filters/FilterValueSlider.qml−87 qml/Dash/Filters/FilterWidget.qml−32 qml/Dash/Filters/FilterWidgetFactory.qml−89 qml/Dash/FiltersPopover.qml−106 qml/Dash/GenericScopeView.qml−797 qml/Dash/PageHeaderExtraPanel.qml−201 qml/Dash/PreviewView.qml−76 qml/Dash/Previews/Preview.qml−145 qml/Dash/Previews/PreviewActionButton.qml−27 qml/Dash/Previews/PreviewActionCombo.qml−79 qml/Dash/Previews/PreviewActions.qml−73 qml/Dash/Previews/PreviewAudioPlayback.qml−152 qml/Dash/Previews/PreviewComment.qml−86 qml/Dash/Previews/PreviewCommentInput.qml−88 qml/Dash/Previews/PreviewExpandable.qml−104 qml/Dash/Previews/PreviewHeader.qml−170 qml/Dash/Previews/PreviewIconActions.qml−88 qml/Dash/Previews/PreviewImageGallery.qml−150 qml/Dash/Previews/PreviewInlineVideo.qml−112 qml/Dash/Previews/PreviewMediaToolbar.qml−57 qml/Dash/Previews/PreviewOverlay.qml−166 qml/Dash/Previews/PreviewProgress.qml−74 qml/Dash/Previews/PreviewRatingDisplay.qml−117 qml/Dash/Previews/PreviewRatingEdit.qml−83 qml/Dash/Previews/PreviewRatingInput.qml−207 qml/Dash/Previews/PreviewRatingSingleDisplay.qml−73 qml/Dash/Previews/PreviewSingleton/PreviewSingleton.qml−22 qml/Dash/Previews/PreviewSingleton/qmldir−1 qml/Dash/Previews/PreviewTable.qml−91 qml/Dash/Previews/PreviewTextSummary.qml−78 qml/Dash/Previews/PreviewVideoPlayback.qml−87 qml/Dash/Previews/PreviewWidget.qml−60 qml/Dash/Previews/PreviewWidgetFactory.qml−101 qml/Dash/Previews/PreviewZoomableImage.qml−103 qml/Dash/PullToRefreshScopeStyle.qml−83 qml/Dash/ScopeListView.qml−28 qml/Dash/ScopeSettings/ScopeSetting.qml−46 qml/Dash/ScopeSettings/ScopeSettingBoolean.qml−63 qml/Dash/ScopeSettings/ScopeSettingList.qml−50 qml/Dash/ScopeSettings/ScopeSettingNumber.qml−21 qml/Dash/ScopeSettings/ScopeSettingString.qml−89 qml/Dash/ScopeSettings/ScopeSettingsWidgetFactory.qml−61 qml/Dash/ScopeSettingsPage.qml−72 qml/Dash/ScopesList.qml−206 qml/Dash/ScopesListCategory.qml−184 qml/Dash/ScopesListCategoryItem.qml−115 qml/Dash/graphics/dark_background.jpg qml/Dash/graphics/header_handlearrow2@27.png qml/Dash/graphics/header_handlearrow@27.png qml/Dash/graphics/icon_clear@20.png qml/Dash/graphics/icon_search_active@20.png qml/Dash/graphics/icon_search_inactive@20.png qml/Dash/graphics/overview_hint@30.png qml/Dash/graphics/pixel.png qml/Dash/graphics/play_button@18.png qml/Dash/graphics/play_button_active@18.png qml/Dash/graphics/play_button_active_big@20.png qml/Dash/graphics/play_button_big@20.png qml/Dash/graphics/rectangular_dropshadow@30.png qml/Dash/graphics/rectangular_dropshadow@30.sci−5 qml/Dash/graphics/tabbarchevron@27.png qml/Dash/graphics/tablet/icon_close_preview@20.png qml/Dash/graphics/tooltip_arrow@27.png qml/ScopeTool.qml−165 qml/Shell.qml−6 qml/Stage/AbstractStage.qml−1 qml/Stage/PhoneStage.qml+5−22 qml/Stage/Stage.qml+1−5 qml/Stage/TabletStage.qml+5−23 qml/Stage/TransformedTabletSpreadDelegate.qml+1−2 src/CMakeLists.txt−2 src/Dash/main.cpp−146 tests/autopilot/unity8/dash.py−247 tests/autopilot/unity8/shell/fixture_setup.py−26 tests/autopilot/unity8/shell/tests/test_helpers.py−74 tests/mocks/Unity/CMakeLists.txt−72 tests/mocks/Unity/DashCommunicator/dashcommunicator.cpp−42 tests/mocks/Unity/DashCommunicator/dashcommunicator.h−39 tests/mocks/Unity/DashCommunicator/dashcommunicatorservice.cpp−46 tests/mocks/Unity/DashCommunicator/dashcommunicatorservice.h−41 tests/mocks/Unity/DashCommunicator/plugin.cpp−31 tests/mocks/Unity/DashCommunicator/plugin.h−34 tests/mocks/Unity/DashCommunicator/qmldir−3 tests/mocks/Unity/fake_categories.cpp−165 tests/mocks/Unity/fake_categories.h−54 tests/mocks/Unity/fake_expandablefilterwidget.cpp−53 tests/mocks/Unity/fake_expandablefilterwidget.h−48 tests/mocks/Unity/fake_filters.cpp−136 tests/mocks/Unity/fake_filters.h−46 tests/mocks/Unity/fake_navigation.cpp−123 tests/mocks/Unity/fake_navigation.h−61 tests/mocks/Unity/fake_optionselectorfilter.cpp−70 tests/mocks/Unity/fake_optionselectorfilter.h−54 tests/mocks/Unity/fake_optionselectoroptions.cpp−90 tests/mocks/Unity/fake_optionselectoroptions.h−49 tests/mocks/Unity/fake_previewmodel.cpp−103 tests/mocks/Unity/fake_previewmodel.h−58 tests/mocks/Unity/fake_previewwidgetmodel.cpp−97 tests/mocks/Unity/fake_previewwidgetmodel.h−47 tests/mocks/Unity/fake_rangeinputfilter.cpp−167 tests/mocks/Unity/fake_rangeinputfilter.h−79 tests/mocks/Unity/fake_resultsmodel.cpp−92 tests/mocks/Unity/fake_resultsmodel.h−52 tests/mocks/Unity/fake_scope.cpp−372 tests/mocks/Unity/fake_scope.h−128 tests/mocks/Unity/fake_scopes.cpp−286 tests/mocks/Unity/fake_scopes.h−83 tests/mocks/Unity/fake_scopesoverview.cpp−340 tests/mocks/Unity/fake_scopesoverview.h−119 tests/mocks/Unity/fake_settingsmodel.cpp−95 tests/mocks/Unity/fake_settingsmodel.h−54 tests/mocks/Unity/fake_unity_plugin.cpp−62 tests/mocks/Unity/fake_unity_plugin.h−34 tests/mocks/Unity/fake_valuesliderfilter.cpp−84 tests/mocks/Unity/fake_valuesliderfilter.h−55 tests/mocks/Unity/fake_valueslidervalues.cpp−51 tests/mocks/Unity/fake_valueslidervalues.h−36 tests/mocks/Unity/qmldir−3 tests/plugins/CMakeLists.txt−1 tests/plugins/Dash/cardcreator/1.res−82 tests/plugins/Dash/cardcreator/1.res.cardcreator−69 tests/plugins/Dash/cardcreator/1.tst−4 tests/plugins/Dash/cardcreator/10.res−129 tests/plugins/Dash/cardcreator/10.res.cardcreator−127 tests/plugins/Dash/cardcreator/10.tst−4 tests/plugins/Dash/cardcreator/11.res−176 tests/plugins/Dash/cardcreator/11.res.cardcreator−160 tests/plugins/Dash/cardcreator/11.tst−4 tests/plugins/Dash/cardcreator/12.res−108 tests/plugins/Dash/cardcreator/12.res.cardcreator−95 tests/plugins/Dash/cardcreator/12.tst−4 tests/plugins/Dash/cardcreator/2.res−128 tests/plugins/Dash/cardcreator/2.res.cardcreator−126 tests/plugins/Dash/cardcreator/2.tst−4 tests/plugins/Dash/cardcreator/3.res−90 tests/plugins/Dash/cardcreator/3.res.cardcreator−86 tests/plugins/Dash/cardcreator/3.tst−4 tests/plugins/Dash/cardcreator/4.res−111 tests/plugins/Dash/cardcreator/4.res.cardcreator−99 tests/plugins/Dash/cardcreator/4.tst−4 tests/plugins/Dash/cardcreator/5.res−102 tests/plugins/Dash/cardcreator/5.res.cardcreator−99 tests/plugins/Dash/cardcreator/5.tst−4 tests/plugins/Dash/cardcreator/6.res−127 tests/plugins/Dash/cardcreator/6.res.cardcreator−116 tests/plugins/Dash/cardcreator/6.tst−4 tests/plugins/Dash/cardcreator/7.res−141 tests/plugins/Dash/cardcreator/7.res.cardcreator−139 tests/plugins/Dash/cardcreator/7.tst−4 tests/plugins/Dash/cardcreator/8.res−109 tests/plugins/Dash/cardcreator/8.res.cardcreator−97 tests/plugins/Dash/cardcreator/8.tst−4 tests/plugins/Dash/cardcreator/9.res−120 tests/plugins/Dash/cardcreator/9.res.cardcreator−109 tests/plugins/Dash/cardcreator/9.tst−4 tests/plugins/Dash/cardcreatortest.cpp−126 tests/plugins/Dash/cardcreatortest.qml−29 tests/plugins/Dash/horizontaljournaltest.cpp−490 tests/plugins/Dash/horizontaljournaltest.qml−44 tests/plugins/Dash/horizontaljournaltry.cpp−91 tests/plugins/Dash/horizontaljournaltry.qml−120 tests/plugins/Dash/listviewwithpageheadersectionexternalmodeltest.cpp−246 tests/plugins/Dash/listviewwithpageheadersectiontest.cpp−2212 tests/plugins/Dash/listviewwithpageheadertest.cpp−2038 tests/plugins/Dash/listviewwithpageheadertest.qml−96 tests/plugins/Dash/listviewwithpageheadertestsection.qml−119 tests/plugins/Dash/listviewwithpageheadertestsectionexternalmodel.qml−76 tests/plugins/Dash/organicgridtest.cpp−533 tests/plugins/Dash/organicgridtest.qml−44 tests/plugins/Dash/organicgridtry.cpp−99 tests/plugins/Dash/organicgridtry.qml−114 tests/plugins/Dash/tst_CardAttributes.qml−57 tests/plugins/Dash/tst_CroppedImageMinimumSourceSize.qml−56 tests/plugins/Dash/tst_ListViewWithPageHeaderQML.qml−140 tests/plugins/Dash/tst_ScopeStyle.qml−188 tests/plugins/Dash/verticaljournaltest.cpp−564 tests/plugins/Dash/verticaljournaltest.qml−45 tests/plugins/Dash/verticaljournaltry.cpp−91 tests/plugins/Dash/verticaljournaltry.qml−121 tests/qmltests/CMakeLists.txt−46 tests/qmltests/Components/tst_ResponsiveVerticalJournal.qml−183 tests/qmltests/Dash/CardHelpers.js−115 tests/qmltests/Dash/Filters/tst_FilterExpandableWidget.qml−99 tests/qmltests/Dash/Filters/tst_FilterOptionSelector.qml−96 tests/qmltests/Dash/Filters/tst_FilterRangeInput.qml−247 tests/qmltests/Dash/Filters/tst_FilterValueSlider.qml−101 tests/qmltests/Dash/Filters/tst_FilterWidgetFactory.qml−59 tests/qmltests/Dash/Previews/MockPreviewWidget.qml−27 tests/qmltests/Dash/Previews/tst_Preview.qml−214 tests/qmltests/Dash/Previews/tst_PreviewActions.qml−262 tests/qmltests/Dash/Previews/tst_PreviewAudioPlayback.qml−182 tests/qmltests/Dash/Previews/tst_PreviewComment.qml−84 tests/qmltests/Dash/Previews/tst_PreviewCommentInput.qml−113 tests/qmltests/Dash/Previews/tst_PreviewExpandable.qml−353 tests/qmltests/Dash/Previews/tst_PreviewHeader.qml−183 tests/qmltests/Dash/Previews/tst_PreviewIconActions.qml−136 tests/qmltests/Dash/Previews/tst_PreviewImageGallery.qml−147 tests/qmltests/Dash/Previews/tst_PreviewInlineVideo.qml−155 tests/qmltests/Dash/Previews/tst_PreviewMediaToolbar.qml−69 tests/qmltests/Dash/Previews/tst_PreviewProgress.qml−100 tests/qmltests/Dash/Previews/tst_PreviewRatingDisplay.qml−123 tests/qmltests/Dash/Previews/tst_PreviewRatingDisplayCreationRanges.qml−131 tests/qmltests/Dash/Previews/tst_PreviewRatingEdit.qml−87 tests/qmltests/Dash/Previews/tst_PreviewRatingInput.qml−246 tests/qmltests/Dash/Previews/tst_PreviewTable.qml−147 tests/qmltests/Dash/Previews/tst_PreviewTextSummary.qml−87 tests/qmltests/Dash/Previews/tst_PreviewVideoPlayback.qml−61 tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml−104 tests/qmltests/Dash/Previews/tst_PreviewZoomableImage.qml−138 tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingBoolean.qml−62 tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingList.qml−84 tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingNumber.qml−98 tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingString.qml−88 tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingsWidgetFactory.qml−65 tests/qmltests/Dash/artwork/avatar@12.png tests/qmltests/Dash/artwork/background.png tests/qmltests/Dash/artwork/checkers.png tests/qmltests/Dash/artwork/emblem.png tests/qmltests/Dash/artwork/music-player-design.png tests/qmltests/Dash/tst_Card.qml−682 tests/qmltests/Dash/tst_CardBenchmark.qml−95 tests/qmltests/Dash/tst_CardCarousel.qml−111 tests/qmltests/Dash/tst_CardTool.qml−379 tests/qmltests/Dash/tst_Dash.qml−648 tests/qmltests/Dash/tst_DashContent.qml−730 tests/qmltests/Dash/tst_DashPageHeader.qml−357 tests/qmltests/Dash/tst_DashShell.qml−84 tests/qmltests/Dash/tst_GenericScopeView.qml−706 tests/qmltests/Dash/tst_PageHeader/logo-ubuntu-orange.svg−60 tests/qmltests/Dash/tst_PreviewView.qml−122 tools/CMakeLists.txt−1 tools/scopetool/registry-tracker.cpp−146 tools/scopetool/registry-tracker.h−49 tools/scopetool/scopetool.cpp−116
CMakeLists.txt−2
@@ -145,8 +145,6 @@ include(autopilot)
145145declare_autopilot_test(shell unity8.shell ${CMAKE_SOURCE_DIR}/tests/autopilot/)
146146
147147set(SHELL_APP unity8)
148−set(DASH_APP unity8-dash)
149−set(SCOPE_TOOL unity-scope-tool)
150148set(INDICATORS_CLIENT_APP indicators-client)
151149set(GREETER_APP unity8-greeter)
152150set(MOCK_INDICATOR_SERVICE_APP unity-mock-indicator-service)
data/CMakeLists.txt−9
@@ -1,13 +1,11 @@
11# generate desktop files
22configure_file(${SHELL_APP}.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/${SHELL_APP}.desktop @ONLY)
3−configure_file(${DASH_APP}.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/${DASH_APP}.desktop @ONLY)
43configure_file(${INDICATORS_CLIENT_APP}.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/${INDICATORS_CLIENT_APP}.desktop @ONLY)
54configure_file(${GREETER_APP}.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/${GREETER_APP}.desktop @ONLY)
65
76# install desktop files
87install(FILES
98 ${CMAKE_CURRENT_BINARY_DIR}/${SHELL_APP}.desktop
10− ${CMAKE_CURRENT_BINARY_DIR}/${DASH_APP}.desktop
119 ${CMAKE_CURRENT_BINARY_DIR}/${INDICATORS_CLIENT_APP}.desktop
1210 DESTINATION ${CMAKE_INSTALL_DATADIR}/applications
1311 )
@@ -22,15 +20,8 @@ install(FILES
2220 DESTINATION ${CMAKE_INSTALL_DATADIR}/lightdm/lightdm.conf.d
2321 )
2422
25−# install dash icon
26−install(FILES
27− ${CMAKE_CURRENT_SOURCE_DIR}/${DASH_APP}.png
28− DESTINATION ${SHELL_APP_DIR}/Dash/
29− )
30−
3123add_custom_target(pkgversion ALL COMMAND dpkg-parsechangelog -l${CMAKE_SOURCE_DIR}/debian/changelog --show-field version > ${CMAKE_CURRENT_BINARY_DIR}/version)
3224
3325install(FILES com.canonical.Unity8.gschema.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas)
3426install(FILES com.canonical.Unity.gschema.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas)
35−install(FILES unity8-dash.url-dispatcher DESTINATION ${CMAKE_INSTALL_DATADIR}/url-dispatcher/urls)
3627install(FILES ${CMAKE_CURRENT_BINARY_DIR}/version DESTINATION ${CMAKE_INSTALL_LOCALSTATEDIR}/lib/unity8)
data/unity8-dash.desktop.indeleted−8
@@ -1,8 +0,0 @@
1−[Desktop Entry]
2−Type=Application
3−Name=Scopes
4−Comment=An interface for using the Scopes system
5−Exec=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/unity8-dash
6−Terminal=false
7−Icon=@CMAKE_INSTALL_PREFIX@/@SHELL_APP_DIR@/Dash/unity8-dash.png
8−X-Ubuntu-Touch=true
data/unity8-dash.pngdeleted

Binary file not shown.

data/unity8-dash.svgdeleted−326
@@ -1,326 +0,0 @@
1−<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2−<!-- Created with Inkscape (http://www.inkscape.org/) -->
3−
4−<svg
5− xmlns:dc="http://purl.org/dc/elements/1.1/"
6− xmlns:cc="http://creativecommons.org/ns#"
7− xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
8− xmlns:svg="http://www.w3.org/2000/svg"
9− xmlns="http://www.w3.org/2000/svg"
10− xmlns:xlink="http://www.w3.org/1999/xlink"
11− xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
12− xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
13− viewBox="0 0 512 512"
14− style="enable-background:new"
15− inkscape:export-ydpi="180"
16− inkscape:export-xdpi="180"
17− inkscape:export-filename="app_shape02.png"
18− sodipodi:docname="apps-scope.svg"
19− inkscape:version="0.91+devel r"
20− version="1.1"
21− id="svg3336"
22− height="512"
23− width="512">
24− <sodipodi:namedview
25− inkscape:snap-global="false"
26− fit-margin-bottom="18"
27− fit-margin-right="0"
28− fit-margin-left="0"
29− fit-margin-top="18"
30− inkscape:snap-grids="true"
31− inkscape:guide-bbox="true"
32− showguides="false"
33− inkscape:snap-center="true"
34− inkscape:snap-object-midpoints="true"
35− inkscape:snap-midpoints="true"
36− inkscape:snap-smooth-nodes="true"
37− inkscape:snap-intersection-paths="true"
38− inkscape:object-nodes="true"
39− inkscape:object-paths="true"
40− inkscape:snap-bbox-midpoints="true"
41− inkscape:snap-bbox-edge-midpoints="true"
42− inkscape:bbox-nodes="true"
43− inkscape:bbox-paths="true"
44− inkscape:snap-bbox="true"
45− showborder="true"
46− inkscape:showpageshadow="false"
47− inkscape:snap-page="true"
48− inkscape:window-maximized="1"
49− inkscape:window-y="24"
50− inkscape:window-x="0"
51− inkscape:window-height="1029"
52− inkscape:window-width="1920"
53− showgrid="false"
54− inkscape:current-layer="layer3"
55− inkscape:document-units="px"
56− inkscape:cy="204.04409"
57− inkscape:cx="-384.5809"
58− inkscape:zoom="0.64"
59− inkscape:pageshadow="2"
60− inkscape:pageopacity="0"
61− borderopacity="1.0"
62− bordercolor="#666666"
63− pagecolor="#4f4f4f"
64− id="base">
65− <inkscape:grid
66− type="xygrid"
67− id="grid811"
68− originx="0"
69− originy="15.999999"
70− visible="true"
71− enabled="true" />
72− <sodipodi:guide
73− orientation="1,0"
74− position="104,176"
75− id="guide819" />
76− <sodipodi:guide
77− orientation="1,0"
78− position="120,160"
79− id="guide821" />
80− <sodipodi:guide
81− orientation="1,0"
82− position="392,144"
83− id="guide823" />
84− <sodipodi:guide
85− orientation="1,0"
86− position="408,144"
87− id="guide825" />
88− <sodipodi:guide
89− orientation="0,1"
90− position="328,408"
91− id="guide827" />
92− <sodipodi:guide
93− orientation="0,1"
94− position="336,392"
95− id="guide829" />
96− <sodipodi:guide
97− orientation="0,1"
98− position="176,120"
99− id="guide831" />
100− <sodipodi:guide
101− orientation="0,1"
102− position="216,104"
103− id="guide833" />
104− <inkscape:grid
105− type="axonomgrid"
106− id="grid835"
107− units="px"
108− empspacing="60"
109− gridanglex="42.9"
110− gridanglez="42.9"
111− spacingy="3.522px"
112− enabled="false"
113− originx="0"
114− originy="16.999996" />
115− <sodipodi:guide
116− orientation="0,1"
117− position="344,376"
118− id="guide4126" />
119− <sodipodi:guide
120− orientation="0,1"
121− position="160,136"
122− id="guide4128" />
123− <sodipodi:guide
124− orientation="1,0"
125− position="136,96"
126− id="guide4130" />
127− <sodipodi:guide
128− orientation="1,0"
129− position="376,136"
130− id="guide4134" />
131− <sodipodi:guide
132− orientation="-0.70710678,0.70710678"
133− position="544,544"
134− id="guide4136" />
135− <sodipodi:guide
136− orientation="1,0"
137− position="256,-32.000001"
138− id="guide4138" />
139− <sodipodi:guide
140− orientation="0,1"
141− position="544,256"
142− id="guide4140" />
143− <sodipodi:guide
144− orientation="0.70710678,0.70710678"
145− position="544,-32.000001"
146− id="guide4142" />
147− <sodipodi:guide
148− orientation="0,1"
149− position="248,15.999999"
150− id="guide4152" />
151− <sodipodi:guide
152− orientation="0,1"
153− position="336,496"
154− id="guide4154" />
155− <sodipodi:guide
156− position="344,96"
157− orientation="1,0"
158− id="guide4361" />
159− <sodipodi:guide
160− position="576,168"
161− orientation="0,1"
162− id="guide4363" />
163− <sodipodi:guide
164− position="168,192"
165− orientation="1,0"
166− id="guide4229" />
167− <sodipodi:guide
168− position="312,344"
169− orientation="0,1"
170− id="guide4233" />
171− <sodipodi:guide
172− position="180.48,-96"
173− orientation="0,1"
174− id="guide4235" />
175− </sodipodi:namedview>
176− <defs
177− id="defs3338">
178− <linearGradient
179− inkscape:collect="always"
180− id="linearGradient4203">
181− <stop
182− style="stop-color:#ea5420;stop-opacity:1"
183− offset="0"
184− id="stop4205" />
185− <stop
186− style="stop-color:#f37e40;stop-opacity:1"
187− offset="1"
188− id="stop4207" />
189− </linearGradient>
190− <clipPath
191− clipPathUnits="userSpaceOnUse"
192− id="clipPath4755">
193− <path
194− style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.24899998;fill:#5e2c73;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
195− d="M 360,50 594,284 V 215.89844 C 594,70.73665 573.2426,50 427.94531,50 Z"
196− id="path4757"
197− inkscape:connector-curvature="0" />
198− </clipPath>
199− <clipPath
200− clipPathUnits="userSpaceOnUse"
201− id="clipPath4767">
202− <path
203− style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:#f6f6f6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
204− d="M 543.8125,454.1875 312.18945,685.81055 367.94531,681 C 512.70468,668.50896 526.55393,654.72881 539,510.10156 Z"
205− id="path4769"
206− inkscape:connector-curvature="0" />
207− </clipPath>
208− <linearGradient
209− inkscape:collect="always"
210− xlink:href="#linearGradient4203"
211− id="linearGradient4209"
212− x1="167.5"
213− y1="17.25"
214− x2="343.25"
215− y2="491"
216− gradientUnits="userSpaceOnUse" />
217− <filter
218− inkscape:collect="always"
219− style="color-interpolation-filters:sRGB"
220− id="filter4220"
221− x="-0.012"
222− width="1.024"
223− y="-0.012"
224− height="1.024">
225− <feGaussianBlur
226− inkscape:collect="always"
227− stdDeviation="1.4390401"
228− id="feGaussianBlur4222" />
229− </filter>
230− <linearGradient
231− inkscape:collect="always"
232− xlink:href="#linearGradient4226"
233− id="linearGradient4232"
234− x1="255.99998"
235− y1="-255.99998"
236− x2="405.35773"
237− y2="-255.99998"
238− gradientUnits="userSpaceOnUse"
239− spreadMethod="reflect" />
240− <linearGradient
241− inkscape:collect="always"
242− id="linearGradient4226">
243− <stop
244− style="stop-color:#a73812;stop-opacity:1"
245− offset="0"
246− id="stop4228" />
247− <stop
248− style="stop-color:#973310;stop-opacity:0"
249− offset="1"
250− id="stop4230" />
251− </linearGradient>
252− <filter
253− inkscape:collect="always"
254− style="color-interpolation-filters:sRGB"
255− id="filter4234"
256− x="-0.096000001"
257− width="1.192"
258− y="-0.096000001"
259− height="1.192">
260− <feGaussianBlur
261− inkscape:collect="always"
262− stdDeviation="11.512321"
263− id="feGaussianBlur4236" />
264− </filter>
265− </defs>
266− <metadata
267− id="metadata3341">
268− <rdf:RDF>
269− <cc:Work
270− rdf:about="">
271− <dc:format>image/svg+xml</dc:format>
272− <dc:type
273− rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
274− <dc:title></dc:title>
275− </cc:Work>
276− </rdf:RDF>
277− </metadata>
278− <g
279− inkscape:groupmode="layer"
280− id="layer3"
281− inkscape:label="Background">
282− <path
283− style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:url(#linearGradient4209);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:accumulate"
284− d="M 0 0 L 0 183.89844 L 0 328.10156 L 0 512 L 512 512 L 512 328.10156 L 512 183.89844 L 512 0 L 0 0 z "
285− id="rect4158" />
286− <path
287− style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:8;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
288− d="M 0 256 L 0 328.10156 L 0 462.53516 C 0 479.69677 0.052846476 496.03174 0.13085938 512 L 511.86914 512 C 511.94715 496.03174 512 479.69677 512 462.53516 L 512 256 L 0 256 z "
289− id="rect4286" />
290− </g>
291− <g
292− inkscape:groupmode="layer"
293− id="layer1"
294− inkscape:label="Pictogram"
295− style="display:inline"
296− transform="translate(-32,-32)">
297− <circle
298− style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.4;fill:#d04616;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:7.99999952;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;filter:url(#filter4220);enable-background:accumulate"
299− id="circle4218"
300− cx="258"
301− cy="-256"
302− r="143.90401"
303− transform="rotate(90,-7.1132638e-7,31.999996)" />
304− <circle
305− transform="rotate(90,-7.1132638e-7,31.999996)"
306− r="143.90401"
307− cy="-256"
308− cx="258"
309− id="circle4224"
310− style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:url(#linearGradient4232);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:7.99999952;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;filter:url(#filter4234);enable-background:accumulate" />
311− <circle
312− transform="rotate(90)"
313− r="143.90401"
314− cy="-288"
315− cx="288"
316− id="circle4206"
317− style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:7.99999952;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" />
318− <path
319− style="display:inline;fill:#ea5420;fill-opacity:1;stroke-width:2.9398191;enable-background:new"
320− id="path4258"
321− d="m 193.9963,269.54024 c -10.19878,0 -18.46137,8.2634 -18.46137,18.46139 0,10.19309 8.26259,18.45568 18.46137,18.45568 10.19311,0 18.45569,-8.26259 18.45569,-18.45568 0,-10.19799 -8.26258,-18.46139 -18.45569,-18.46139 z m 131.78525,83.88906 c -8.82832,5.09898 -11.85536,16.38129 -6.75557,25.20475 5.0933,8.82834 16.37561,11.85455 25.20393,6.75556 8.82752,-5.0933 11.85457,-16.37561 6.75559,-25.20475 -5.0933,-8.82263 -16.38212,-11.84887 -25.20395,-6.75556 z m -91.69319,-65.42767 c 0,-18.24028 9.05999,-34.35498 22.92309,-44.11321 l -13.49406,-22.6012 c -16.14883,10.79461 -28.16435,27.28971 -33.15766,46.60863 5.82648,4.75434 9.55584,11.99194 9.55584,20.10497 0,8.10813 -3.72936,15.34572 -9.55584,20.10006 4.98681,19.32463 17.00232,35.82055 33.15766,46.61514 l 13.49406,-22.60689 c -13.8631,-9.75253 -22.92309,-25.86641 -22.92309,-44.1075 z m 53.91207,-53.91776 c 28.16514,0 51.27274,21.59491 53.69828,49.13495 l 26.30048,-0.38772 c -1.29405,-20.33173 -10.17604,-38.58421 -23.82372,-52.00594 -7.01814,2.65149 -15.12464,2.2459 -22.13139,-1.79314 -7.01894,-4.0504 -11.41969,-10.88319 -12.62271,-18.30044 -6.8214,-1.88254 -14.00046,-2.91323 -21.42257,-2.91323 -12.75925,0 -24.82271,2.99695 -35.53359,8.29836 l 12.82509,22.98243 c 6.89944,-3.21075 14.5963,-5.01526 22.71013,-5.01526 z m 0,107.82982 c -8.11383,0 -15.81069,-1.80533 -22.70931,-5.01528 l -12.82511,22.98163 c 10.71088,5.3079 22.77434,8.30568 35.53442,8.30568 7.42211,0 14.60118,-1.0315 21.42177,-2.91975 1.20301,-7.41724 5.60537,-14.24352 12.6227,-18.30125 7.01161,-4.04555 15.11326,-4.44382 22.13137,-1.79232 13.64769,-13.42174 22.52968,-31.67421 23.82372,-52.00595 l -26.30696,-0.38772 c -2.41986,27.54738 -25.52665,49.13496 -53.6926,49.13496 z m 37.77461,-119.35113 c 8.82834,5.09818 20.11145,2.07845 25.20475,-6.74987 5.099,-8.82833 2.07928,-20.11145 -6.74988,-25.21126 -8.82832,-5.0933 -20.11063,-2.06705 -25.21125,6.76127 -5.09247,8.82345 -2.06625,20.10657 6.75638,25.19986 z"
322− inkscape:connector-curvature="0"
323− inkscape:transform-center-x="16.232534"
324− inkscape:transform-center-y="-0.0024900663" />
325− </g>
326−</svg>
data/unity8-dash.url-dispatcherdeleted−6
@@ -1,6 +0,0 @@
1−[
2− {
3− "protocol": "scope"
4− }
5−]
6−
debian/control+3−18
@@ -105,19 +105,6 @@ Provides: lightdm-greeter
105105Description: The Unity8 Greeter
106106 The Unity 8 greeter is the primary login greeter for Ubuntu devices.
107107
108−Package: unity-scope-tool
109−Architecture: any
110−Depends: unity8-common (= ${source:Version}),
111− unity8-private (= ${binary:Version}),
112− ${misc:Depends},
113− ${shlibs:Depends},
114−# We do call pkg-config libunity-scopes from the code
115− pkg-config,
116− libunity-scopes-dev,
117−Description: Development tool for Unity scopes
118− This package contains the development tool for new generation Unity scopes, based
119− on Unity8.
120−
121108Package: unity8
122109Architecture: any
123110Provides: indicator-renderer,
@@ -145,13 +132,14 @@ Depends: dmz-cursor-theme,
145132Recommends: indicator-keyboard,
146133 indicator-session,
147134 unity-greeter-session-broadcast,
148−Suggests: unity-scope-mediascanner2,
149135Breaks: indicator-network (<< 0.5.1+14.10.20141014),
150136 ubuntu-touch-session (<< 0.107),
151137 unity8-greeter (<< 7.89),
138+ unity-scope-tool,
152139 ubuntu-keyboard (<< 0.100),
153140Replaces: ubuntu-touch-session (<< 0.82~),
154141 unity8-greeter (<< 7.89),
142+ unity-scope-tool,
155143Conflicts: ubuntu-system-settings-wizard,
156144Description: Unity 8 shell
157145 The Unity 8 shell is the primary user interface for Ubuntu devices.
@@ -167,8 +155,6 @@ Depends: qml-module-qtquick-layouts,
167155 ubuntu-thumbnailer-impl-0,
168156 unity-application-impl-27,
169157 unity-notifications-impl-3,
170− unity-plugin-scopes | unity-scopes-impl,
171− unity-scopes-impl-12,
172158 unity8-tests | unity-application-impl,
173159 unity8-schemas,
174160 ${misc:Depends},
@@ -177,8 +163,7 @@ Replaces: unity8 (<< 7.86),
177163Description: Unity 8 shell (common files)
178164 The Unity 8 shell is the primary user interface for Ubuntu devices.
179165 .
180− This package contains the QML, graphics and locale files shared between
181− unity8 and unity-scope-tool.
166+ This package contains the QML, graphics and locale files for unity8.
182167
183168Package: unity8-autopilot
184169Architecture: all
debian/rules−4
@@ -29,10 +29,6 @@ override_dh_install:
2929 cd $(CURDIR)
3030 dh_install -X'*.pyc' --fail-missing
3131
32−override_dh_installdeb:
33− dh_apparmor --profile-name=usr.bin.unity8-dash -punity8-dash
34− dh_installdeb
35−
3632# use private lib directories
3733override_dh_makeshlibs:
3834 dh_makeshlibs -Nunity8-private -Nunity8-tests
debian/unity-scope-tool.installdeleted−2
@@ -1,2 +0,0 @@
1−usr/bin/unity-scope-tool
2−usr/share/unity8/ScopeTool.qml
debian/unity8-common.install−1
@@ -1,6 +1,5 @@
11usr/share/locale
22usr/share/unity8/Components
3−usr/share/unity8/Dash
43usr/share/unity8/Notifications
54usr/share/unity8/graphics
65var/lib/polkit-1/localauthority/10-vendor.d
debian/unity8-private.install−1
@@ -1,7 +1,6 @@
11usr/lib/*/libunity8-private.*
22usr/lib/*/unity8/qml/AccountsService
33usr/lib/*/unity8/qml/Cursor
4−usr/lib/*/unity8/qml/Dash
54usr/lib/*/unity8/qml/GlobalShortcut
65usr/lib/*/unity8/qml/Greeter
76usr/lib/*/unity8/qml/ImageCache
debian/unity8-tests.install−1
@@ -2,7 +2,6 @@ data/unity-mock-indicator-service.conf usr/share/upstart/sessions/
22usr/bin/unity-mock-indicator-service
33usr/lib/*/unity8/qml/mocks
44usr/lib/*/unity8/qml/nonmirplugins
5−usr/lib/*/unity8/qml/scopefakes
65usr/lib/*/unity8/tests
76usr/lib/*/unity8/uqmlscene
87usr/share/unity8/mocks
debian/unity8.install−4
@@ -1,12 +1,9 @@
1−debian/usr.bin.unity8-dash etc/apparmor.d
21var/lib/unity8/version
32data/unity8-filewatcher.conf usr/share/upstart/sessions/
43data/unity8.conf usr/share/upstart/sessions/
54data/devices.conf etc/ubuntu/
65data/test.sensors etc/ubuntusensors/
76usr/bin/unity8
8−usr/bin/unity8-dash
9−usr/share/applications/unity8-dash.desktop
107usr/share/applications/unity8.desktop
118usr/share/unity8/ApplicationMenus
129usr/share/unity8/Greeter
@@ -20,4 +17,3 @@ usr/share/unity8/Shell.qml
2017usr/share/unity8/Stage
2118usr/share/unity8/Tutorial
2219usr/share/unity8/Wizard
23−usr/share/url-dispatcher/urls/unity8-dash.url-dispatcher
debian/usr.bin.unity8-dashdeleted−21
@@ -1,21 +0,0 @@
1−# vim:syntax=apparmor
2−
3−#include <tunables/global>
4−
5−# v2 compatible wildly permissive profile
6−profile unity8-dash /usr/bin/unity8-dash (attach_disconnected) {
7− capability,
8− network,
9− / rwkl,
10− /** rwlkm,
11− /** pix,
12−
13− mount,
14− remount,
15− umount,
16− pivot_root,
17− dbus,
18− signal,
19− ptrace,
20− unix,
21−}
plugins/CMakeLists.txt−1
@@ -18,7 +18,6 @@ add_subdirectory(Greeter)
1818add_subdirectory(ImageCache)
1919add_subdirectory(LightDM)
2020add_subdirectory(Lights)
21−add_subdirectory(Dash)
2221add_subdirectory(Powerd)
2322add_subdirectory(ScreenshotDirectory)
2423add_subdirectory(SessionBroadcast)
plugins/Dash/AudioProgressBar.qmldeleted−54
@@ -1,54 +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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Dash 0.1
20−
21−Item {
22− id: root
23−
24− implicitHeight: progressBarImage.height
25−
26− property url source
27− readonly property double progress: AudioUrlComparer.compare(source, DashAudioPlayer.currentSource) ? DashAudioPlayer.progress : 0
28−
29− Image {
30− id: progressBarImage
31− anchors { left: parent.left; right: parent.right }
32− height: units.dp(6)
33− source: "graphics/music_progress_bg.png"
34− asynchronous: true
35− sourceSize.width: width
36− sourceSize.height: height
37− }
38−
39− UbuntuShape {
40− id: progressBarFill
41− objectName: "progressBarFill"
42−
43− readonly property int maxWidth: progressBarImage.width
44−
45− anchors {
46− left: progressBarImage.left
47− right: progressBarImage.right
48− verticalCenter: progressBarImage.verticalCenter
49− rightMargin: maxWidth - (maxWidth * root.progress)
50− }
51− height: units.dp(2)
52− backgroundColor: theme.palette.normal.activity
53− }
54−}
plugins/Dash/CardAttributes.qmldeleted−71
@@ -1,71 +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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import QtQuick.Layouts 1.1
19−import Ubuntu.Components 1.3
20−
21−GridLayout {
22− id: grid
23− anchors {
24− left: parent.left;
25− right: parent.right;
26− }
27− columns: 2 + repeater.count % 2
28− rowSpacing: units.gu(.5)
29− property alias model: repeater.model
30− property color color: theme.palette.normal.baseText
31− property real fontScale: 1.0
32−
33− Repeater {
34− id: repeater
35− delegate: Row {
36− spacing: units.gu(0.5)
37− readonly property int column: index % grid.columns;
38− Layout.alignment: {
39− if (column == 0) return Qt.AlignLeft;
40− if (column == grid.columns - 1 || index == repeater.count - 1) return Qt.AlignRight;
41− if (column == 1) return Qt.AlignHCenter;
42− }
43− Layout.column: index % grid.columns
44− Layout.row: index / grid.columns
45− Layout.columnSpan: index == repeater.count - 1 && grid.columns == 3 && column == 1 ? 2 : 1
46− Layout.maximumWidth: Math.max(icon.width, label.x + label.implicitWidth)
47− Layout.fillWidth: true
48− height: units.gu(2)
49− Icon {
50− id: icon
51− height: units.gu(2)
52− // FIXME Workaround for bug https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1421293
53− width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth
54− source: "icon" in modelData && modelData["icon"] || ""
55− color: grid.color
56− }
57− Label {
58− id: label
59− width: parent.width - x
60− anchors.verticalCenter: parent.verticalCenter
61− text: "value" in modelData && modelData["value"] || "";
62− elide: Text.ElideRight
63− maximumLineCount: 1
64− font.weight: "style" in modelData && modelData["style"] === "highlighted" ? Font.Bold : Font.Light
65− fontSize: "x-small"
66− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale)
67− color: grid.color
68− }
69− }
70− }
71−}
plugins/Dash/CardAudioProgress.qmldeleted−59
@@ -1,59 +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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Dash 0.1
20−
21−Item {
22− id: root
23−
24− implicitHeight: positionLabel.y + positionLabel.height
25− visible: AudioUrlComparer.compare(source, DashAudioPlayer.currentSource)
26−
27− property int duration: 0
28− property alias source: progress.source
29− property color color: theme.palette.normal.baseText
30− readonly property int position: root.visible ? DashAudioPlayer.position / 1000 : 0
31−
32− AudioProgressBar {
33− id: progress
34− anchors { left: parent.left; right: parent.right }
35− }
36−
37− Label {
38− id: positionLabel
39− anchors {
40− left: parent.left
41− top: progress.bottom
42− }
43− verticalAlignment: Text.AlignBottom
44− fontSize: "x-small"
45− text: DashAudioPlayer.lengthToString(root.position)
46− color: root.color
47− }
48−
49− Label {
50− anchors {
51− right: parent.right
52− top: progress.bottom
53− }
54− verticalAlignment: Text.AlignBottom
55− fontSize: "x-small"
56− text: DashAudioPlayer.lengthToString(duration)
57− color: root.color
58− }
59−}
plugins/Dash/CardCreator.jsdeleted−999
@@ -1,999 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−.pragma library
18−
19−// %1 is the template["card-background"]["elements"][0]
20−// %2 is the template["card-background"]["elements"][1]
21−// %3 is whether the loader should be asynchronous or not
22−// %4 is the template["card-background"] string
23−var kBackgroundLoaderCode = 'Loader {\n\
24− id: backgroundLoader; \n\
25− objectName: "backgroundLoader"; \n\
26− anchors.fill: parent; \n\
27− asynchronous: %3; \n\
28− visible: status === Loader.Ready; \n\
29− sourceComponent: UbuntuShape { \n\
30− objectName: "background"; \n\
31− radius: "small"; \n\
32− aspect: { \n\
33− switch (root.backgroundShapeStyle) { \n\
34− case "inset": return UbuntuShape.Inset; \n\
35− case "shadow": return UbuntuShape.DropShadow; \n\
36− default: \n\
37− case "flat": return UbuntuShape.Flat; \n\
38− } \n\
39− } \n\
40− backgroundColor: getColor(0) || "white"; \n\
41− secondaryBackgroundColor: getColor(1) || backgroundColor; \n\
42− backgroundMode: UbuntuShape.VerticalGradient; \n\
43− anchors.fill: parent; \n\
44− source: backgroundImage.source ? backgroundImage : null; \n\
45− property real luminance: Style.luminance(backgroundColor); \n\
46− property Image backgroundImage: Image { \n\
47− objectName: "backgroundImage"; \n\
48− source: { \n\
49− if (cardData && typeof cardData["background"] === "string") return cardData["background"]; \n\
50− else return %4; \n\
51− } \n\
52− } \n\
53− function getColor(index) { \n\
54− if (cardData && typeof cardData["background"] === "object" \n\
55− && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { \n\
56− return cardData["background"]["elements"][index]; \n\
57− } else return index === 0 ? %1 : %2; \n\
58− } \n\
59− } \n\
60− }\n';
61−
62−// %1 is the aspect of the UbuntuShape
63−var kArtUbuntuShapeCode = 'UbuntuShape { \n\
64− anchors.fill: parent; \n\
65− source: artImage; \n\
66− sourceFillMode: UbuntuShape.PreserveAspectCrop; \n\
67− radius: "small"; \n\
68− aspect: %1; \n\
69− }';
70−
71−var kArtProportionalShapeCode = 'ProportionalShape { \n\
72− anchors.left: parent.left; \n\
73− anchors.right: parent.right; \n\
74− source: artImage; \n\
75− aspect: UbuntuShape.DropShadow; \n\
76− }';
77−
78−// %1 is used as anchors of artShapeLoader
79−// %2 is used as image width
80−// %3 is used as image height
81−// %4 is whether the image should be visible
82−// %5 is whether the loader should be asynchronous or not
83−// %6 is the shape code we want to use
84−// %7 is injected as code to artImage
85−// %8 is used as image fallback
86−var kArtShapeHolderCode = 'Loader { \n\
87− id: artShapeLoader; \n\
88− height: root.fixedArtShapeSize.height; \n\
89− width: root.fixedArtShapeSize.width; \n\
90− anchors { %1 } \n\
91− objectName: "artShapeLoader"; \n\
92− readonly property string cardArt: cardData && cardData["art"] || %8; \n\
93− onCardArtChanged: { if (item) { item.image.source = cardArt; } } \n\
94− active: cardArt != ""; \n\
95− asynchronous: %5; \n\
96− visible: status === Loader.Ready; \n\
97− sourceComponent: Item { \n\
98− id: artShape; \n\
99− objectName: "artShape"; \n\
100− visible: image.status === Image.Ready; \n\
101− readonly property alias image: artImage; \n\
102− %6 \n\
103− width: root.fixedArtShapeSize.width; \n\
104− height: root.fixedArtShapeSize.height; \n\
105− CroppedImageMinimumSourceSize { \n\
106− id: artImage; \n\
107− objectName: "artImage"; \n\
108− source: artShapeLoader.cardArt; \n\
109− asynchronous: %5; \n\
110− visible: %4; \n\
111− width: %2; \n\
112− height: %3; \n\
113− %7 \n\
114− } \n\
115− } \n\
116− }\n';
117−
118−// %1 is used as anchors of artShapeLoader
119−// %2 is used as image width
120−// %3 is used as image height
121−// %4 is whether the image should be visible
122−// %5 is whether the loader should be asynchronous or not
123−// %6 is the shape code we want to use
124−// %7 is injected as code to artImage
125−// %8 is used as image fallback
126−var kArtShapeHolderCodeCardToolCard = 'Loader { \n\
127− id: artShapeLoader; \n\
128− anchors { %1 } \n\
129− objectName: "artShapeLoader"; \n\
130− readonly property string cardArt: cardData && cardData["art"] || %8; \n\
131− onCardArtChanged: { if (item) { item.image.source = cardArt; } } \n\
132− active: cardArt != ""; \n\
133− asynchronous: %5; \n\
134− visible: status === Loader.Ready; \n\
135− sourceComponent: Item { \n\
136− id: artShape; \n\
137− objectName: "artShape"; \n\
138− visible: image.status === Image.Ready; \n\
139− readonly property alias image: artImage; \n\
140− %6 \n\
141− width: image.status !== Image.Ready ? 0 : image.width; \n\
142− height: image.status !== Image.Ready ? 0 : image.height; \n\
143− CroppedImageMinimumSourceSize { \n\
144− id: artImage; \n\
145− objectName: "artImage"; \n\
146− source: artShapeLoader.cardArt; \n\
147− asynchronous: %5; \n\
148− visible: %4; \n\
149− width: %2; \n\
150− height: %3; \n\
151− %7 \n\
152− } \n\
153− } \n\
154− }\n';
155−
156−// %1 is anchors.fill
157−// %2 is width
158−// %3 is height
159−// %4 is whether the icon should be asynchronous or not
160−var kAudioButtonCode = 'AbstractButton { \n\
161− id: audioButton; \n\
162− anchors.fill: %1; \n\
163− width: %2; \n\
164− height: %3; \n\
165− readonly property url source: (cardData["quickPreviewData"] && cardData["quickPreviewData"]["uri"]) || ""; \n\
166− UbuntuShape { \n\
167− anchors.fill: parent; \n\
168− visible: parent.pressed; \n\
169− radius: "small"; \n\
170− } \n\
171− Rectangle { \n\
172− color: Qt.rgba(0, 0, 0, 0.5); \n\
173− anchors.centerIn: parent; \n\
174− width: parent.width * 0.5; \n\
175− height: width; \n\
176− radius: width / 2; \n\
177− } \n\
178− Icon { \n\
179− anchors.centerIn: parent; \n\
180− width: parent.width * 0.3; \n\
181− height: width; \n\
182− opacity: 0.9; \n\
183− name: DashAudioPlayer.playing && AudioUrlComparer.compare(parent.source, DashAudioPlayer.currentSource) ? "media-playback-pause" : "media-playback-start"; \n\
184− color: "white"; \n\
185− asynchronous: %4; \n\
186− } \n\
187− onClicked: { \n\
188− if (AudioUrlComparer.compare(source, DashAudioPlayer.currentSource)) { \n\
189− if (DashAudioPlayer.playing) { \n\
190− DashAudioPlayer.pause(); \n\
191− } else { \n\
192− DashAudioPlayer.play(); \n\
193− } \n\
194− } else { \n\
195− var playlist = (cardData["quickPreviewData"] && cardData["quickPreviewData"]["playlist"]) || null; \n\
196− DashAudioPlayer.playSource(source, playlist); \n\
197− } \n\
198− } \n\
199− onPressAndHold: { \n\
200− root.pressAndHold(); \n\
201− } \n\
202− }';
203−
204−// %1 is whether the loader should be asynchronous or not
205−// %2 is the header height code
206−var kOverlayLoaderCode = 'Loader { \n\
207− id: overlayLoader; \n\
208− readonly property real overlayHeight: %2 + units.gu(2); \n\
209− anchors.fill: artShapeLoader; \n\
210− active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false; \n\
211− asynchronous: %1; \n\
212− visible: showHeader && status === Loader.Ready; \n\
213− sourceComponent: UbuntuShapeOverlay { \n\
214− id: overlay; \n\
215− property real luminance: Style.luminance(overlayColor); \n\
216− aspect: UbuntuShape.Flat; \n\
217− radius: "small"; \n\
218− overlayColor: cardData && cardData["overlayColor"] || "#99000000"; \n\
219− overlayRect: Qt.rect(0, 1 - overlayLoader.overlayHeight / height, 1, 1); \n\
220− } \n\
221− }\n';
222−
223−// multiple row version of HeaderRowCode
224−function kHeaderRowCodeGenerator() {
225− var kHeaderRowCodeTemplate = 'Row { \n\
226− id: row; \n\
227− objectName: "outerRow"; \n\
228− property real margins: units.gu(1); \n\
229− spacing: margins; \n\
230− %2\
231− anchors { %1 } \n\
232− anchors.right: parent.right; \n\
233− anchors.margins: margins; \n\
234− anchors.rightMargin: 0; \n\
235− data: [ \n\
236− %3 \n\
237− ] \n\
238− }\n';
239− var args = Array.prototype.slice.call(arguments);
240− var isCardTool = args.shift();
241− var heightCode = isCardTool ? "" : "height: root.fixedHeaderHeight; \n";
242− var code = kHeaderRowCodeTemplate.arg(args.shift()).arg(heightCode).arg(args.join(',\n'));
243− return code;
244−}
245−
246−// multiple item version of kHeaderContainerCode
247−function kHeaderContainerCodeGenerator() {
248− var headerContainerCodeTemplate = 'Item { \n\
249− id: headerTitleContainer; \n\
250− anchors { %1 } \n\
251− width: parent.width - x; \n\
252− implicitHeight: %2; \n\
253− data: [ \n\
254− %3 \n\
255− ]\n\
256− }\n';
257− var args = Array.prototype.slice.call(arguments);
258− var code = headerContainerCodeTemplate.arg(args.shift()).arg(args.shift()).arg(args.join(',\n'));
259− return code;
260−}
261−
262−// %1 is used as anchors of mascotShapeLoader
263−// %2 is whether the loader should be asynchronous or not
264−var kMascotShapeLoaderCode = 'Loader { \n\
265− id: mascotShapeLoader; \n\
266− objectName: "mascotShapeLoader"; \n\
267− asynchronous: %2; \n\
268− active: mascotImage.status === Image.Ready; \n\
269− visible: showHeader && active && status === Loader.Ready; \n\
270− width: units.gu(6); \n\
271− height: units.gu(5.625); \n\
272− sourceComponent: UbuntuShape { aspect: UbuntuShape.Flat; image: mascotImage } \n\
273− anchors { %1 } \n\
274− }\n';
275−
276−// %1 is used as anchors of mascotImage
277−// %2 is used as visible of mascotImage
278−// %3 is injected as code to mascotImage
279−// %4 is used as fallback image
280−var kMascotImageCode = 'CroppedImageMinimumSourceSize { \n\
281− id: mascotImage; \n\
282− objectName: "mascotImage"; \n\
283− anchors { %1 } \n\
284− source: cardData && cardData["mascot"] || %4; \n\
285− width: units.gu(6); \n\
286− height: units.gu(5.625); \n\
287− horizontalAlignment: Image.AlignHCenter; \n\
288− verticalAlignment: Image.AlignVCenter; \n\
289− visible: %2; \n\
290− %3 \n\
291− }\n';
292−
293−// %1 is used as anchors of titleLabel
294−// %2 is used as color of titleLabel
295−// %3 is used as extra condition for visible of titleLabel
296−// %4 is used as title width
297−// %5 is used as horizontal alignment
298−var kTitleLabelCode = 'Label { \n\
299− id: titleLabel; \n\
300− objectName: "titleLabel"; \n\
301− anchors { %1 } \n\
302− elide: Text.ElideRight; \n\
303− fontSize: "small"; \n\
304− wrapMode: Text.Wrap; \n\
305− maximumLineCount: 2; \n\
306− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\
307− color: %2; \n\
308− visible: showHeader %3; \n\
309− width: %4; \n\
310− text: root.title; \n\
311− font.weight: Font.Normal; \n\
312− horizontalAlignment: %5; \n\
313− }\n';
314−
315−// %1 is used as extra anchors of emblemIcon
316−// %2 is used as color of emblemIcon
317−// FIXME The width code is a
318−// Workaround for bug https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1421293
319−var kEmblemIconCode = 'Icon { \n\
320− id: emblemIcon; \n\
321− objectName: "emblemIcon"; \n\
322− anchors { \n\
323− bottom: titleLabel.baseline; \n\
324− right: parent.right; \n\
325− %1 \n\
326− } \n\
327− source: cardData && cardData["emblem"] || ""; \n\
328− color: %2; \n\
329− height: source != "" ? titleLabel.font.pixelSize : 0; \n\
330− width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth; \n\
331− }\n';
332−
333−// %1 is used as anchors of touchdown effect
334−var kTouchdownCode = 'Loader { \n\
335− active: root.pressed; \n\
336− anchors { %1 } \n\
337− sourceComponent: UbuntuShape { \n\
338− objectName: "touchdown"; \n\
339− anchors.fill: parent; \n\
340− radius: "small"; \n\
341− borderSource: "radius_pressed.sci" \n\
342− } \n\
343− }\n';
344−
345−// %1 is used as anchors of subtitleLabel
346−// %2 is used as color of subtitleLabel
347−var kSubtitleLabelCode = 'Label { \n\
348− id: subtitleLabel; \n\
349− objectName: "subtitleLabel"; \n\
350− anchors { %1 } \n\
351− anchors.topMargin: units.dp(2); \n\
352− elide: Text.ElideRight; \n\
353− maximumLineCount: 1; \n\
354− fontSize: "x-small"; \n\
355− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\
356− color: %2; \n\
357− visible: titleLabel.visible && titleLabel.text; \n\
358− text: cardData && cardData["subtitle"] || ""; \n\
359− font.weight: Font.Light; \n\
360− }\n';
361−
362−// %1 is used as anchors of attributesRow
363−// %2 is used as color of attributesRow
364−var kAttributesRowCode = 'CardAttributes { \n\
365− id: attributesRow; \n\
366− objectName: "attributesRow"; \n\
367− anchors { %1 } \n\
368− color: %2; \n\
369− fontScale: root.fontScale; \n\
370− model: cardData && cardData["attributes"]; \n\
371− }\n';
372−
373−// %1 is used as anchors of socialActionsRow
374−// %2 is used as color of socialActionsRow
375−var kSocialActionsRowCode = 'CardSocialActions { \n\
376− id: socialActionsRow; \n\
377− objectName: "socialActionsRow"; \n\
378− anchors { %1 } \n\
379− color: %2; \n\
380− model: cardData && cardData["socialActions"]; \n\
381− onClicked: root.action(actionId); \n\
382− }\n';
383−
384−// %1 is used as top anchor of summary
385−// %2 is used as topMargin anchor of summary
386−// %3 is used as color of summary
387−var kSummaryLabelCode = 'Label { \n\
388− id: summary; \n\
389− objectName: "summaryLabel"; \n\
390− anchors { \n\
391− top: %1; \n\
392− left: parent.left; \n\
393− right: parent.right; \n\
394− margins: units.gu(1); \n\
395− topMargin: %2; \n\
396− } \n\
397− wrapMode: Text.Wrap; \n\
398− maximumLineCount: 5; \n\
399− elide: Text.ElideRight; \n\
400− text: cardData && cardData["summary"] || ""; \n\
401− height: text ? implicitHeight : 0; \n\
402− fontSize: "x-small"; \n\
403− font.weight: Font.Light; \n\
404− color: %3; \n\
405− }\n';
406−
407−// %1 is used as bottom anchor of audio progress bar
408−// %2 is used as left anchor of audio progress bar
409−// %3 is used as text color
410−var kAudioProgressBarCode = 'CardAudioProgress { \n\
411− id: audioProgressBar; \n\
412− duration: (cardData["quickPreviewData"] && cardData["quickPreviewData"]["duration"]) || 0; \n\
413− source: (cardData["quickPreviewData"] && cardData["quickPreviewData"]["uri"]) || ""; \n\
414− anchors { \n\
415− bottom: %1; \n\
416− left: %2; \n\
417− right: parent.right; \n\
418− margins: units.gu(1); \n\
419− } \n\
420− color: %3; \n\
421− }';
422−
423−function sanitizeColor(colorString) {
424− if (colorString !== undefined) {
425− if (colorString.match(/^[#a-z0-9]*$/i) === null) {
426− // This is not the perfect regexp for color
427− // but what we're trying to do here is just protect
428− // against injection so it's ok
429− return "";
430− }
431− }
432− return colorString;
433−}
434−
435−function cardString(template, components, isCardTool, artShapeStyle, categoryLayout) {
436− var code;
437−
438− var templateInteractive = (template == null ? true : (template["non-interactive"] !== undefined ? !template["non-interactive"] : true)) ? "true" : "false";
439−
440− code = 'AbstractButton { \n\
441− id: root; \n\
442− property var cardData; \n\
443− property string backgroundShapeStyle: "flat"; \n\
444− property real fontScale: 1.0; \n\
445− property var scopeStyle: null; \n\
446− readonly property string title: cardData && cardData["title"] || ""; \n\
447− property bool showHeader: true; \n\
448− implicitWidth: childrenRect.width; \n\
449− enabled: %1; \n\
450− \n'.arg(templateInteractive);
451−
452− if (!isCardTool) {
453− code += "property int fixedHeaderHeight: -1; \n\
454− property size fixedArtShapeSize: Qt.size(-1, -1); \n";
455− }
456−
457− var hasArt = components["art"] && components["art"]["field"] || false;
458− var hasSummary = components["summary"] || false;
459− var isConciergeMode = components["art"] && components["art"]["conciergeMode"] || false;
460− var artAndSummary = hasArt && hasSummary && !isConciergeMode;
461− var isHorizontal = template["card-layout"] === "horizontal";
462− var hasBackground = (!isHorizontal && (template["card-background"] || components["background"] || artAndSummary)) ||
463− (hasSummary && (template["card-background"] || components["background"]));
464− var hasTitle = components["title"] || false;
465− var hasMascot = components["mascot"] || false;
466− var hasEmblem = components["emblem"] && !(hasMascot && template["card-size"] === "small") || false;
467− var headerAsOverlay = hasArt && template && template["overlay"] === true && (hasTitle || hasMascot);
468− var hasSubtitle = hasTitle && components["subtitle"] || false;
469− var hasHeaderRow = hasMascot && hasTitle;
470− var hasAttributes = hasTitle && components["attributes"] && components["attributes"]["field"] || false;
471− var hasSocialActions = hasTitle && components["social-actions"] || false;
472− var isAudio = template["quick-preview-type"] === "audio";
473− var asynchronous = isCardTool ? "false" : "true";
474−
475− code += 'signal action(var actionId);\n';
476− if (isAudio) {
477− // For now we only support audio cards with [optional] art, title, subtitle
478− // in horizontal mode
479− // Anything else makes it behave not like an audio card
480− if (hasSummary) isAudio = false;
481− if (!isHorizontal) isAudio = false;
482− if (hasMascot) isAudio = false;
483− if (hasEmblem) isAudio = false;
484− if (headerAsOverlay) isAudio = false;
485− if (hasAttributes) isAudio = false;
486− }
487−
488− if (hasBackground) {
489− var templateCardBackground;
490− if (template && typeof template["card-background"] === "string") {
491− templateCardBackground = 'decodeURI("' + encodeURI(template["card-background"]) + '")';
492− } else {
493− templateCardBackground = '""';
494− }
495−
496− var backgroundElements0;
497− var backgroundElements1;
498− if (template && typeof template["card-background"] === "object" && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) {
499− var element0 = sanitizeColor(template["card-background"]["elements"][0]);
500− var element1 = sanitizeColor(template["card-background"]["elements"][1]);
501− if (element0 !== undefined) {
502− backgroundElements0 = '"%1"'.arg(element0);
503− }
504− if (element1 !== undefined) {
505− backgroundElements1 = '"%1"'.arg(element1);
506− }
507− }
508− code += kBackgroundLoaderCode.arg(backgroundElements0).arg(backgroundElements1).arg(asynchronous).arg(templateCardBackground);
509− }
510−
511− if (hasArt) {
512− var artShapeAspect;
513− if (isCardTool) {
514− code += 'readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);\n';
515−
516− var artShapeAspect = components["art"] && components["art"]["aspect-ratio"] || 1;
517− if (isNaN(artShapeAspect)) {
518− artShapeAspect = 1;
519− }
520− } else {
521− artShapeAspect = "(root.fixedArtShapeSize.width / root.fixedArtShapeSize.height)";
522− }
523−
524− var widthCode, heightCode;
525− var artAnchors;
526− if (isHorizontal) {
527− artAnchors = 'left: parent.left';
528− if (hasMascot || hasTitle) {
529− widthCode = 'height * ' + artShapeAspect;
530− heightCode = 'headerHeight + 2 * units.gu(1)';
531− } else {
532− // This side of the else is a bit silly, who wants an horizontal layout without mascot and title?
533− // So we define a "random" height of the image height + 2 gu for the margins
534− widthCode = 'height * ' + artShapeAspect
535− heightCode = 'units.gu(7.625)';
536− }
537− } else {
538− artAnchors = 'horizontalCenter: parent.horizontalCenter;';
539− widthCode = 'root.width'
540− heightCode = 'width / ' + artShapeAspect;
541− }
542−
543− var fallback = !isCardTool && components["art"] && components["art"]["fallback"] || "";
544− fallback = encodeURI(fallback);
545− var fallbackStatusCode = "";
546− var fallbackURICode = '""';
547− if (fallback !== "") {
548− // fallbackStatusCode has %8 in it because we want to substitute it for fallbackURICode
549− // which in kArtShapeHolderCode is %8
550− fallbackStatusCode += 'onStatusChanged: if (status === Image.Error) source = %8;';
551− fallbackURICode = 'decodeURI("%1")'.arg(fallback);
552− }
553− var artShapeHolderShapeCode;
554− if (!isConciergeMode) {
555− if (artShapeStyle === "icon") {
556− artShapeHolderShapeCode = kArtProportionalShapeCode;
557− } else {
558− var artShapeHolderShapeAspect;
559− switch (artShapeStyle) {
560− case "inset": artShapeHolderShapeAspect = "UbuntuShape.Inset"; break;
561− case "shadow": artShapeHolderShapeAspect = "UbuntuShape.DropShadow"; break;
562− default:
563− case "flat": artShapeHolderShapeAspect = "UbuntuShape.Flat"; break;
564− }
565− artShapeHolderShapeCode = kArtUbuntuShapeCode.arg(artShapeHolderShapeAspect);
566− }
567− } else {
568− artShapeHolderShapeCode = "";
569− }
570− var artShapeHolderCode = isCardTool ? kArtShapeHolderCodeCardToolCard : kArtShapeHolderCode;
571− code += artShapeHolderCode.arg(artAnchors)
572− .arg(widthCode)
573− .arg(heightCode)
574− .arg(isConciergeMode ? "true" : "false")
575− .arg(asynchronous)
576− .arg(artShapeHolderShapeCode)
577− .arg(fallbackStatusCode)
578− .arg(fallbackURICode);
579− } else if (isCardTool) {
580− code += 'readonly property size artShapeSize: Qt.size(-1, -1);\n'
581− }
582−
583− if (headerAsOverlay) {
584− var headerHeightCode = isCardTool ? "headerHeight" : "root.fixedHeaderHeight";
585− code += kOverlayLoaderCode.arg(asynchronous).arg(headerHeightCode);
586− }
587−
588− var headerVerticalAnchors;
589− if (headerAsOverlay) {
590− headerVerticalAnchors = 'bottom: artShapeLoader.bottom; \n\
591− bottomMargin: units.gu(1);\n';
592− } else {
593− if (hasArt) {
594− if (isHorizontal) {
595− headerVerticalAnchors = 'top: artShapeLoader.top; \n\
596− topMargin: units.gu(1);\n';
597− } else {
598− headerVerticalAnchors = 'top: artShapeLoader.bottom; \n\
599− topMargin: units.gu(1);\n';
600− }
601− } else {
602− headerVerticalAnchors = 'top: parent.top; \n\
603− topMargin: units.gu(1);\n';
604− }
605− }
606−
607− var headerLeftAnchor;
608− var headerLeftAnchorHasMargin = false;
609− if (isHorizontal && hasArt) {
610− headerLeftAnchor = 'left: artShapeLoader.right; \n\
611− leftMargin: units.gu(1);\n';
612− headerLeftAnchorHasMargin = true;
613− } else if (isHorizontal && isAudio) {
614− headerLeftAnchor = 'left: audioButton.right; \n\
615− leftMargin: units.gu(1);\n';
616− headerLeftAnchorHasMargin = true;
617− } else {
618− headerLeftAnchor = 'left: parent.left;\n';
619− }
620−
621− var touchdownOnArtShape = !hasBackground && hasArt && !hasMascot && !hasSummary && !isAudio;
622−
623− if (hasHeaderRow) {
624− code += 'readonly property int headerHeight: row.height;\n'
625− } else if (hasMascot) {
626− code += 'readonly property int headerHeight: mascotImage.height;\n'
627− } else if (hasAttributes) {
628− if (hasTitle && hasSubtitle) {
629− code += 'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin + attributesRow.height + attributesRow.anchors.topMargin;\n'
630− } else if (hasTitle) {
631− code += 'readonly property int headerHeight: titleLabel.height + attributesRow.height + attributesRow.anchors.topMargin;\n'
632− } else {
633− code += 'readonly property int headerHeight: attributesRow.height;\n'
634− }
635− } else if (isAudio) {
636− if (hasSubtitle) {
637− code += 'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin + audioProgressBar.height + audioProgressBar.anchors.topMargin;\n'
638− } else if (hasTitle) {
639− code += 'readonly property int headerHeight: titleLabel.height + audioProgressBar.height + audioProgressBar.anchors.topMargin;\n'
640− } else {
641− code += 'readonly property int headerHeight: audioProgressBar.height;\n'
642− }
643− } else if (hasSubtitle) {
644− code += 'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;\n'
645− } else if (hasTitle) {
646− code += 'readonly property int headerHeight: titleLabel.height;\n'
647− } else {
648− code += 'readonly property int headerHeight: 0;\n'
649− }
650−
651− var mascotShapeCode = '';
652− var mascotCode = '';
653− if (hasMascot) {
654− var useMascotShape = !hasBackground && !headerAsOverlay;
655− var mascotAnchors = '';
656− if (!hasHeaderRow) {
657− mascotAnchors += headerLeftAnchor;
658− mascotAnchors += headerVerticalAnchors;
659− if (!headerLeftAnchorHasMargin) {
660− mascotAnchors += 'leftMargin: units.gu(1);\n'
661− }
662− } else {
663− mascotAnchors = 'verticalCenter: parent.verticalCenter;'
664− }
665−
666− if (useMascotShape) {
667− mascotShapeCode = kMascotShapeLoaderCode.arg(mascotAnchors).arg(asynchronous);
668− }
669−
670− var mascotImageVisible = useMascotShape ? 'false' : 'showHeader';
671− var fallback = !isCardTool && components["mascot"] && components["mascot"]["fallback"] || "";
672− fallback = encodeURI(fallback);
673− var fallbackStatusCode = "";
674− var fallbackURICode = '""';
675− if (fallback !== "") {
676− // fallbackStatusCode has %4 in it because we want to substitute it for fallbackURICode
677− // which in kMascotImageCode is %4
678− fallbackStatusCode += 'onStatusChanged: if (status === Image.Error) source = %4;';
679− fallbackURICode = 'decodeURI("%1")'.arg(fallback);
680− }
681− mascotCode = kMascotImageCode.arg(mascotAnchors).arg(mascotImageVisible).arg(fallbackStatusCode).arg(fallbackURICode);
682− }
683−
684− var summaryColorWithBackground = 'backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white")';
685−
686− var hasTitleContainer = hasTitle && (hasEmblem || (hasMascot && (hasSubtitle || hasAttributes)));
687− var titleSubtitleCode = '';
688− if (hasTitle) {
689− var titleColor;
690− if (headerAsOverlay) {
691− titleColor = 'root.scopeStyle && overlayLoader.item ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item && overlayLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white")';
692− } else if (hasSummary) {
693− titleColor = 'summary.color';
694− } else if (hasBackground) {
695− titleColor = summaryColorWithBackground;
696− } else {
697− titleColor = 'root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText';
698− }
699−
700− var titleAnchors;
701− var subtitleAnchors;
702− var attributesAnchors;
703− var titleContainerAnchors;
704− var titleRightAnchor;
705− var titleWidth = "undefined";
706−
707− var extraRightAnchor = '';
708− var extraLeftAnchor = '';
709− if (!touchdownOnArtShape) {
710− extraRightAnchor = 'rightMargin: units.gu(1); \n';
711− extraLeftAnchor = 'leftMargin: units.gu(1); \n';
712− } else if (headerAsOverlay && !hasEmblem) {
713− extraRightAnchor = 'rightMargin: units.gu(1); \n';
714− }
715−
716− if (hasMascot) {
717− titleContainerAnchors = 'verticalCenter: parent.verticalCenter; ';
718− } else {
719− titleContainerAnchors = 'right: parent.right; ';
720− titleContainerAnchors += headerLeftAnchor;
721− titleContainerAnchors += headerVerticalAnchors;
722− if (!headerLeftAnchorHasMargin) {
723− titleContainerAnchors += extraLeftAnchor;
724− }
725− }
726− if (hasEmblem) {
727− titleRightAnchor = 'right: emblemIcon.left; \n\
728− rightMargin: emblemIcon.width > 0 ? units.gu(0.5) : 0; \n';
729− } else {
730− titleRightAnchor = 'right: parent.right; \n'
731− titleRightAnchor += extraRightAnchor;
732− }
733−
734− if (hasTitleContainer) {
735− // Using headerTitleContainer
736− titleAnchors = titleRightAnchor;
737− titleAnchors += 'left: parent.left; \n\
738− top: parent.top;';
739− subtitleAnchors = 'right: parent.right; \n\
740− left: parent.left; \n';
741− subtitleAnchors += extraRightAnchor;
742− if (hasSubtitle) {
743− attributesAnchors = subtitleAnchors + 'top: subtitleLabel.bottom;\n';
744− subtitleAnchors += 'top: titleLabel.bottom;\n';
745− } else {
746− attributesAnchors = subtitleAnchors + 'top: titleLabel.bottom;\n';
747− }
748− } else if (hasMascot) {
749− // Using row without titleContainer
750− titleAnchors = 'verticalCenter: parent.verticalCenter;\n';
751− titleWidth = "parent.width - x";
752− } else {
753− if (headerAsOverlay) {
754− // Using anchors to the overlay
755− titleAnchors = titleRightAnchor;
756− titleAnchors += 'left: parent.left; \n\
757− leftMargin: units.gu(1); \n\
758− top: overlayLoader.top; \n\
759− topMargin: units.gu(1) + overlayLoader.height - overlayLoader.overlayHeight; \n';
760− } else {
761− // Using anchors to the mascot/parent
762− titleAnchors = titleRightAnchor;
763− titleAnchors += headerLeftAnchor;
764− titleAnchors += headerVerticalAnchors;
765− if (!headerLeftAnchorHasMargin) {
766− titleAnchors += extraLeftAnchor;
767− }
768− }
769− subtitleAnchors = 'left: titleLabel.left; \n\
770− leftMargin: titleLabel.leftMargin; \n';
771− subtitleAnchors += extraRightAnchor;
772− if (hasEmblem) {
773− // using container
774− subtitleAnchors += 'right: parent.right; \n';
775− } else {
776− subtitleAnchors += 'right: titleLabel.right; \n';
777− }
778−
779− if (hasSubtitle) {
780− attributesAnchors = subtitleAnchors + 'top: subtitleLabel.bottom;\n';
781− subtitleAnchors += 'top: titleLabel.bottom;\n';
782− } else {
783− attributesAnchors = subtitleAnchors + 'top: titleLabel.bottom;\n';
784− }
785− }
786−
787− var titleAlignment = "Text.AlignHCenter";
788− if (template["card-layout"] === "horizontal"
789− || typeof components["title"] !== "object"
790− || components["title"]["align"] === "left") titleAlignment = "Text.AlignLeft";
791− var keys = ["mascot", "emblem", "subtitle", "attributes", "summary"];
792− for (var key in keys) {
793− key = keys[key];
794− try {
795− if (typeof components[key] === "string"
796− || typeof components[key]["field"] === "string") titleAlignment = "Text.AlignLeft";
797− } catch (e) {
798− continue;
799− }
800− }
801−
802− // code for different elements
803− var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');
804− var titleCode = kTitleLabelCode.arg(titleAnchors).arg(titleColor).arg(titleLabelVisibleExtra).arg(titleWidth).arg(titleAlignment);
805− var subtitleCode;
806− var attributesCode;
807−
808− // code for the title container
809− var containerCode = [];
810− var containerHeight = 'titleLabel.height';
811− containerCode.push(titleCode);
812− if (hasSubtitle) {
813− subtitleCode = kSubtitleLabelCode.arg(subtitleAnchors).arg(titleColor);
814− containerCode.push(subtitleCode);
815− containerHeight += ' + subtitleLabel.height';
816− }
817− if (hasEmblem) {
818− containerCode.push(kEmblemIconCode.arg(extraRightAnchor).arg(titleColor));
819− }
820− if (hasAttributes) {
821− attributesCode = kAttributesRowCode.arg(attributesAnchors).arg(titleColor);
822− containerCode.push(attributesCode);
823− containerHeight += ' + attributesRow.height';
824− }
825−
826− if (hasTitleContainer) {
827− // use container
828− titleSubtitleCode = kHeaderContainerCodeGenerator(titleContainerAnchors, containerHeight, containerCode);
829− } else {
830− // no container
831− titleSubtitleCode = titleCode;
832− if (hasSubtitle) {
833− titleSubtitleCode += subtitleCode;
834− }
835− if (hasAttributes) {
836− titleSubtitleCode += attributesCode;
837− }
838− }
839− }
840−
841− if (hasHeaderRow) {
842− var rowCode = [mascotCode, titleSubtitleCode];
843− if (mascotShapeCode != '') {
844− rowCode.unshift(mascotShapeCode);
845− }
846− code += kHeaderRowCodeGenerator(isCardTool, headerVerticalAnchors + headerLeftAnchor, rowCode)
847− } else {
848− code += mascotShapeCode + mascotCode + titleSubtitleCode;
849− }
850−
851− if (isAudio) {
852− var audioProgressBarLeftAnchor = 'audioButton.right';
853− var audioProgressBarBottomAnchor = 'audioButton.bottom';
854− var audioProgressBarTextColor = 'root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText';
855−
856− code += kAudioProgressBarCode.arg(audioProgressBarBottomAnchor)
857− .arg(audioProgressBarLeftAnchor)
858− .arg(audioProgressBarTextColor);
859−
860− var audioButtonAnchorsFill;
861− var audioButtonWidth;
862− var audioButtonHeight;
863− if (hasArt) {
864− audioButtonAnchorsFill = 'artShapeLoader';
865− audioButtonWidth = 'undefined';
866− audioButtonHeight = 'undefined';
867− } else {
868− audioButtonAnchorsFill = 'undefined';
869− audioButtonWidth = 'height';
870− audioButtonHeight = isCardTool ? 'headerHeight + 2 * units.gu(1)'
871− : 'root.fixedHeaderHeight + 2 * units.gu(1)';
872− }
873− code += kAudioButtonCode.arg(audioButtonAnchorsFill).arg(audioButtonWidth).arg(audioButtonHeight).arg(asynchronous);
874− }
875−
876− if (hasSummary) {
877− var summaryTopAnchor;
878− if (isHorizontal && hasArt) summaryTopAnchor = 'artShapeLoader.bottom';
879− else if (headerAsOverlay && hasArt) summaryTopAnchor = 'artShapeLoader.bottom';
880− else if (hasHeaderRow) summaryTopAnchor = 'row.bottom';
881− else if (hasTitleContainer) summaryTopAnchor = 'headerTitleContainer.bottom';
882− else if (hasMascot) summaryTopAnchor = 'mascotImage.bottom';
883− else if (hasAttributes) summaryTopAnchor = 'attributesRow.bottom';
884− else if (hasSubtitle) summaryTopAnchor = 'subtitleLabel.bottom';
885− else if (hasTitle) summaryTopAnchor = 'titleLabel.bottom';
886− else if (hasArt) summaryTopAnchor = 'artShapeLoader.bottom';
887− else summaryTopAnchor = 'parent.top';
888−
889− var summaryColor;
890− if (hasBackground) {
891− summaryColor = summaryColorWithBackground;
892− } else {
893− summaryColor = 'root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText';
894− }
895−
896− var summaryTopMargin = (hasMascot || hasSubtitle || hasAttributes ? 'anchors.margins' : '0');
897−
898− code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(summaryColor);
899− }
900−
901− if (hasSocialActions) {
902− var socialAnchors;
903− var socialTopAnchor;
904−
905− if (hasSummary) socialTopAnchor = 'summary.bottom;';
906− else if (isHorizontal && hasArt) socialTopAnchor = 'artShapeLoader.bottom;';
907− else if (headerAsOverlay && hasArt) socialTopAnchor = 'artShapeLoader.bottom;';
908− else if (hasHeaderRow) socialTopAnchor = 'row.bottom;';
909− else if (hasTitleContainer) socialTopAnchor = 'headerTitleContainer.bottom;';
910− else if (hasMascot) socialTopAnchor = 'mascotImage.bottom;';
911− else if (hasAttributes) socialTopAnchor = 'attributesRow.bottom;';
912− else if (hasSubtitle) socialTopAnchor = 'subtitleLabel.bottom;';
913− else if (hasTitle) socialTopAnchor = 'titleLabel.bottom;';
914− else if (hasArt) socialTopAnchor = 'artShapeLoader.bottom;';
915− else socialTopAnchor = 'parent.top';
916−
917− socialAnchors = 'top: ' + socialTopAnchor + ' left: parent.left; right: parent.right; topMargin: units.gu(1);'
918−
919− var socialColor;
920− if (hasBackground) {
921− socialColor = summaryColorWithBackground;
922− } else {
923− socialColor = 'root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText';
924− }
925−
926− code += kSocialActionsRowCode.arg(socialAnchors).arg(socialColor);
927− }
928−
929− if (artShapeStyle != "shadow" && artShapeStyle != "icon" && !isCardTool) {
930− var touchdownAnchors;
931− if (hasBackground) {
932− touchdownAnchors = 'fill: backgroundLoader';
933− } else if (touchdownOnArtShape) {
934− touchdownAnchors = 'fill: artShapeLoader';
935− } else {
936− touchdownAnchors = 'fill: root'
937− }
938− code += kTouchdownCode.arg(touchdownAnchors);
939− }
940−
941− if (isCardTool || categoryLayout !== "grid") {
942− var implicitHeight = 'implicitHeight: ';
943− if (hasSocialActions) {
944− implicitHeight += 'socialActionsRow.y + socialActionsRow.height + units.gu(1);\n';
945− } else if (hasSummary) {
946− implicitHeight += 'summary.y + summary.height + units.gu(1);\n';
947− } else if (isAudio) {
948− implicitHeight += 'audioButton.height;\n';
949− } else if (headerAsOverlay) {
950− implicitHeight += 'artShapeLoader.height;\n';
951− } else if (hasHeaderRow) {
952− implicitHeight += 'row.y + row.height + units.gu(1);\n';
953− } else if (hasMascot) {
954− implicitHeight += 'mascotImage.y + mascotImage.height;\n';
955− } else if (hasTitleContainer) {
956− implicitHeight += 'headerTitleContainer.y + headerTitleContainer.height + units.gu(1);\n';
957− } else if (hasAttributes) {
958− implicitHeight += 'attributesRow.y + attributesRow.height + units.gu(1);\n';
959− } else if (hasSubtitle) {
960− implicitHeight += 'subtitleLabel.y + subtitleLabel.height + units.gu(1);\n';
961− } else if (hasTitle) {
962− implicitHeight += 'titleLabel.y + titleLabel.height + units.gu(1);\n';
963− } else if (hasArt) {
964− implicitHeight += 'artShapeLoader.height;\n';
965− } else {
966− implicitHeight = '';
967− }
968− } else {
969− implicitHeight = '';
970− }
971−
972− // Close the AbstractButton
973− code += implicitHeight + '}\n';
974−
975− return code;
976−}
977−
978−function createCardComponent(parent, template, components, isCardTool, artShapeStyle, categoryLayout, identifier) {
979− var imports = 'import QtQuick 2.4; \n\
980− import Ubuntu.Components 1.3; \n\
981− import Ubuntu.Settings.Components 0.1; \n\
982− import Dash 0.1;\n\
983− import Utils 0.1;\n';
984− var card = cardString(template, components, isCardTool, artShapeStyle, categoryLayout);
985− var code = imports + 'Component {\n' + card + '}\n';
986−
987− try {
988− return Qt.createQmlObject(code, parent, identifier);
989− } catch (e) {
990− console.error("ERROR: Invalid component created.");
991− console.error("Template:");
992− console.error(JSON.stringify(template));
993− console.error("Components:");
994− console.error(JSON.stringify(components));
995− console.error("Code:");
996− console.error(code);
997− throw e;
998− }
999−}
plugins/Dash/CardCreatorCache.qmldeleted−40
@@ -1,40 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−pragma Singleton
18−import QtQuick 2.4
19−import "CardCreator.js" as CardCreator
20−
21−QtObject {
22− id: root
23−
24− property var cache: new Object();
25−
26− function getCardComponent(template, components, isCardTool, artShapeStyle, categoryLayout) {
27− if (template === undefined || components === undefined)
28− return undefined;
29−
30− var tString = JSON.stringify(template);
31− var cString = JSON.stringify(components);
32− var allString = tString + cString + isCardTool + artShapeStyle + categoryLayout;
33− var component = cache[allString];
34− if (component === undefined) {
35− component = CardCreator.createCardComponent(root, template, components, isCardTool, artShapeStyle, categoryLayout, allString);
36− cache[allString] = component;
37− }
38− return component;
39− }
40−}
plugins/Dash/CardSocialActions.qmldeleted−94
@@ -1,94 +0,0 @@
1−/*
2− * Copyright 2016 Canonical Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import QtQuick.Layouts 1.1
19−import Ubuntu.Components 1.3
20−
21−Column {
22− id: socialActions
23− spacing: units.gu(0.5)
24−
25− property alias model: repeater.model
26− property color color: theme.palette.normal.baseText
27−
28− signal clicked(var actionId)
29−
30− Rectangle {
31− id: divider
32− visible: repeater.count > 0
33− anchors {
34− left: parent.left;
35− right: parent.right;
36− leftMargin:units.dp(1);
37− rightMargin: units.dp(1);
38− }
39− color: Qt.darker(theme.palette.normal.background, 1.12)
40− height: visible ? units.dp(1) : 0
41− }
42−
43− Row {
44− id: row
45− anchors {
46− left: parent.left
47− right: parent.right
48− leftMargin: units.gu(1)
49− rightMargin: units.gu(1)
50− }
51− spacing: units.gu(2)
52− readonly property int visibleItems: {
53− if (width <= units.gu(12)) // small card
54− return 2;
55− else if (width <= units.gu(21)) // medium card
56− return 3;
57− else // large or horizontal card
58− return 4;
59− }
60−
61− Repeater {
62− id: repeater
63− delegate: Loader {
64− height: units.gu(2)
65− active: index < row.visibleItems
66− sourceComponent: AbstractButton {
67− objectName: "delegate" + index
68− height: units.gu(2)
69− width: icon.width
70− Icon {
71− id: icon
72− objectName: "icon"
73−
74− readonly property url urlIcon: modelData && modelData["icon"] || ""
75− readonly property url urlTemporaryIcon: "temporaryIcon" in modelData && modelData["temporaryIcon"] || ""
76−
77− height: units.gu(2)
78− // FIXME Workaround for bug https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1421293
79− width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth
80− source: urlIcon
81− color: socialActions.color
82−
83− onUrlIconChanged: {
84− if (urlIcon) source = urlIcon
85− }
86− }
87−
88− onClicked: socialActions.clicked(modelData["id"]);
89− onPressedChanged: if (pressed && icon.urlTemporaryIcon != "") icon.source = icon.urlTemporaryIcon
90− }
91− }
92− }
93− }
94−}
plugins/Dash/CroppedImageMinimumSourceSize.qmldeleted−38
@@ -1,38 +0,0 @@
1−/*
2− * Copyright (C) 2014, 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−
19−Image {
20− id: root
21−
22− fillMode: Image.PreserveAspectCrop
23−
24− property bool useHeight: false
25− function updateUseHeight()
26− {
27− // Do not turn into a binding since otherwise the qml
28− // engine complains about binding loops
29− useHeight = (implicitWidth / implicitHeight) > (width / height);
30− }
31−
32− onHeightChanged: updateUseHeight();
33− onWidthChanged: updateUseHeight();
34− onImplicitHeightChanged: updateUseHeight();
35− onImplicitWidthChanged: updateUseHeight();
36−
37− sourceSize: useHeight ? Qt.size(0, height) : Qt.size(width, 0)
38−}
plugins/Dash/DashAudioPlayer.qmldeleted−120
@@ -1,120 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−pragma Singleton
18−import QtQuick 2.4
19−import QtMultimedia 5.6
20−import Dash 0.1
21−
22−QtObject {
23− id: root
24− readonly property real progress: priv.audio ? priv.audio.position / priv.audio.duration : 0.0
25− readonly property bool playing: priv.audio ? priv.audio.playbackState === Audio.PlayingState : false
26− readonly property bool paused: priv.audio ? priv.audio.playbackState === Audio.PausedState : false
27− readonly property bool stopped: priv.audio ? priv.audio.playbackState === Audio.StoppedState : true
28− readonly property int position: priv.audio ? priv.audio.position : 0
29− readonly property url currentSource: priv.audio ? priv.audio.playlist.currentItemSource : ""
30− readonly property Playlist playlist: priv.audio ? priv.audio.playlist : null
31−
32− function playSource(newSource, newPlaylist) {
33− if (!priv.audio) {
34− console.info("DashAudioPlayer: creating player");
35− priv.audio = priv.audioComponent.createObject(root);
36− }
37− stop();
38− priv.audio.playlist.clear();
39− if (newPlaylist) {
40− // Look for newSource in newPlaylist
41− var sourceIndex = -1;
42− for (var i in newPlaylist) {
43− if (AudioUrlComparer.compare(newSource, newPlaylist[i])) {
44− sourceIndex = i;
45− break;
46− }
47− }
48− var urls = [];
49− if (sourceIndex === -1 && newSource != "") {
50− // If the playing song is not in the playlist, add it
51− urls.push(newSource);
52− sourceIndex = 0;
53− }
54− for (var i in newPlaylist) {
55− urls.push(newPlaylist[i]);
56− }
57− priv.audio.playlist.addItems(urls);
58− priv.audio.playlist.currentIndex = sourceIndex;
59− } else {
60− priv.audio.playlist.addItem(newSource);
61− priv.audio.playlist.currentIndex = 0;
62− }
63− play();
64− }
65−
66− function stop() {
67− if (priv.audio) {
68− priv.audio.stop();
69− }
70− }
71−
72− function play() {
73− if (priv.audio) {
74− priv.audio.play();
75− }
76− }
77−
78− function pause() {
79− if (priv.audio) {
80− priv.audio.pause();
81− }
82− }
83−
84− property QtObject priv: QtObject {
85− id: priv
86− property Audio audio: null
87− property Component audioComponent: Component {
88− Audio {
89− playlist: Playlist {
90− objectName: "playlist"
91− }
92− /* Remove player in case of error so it gets recreated next time
93− * we need it. Happens if backend media player restarted, for
94− * instance. qtmultimedia should probably handle this
95− * transparently (LP: #1616425).
96− */
97− onError: {
98− console.warn("DashAudioPlayer: error event (" +
99− priv.audio.errorString + "), destroying");
100− priv.audio.destroy();
101− }
102− }
103− }
104− }
105−
106− function lengthToString(s) {
107− if (typeof(s) !== "number" || s < 0) return "";
108−
109− var sec = "" + s % 60;
110− if (sec.length == 1) sec = "0" + sec;
111− var hour = Math.floor(s / 3600);
112− if (hour < 1) {
113− return Math.floor(s / 60) + ":" + sec;
114− } else {
115− var min = "" + Math.floor(s / 60) % 60;
116− if (min.length == 1) min = "0" + min;
117− return hour + ":" + min + ":" + sec;
118− }
119− }
120−}
plugins/Dash/ScopeStyle.qmldeleted−102
@@ -1,102 +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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Utils 0.1
19−import GSettings 1.0
20−import Ubuntu.Components 1.3
21−import Ubuntu.Components.Themes 1.3
22−
23−/*! \brief Helper for processing scope customization options.
24−
25− It will take the customizations object passed by the scope and
26− process it to provide the scope UI with data such as colors or
27− image paths.
28− */
29−
30−QtObject {
31−
32− property var gsettings: GSettings {
33− schema.id: "com.ubuntu.touch.system-settings"
34− }
35−
36− /// Style object passed from the scope
37− property var style: Object()
38−
39− /// Color used for text and symbolic icons
40− property color foreground: gsettings.dashBackground ? "white" : ("foreground-color" in style ? style["foreground-color"] : d.defaultDark)
41−
42− /// Luminance of the foreground color
43− readonly property real foregroundLuminance: foreground ? Style.luminance(foreground) : Style.luminance(d.defaultDark)
44−
45− /// Color used for the overall background
46− property color background: "background-color" in style ? style["background-color"] : gsettings.dashBackground ? "transparent" : "#00f5f5f5"
47−
48− /// Luminance of the background color
49− readonly property real backgroundLuminance: background ? Style.luminance(background) : Style.luminance(d.defaultLight)
50−
51− /*! \brief Get the most contrasting available color based on luminance
52− *
53− * If background color is transparent, theme provided colors are taken into account
54− */
55− function getTextColor(luminance) {
56− if (Math.abs(foregroundLuminance - luminance) >
57− Math.abs(d.opaqueBackgroundLuminance - luminance)) {
58− return foreground;
59− } else {
60− return d.opaqueBackground;
61− }
62− }
63−
64− /// Source of the logo image for the header
65− readonly property url headerLogo: "logo" in d.headerStyle ? d.headerStyle["logo"] : ""
66−
67− /// Background style for the header
68− property url headerBackground: "background" in d.headerStyle ? d.headerStyle["background"] : gsettings.dashBackground ? "color:///transparent" : "color:///#ffffff"
69−
70− /// Foreground color for the header
71− property color headerForeground: "foreground-color" in d.headerStyle ? d.headerStyle["foreground-color"] : gsettings.dashBackground ? "white" : foreground
72−
73− /// Color of the header divider
74− property color headerDividerColor: "divider-color" in d.headerStyle ? d.headerStyle["divider-color"] : gsettings.dashBackground ? "transparent" : "#e0e0e0"
75−
76− /// Background style for the navigation
77− property url navigationBackground: "navigation-background" in d.headerStyle ? d.headerStyle["navigation-background"] : gsettings.dashBackground ? "color:///white" : "color:///#f5f5f5"
78−
79− /// Color of the primary preview button
80− readonly property color previewButtonColor: "preview-button-color" in style ? style["preview-button-color"] : theme.palette.normal.positive
81−
82− //! @cond
83− property var d: QtObject {
84− // FIXME: should be taken from the theme
85− readonly property color defaultLight: "white"
86− readonly property color defaultDark: UbuntuColors.darkGrey
87− readonly property real defaultLightLuminance: Style.luminance(defaultLight)
88− readonly property real defaultDarkLuminance: Style.luminance(defaultDark)
89−
90− readonly property color opaqueBackground: {
91− background.a > 0 ?
92− background :
93− (Math.abs(foregroundLuminance - defaultLightLuminance) >
94− Math.abs(foregroundLuminance - defaultDarkLuminance)) ?
95− defaultLight : defaultDark
96− }
97− readonly property real opaqueBackgroundLuminance: Style.luminance(opaqueBackground)
98−
99− readonly property var headerStyle: "page-header" in style ? style["page-header"] : { }
100− }
101− //! @endcond
102−}
plugins/Dash/abstractdashview.cppdeleted−359
@@ -1,359 +0,0 @@
1−/*
2− * Copyright (C) 2013, 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "abstractdashview.h"
18−
19−#include <private/qquickitem_p.h>
20−
21−AbstractDashView::AbstractDashView()
22− : m_delegateModel(nullptr)
23− , m_asyncRequestedIndex(-1)
24− , m_columnSpacing(0)
25− , m_rowSpacing(0)
26− , m_buffer(320) // Same value as QML_VIEW_DEFAULTCACHEBUFFER in qquickitemview.cpp (Qt 5.6)
27− , m_displayMarginBeginning(0)
28− , m_displayMarginEnd(0)
29− , m_needsRelayout(false)
30− , m_delegateValidated(false)
31− , m_implicitHeightDirty(false)
32−{
33− connect(this, &AbstractDashView::widthChanged, this, &AbstractDashView::relayout);
34− connect(this, &AbstractDashView::heightChanged, this, &AbstractDashView::onHeightChanged);
35−}
36−
37−QAbstractItemModel *AbstractDashView::model() const
38−{
39− return m_delegateModel ? m_delegateModel->model().value<QAbstractItemModel *>() : nullptr;
40−}
41−
42−void AbstractDashView::setModel(QAbstractItemModel *model)
43−{
44− if (model != this->model()) {
45− if (!m_delegateModel) {
46− createDelegateModel();
47− } else {
48− disconnect(m_delegateModel, &QQmlDelegateModel::modelUpdated, this, &AbstractDashView::onModelUpdated);
49− }
50− m_delegateModel->setModel(QVariant::fromValue<QAbstractItemModel *>(model));
51− connect(m_delegateModel, &QQmlDelegateModel::modelUpdated, this, &AbstractDashView::onModelUpdated);
52−
53− cleanupExistingItems();
54−
55− Q_EMIT modelChanged();
56− polish();
57− }
58−}
59−
60−QQmlComponent *AbstractDashView::delegate() const
61−{
62− return m_delegateModel ? m_delegateModel->delegate() : nullptr;
63−}
64−
65−void AbstractDashView::setDelegate(QQmlComponent *delegate)
66−{
67− if (delegate != this->delegate()) {
68− if (!m_delegateModel) {
69− createDelegateModel();
70− }
71−
72− cleanupExistingItems();
73−
74− m_delegateModel->setDelegate(delegate);
75−
76− Q_EMIT delegateChanged();
77− m_delegateValidated = false;
78− polish();
79− }
80−}
81−
82−qreal AbstractDashView::columnSpacing() const
83−{
84− return m_columnSpacing;
85−}
86−
87−void AbstractDashView::setColumnSpacing(qreal columnSpacing)
88−{
89− if (columnSpacing != m_columnSpacing) {
90− m_columnSpacing = columnSpacing;
91− Q_EMIT columnSpacingChanged();
92−
93− if (isComponentComplete()) {
94− relayout();
95− }
96− }
97−}
98−
99−qreal AbstractDashView::rowSpacing() const
100−{
101− return m_rowSpacing;
102−}
103−
104−void AbstractDashView::setRowSpacing(qreal rowSpacing)
105−{
106− if (rowSpacing != m_rowSpacing) {
107− m_rowSpacing = rowSpacing;
108− Q_EMIT rowSpacingChanged();
109−
110− if (isComponentComplete()) {
111− relayout();
112− }
113− }
114−}
115−
116−int AbstractDashView::cacheBuffer() const
117−{
118− return m_buffer;
119−}
120−
121−void AbstractDashView::setCacheBuffer(int buffer)
122−{
123− if (buffer < 0) {
124− qmlInfo(this) << "Cannot set a negative cache buffer";
125− return;
126− }
127−
128− if (m_buffer != buffer) {
129− m_buffer = buffer;
130− if (isComponentComplete()) {
131− polish();
132− }
133− emit cacheBufferChanged();
134− }
135−}
136−
137−qreal AbstractDashView::displayMarginBeginning() const
138−{
139− return m_displayMarginBeginning;
140−}
141−
142−void AbstractDashView::setDisplayMarginBeginning(qreal begin)
143−{
144− if (m_displayMarginBeginning == begin)
145− return;
146− m_displayMarginBeginning = begin;
147− if (isComponentComplete()) {
148− polish();
149− }
150− emit displayMarginBeginningChanged();
151−}
152−
153−qreal AbstractDashView::displayMarginEnd() const
154−{
155− return m_displayMarginEnd;
156−}
157−
158−void AbstractDashView::setDisplayMarginEnd(qreal end)
159−{
160− if (m_displayMarginEnd == end)
161− return;
162− m_displayMarginEnd = end;
163− if (isComponentComplete()) {
164− polish();
165− }
166− emit displayMarginEndChanged();
167−}
168−
169−void AbstractDashView::createDelegateModel()
170−{
171− m_delegateModel = new QQmlDelegateModel(qmlContext(this), this);
172− connect(m_delegateModel, &QQmlDelegateModel::createdItem, this, &AbstractDashView::itemCreated);
173− if (isComponentComplete())
174− m_delegateModel->componentComplete();
175−}
176−
177−void AbstractDashView::refill()
178−{
179− if (!isComponentComplete() || height() < 0) {
180− return;
181− }
182−
183− const qreal from = -m_displayMarginBeginning;
184− const qreal to = height() + m_displayMarginEnd;
185− const qreal bufferFrom = from - m_buffer;
186− const qreal bufferTo = to + m_buffer;
187−
188− bool added = addVisibleItems(from, to, false);
189− bool removed = removeNonVisibleItems(bufferFrom, bufferTo);
190− added |= addVisibleItems(bufferFrom, bufferTo, true);
191−
192− if (added || removed) {
193− m_implicitHeightDirty = true;
194− polish();
195− }
196−}
197−
198−bool AbstractDashView::addVisibleItems(qreal fillFromY, qreal fillToY, bool asynchronous)
199−{
200− if (fillToY <= fillFromY)
201− return false;
202−
203− if (!delegate())
204− return false;
205−
206− if (m_delegateModel->count() == 0)
207− return false;
208−
209− int modelIndex;
210− qreal yPos;
211− findBottomModelIndexToAdd(&modelIndex, &yPos);
212− bool changed = false;
213− while (modelIndex < m_delegateModel->count() && yPos <= fillToY) {
214− if (!createItem(modelIndex, asynchronous))
215− break;
216−
217− changed = true;
218− findBottomModelIndexToAdd(&modelIndex, &yPos);
219− }
220−
221− findTopModelIndexToAdd(&modelIndex, &yPos);
222− while (modelIndex >= 0 && yPos > fillFromY) {
223− if (!createItem(modelIndex, asynchronous))
224− break;
225−
226− changed = true;
227− findTopModelIndexToAdd(&modelIndex, &yPos);
228− }
229−
230− return changed;
231−}
232−
233−QQuickItem *AbstractDashView::createItem(int modelIndex, bool asynchronous)
234−{
235− if (asynchronous && m_asyncRequestedIndex != -1)
236− return nullptr;
237−
238− m_asyncRequestedIndex = -1;
239− QObject* object = m_delegateModel->object(modelIndex, asynchronous ? QQmlIncubator::Asynchronous : QQmlIncubator::AsynchronousIfNested);
240− QQuickItem *item = qmlobject_cast<QQuickItem*>(object);
241− if (!item) {
242− if (object) {
243− m_delegateModel->release(object);
244− if (!m_delegateValidated) {
245− m_delegateValidated = true;
246− QObject* delegateObj = delegate();
247− qmlInfo(delegateObj ? delegateObj : this) << "Delegate must be of Item type";
248− }
249− } else {
250− m_asyncRequestedIndex = modelIndex;
251− }
252− return nullptr;
253− } else {
254− QQuickItemPrivate::get(item)->addItemChangeListener(this, QQuickItemPrivate::Geometry);
255− addItemToView(modelIndex, item);
256− return item;
257− }
258−}
259−
260−void AbstractDashView::releaseItem(QQuickItem *item)
261−{
262− QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::Geometry);
263− QQmlDelegateModel::ReleaseFlags flags = m_delegateModel->release(item);
264− if (flags & QQmlDelegateModel::Destroyed) {
265− item->setParentItem(nullptr);
266− }
267−}
268−
269−void AbstractDashView::setImplicitHeightDirty()
270−{
271− m_implicitHeightDirty = true;
272−}
273−
274−void AbstractDashView::itemCreated(int modelIndex, QObject *object)
275−{
276− QQuickItem *item = qmlobject_cast<QQuickItem*>(object);
277− if (!item) {
278− qWarning() << "AbstractDashView::itemCreated got a non item for index" << modelIndex;
279− return;
280− }
281− item->setParentItem(this);
282−
283− // We only need to call createItem if we are here because of an asynchronous generation
284− // otherwise we are in this slot because createItem is creating the item sync
285− // and thus we don't need to call createItem again, nor need to set m_implicitHeightDirty
286− // and call polish because the sync createItem was called from addVisibleItems that
287− // is called from refill that will already do those if an item was added
288− if (modelIndex == m_asyncRequestedIndex) {
289− createItem(modelIndex, false);
290− m_implicitHeightDirty = true;
291− polish();
292− }
293−}
294−
295−void AbstractDashView::onModelUpdated(const QQmlChangeSet &changeSet, bool reset)
296−{
297− if (reset) {
298− cleanupExistingItems();
299− } else {
300− processModelRemoves(changeSet.removes());
301−
302− // The current AbstractDashViews do not support insertions that are not at the end
303− // so reset if that happens
304− Q_FOREACH(const QQmlChangeSet::Change insert, changeSet.inserts()) {
305− if (insert.index < m_delegateModel->count() - 1) {
306− cleanupExistingItems();
307− break;
308− }
309− }
310− }
311− polish();
312−}
313−
314−
315−void AbstractDashView::relayout()
316−{
317− m_needsRelayout = true;
318− polish();
319−}
320−
321−void AbstractDashView::onHeightChanged()
322−{
323− polish();
324−}
325−
326−void AbstractDashView::updatePolish()
327−{
328− if (!model())
329− return;
330−
331− if (m_needsRelayout) {
332− doRelayout();
333− m_needsRelayout = false;
334− m_implicitHeightDirty = true;
335− }
336−
337− refill();
338−
339− const qreal from = -m_displayMarginBeginning;
340− const qreal to = height() + m_displayMarginEnd;
341− updateItemCulling(from, to);
342−
343− if (m_implicitHeightDirty) {
344− calculateImplicitHeight();
345− m_implicitHeightDirty = false;
346− }
347−}
348−
349−void AbstractDashView::componentComplete()
350−{
351− if (m_delegateModel)
352− m_delegateModel->componentComplete();
353−
354− QQuickItem::componentComplete();
355−
356− m_needsRelayout = true;
357−
358− polish();
359−}
plugins/Dash/abstractdashview.hdeleted−128
@@ -1,128 +0,0 @@
1−/*
2− * Copyright (C) 2013, 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef ABSTRACTDASHVIEW_H
18−#define ABSTRACTDASHVIEW_H
19−
20−#include <QQuickItem>
21−
22−class QAbstractItemModel;
23−class QQmlComponent;
24−
25−#include <private/qqmldelegatemodel_p.h>
26−#include <private/qquickitemchangelistener_p.h>
27−#include <qqmlinfo.h>
28−
29−class AbstractDashView : public QQuickItem, public QQuickItemChangeListener
30−{
31− Q_OBJECT
32−
33− Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelChanged)
34− Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
35− Q_PROPERTY(qreal columnSpacing READ columnSpacing WRITE setColumnSpacing NOTIFY columnSpacingChanged)
36− Q_PROPERTY(qreal rowSpacing READ rowSpacing WRITE setRowSpacing NOTIFY rowSpacingChanged)
37− Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer NOTIFY cacheBufferChanged)
38− Q_PROPERTY(qreal displayMarginBeginning READ displayMarginBeginning
39− WRITE setDisplayMarginBeginning
40− NOTIFY displayMarginBeginningChanged)
41− Q_PROPERTY(qreal displayMarginEnd READ displayMarginEnd
42− WRITE setDisplayMarginEnd
43− NOTIFY displayMarginEndChanged)
44−
45−friend class VerticalJournalTest;
46−friend class HorizontalJournalTest;
47−friend class OrganicGridTest;
48−
49−public:
50− AbstractDashView();
51−
52− QAbstractItemModel *model() const;
53− void setModel(QAbstractItemModel *model);
54−
55− QQmlComponent *delegate() const;
56− void setDelegate(QQmlComponent *delegate);
57−
58− qreal columnSpacing() const;
59− void setColumnSpacing(qreal columnSpacing);
60−
61− qreal rowSpacing() const;
62− void setRowSpacing(qreal rowSpacing);
63−
64− int cacheBuffer() const;
65− void setCacheBuffer(int);
66−
67− qreal displayMarginBeginning() const;
68− void setDisplayMarginBeginning(qreal);
69−
70− qreal displayMarginEnd() const;
71− void setDisplayMarginEnd(qreal);
72−
73−Q_SIGNALS:
74− void modelChanged();
75− void delegateChanged();
76− void columnSpacingChanged();
77− void rowSpacingChanged();
78− void cacheBufferChanged();
79− void displayMarginBeginningChanged();
80− void displayMarginEndChanged();
81−
82−protected Q_SLOTS:
83− void relayout();
84−
85−protected:
86− void updatePolish() override;
87− void componentComplete() override;
88−
89− void releaseItem(QQuickItem *item);
90− void setImplicitHeightDirty();
91−
92−private Q_SLOTS:
93− void itemCreated(int modelIndex, QObject *object);
94− void onModelUpdated(const QQmlChangeSet &changeSet, bool reset);
95− void onHeightChanged();
96−
97−private:
98− void createDelegateModel();
99− void refill();
100− bool addVisibleItems(qreal fillFromY, qreal fillToY, bool asynchronous);
101− QQuickItem *createItem(int modelIndex, bool asynchronous);
102−
103− virtual void findBottomModelIndexToAdd(int *modelIndex, qreal *yPos) = 0;
104− virtual void findTopModelIndexToAdd(int *modelIndex, qreal *yPos) = 0;
105− virtual void addItemToView(int modelIndex, QQuickItem *item) = 0;
106− virtual bool removeNonVisibleItems(qreal bufferFromY, qreal bufferToY) = 0;
107− virtual void cleanupExistingItems() = 0;
108− virtual void doRelayout() = 0;
109− virtual void updateItemCulling(qreal visibleFromY, qreal visibleToY) = 0;
110− virtual void calculateImplicitHeight() = 0;
111− virtual void processModelRemoves(const QVector<QQmlChangeSet::Change> &removes) = 0;
112−
113− QQmlDelegateModel *m_delegateModel;
114−
115− // Index we are waiting because we requested it asynchronously
116− int m_asyncRequestedIndex;
117−
118− int m_columnSpacing;
119− int m_rowSpacing;
120− int m_buffer;
121− qreal m_displayMarginBeginning;
122− qreal m_displayMarginEnd;
123− bool m_needsRelayout;
124− bool m_delegateValidated;
125− bool m_implicitHeightDirty;
126−};
127−
128−#endif
plugins/Dash/graphics/music_progress_bg.pngdeleted

Binary file not shown.

plugins/Dash/horizontaljournal.cppdeleted−239
@@ -1,239 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−/*
18− * The implementation is centered around m_visibleItems
19− * that a list for each of the items in the view.
20− * m_firstVisibleIndex is the index of the first item in m_visibleItems
21− * m_lastInRowIndexPosition is a map that contains the x position
22− * of items that are the last ones of a row so we can reconstruct the rows
23− * when building back
24− */
25−
26−#include "horizontaljournal.h"
27−
28−#include <qqmlengine.h>
29−#include <qqmlinfo.h>
30−#include <private/qqmldelegatemodel_p.h>
31−#include <private/qquickitem_p.h>
32−
33−HorizontalJournal::HorizontalJournal()
34− : m_firstVisibleIndex(-1)
35− , m_rowHeight(0)
36−{
37−}
38−
39−qreal HorizontalJournal::rowHeight() const
40−{
41− return m_rowHeight;
42−}
43−
44−void HorizontalJournal::setRowHeight(qreal rowHeight)
45−{
46− if (rowHeight != m_rowHeight) {
47− m_rowHeight = rowHeight;
48− Q_EMIT rowHeightChanged();
49−
50− if (isComponentComplete()) {
51− Q_FOREACH(QQuickItem *item, m_visibleItems) {
52− item->setHeight(rowHeight);
53− }
54− relayout();
55− }
56− }
57−}
58−
59−void HorizontalJournal::findBottomModelIndexToAdd(int *modelIndex, qreal *yPos)
60−{
61− if (m_visibleItems.isEmpty()) {
62− *modelIndex = 0;
63− *yPos = 0;
64− } else {
65− *modelIndex = m_firstVisibleIndex + m_visibleItems.count();
66− if (m_lastInRowIndexPosition.contains(*modelIndex - 1)) {
67− *yPos = m_visibleItems.last()->y() + m_rowHeight + rowSpacing();
68− } else {
69− *yPos = m_visibleItems.last()->y();
70− }
71− }
72−}
73−
74−void HorizontalJournal::findTopModelIndexToAdd(int *modelIndex, qreal *yPos)
75−{
76− if (m_visibleItems.isEmpty()) {
77− *modelIndex = -1;
78− *yPos = INT_MIN;
79− } else {
80− *modelIndex = m_firstVisibleIndex - 1;
81− if (m_lastInRowIndexPosition.contains(*modelIndex)) {
82− *yPos = m_visibleItems.first()->y() - rowSpacing() - m_rowHeight;
83− } else {
84− *yPos = m_visibleItems.first()->y();
85− }
86− }
87−}
88−
89−bool HorizontalJournal::removeNonVisibleItems(qreal bufferFromY, qreal bufferToY)
90−{
91− bool changed = false;
92−
93− while (!m_visibleItems.isEmpty() && m_visibleItems.first()->y() + m_rowHeight < bufferFromY) {
94− releaseItem(m_visibleItems.takeFirst());
95− changed = true;
96− m_firstVisibleIndex++;
97− }
98−
99− while (!m_visibleItems.isEmpty() && m_visibleItems.last()->y() > bufferToY) {
100− releaseItem(m_visibleItems.takeLast());
101− changed = true;
102− m_lastInRowIndexPosition.remove(m_firstVisibleIndex + m_visibleItems.count());
103− }
104−
105− if (m_visibleItems.isEmpty()) {
106− m_firstVisibleIndex = -1;
107− }
108−
109− return changed;
110−}
111−
112−void HorizontalJournal::addItemToView(int modelIndex, QQuickItem *item)
113−{
114− if (item->height() != m_rowHeight) {
115− qWarning() << "Item" << modelIndex << "height is not the one that the rowHeight mandates, resetting it";
116− item->setHeight(m_rowHeight);
117− }
118−
119− if (m_visibleItems.isEmpty()) {
120− Q_ASSERT(modelIndex == 0);
121− item->setY(0);
122− item->setX(0);
123− m_visibleItems << item;
124− m_firstVisibleIndex = 0;
125− } else {
126− // modelIndex has to be either m_firstVisibleIndex - 1 or m_firstVisibleIndex + m_visibleItems.count()
127− if (modelIndex == m_firstVisibleIndex + m_visibleItems.count()) {
128− QQuickItem *lastItem = m_visibleItems.last();
129− if (lastItem->x() + lastItem->width() + columnSpacing() + item->width() <= width()) {
130− // Fits in the row
131− item->setY(lastItem->y());
132− item->setX(lastItem->x() + lastItem->width() + columnSpacing());
133− } else {
134− // Starts a new row
135− item->setY(lastItem->y() + m_rowHeight + rowSpacing());
136− item->setX(0);
137− m_lastInRowIndexPosition[modelIndex - 1] = lastItem->x();
138− }
139− m_visibleItems << item;
140− } else if (modelIndex == m_firstVisibleIndex - 1) {
141− QQuickItem *firstItem = m_visibleItems.first();
142− if (m_lastInRowIndexPosition.contains(modelIndex)) {
143− // It is the last item of its row, so start a new one since we're going back
144− item->setY(firstItem->y() - rowSpacing() - m_rowHeight);
145− item->setX(m_lastInRowIndexPosition[modelIndex]);
146− } else {
147− item->setY(firstItem->y());
148− item->setX(firstItem->x() - columnSpacing() - item->width());
149− }
150− m_firstVisibleIndex = modelIndex;
151− m_visibleItems.prepend(item);
152− } else {
153− qWarning() << "HorizontalJournal::addItemToView - Got unexpected modelIndex"
154− << modelIndex << m_firstVisibleIndex << m_visibleItems.count();
155− }
156− }
157−}
158−
159−void HorizontalJournal::cleanupExistingItems()
160−{
161− // Cleanup the existing items
162− Q_FOREACH(QQuickItem *item, m_visibleItems)
163− releaseItem(item);
164− m_visibleItems.clear();
165− m_lastInRowIndexPosition.clear();
166− m_firstVisibleIndex = -1;
167− setImplicitHeightDirty();
168−}
169−
170−void HorizontalJournal::calculateImplicitHeight()
171−{
172− if (m_firstVisibleIndex >= 0) {
173− const int nIndexes = m_firstVisibleIndex + m_visibleItems.count();
174− const double bottomMostY = m_visibleItems.last()->y() + m_rowHeight;
175− const double averageHeight = bottomMostY / nIndexes;
176− setImplicitHeight(bottomMostY + averageHeight * (model()->rowCount() - nIndexes));
177− } else {
178− setImplicitHeight(0);
179− }
180−}
181−
182−void HorizontalJournal::processModelRemoves(const QVector<QQmlChangeSet::Change> &removes)
183−{
184− Q_FOREACH(const QQmlChangeSet::Change remove, removes) {
185− for (int i = remove.count - 1; i >= 0; --i) {
186− const int indexToRemove = remove.index + i;
187− // We only support removing from the end so
188− // any of the last items of a column has to be indexToRemove
189− const int lastIndex = m_firstVisibleIndex + m_visibleItems.count() - 1;
190− if (indexToRemove == lastIndex) {
191− releaseItem(m_visibleItems.takeLast());
192− m_lastInRowIndexPosition.remove(indexToRemove);
193− } else {
194− if (indexToRemove < lastIndex) {
195− qDebug() << "HorizontalJournal only supports removal from the end of the model, resetting instead";
196− cleanupExistingItems();
197− break;
198− } else {
199− setImplicitHeightDirty();
200− }
201− }
202− }
203− }
204− if (m_visibleItems.isEmpty()) {
205− m_firstVisibleIndex = -1;
206− }
207−}
208−
209−
210−void HorizontalJournal::doRelayout()
211−{
212− // If m_firstVisibleIndex is not 0 we need to drop all the delegates
213− // since we can't consistently relayout without the first item being there
214−
215− if (m_firstVisibleIndex == 0) {
216− int i = 0;
217− const QList<QQuickItem*> allItems = m_visibleItems;
218− m_visibleItems.clear();
219− m_lastInRowIndexPosition.clear();
220− Q_FOREACH(QQuickItem *item, allItems) {
221− addItemToView(i, item);
222− ++i;
223− }
224− } else {
225− Q_FOREACH(QQuickItem *item, m_visibleItems) {
226− releaseItem(item);
227− }
228− m_visibleItems.clear();
229− m_lastInRowIndexPosition.clear();
230− m_firstVisibleIndex = -1;
231− }
232−}
233−
234−void HorizontalJournal::updateItemCulling(qreal visibleFromY, qreal visibleToY)
235−{
236− Q_FOREACH(QQuickItem *item, m_visibleItems) {
237− QQuickItemPrivate::get(item)->setCulled(item->y() + m_rowHeight <= visibleFromY || item->y() >= visibleToY);
238− }
239−}
plugins/Dash/horizontaljournal.hdeleted−63
@@ -1,63 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef HORIZONTALJOURNAL_H
18−#define HORIZONTALJOURNAL_H
19−
20−#include "abstractdashview.h"
21−
22− /** A horizontal journal is a view that creates delegates
23− * based on a model and layouts them one after the other
24− * in the same row until there is no more free space for the next item
25− * and so that item is layouted in the next row
26− *
27− * All delegates are forced to rowHeight if they don't have it.
28− */
29− class HorizontalJournal : public AbstractDashView
30−{
31− Q_OBJECT
32−
33− Q_PROPERTY(qreal rowHeight READ rowHeight WRITE setRowHeight NOTIFY rowHeightChanged)
34−
35−friend class HorizontalJournalTest;
36−
37−public:
38− HorizontalJournal();
39−
40− qreal rowHeight() const;
41− void setRowHeight(qreal rowHeight);
42−
43−Q_SIGNALS:
44− void rowHeightChanged();
45−
46−private:
47− void findBottomModelIndexToAdd(int *modelIndex, qreal *yPos) override;
48− void findTopModelIndexToAdd(int *modelIndex, qreal *yPos) override;
49− bool removeNonVisibleItems(qreal bufferFromY, qreal bufferToY) override;
50− void addItemToView(int modelIndex, QQuickItem *item) override;
51− void cleanupExistingItems() override;
52− void calculateImplicitHeight() override;
53− void doRelayout() override;
54− void updateItemCulling(qreal visibleFromY, qreal visibleToY) override;
55− void processModelRemoves(const QVector<QQmlChangeSet::Change> &removes) override;
56−
57− int m_firstVisibleIndex;
58− QList<QQuickItem*> m_visibleItems;
59− QMap<int, double> m_lastInRowIndexPosition;
60− int m_rowHeight;
61−};
62−
63−#endif
plugins/Dash/listviewwithpageheader.cppdeleted−1396
@@ -1,1396 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−/*
18− * Some documentation on how this thing works:
19− *
20− * A flickable has two very important concepts that define the top and
21− * height of the flickable area.
22− * The top is returned in minYExtent()
23− * The height is set using setContentHeight()
24− * By changing those two values we can make the list grow up or down
25− * as needed. e.g. if we are in the middle of the list
26− * and something that is above the viewport grows, since we do not
27− * want to change the viewport because of that we just adjust the
28− * minYExtent so that the list grows up.
29− *
30− * The implementation on the list relies on the delegateModel doing
31− * most of the instantiation work. You call createItem() when you
32− * need to create an item asking for it async or not. If returns null
33− * it means the item will be created async and the model will call the
34− * itemCreated slot with the item.
35− *
36− * updatePolish is the central point of dispatch for the work of the
37− * class. It is called by the scene graph just before drawing the class.
38− * In it we:
39− * * Make sure all items are positioned correctly
40− * * Add/Remove items if needed
41− * * Update the content height if it was dirty
42− *
43− * m_visibleItems contains all the items we have created at the moment.
44− * Actually not all of them are visible since it includes the ones
45− * in the cache area we create asynchronously to help performance.
46− * The first item in m_visibleItems has the m_firstVisibleIndex in
47− * the model. If you actually want to know what is the first
48− * item in the viewport you have to find the first non culled element
49− * in m_visibleItems
50− *
51− * All the items (except the header) are childs of m_clipItem which
52− * is a child of the contentItem() of the flickable (The contentItem()
53− * is what actually 'moves' in a a flickable). This way
54− * we can implement the clipping needed so we can have the header
55− * shown in the middle of the list over the items without the items
56− * leaking under the header in case it is transparent.
57− *
58− * The first item of m_visibleItems is the one that defines the
59− * positions of all the rest of items (see updatePolish()) and
60− * this is why sometimes we move it even if it's not the item
61− * that has triggered the function (i.e. in itemGeometryChanged())
62− *
63− * m_visibleItems is a list of ListItem. Each ListItem
64− * will contain a item and potentially a sectionItem. The sectionItem
65− * is only there when the list is using sectionDelegate+sectionProperty
66− * and this is the first item of the section. Each ListItem is vertically
67− * layouted with the sectionItem first and then the item.
68− *
69− * For sectioning we also have a section item alone (m_topSectionItem)
70− * that is used for the cases we need to show the sticky section item at
71− * the top of the view.
72− *
73− * Each delegate item has a context property called heightToClip that is
74− * used to communicate to the delegate implementation in case it has to
75− * clip itself because of overlapping with the top sticky section item.
76− * This is an implementation decision since it has been agreed it
77− * is easier to implement the clipping in QML with this info than to
78− * do it at the C++ level.
79− *
80− * Note that minYExtent and height are not always totally accurate, since
81− * we don't have the items created we can't guess their heights
82− * so we can only guarantee the values are correct when the first/last
83− * items of the list are visible, otherwise we just live with good enough
84− * values that make the list scrollable
85− *
86− * There are a few things that are not really implemented or tested properly
87− * which we don't use at the moment like changing the model, changing
88− * the section delegate, having a section delegate that changes its size, etc.
89− * The known missing features are marked with TODOs along the code.
90− */
91−
92−#include "listviewwithpageheader.h"
93−
94−#include <QCoreApplication>
95−#include <QDebug>
96−#include <qqmlinfo.h>
97−#include <qqmlengine.h>
98−#include <private/qqmlcontext_p.h>
99−#include <private/qqmldelegatemodel_p.h>
100−#include <private/qqmlglobal_p.h>
101−#include <private/qquickitem_p.h>
102−#include <private/qquickanimation_p.h>
103−// #include <private/qquickrectangle_p.h>
104−
105−qreal ListViewWithPageHeader::ListItem::height() const
106−{
107− return m_item->height() + (m_sectionItem ? m_sectionItem->height() : 0);
108−}
109−
110−qreal ListViewWithPageHeader::ListItem::y() const
111−{
112− return m_item->y() - (m_sectionItem ? m_sectionItem->height() : 0);
113−}
114−
115−void ListViewWithPageHeader::ListItem::setY(qreal newY)
116−{
117− if (m_sectionItem) {
118− m_sectionItem->setY(newY);
119− m_item->setY(newY + m_sectionItem->height());
120− } else {
121− m_item->setY(newY);
122− }
123−}
124−
125−bool ListViewWithPageHeader::ListItem::culled() const
126−{
127− return QQuickItemPrivate::get(m_item)->culled;
128−}
129−
130−void ListViewWithPageHeader::ListItem::setCulled(bool culled)
131−{
132− QQuickItemPrivate::get(m_item)->setCulled(culled);
133− if (m_sectionItem)
134− QQuickItemPrivate::get(m_sectionItem)->setCulled(culled);
135−}
136−
137−void ListViewWithPageHeader::ListItem::setSectionItem(QQuickItem *sectionItem)
138−{
139− m_sectionItem = sectionItem;
140−}
141−
142−ListViewWithPageHeader::ListViewWithPageHeader()
143− : m_delegateModel(nullptr)
144− , m_asyncRequestedIndex(-1)
145− , m_delegateValidated(false)
146− , m_firstVisibleIndex(-1)
147− , m_minYExtent(0)
148− , m_contentHeightDirty(false)
149− , m_headerItem(nullptr)
150− , m_previousContentY(0)
151− , m_headerItemShownHeight(0)
152− , m_sectionDelegate(nullptr)
153− , m_topSectionItem(nullptr)
154− , m_forceNoClip(false)
155− , m_inLayout(false)
156− , m_inContentHeightKeepHeaderShown(false)
157− , m_cacheBuffer(0)
158−{
159− m_clipItem = new QQuickItem(contentItem());
160−// m_clipItem = new QQuickRectangle(contentItem());
161−// ((QQuickRectangle*)m_clipItem)->setColor(Qt::gray);
162−
163− m_contentYAnimation = new QQuickNumberAnimation(this);
164− m_contentYAnimation->setEasing(QEasingCurve::OutQuad);
165− m_contentYAnimation->setProperty(QStringLiteral("contentY"));
166− m_contentYAnimation->setDuration(200);
167− m_contentYAnimation->setTargetObject(this);
168−
169− connect(contentItem(), &QQuickItem::widthChanged, this, &ListViewWithPageHeader::onContentWidthChanged);
170− connect(this, &ListViewWithPageHeader::contentHeightChanged, this, &ListViewWithPageHeader::onContentHeightChanged);
171− connect(this, &ListViewWithPageHeader::heightChanged, this, &ListViewWithPageHeader::onHeightChanged);
172− connect(m_contentYAnimation, &QQuickNumberAnimation::runningChanged, this, &ListViewWithPageHeader::contentYAnimationRunningChanged);
173−
174− setFlickableDirection(VerticalFlick);
175−}
176−
177−ListViewWithPageHeader::~ListViewWithPageHeader()
178−{
179−}
180−
181−QAbstractItemModel *ListViewWithPageHeader::model() const
182−{
183− return m_delegateModel ? m_delegateModel->model().value<QAbstractItemModel *>() : nullptr;
184−}
185−
186−void ListViewWithPageHeader::setModel(QAbstractItemModel *model)
187−{
188− if (model != this->model()) {
189− if (!m_delegateModel) {
190− createDelegateModel();
191− } else {
192− disconnect(m_delegateModel, &QQmlDelegateModel::modelUpdated, this, &ListViewWithPageHeader::onModelUpdated);
193− }
194− m_delegateModel->setModel(QVariant::fromValue<QAbstractItemModel *>(model));
195− connect(m_delegateModel, &QQmlDelegateModel::modelUpdated, this, &ListViewWithPageHeader::onModelUpdated);
196− Q_EMIT modelChanged();
197− polish();
198− // TODO?
199−// Q_EMIT contentHeightChanged();
200−// Q_EMIT contentYChanged();
201− }
202−}
203−
204−QQmlComponent *ListViewWithPageHeader::delegate() const
205−{
206− return m_delegateModel ? m_delegateModel->delegate() : nullptr;
207−}
208−
209−void ListViewWithPageHeader::setDelegate(QQmlComponent *delegate)
210−{
211− if (delegate != this->delegate()) {
212− if (!m_delegateModel) {
213− createDelegateModel();
214− }
215−
216− // Cleanup the existing items
217− Q_FOREACH(ListItem *item, m_visibleItems)
218− releaseItem(item);
219− m_visibleItems.clear();
220− initializeValuesForEmptyList();
221−
222− m_delegateModel->setDelegate(delegate);
223−
224− Q_EMIT delegateChanged();
225− m_delegateValidated = false;
226− m_contentHeightDirty = true;
227− polish();
228− }
229−}
230−
231−void ListViewWithPageHeader::initializeValuesForEmptyList()
232−{
233− m_firstVisibleIndex = -1;
234− adjustMinYExtent();
235− setContentY(0);
236− m_clipItem->setY(0);
237− if (m_topSectionItem) {
238− QQuickItemPrivate::get(m_topSectionItem)->setCulled(true);
239− }
240−}
241−
242−QQuickItem *ListViewWithPageHeader::header() const
243−{
244− return m_headerItem;
245−}
246−
247−void ListViewWithPageHeader::setHeader(QQuickItem *headerItem)
248−{
249− if (m_headerItem != headerItem) {
250− qreal oldHeaderHeight = 0;
251− qreal oldHeaderY = 0;
252− if (m_headerItem) {
253− oldHeaderHeight = m_headerItem->height();
254− oldHeaderY = m_headerItem->y();
255− m_headerItem->setParentItem(nullptr);
256− QQuickItemPrivate::get(m_headerItem)->removeItemChangeListener(this, QQuickItemPrivate::ImplicitHeight);
257− }
258− m_headerItem = headerItem;
259− if (m_headerItem) {
260− m_headerItem->setParentItem(contentItem());
261− m_headerItem->setZ(1);
262− m_previousHeaderImplicitHeight = m_headerItem->implicitHeight();
263− QQuickItemPrivate::get(m_headerItem)->addItemChangeListener(this, QQuickItemPrivate::ImplicitHeight);
264− }
265− qreal newHeaderHeight = m_headerItem ? m_headerItem->height() : 0;
266− if (!m_visibleItems.isEmpty() && newHeaderHeight != oldHeaderHeight) {
267− headerHeightChanged(newHeaderHeight, oldHeaderHeight, oldHeaderY);
268− polish();
269− m_contentHeightDirty = true;
270− }
271− Q_EMIT headerChanged();
272− }
273−}
274−
275−QQmlComponent *ListViewWithPageHeader::sectionDelegate() const
276−{
277− return m_sectionDelegate;
278−}
279−
280−void ListViewWithPageHeader::setSectionDelegate(QQmlComponent *delegate)
281−{
282− if (delegate != m_sectionDelegate) {
283− // TODO clean existing sections
284−
285− m_sectionDelegate = delegate;
286−
287− m_topSectionItem = getSectionItem(QString(), false /*watchGeometry*/);
288− if (m_topSectionItem) {
289− m_topSectionItem->setZ(3);
290− QQuickItemPrivate::get(m_topSectionItem)->setCulled(true);
291− connect(m_topSectionItem, &QQuickItem::heightChanged, this, &ListViewWithPageHeader::stickyHeaderHeightChanged);
292− }
293−
294− // TODO create sections for existing items
295−
296− Q_EMIT sectionDelegateChanged();
297− Q_EMIT stickyHeaderHeightChanged();
298− }
299−}
300−
301−QString ListViewWithPageHeader::sectionProperty() const
302−{
303− return m_sectionProperty;
304−}
305−
306−void ListViewWithPageHeader::setSectionProperty(const QString &property)
307−{
308− if (property != m_sectionProperty) {
309− m_sectionProperty = property;
310−
311− updateWatchedRoles();
312−
313− // TODO recreate sections
314−
315− Q_EMIT sectionPropertyChanged();
316− }
317−}
318−
319−bool ListViewWithPageHeader::forceNoClip() const
320−{
321− return m_forceNoClip;
322−}
323−
324−void ListViewWithPageHeader::setForceNoClip(bool noClip)
325−{
326− if (noClip != m_forceNoClip) {
327− m_forceNoClip = noClip;
328− updateClipItem();
329− Q_EMIT forceNoClipChanged();
330− }
331−}
332−
333−int ListViewWithPageHeader::stickyHeaderHeight() const
334−{
335− return m_topSectionItem ? m_topSectionItem->height() : 0;
336−}
337−
338−qreal ListViewWithPageHeader::headerItemShownHeight() const
339−{
340− return m_headerItemShownHeight;
341−}
342−
343−int ListViewWithPageHeader::cacheBuffer() const
344−{
345− return m_cacheBuffer;
346−}
347−
348−void ListViewWithPageHeader::setCacheBuffer(int cacheBuffer)
349−{
350− if (cacheBuffer < 0) {
351− qmlInfo(this) << "Cannot set a negative cache buffer";
352− return;
353− }
354−
355− if (cacheBuffer != m_cacheBuffer) {
356− m_cacheBuffer = cacheBuffer;
357− Q_EMIT cacheBufferChanged();
358− polish();
359− }
360−}
361−
362−void ListViewWithPageHeader::positionAtBeginning()
363−{
364− if (m_delegateModel->count() <= 0)
365− return;
366−
367− qreal headerHeight = (m_headerItem ? m_headerItem->height() : 0);
368− if (m_firstVisibleIndex != 0) {
369− // TODO This could be optimized by trying to reuse the interesection
370− // of items that may end up intersecting between the existing
371− // m_visibleItems and the items we are creating in the next loop
372− Q_FOREACH(ListItem *item, m_visibleItems)
373− releaseItem(item);
374− m_visibleItems.clear();
375− m_firstVisibleIndex = -1;
376−
377− // Create the item 0, it will be already correctly positioned at createItem()
378− m_clipItem->setY(0);
379− ListItem *item = createItem(0, false);
380− // Create the subsequent items
381− int modelIndex = 1;
382− qreal pos = item->y() + item->height();
383− const qreal bufferTo = height() + m_cacheBuffer;
384− while (modelIndex < m_delegateModel->count() && pos <= bufferTo) {
385− if (!(item = createItem(modelIndex, false)))
386− break;
387− pos += item->height();
388− ++modelIndex;
389− }
390−
391− m_previousContentY = m_visibleItems.first()->y() - headerHeight;
392− }
393− setContentY(m_visibleItems.first()->y() + m_clipItem->y() - headerHeight);
394− if (m_headerItem) {
395− // TODO This should not be needed and the code that adjust the m_headerItem position
396− // in viewportMoved() should be enough but in some cases we have not found a way to reproduce
397− // yet the code of viewportMoved() fails so here we make sure that at least if we are calling
398− // positionAtBeginning the header item will be correctly positioned
399− m_headerItem->setY(-m_minYExtent);
400− }
401−}
402−
403−static inline bool uFuzzyCompare(qreal r1, qreal r2)
404−{
405− return qFuzzyCompare(r1, r2) || (qFuzzyIsNull(r1) && qFuzzyIsNull(r2));
406−}
407−
408−void ListViewWithPageHeader::showHeader()
409−{
410− if (!m_headerItem)
411− return;
412−
413− const auto to = qMax(-minYExtent(), contentY() - m_headerItem->height() + m_headerItemShownHeight);
414− if (!uFuzzyCompare(to, contentY())) {
415− const bool headerShownByItsOwn = contentY() < m_headerItem->y() + m_headerItem->height();
416− if (headerShownByItsOwn && m_headerItemShownHeight == 0) {
417− // We are not clipping since we are just at the top of the viewport
418− // but because of the showHeader animation we will need to, so
419− // enable the clipping without logically moving the items
420− m_headerItemShownHeight = m_headerItem->y() + m_headerItem->height() - contentY();
421− if (!m_visibleItems.isEmpty()) {
422− updateClipItem();
423− ListItem *firstItem = m_visibleItems.first();
424− firstItem->setY(firstItem->y() - m_headerItemShownHeight);
425− layout();
426− }
427− Q_EMIT headerItemShownHeightChanged();
428− }
429− m_contentYAnimation->setTo(to);
430− contentYAnimationType = ContentYAnimationShowHeader;
431− m_contentYAnimation->start();
432− }
433−}
434−
435−int ListViewWithPageHeader::firstCreatedIndex() const
436−{
437− return m_firstVisibleIndex;
438−}
439−
440−int ListViewWithPageHeader::createdItemCount() const
441−{
442− return m_visibleItems.count();
443−}
444−
445−QQuickItem *ListViewWithPageHeader::item(int modelIndex) const
446−{
447− ListItem *item = itemAtIndex(modelIndex);
448− if (item)
449− return item->m_item;
450− else
451− return nullptr;
452−}
453−
454−bool ListViewWithPageHeader::maximizeVisibleArea(int modelIndex)
455−{
456− ListItem *listItem = itemAtIndex(modelIndex);
457− if (listItem) {
458− return maximizeVisibleArea(listItem, listItem->height());
459− }
460−
461− return false;
462−}
463−
464−bool ListViewWithPageHeader::maximizeVisibleArea(int modelIndex, int itemHeight)
465−{
466− if (itemHeight < 0)
467− return false;
468−
469− ListItem *listItem = itemAtIndex(modelIndex);
470− if (listItem) {
471− return maximizeVisibleArea(listItem, itemHeight + (listItem->sectionItem() ? listItem->sectionItem()->height() : 0));
472− }
473−
474− return false;
475−}
476−
477−bool ListViewWithPageHeader::maximizeVisibleArea(ListItem *listItem, int listItemHeight)
478−{
479− if (listItem) {
480− layout();
481− const auto listItemY = m_clipItem->y() + listItem->y();
482− if (listItemY > contentY() && listItemY + listItemHeight > contentY() + height()) {
483− // we can scroll the list up to show more stuff
484− const auto to = qMin(listItemY, listItemY + listItemHeight - height());
485− m_contentYAnimation->setTo(to);
486− contentYAnimationType = ContentYAnimationMaximizeVisibleArea;
487− m_contentYAnimation->start();
488− } else if ((listItemY < contentY() && listItemY + listItemHeight < contentY() + height()) ||
489− (m_topSectionItem && !listItem->sectionItem() && listItemY - m_topSectionItem->height() < contentY() && listItemY + listItemHeight < contentY() + height()))
490− {
491− // we can scroll the list down to show more stuff
492− auto realVisibleListItemY = listItemY;
493− if (m_topSectionItem) {
494− // If we are showing the top section sticky item and this item doesn't have a section
495− // item we have to make sure to scroll it a bit more so that it is not underlapping
496− // the top section sticky item
497− bool topSectionShown = !QQuickItemPrivate::get(m_topSectionItem)->culled;
498− if (topSectionShown && !listItem->sectionItem()) {
499− realVisibleListItemY -= m_topSectionItem->height();
500− }
501− }
502− const auto to = qMax(realVisibleListItemY, listItemY + listItemHeight - height());
503− m_contentYAnimation->setTo(to);
504− contentYAnimationType = ContentYAnimationMaximizeVisibleArea;
505− m_contentYAnimation->start();
506− }
507− return true;
508− }
509− return false;
510−}
511−
512−qreal ListViewWithPageHeader::minYExtent() const
513−{
514−// qDebug() << "ListViewWithPageHeader::minYExtent" << m_minYExtent;
515− return m_minYExtent;
516−}
517−
518−qreal ListViewWithPageHeader::maxYExtent() const
519−{
520− return height() - contentHeight();
521−}
522−
523−void ListViewWithPageHeader::componentComplete()
524−{
525− if (m_delegateModel)
526− m_delegateModel->componentComplete();
527−
528− QQuickFlickable::componentComplete();
529−
530− polish();
531−}
532−
533−void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
534−{
535− // Check we are not being taken down and don't paint anything
536− // TODO Check if we still need this in 5.2
537− // For reproduction just inifnite loop testDash or testDashContent
538− if (!QQmlEngine::contextForObject(this)->parentContext())
539− return;
540−
541− QQuickFlickable::viewportMoved(orient);
542−// qDebug() << "ListViewWithPageHeader::viewportMoved" << contentY();
543− const qreal diff = m_previousContentY - contentY();
544− adjustHeader(diff);
545− m_previousContentY = contentY();
546− layout();
547− polish();
548−}
549−
550−void ListViewWithPageHeader::adjustHeader(qreal diff)
551−{
552− const bool showHeaderAnimationRunning = m_contentYAnimation->isRunning() && contentYAnimationType == ContentYAnimationShowHeader;
553− if (m_headerItem) {
554− const auto oldHeaderItemShownHeight = m_headerItemShownHeight;
555− if (uFuzzyCompare(contentY(), -m_minYExtent) || contentY() > -m_minYExtent) {
556− m_headerItem->setHeight(m_headerItem->implicitHeight());
557− // We are going down (but it's not because of the rebound at the end)
558− // (but the header was not shown by it's own position)
559− // or the header is partially shown and we are not doing a maximizeVisibleArea either
560− const bool scrolledUp = m_previousContentY > contentY();
561− const bool notRebounding = qRound(contentY() + height()) < qRound(contentHeight());
562− const bool notShownByItsOwn = contentY() + diff >= m_headerItem->y() + m_headerItem->height();
563− const bool maximizeVisibleAreaRunning = m_contentYAnimation->isRunning() && contentYAnimationType == ContentYAnimationMaximizeVisibleArea;
564−
565− if (!scrolledUp && (contentY() == -m_minYExtent || (m_headerItemShownHeight == 0 && m_previousContentY == m_headerItem->y()))) {
566− m_headerItemShownHeight = 0;
567− m_headerItem->setY(-m_minYExtent);
568− } else if ((scrolledUp && notRebounding && notShownByItsOwn && !maximizeVisibleAreaRunning) || (m_headerItemShownHeight > 0) || m_inContentHeightKeepHeaderShown) {
569− if (maximizeVisibleAreaRunning && diff > 0) {
570− // If we are maximizing and the header was shown, make sure we hide it
571− m_headerItemShownHeight -= diff;
572− } else {
573− m_headerItemShownHeight += diff;
574− }
575− if (uFuzzyCompare(contentY(), -m_minYExtent)) {
576− m_headerItemShownHeight = 0;
577− } else {
578− m_headerItemShownHeight = qBound(static_cast<qreal>(0.), m_headerItemShownHeight, m_headerItem->height());
579− }
580− if (m_headerItemShownHeight > 0) {
581− if (uFuzzyCompare(m_headerItem->height(), m_headerItemShownHeight)) {
582− m_headerItem->setY(contentY());
583− m_headerItemShownHeight = m_headerItem->height();
584− } else {
585− m_headerItem->setY(contentY() - m_headerItem->height() + m_headerItemShownHeight);
586− }
587− } else {
588− m_headerItem->setY(-m_minYExtent);
589− }
590− } else if (m_headerItemShownHeight == 0 && m_previousContentY > m_headerItem->y() && contentY() < m_headerItem->y()) {
591− // The header was hidden but now that we've moved up (e.g. because of item removed) it's visible
592− // make sure it isn't
593− m_headerItem->setY(-m_minYExtent);
594− }
595− Q_EMIT headerItemShownHeightChanged();
596− } else {
597− // Stick the header item to the top when dragging down
598− m_headerItem->setY(contentY());
599− m_headerItem->setHeight(m_headerItem->implicitHeight() + (-m_minYExtent - contentY()));
600− }
601− // We will be changing the clip item, need to accomadate for it
602− // otherwise we move the firstItem down/up twice (unless the
603− // show header animation is running, where we want to keep the viewport stable)
604− if (!showHeaderAnimationRunning) {
605− diff += oldHeaderItemShownHeight - m_headerItemShownHeight;
606− } else {
607− diff = -diff;
608− }
609− }
610− if (!m_visibleItems.isEmpty()) {
611− updateClipItem();
612− ListItem *firstItem = m_visibleItems.first();
613− firstItem->setY(firstItem->y() + diff);
614− if (showHeaderAnimationRunning) {
615− adjustMinYExtent();
616− }
617− }
618−}
619−
620−void ListViewWithPageHeader::createDelegateModel()
621−{
622− m_delegateModel = new QQmlDelegateModel(qmlContext(this), this);
623− connect(m_delegateModel, &QQmlDelegateModel::createdItem, this, &ListViewWithPageHeader::itemCreated);
624− if (isComponentComplete())
625− m_delegateModel->componentComplete();
626− updateWatchedRoles();
627−}
628−
629−void ListViewWithPageHeader::refill()
630−{
631− if (m_inLayout) {
632− return;
633− }
634− if (!isComponentComplete()) {
635− return;
636− }
637−
638− const qreal from = contentY();
639− const qreal to = from + height();
640− const qreal bufferFrom = from - m_cacheBuffer;
641− const qreal bufferTo = to + m_cacheBuffer;
642−
643− bool added = addVisibleItems(from, to, false);
644− bool removed = removeNonVisibleItems(bufferFrom, bufferTo);
645− added |= addVisibleItems(bufferFrom, bufferTo, true);
646−
647− if (added || removed) {
648− m_contentHeightDirty = true;
649− }
650−}
651−
652−bool ListViewWithPageHeader::addVisibleItems(qreal fillFrom, qreal fillTo, bool asynchronous)
653−{
654− if (!delegate())
655− return false;
656−
657− if (m_delegateModel->count() == 0)
658− return false;
659−
660− ListItem *item;
661−// qDebug() << "ListViewWithPageHeader::addVisibleItems" << fillFrom << fillTo << asynchronous;
662−
663− int modelIndex = 0;
664− qreal pos = 0;
665− if (!m_visibleItems.isEmpty()) {
666− modelIndex = m_firstVisibleIndex + m_visibleItems.count();
667− item = m_visibleItems.last();
668− pos = item->y() + item->height() + m_clipItem->y();
669− }
670− bool changed = false;
671−// qDebug() << (modelIndex < m_delegateModel->count()) << pos << fillTo;
672− while (modelIndex < m_delegateModel->count() && pos <= fillTo) {
673−// qDebug() << "refill: append item" << modelIndex << "pos" << pos << "asynchronous" << asynchronous;
674− if (!(item = createItem(modelIndex, asynchronous)))
675− break;
676− pos += item->height();
677− ++modelIndex;
678− changed = true;
679− }
680−
681− modelIndex = 0;
682− pos = 0;
683− if (!m_visibleItems.isEmpty()) {
684− modelIndex = m_firstVisibleIndex - 1;
685− item = m_visibleItems.first();
686− pos = item->y() + m_clipItem->y();
687− }
688− while (modelIndex >= 0 && pos > fillFrom) {
689−// qDebug() << "refill: prepend item" << modelIndex << "pos" << pos << "fillFrom" << fillFrom << "asynchronous" << asynchronous;
690− if (!(item = createItem(modelIndex, asynchronous)))
691− break;
692− pos -= item->height();
693− --modelIndex;
694− changed = true;
695− }
696−
697− return changed;
698−}
699−
700−void ListViewWithPageHeader::reallyReleaseItem(ListItem *listItem)
701−{
702− QQuickItem *item = listItem->m_item;
703− QQmlDelegateModel::ReleaseFlags flags = m_delegateModel->release(item);
704− if (flags & QQmlDelegateModel::Destroyed) {
705− item->setParentItem(nullptr);
706− }
707− if (listItem->sectionItem()) {
708− listItem->sectionItem()->deleteLater();
709− }
710− delete listItem;
711−}
712−
713−void ListViewWithPageHeader::releaseItem(ListItem *listItem)
714−{
715− QQuickItemPrivate::get(listItem->m_item)->removeItemChangeListener(this, QQuickItemPrivate::Geometry);
716− if (listItem->sectionItem()) {
717− QQuickItemPrivate::get(listItem->sectionItem())->removeItemChangeListener(this, QQuickItemPrivate::Geometry);
718− }
719− m_itemsToRelease << listItem;
720−}
721−
722−void ListViewWithPageHeader::updateWatchedRoles()
723−{
724− if (m_delegateModel) {
725− QList<QByteArray> roles;
726− if (!m_sectionProperty.isEmpty())
727− roles << m_sectionProperty.toUtf8();
728− m_delegateModel->setWatchedRoles(roles);
729− }
730−}
731−
732−QQuickItem *ListViewWithPageHeader::getSectionItem(int modelIndex, bool alreadyInserted)
733−{
734− if (!m_sectionDelegate)
735− return nullptr;
736−
737− const QString section = m_delegateModel->stringValue(modelIndex, m_sectionProperty);
738−
739− if (modelIndex > 0) {
740− const QString prevSection = m_delegateModel->stringValue(modelIndex - 1, m_sectionProperty);
741− if (section == prevSection)
742− return nullptr;
743− }
744− if (modelIndex + 1 < model()->rowCount() && !alreadyInserted) {
745− // Already inserted items can't steal next section header
746− const QString nextSection = m_delegateModel->stringValue(modelIndex + 1, m_sectionProperty);
747− if (section == nextSection) {
748− // Steal the section header
749− ListItem *nextItem = itemAtIndex(modelIndex); // Not +1 since not yet inserted into m_visibleItems
750− if (nextItem) {
751− QQuickItem *sectionItem = nextItem->sectionItem();
752− nextItem->setSectionItem(nullptr);
753− return sectionItem;
754− }
755− }
756− }
757−
758− return getSectionItem(section);
759−}
760−
761−QQuickItem *ListViewWithPageHeader::getSectionItem(const QString &sectionText, bool watchGeometry)
762−{
763− QQuickItem *sectionItem = nullptr;
764−
765− QQmlContext *creationContext = m_sectionDelegate->creationContext();
766− QQmlContext *context = new QQmlContext(creationContext ? creationContext : qmlContext(this));
767− QObject *nobj = m_sectionDelegate->beginCreate(context);
768− if (nobj) {
769− QQml_setParent_noEvent(context, nobj);
770− sectionItem = qobject_cast<QQuickItem *>(nobj);
771− if (!sectionItem) {
772− delete nobj;
773− } else {
774− sectionItem->setProperty("text", sectionText);
775− sectionItem->setProperty("delegate", QVariant());
776− sectionItem->setZ(2);
777− QQml_setParent_noEvent(sectionItem, m_clipItem);
778− sectionItem->setParentItem(m_clipItem);
779− }
780− } else {
781− delete context;
782− }
783− m_sectionDelegate->completeCreate();
784−
785− if (watchGeometry && sectionItem) {
786− QQuickItemPrivate::get(sectionItem)->addItemChangeListener(this, QQuickItemPrivate::Geometry);
787− }
788−
789− return sectionItem;
790−}
791−
792−void ListViewWithPageHeader::updateSectionItem(int modelIndex)
793−{
794− ListItem *item = itemAtIndex(modelIndex);
795− if (item) {
796− const QString sectionText = m_delegateModel->stringValue(modelIndex, m_sectionProperty);
797−
798− bool needSectionHeader = true;
799− // if it is the same section as the previous item need to drop the section
800− if (modelIndex > 0) {
801− const QString prevSection = m_delegateModel->stringValue(modelIndex - 1, m_sectionProperty);
802− if (sectionText == prevSection) {
803− needSectionHeader = false;
804− }
805− }
806−
807− if (needSectionHeader) {
808− if (!item->sectionItem()) {
809− item->setSectionItem(getSectionItem(sectionText));
810− } else {
811− item->sectionItem()->setProperty("text", sectionText);
812− }
813− } else {
814− if (item->sectionItem()) {
815− item->sectionItem()->deleteLater();
816− item->setSectionItem(nullptr);
817− }
818− }
819− }
820−}
821−
822−bool ListViewWithPageHeader::removeNonVisibleItems(qreal bufferFrom, qreal bufferTo)
823−{
824−// qDebug() << "ListViewWithPageHeader::removeNonVisibleItems" << bufferFrom << bufferTo;
825− // Do not remove items if we are overshooting up or down, since we'll come back
826− // to the "stable" position and delete/create items without any reason
827− if (contentY() < -m_minYExtent) {
828− return false;
829− } else if (contentY() + height() > contentHeight()) {
830− return false;
831− }
832− bool changed = false;
833−
834− bool foundVisible = false;
835− int i = 0;
836− int removedItems = 0;
837− const auto oldFirstVisibleIndex = m_firstVisibleIndex;
838− while (i < m_visibleItems.count()) {
839− ListItem *item = m_visibleItems[i];
840− const qreal pos = item->y() + m_clipItem->y();
841−// qDebug() << i << pos << (pos + item->height()) << bufferFrom << bufferTo;
842− if (pos + item->height() < bufferFrom || pos > bufferTo) {
843−// qDebug() << "Releasing" << i << (pos + item->height() < bufferFrom) << pos + item->height() << bufferFrom << (pos > bufferTo) << pos << bufferTo;
844− releaseItem(item);
845− m_visibleItems.removeAt(i);
846− changed = true;
847− ++removedItems;
848− } else {
849− if (!foundVisible) {
850− foundVisible = true;
851− const int itemIndex = m_firstVisibleIndex + removedItems + i;
852− m_firstVisibleIndex = itemIndex;
853− }
854− ++i;
855− }
856− }
857− if (!foundVisible) {
858− initializeValuesForEmptyList();
859− }
860− if (m_firstVisibleIndex != oldFirstVisibleIndex) {
861− adjustMinYExtent();
862− }
863−
864− return changed;
865−}
866−
867−ListViewWithPageHeader::ListItem *ListViewWithPageHeader::createItem(int modelIndex, bool asynchronous)
868−{
869−// qDebug() << "CREATE ITEM" << modelIndex;
870− if (asynchronous && m_asyncRequestedIndex != -1)
871− return nullptr;
872−
873− m_asyncRequestedIndex = -1;
874− QObject* object = m_delegateModel->object(modelIndex, asynchronous ? QQmlIncubator::Asynchronous : QQmlIncubator::AsynchronousIfNested);
875− QQuickItem *item = qmlobject_cast<QQuickItem*>(object);
876− if (!item) {
877− if (object) {
878− m_delegateModel->release(object);
879− if (!m_delegateValidated) {
880− m_delegateValidated = true;
881− QObject* delegateObj = delegate();
882− qmlInfo(delegateObj ? delegateObj : this) << "Delegate must be of Item type";
883− }
884− } else {
885− m_asyncRequestedIndex = modelIndex;
886− }
887− return 0;
888− } else {
889−// qDebug() << "ListViewWithPageHeader::createItem::We have the item" << modelIndex << item;
890− ListItem *listItem = new ListItem;
891− listItem->m_item = item;
892− listItem->setSectionItem(getSectionItem(modelIndex, false /*Not yet inserted into m_visibleItems*/));
893− QQuickItemPrivate::get(item)->addItemChangeListener(this, QQuickItemPrivate::Geometry);
894− ListItem *prevItem = itemAtIndex(modelIndex - 1);
895− bool lostItem = false; // Is an item that we requested async but because of model changes
896− // it is no longer attached to any of the existing items (has no prev nor next item)
897− // nor is the first item
898− if (prevItem) {
899− listItem->setY(prevItem->y() + prevItem->height());
900− } else {
901− ListItem *currItem = itemAtIndex(modelIndex);
902− if (currItem) {
903− // There's something already in m_visibleItems at out index, meaning this is an insert, so attach to its top
904− listItem->setY(currItem->y() - listItem->height());
905− } else {
906− ListItem *nextItem = itemAtIndex(modelIndex + 1);
907− if (nextItem) {
908− listItem->setY(nextItem->y() - listItem->height());
909− } else if (modelIndex == 0) {
910− listItem->setY(-m_clipItem->y() + (m_headerItem ? m_headerItem->height() : 0));
911− } else if (!m_visibleItems.isEmpty()) {
912− lostItem = true;
913− }
914− }
915− }
916− if (lostItem) {
917− listItem->setCulled(true);
918− releaseItem(listItem);
919− listItem = nullptr;
920− } else {
921− listItem->setCulled(listItem->y() + listItem->height() + m_clipItem->y() <= contentY() || listItem->y() + m_clipItem->y() >= contentY() + height());
922− if (m_visibleItems.isEmpty()) {
923− m_visibleItems << listItem;
924− } else {
925− m_visibleItems.insert(modelIndex - m_firstVisibleIndex, listItem);
926− }
927− if (m_firstVisibleIndex < 0 || modelIndex < m_firstVisibleIndex) {
928− m_firstVisibleIndex = modelIndex;
929− polish();
930− }
931− if (listItem->sectionItem()) {
932− listItem->sectionItem()->setProperty("delegate", QVariant::fromValue(listItem->m_item));
933− }
934− adjustMinYExtent();
935− m_contentHeightDirty = true;
936− }
937− return listItem;
938− }
939−}
940−
941−void ListViewWithPageHeader::itemCreated(int modelIndex, QObject *object)
942−{
943− QQuickItem *item = qmlobject_cast<QQuickItem*>(object);
944− if (!item) {
945− qWarning() << "ListViewWithPageHeader::itemCreated got a non item for index" << modelIndex;
946− return;
947− }
948−// qDebug() << "ListViewWithPageHeader::itemCreated" << modelIndex << item;
949− // Check we are not being taken down and don't paint anything
950− // TODO Check if we still need this in 5.2
951− // For reproduction just inifnite loop testDash or testDashContent
952− if (!QQmlEngine::contextForObject(this)->parentContext())
953− return;
954−
955− item->setParentItem(m_clipItem);
956− // FIXME Why do we need the refreshExpressions call?
957− QQmlContext *context = QQmlEngine::contextForObject(item)->parentContext();
958− QQmlContextPrivate::get(context)->data->refreshExpressions();
959− item->setProperty("heightToClip", QVariant::fromValue<int>(0));
960− if (modelIndex == m_asyncRequestedIndex) {
961− createItem(modelIndex, false);
962− refill();
963− }
964−}
965−
966−void ListViewWithPageHeader::updateClipItem()
967−{
968− m_clipItem->setHeight(height() - m_headerItemShownHeight);
969− m_clipItem->setY(contentY() + m_headerItemShownHeight);
970− m_clipItem->setClip(!m_forceNoClip && m_headerItemShownHeight > 0);
971−}
972−
973−void ListViewWithPageHeader::onContentHeightChanged()
974−{
975− updateClipItem();
976−}
977−
978−void ListViewWithPageHeader::onContentWidthChanged()
979−{
980− m_clipItem->setWidth(contentItem()->width());
981−}
982−
983−void ListViewWithPageHeader::onHeightChanged()
984−{
985− m_clipItem->setHeight(height() - m_headerItemShownHeight);
986− polish();
987−}
988−
989−
990−void ListViewWithPageHeader::onModelUpdated(const QQmlChangeSet &changeSet, bool /*reset*/)
991−{
992− // TODO Do something with reset
993−// qDebug() << "ListViewWithPageHeader::onModelUpdated" << changeSet << reset;
994− const auto oldFirstVisibleIndex = m_firstVisibleIndex;
995−
996− Q_FOREACH(const QQmlChangeSet::Change remove, changeSet.removes()) {
997−// qDebug() << "ListViewWithPageHeader::onModelUpdated Remove" << remove.index << remove.count;
998− if (remove.index + remove.count > m_firstVisibleIndex && remove.index < m_firstVisibleIndex + m_visibleItems.count()) {
999− const qreal oldFirstValidIndexPos = m_visibleItems.first()->y();
1000− // If all the items we are removing are either not created or culled
1001− // we have to grow down to avoid viewport changing
1002− bool growDown = true;
1003− for (int i = 0; growDown && i < remove.count; ++i) {
1004− const int modelIndex = remove.index + i;
1005− ListItem *item = itemAtIndex(modelIndex);
1006− if (item && !item->culled()) {
1007− growDown = false;
1008− }
1009− }
1010− for (int i = remove.count - 1; i >= 0; --i) {
1011− const int visibleIndex = remove.index + i - m_firstVisibleIndex;
1012− if (visibleIndex >= 0 && visibleIndex < m_visibleItems.count()) {
1013− ListItem *item = m_visibleItems[visibleIndex];
1014− // Pass the section item down if needed
1015− if (item->sectionItem() && visibleIndex + 1 < m_visibleItems.count()) {
1016− ListItem *nextItem = m_visibleItems[visibleIndex + 1];
1017− if (!nextItem->sectionItem()) {
1018− nextItem->setSectionItem(item->sectionItem());
1019− item->setSectionItem(nullptr);
1020− }
1021− }
1022− releaseItem(item);
1023− m_visibleItems.removeAt(visibleIndex);
1024− }
1025− }
1026− if (growDown) {
1027− adjustMinYExtent();
1028− } else if (remove.index <= m_firstVisibleIndex && !m_visibleItems.isEmpty()) {
1029− m_visibleItems.first()->setY(oldFirstValidIndexPos);
1030− }
1031− if (m_visibleItems.isEmpty()) {
1032− m_firstVisibleIndex = -1;
1033− } else {
1034− m_firstVisibleIndex -= qMax(0, m_firstVisibleIndex - remove.index);
1035− }
1036− } else if (remove.index + remove.count <= m_firstVisibleIndex) {
1037− m_firstVisibleIndex -= remove.count;
1038− }
1039− for (int i = remove.count - 1; i >= 0; --i) {
1040− const int modelIndex = remove.index + i;
1041− if (modelIndex == m_asyncRequestedIndex) {
1042− m_asyncRequestedIndex = -1;
1043− } else if (modelIndex < m_asyncRequestedIndex) {
1044− m_asyncRequestedIndex--;
1045− }
1046− }
1047− }
1048−
1049− Q_FOREACH(const QQmlChangeSet::Change insert, changeSet.inserts()) {
1050−// qDebug() << "ListViewWithPageHeader::onModelUpdated Insert" << insert.index << insert.count;
1051− const bool insertingInValidIndexes = insert.index > m_firstVisibleIndex && insert.index < m_firstVisibleIndex + m_visibleItems.count();
1052− const bool firstItemWithViewOnTop = insert.index == 0 && m_firstVisibleIndex == 0 && m_visibleItems.first()->y() + m_clipItem->y() > contentY();
1053− if (insertingInValidIndexes || firstItemWithViewOnTop)
1054− {
1055− // If the items we are adding won't be really visible
1056− // we grow up instead of down to not change the viewport
1057− bool growUp = false;
1058− if (!firstItemWithViewOnTop) {
1059− for (int i = 0; i < m_visibleItems.count(); ++i) {
1060− if (!m_visibleItems[i]->culled()) {
1061− if (insert.index <= m_firstVisibleIndex + i) {
1062− growUp = true;
1063− }
1064− break;
1065− }
1066− }
1067− }
1068−
1069− const qreal oldFirstValidIndexPos = m_visibleItems.first()->y();
1070− for (int i = insert.count - 1; i >= 0; --i) {
1071− const int modelIndex = insert.index + i;
1072− ListItem *item = createItem(modelIndex, false);
1073− if (growUp) {
1074− ListItem *firstItem = m_visibleItems.first();
1075− firstItem->setY(firstItem->y() - item->height());
1076− }
1077− // Adding an item may break a "same section" chain, so check
1078− // if we need adding a new section item
1079− if (m_sectionDelegate) {
1080− ListItem *nextItem = itemAtIndex(modelIndex + 1);
1081− if (nextItem && !nextItem->sectionItem()) {
1082− nextItem->setSectionItem(getSectionItem(modelIndex + 1, true /* alredy inserted into m_visibleItems*/));
1083− if (growUp && nextItem->sectionItem()) {
1084− ListItem *firstItem = m_visibleItems.first();
1085− firstItem->setY(firstItem->y() - nextItem->sectionItem()->height());
1086− }
1087− }
1088− }
1089− }
1090− if (firstItemWithViewOnTop) {
1091− ListItem *firstItem = m_visibleItems.first();
1092− firstItem->setY(oldFirstValidIndexPos);
1093− }
1094− adjustMinYExtent();
1095− } else if (insert.index <= m_firstVisibleIndex) {
1096− m_firstVisibleIndex += insert.count;
1097− }
1098−
1099− for (int i = insert.count - 1; i >= 0; --i) {
1100− const int modelIndex = insert.index + i;
1101− if (modelIndex <= m_asyncRequestedIndex) {
1102− m_asyncRequestedIndex++;
1103− }
1104− }
1105− }
1106−
1107− Q_FOREACH(const QQmlChangeSet::Change change, changeSet.changes()) {
1108− for (int i = change.start(); i < change.end(); ++i) {
1109− updateSectionItem(i);
1110− }
1111− // Also update the section header for the next item after the change since it may be influenced
1112− updateSectionItem(change.end());
1113− }
1114−
1115− if (m_firstVisibleIndex != oldFirstVisibleIndex) {
1116− if (m_visibleItems.isEmpty()) {
1117− initializeValuesForEmptyList();
1118− } else {
1119− adjustMinYExtent();
1120− }
1121− }
1122−
1123− for (int i = 0; i < m_visibleItems.count(); ++i) {
1124− ListItem *item = m_visibleItems[i];
1125− if (item->sectionItem()) {
1126− item->sectionItem()->setProperty("delegate", QVariant::fromValue(item->m_item));
1127− }
1128− }
1129−
1130− layout();
1131− polish();
1132− m_contentHeightDirty = true;
1133−}
1134−
1135−void ListViewWithPageHeader::contentYAnimationRunningChanged(bool running)
1136−{
1137− setInteractive(!running);
1138− if (!running) {
1139− m_contentHeightDirty = true;
1140− polish();
1141− }
1142−}
1143−
1144−/*
1145−void ListViewWithPageHeader::itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry)
1146−{
1147− const qreal heightDiff = newGeometry.height() - oldGeometry.height();
1148− if (heightDiff != 0) {
1149− if (!m_visibleItems.isEmpty()) {
1150− ListItem *firstItem = m_visibleItems.first();
1151− const auto prevFirstItemY = firstItem->y();
1152− if (!m_inContentHeightKeepHeaderShown && oldGeometry.y() + oldGeometry.height() + m_clipItem->y() <= contentY()) {
1153− firstItem->setY(firstItem->y() - heightDiff);
1154− } else if (item == firstItem->sectionItem()) {
1155− firstItem->setY(firstItem->y() + heightDiff);
1156− }
1157−
1158− if (firstItem->y() != prevFirstItemY) {
1159− adjustMinYExtent();
1160− layout();
1161− }
1162− }
1163− refill();
1164− adjustMinYExtent();
1165− polish();
1166− m_contentHeightDirty = true;
1167− }
1168−}
1169−*/
1170−
1171−void ListViewWithPageHeader::itemImplicitHeightChanged(QQuickItem *item)
1172−{
1173− if (item == m_headerItem) {
1174− const qreal diff = m_headerItem->implicitHeight() - m_previousHeaderImplicitHeight;
1175− if (diff != 0) {
1176− adjustHeader(diff);
1177− m_previousHeaderImplicitHeight = m_headerItem->implicitHeight();
1178− layout();
1179− polish();
1180− m_contentHeightDirty = true;
1181− }
1182− }
1183−}
1184−
1185−void ListViewWithPageHeader::headerHeightChanged(qreal newHeaderHeight, qreal oldHeaderHeight, qreal oldHeaderY)
1186−{
1187− const qreal heightDiff = newHeaderHeight - oldHeaderHeight;
1188− if (m_headerItemShownHeight > 0) {
1189− // If the header is shown because of the clip
1190− // Change its size
1191− m_headerItemShownHeight += heightDiff;
1192− m_headerItemShownHeight = qBound(static_cast<qreal>(0.), m_headerItemShownHeight, newHeaderHeight);
1193− updateClipItem();
1194− adjustMinYExtent();
1195− Q_EMIT headerItemShownHeightChanged();
1196− } else {
1197− if (oldHeaderY + oldHeaderHeight > contentY()) {
1198− // If the header is shown because its position
1199− // Change its size
1200− ListItem *firstItem = m_visibleItems.first();
1201− firstItem->setY(firstItem->y() + heightDiff);
1202− layout();
1203− } else {
1204− // If the header is not on screen, just change the start of the list
1205− // so the viewport is not changed
1206− adjustMinYExtent();
1207− }
1208− }
1209−}
1210−
1211−
1212−void ListViewWithPageHeader::adjustMinYExtent()
1213−{
1214− if (m_visibleItems.isEmpty() || (contentHeight() + m_minYExtent < height())) {
1215− m_minYExtent = 0;
1216− } else {
1217− qreal nonCreatedHeight = 0;
1218− if (m_firstVisibleIndex != 0) {
1219− // Calculate the average height of items to estimate the position of the list start
1220− const int visibleItems = m_visibleItems.count();
1221− qreal visibleItemsHeight = 0;
1222− Q_FOREACH(ListItem *item, m_visibleItems) {
1223− visibleItemsHeight += item->height();
1224− }
1225− nonCreatedHeight = m_firstVisibleIndex * visibleItemsHeight / visibleItems;
1226−// qDebug() << m_firstVisibleIndex << visibleItemsHeight << visibleItems << nonCreatedHeight;
1227− }
1228− const qreal headerHeight = (m_headerItem ? m_headerItem->implicitHeight() : 0);
1229− m_minYExtent = nonCreatedHeight - m_visibleItems.first()->y() - m_clipItem->y() + headerHeight;
1230− if (m_minYExtent != 0 && qFuzzyIsNull(m_minYExtent)) {
1231− m_minYExtent = 0;
1232− m_visibleItems.first()->setY(nonCreatedHeight - m_clipItem->y() + headerHeight);
1233− }
1234− }
1235−}
1236−
1237−ListViewWithPageHeader::ListItem *ListViewWithPageHeader::itemAtIndex(int modelIndex) const
1238−{
1239− const int visibleIndexedModelIndex = modelIndex - m_firstVisibleIndex;
1240− if (visibleIndexedModelIndex >= 0 && visibleIndexedModelIndex < m_visibleItems.count())
1241− return m_visibleItems[visibleIndexedModelIndex];
1242−
1243− return nullptr;
1244−}
1245−
1246−void ListViewWithPageHeader::layout()
1247−{
1248− if (m_inLayout)
1249− return;
1250−
1251− m_inLayout = true;
1252− if (!m_visibleItems.isEmpty()) {
1253− const qreal visibleFrom = contentY() - m_clipItem->y() + m_headerItemShownHeight;
1254− const qreal visibleTo = contentY() + height() - m_clipItem->y();
1255−
1256− qreal pos = m_visibleItems.first()->y();
1257−
1258−// qDebug() << "ListViewWithPageHeader::layout Updating positions and heights. contentY" << contentY() << "minYExtent" << minYExtent();
1259− int firstReallyVisibleItem = -1;
1260− int modelIndex = m_firstVisibleIndex;
1261− Q_FOREACH(ListItem *item, m_visibleItems) {
1262− const bool cull = pos + item->height() <= visibleFrom || pos >= visibleTo;
1263− item->setCulled(cull);
1264− item->setY(pos);
1265− if (!cull && firstReallyVisibleItem == -1) {
1266− firstReallyVisibleItem = modelIndex;
1267− if (m_topSectionItem) {
1268− // Positing the top section sticky item is a two step process
1269− // First we set it either we cull it (because it doesn't need to be sticked to the top)
1270− // or stick it to the top
1271− // Then after the loop we'll make sure that if there's another section just below it
1272− // pushed the sticky section up to make it disappear
1273− const qreal topSectionStickPos = m_headerItemShownHeight + contentY() - m_clipItem->y();
1274− bool showStickySectionItem;
1275− // We need to show the "top section sticky item" when the position at the "top" of the
1276− // viewport is bigger than the start of the position of the first visible item
1277− // i.e. the first visible item starts before the viewport, or when the first
1278− // visible item starts just at the viewport start and it does not have its own section item
1279− if (topSectionStickPos > pos) {
1280− showStickySectionItem = true;
1281− } else if (topSectionStickPos == pos) {
1282− showStickySectionItem = !item->sectionItem();
1283− } else {
1284− showStickySectionItem = false;
1285− }
1286− if (!showStickySectionItem) {
1287− QQuickItemPrivate::get(m_topSectionItem)->setCulled(true);
1288− if (item->sectionItem()) {
1289− // This seems it should happen since why would we cull the top section
1290− // if the first visible item has no section header? This only happens briefly
1291− // when increasing the height of a list that is at the bottom, the m_topSectionItem
1292− // gets shown shortly in the next polish call
1293− QQuickItemPrivate::get(item->sectionItem())->setCulled(false);
1294− }
1295− } else {
1296− // Update the top sticky section header
1297− const QString section = m_delegateModel->stringValue(modelIndex, m_sectionProperty);
1298− m_topSectionItem->setProperty("text", section);
1299−
1300− QQuickItemPrivate::get(m_topSectionItem)->setCulled(false);
1301− m_topSectionItem->setY(topSectionStickPos);
1302− m_topSectionItem->setProperty("delegate", QVariant::fromValue(item->m_item));
1303− if (item->sectionItem()) {
1304− QQuickItemPrivate::get(item->sectionItem())->setCulled(true);
1305− }
1306− }
1307− }
1308− }
1309− const qreal clipFrom = visibleFrom + (!item->sectionItem() && m_topSectionItem && !QQuickItemPrivate::get(m_topSectionItem)->culled ? m_topSectionItem->height() : 0);
1310− if (!cull && pos < clipFrom) {
1311− item->m_item->setProperty("heightToClip", clipFrom - pos);
1312− } else {
1313− item->m_item->setProperty("heightToClip", QVariant::fromValue<int>(0));
1314− }
1315−// qDebug() << "ListViewWithPageHeader::layout" << item->m_item;
1316− pos += item->height();
1317− ++modelIndex;
1318− }
1319−
1320− // Second step of section sticky item positioning
1321− // Look at the next section header, check if it's pushing up the sticky one
1322− if (m_topSectionItem) {
1323− if (firstReallyVisibleItem >= 0) {
1324− for (int i = firstReallyVisibleItem - m_firstVisibleIndex + 1; i < m_visibleItems.count(); ++i) {
1325− ListItem *item = m_visibleItems[i];
1326− if (item->sectionItem()) {
1327− if (m_topSectionItem->y() + m_topSectionItem->height() > item->y()) {
1328− m_topSectionItem->setY(item->y() - m_topSectionItem->height());
1329− }
1330− break;
1331− }
1332− }
1333− }
1334− }
1335− }
1336− if (m_headerItem) {
1337− const bool cullHeader = m_headerItem->y() + m_headerItem->height() < contentY();
1338− QQuickItemPrivate::get(m_headerItem)->setCulled(cullHeader);
1339− }
1340− m_inLayout = false;
1341−}
1342−
1343−void ListViewWithPageHeader::updatePolish()
1344−{
1345− // Check we are not being taken down and don't paint anything
1346− // TODO Check if we still need this in 5.2
1347− // For reproduction just inifnite loop testDash or testDashContent
1348− if (!QQmlEngine::contextForObject(this)->parentContext())
1349− return;
1350−
1351− Q_FOREACH(ListItem *item, m_itemsToRelease)
1352− reallyReleaseItem(item);
1353− m_itemsToRelease.clear();
1354−
1355− if (!model())
1356− return;
1357−
1358− layout();
1359−
1360− refill();
1361−
1362− if (m_contentHeightDirty) {
1363− qreal contentHeight;
1364− if (m_visibleItems.isEmpty()) {
1365− contentHeight = m_headerItem ? m_headerItem->height() : 0;
1366− } else {
1367− const int modelCount = model()->rowCount();
1368− const int visibleItems = m_visibleItems.count();
1369− const int lastValidIndex = m_firstVisibleIndex + visibleItems - 1;
1370− qreal nonCreatedHeight = 0;
1371− if (lastValidIndex != modelCount - 1) {
1372− const int visibleItems = m_visibleItems.count();
1373− qreal visibleItemsHeight = 0;
1374− Q_FOREACH(ListItem *item, m_visibleItems) {
1375− visibleItemsHeight += item->height();
1376− }
1377− const int unknownSizes = modelCount - (m_firstVisibleIndex + visibleItems);
1378− nonCreatedHeight = unknownSizes * visibleItemsHeight / visibleItems;
1379− }
1380− ListItem *item = m_visibleItems.last();
1381− contentHeight = nonCreatedHeight + item->y() + item->height() + m_clipItem->y();
1382− if (m_firstVisibleIndex != 0) {
1383− // Make sure that if we are shrinking we tell the view we still fit
1384− m_minYExtent = qMax(m_minYExtent, -(contentHeight - height()));
1385− }
1386− }
1387−
1388− m_contentHeightDirty = false;
1389− adjustMinYExtent();
1390− m_inContentHeightKeepHeaderShown = m_headerItem && m_headerItem->y() == contentY();
1391− setContentHeight(contentHeight);
1392− m_inContentHeightKeepHeaderShown = false;
1393− }
1394−}
1395−
1396−#include "moc_listviewwithpageheader.cpp"
plugins/Dash/listviewwithpageheader.hdeleted−218
@@ -1,218 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef LISTVIEWWITHPAGEHEADER_H
18−#define LISTVIEWWITHPAGEHEADER_H
19−
20−#include <private/qquickitemchangelistener_p.h>
21−#include <private/qquickflickable_p.h>
22−
23−class QAbstractItemModel;
24−class QQuickNumberAnimation;
25−class QQmlChangeSet;
26−class QQmlDelegateModel;
27−
28−
29−/**
30− Note for users of this class
31−
32− ListViewWithPageHeader already loads delegates async when appropiate so if
33− your delegate uses a Loader you should not enable the asynchronous feature since
34− that will need to introduce sizing problems
35−
36− With the double async it may happen what while we are scrolling down
37− we reach to a point where given the size of the just created delegate with loader not yet loaded (which will be very close to 0)
38− we are already "at the end" of the list, but then a few milliseconds later the loader finishes loading and we could
39− have kept scrolling. This is specially visible at the end of the list where you realize
40− that scrolling ended a bit before the end of the list but the speed of the flicking was good
41− to reach the end
42−
43− By not having the second async we get a better sizing when the delegate is created and things work better
44−*/
45−
46−class ListViewWithPageHeader : public QQuickFlickable, public QQuickItemChangeListener
47−{
48− Q_OBJECT
49− Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelChanged)
50− Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
51− Q_PROPERTY(QQuickItem *pageHeader READ header WRITE setHeader NOTIFY headerChanged)
52− Q_PROPERTY(QQmlComponent *sectionDelegate READ sectionDelegate WRITE setSectionDelegate NOTIFY sectionDelegateChanged)
53− Q_PROPERTY(QString sectionProperty READ sectionProperty WRITE setSectionProperty NOTIFY sectionPropertyChanged)
54− Q_PROPERTY(bool forceNoClip READ forceNoClip WRITE setForceNoClip NOTIFY forceNoClipChanged)
55− Q_PROPERTY(int stickyHeaderHeight READ stickyHeaderHeight NOTIFY stickyHeaderHeightChanged)
56− Q_PROPERTY(qreal headerItemShownHeight READ headerItemShownHeight NOTIFY headerItemShownHeightChanged)
57− Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer NOTIFY cacheBufferChanged)
58−
59− friend class ListViewWithPageHeaderTest;
60− friend class ListViewWithPageHeaderTestSection;
61− friend class ListViewWithPageHeaderTestExternalModel;
62−
63−public:
64− ListViewWithPageHeader();
65− ~ListViewWithPageHeader();
66−
67− QAbstractItemModel *model() const;
68− void setModel(QAbstractItemModel *model);
69−
70− QQmlComponent *delegate() const;
71− void setDelegate(QQmlComponent *delegate);
72−
73− QQuickItem *header() const;
74− void setHeader(QQuickItem *header);
75−
76− QQmlComponent *sectionDelegate() const;
77− void setSectionDelegate(QQmlComponent *delegate);
78−
79− QString sectionProperty() const;
80− void setSectionProperty(const QString &property);
81−
82− bool forceNoClip() const;
83− void setForceNoClip(bool noClip);
84−
85− int stickyHeaderHeight() const;
86− qreal headerItemShownHeight() const;
87−
88− int cacheBuffer() const;
89− void setCacheBuffer(int cacheBuffer);
90−
91− Q_INVOKABLE void positionAtBeginning();
92− Q_INVOKABLE void showHeader();
93− Q_INVOKABLE int firstCreatedIndex() const;
94− Q_INVOKABLE int createdItemCount() const;
95− Q_INVOKABLE QQuickItem *item(int modelIndex) const;
96−
97− // The index has to be created for this to try to do something
98− // Created items are those visible and the precached ones
99− // Returns if the item existed or not
100− Q_INVOKABLE bool maximizeVisibleArea(int modelIndex);
101− Q_INVOKABLE bool maximizeVisibleArea(int modelIndex, int itemHeight);
102−
103−Q_SIGNALS:
104− void modelChanged();
105− void delegateChanged();
106− void headerChanged();
107− void sectionDelegateChanged();
108− void sectionPropertyChanged();
109− void forceNoClipChanged();
110− void stickyHeaderHeightChanged();
111− void headerItemShownHeightChanged();
112− void cacheBufferChanged();
113−
114−protected:
115− void componentComplete() override;
116− void viewportMoved(Qt::Orientations orient) override;
117− qreal minYExtent() const override;
118− qreal maxYExtent() const override;
119− //void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) override;
120− void itemImplicitHeightChanged(QQuickItem *item) override;
121− void updatePolish() override;
122−
123−private Q_SLOTS:
124− void itemCreated(int modelIndex, QObject *object);
125− void onContentHeightChanged();
126− void onContentWidthChanged();
127− void onHeightChanged();
128− void onModelUpdated(const QQmlChangeSet &changeSet, bool reset);
129− void contentYAnimationRunningChanged(bool running);
130−
131−private:
132− class ListItem
133− {
134− public:
135− qreal height() const;
136−
137− qreal y() const;
138− void setY(qreal newY);
139−
140− bool culled() const;
141− void setCulled(bool culled);
142−
143− QQuickItem *sectionItem() const { return m_sectionItem; }
144− void setSectionItem(QQuickItem *sectionItem);
145−
146− QQuickItem *m_item;
147− private:
148− QQuickItem *m_sectionItem;
149− };
150−
151− bool maximizeVisibleArea(ListItem *listItem, int listItemHeight);
152−
153− void createDelegateModel();
154−
155− void layout();
156− void refill();
157− bool addVisibleItems(qreal fillFrom, qreal fillTo, bool asynchronous);
158− bool removeNonVisibleItems(qreal bufferFrom, qreal bufferTo);
159− ListItem *createItem(int modelIndex, bool asynchronous);
160−
161− void adjustHeader(qreal diff);
162− void adjustMinYExtent();
163− void updateClipItem();
164− void headerHeightChanged(qreal newHeaderHeight, qreal oldHeaderHeight, qreal oldHeaderY);
165− ListItem *itemAtIndex(int modelIndex) const; // Returns the item at modelIndex if has been created
166− void releaseItem(ListItem *item);
167− void reallyReleaseItem(ListItem *item);
168− void updateWatchedRoles();
169− QQuickItem *getSectionItem(int modelIndex, bool alreadyInserted);
170− QQuickItem *getSectionItem(const QString &sectionText, bool watchGeometry = true);
171− void updateSectionItem(int modelIndex);
172− void initializeValuesForEmptyList();
173−
174− QQmlDelegateModel *m_delegateModel;
175−
176− // Index we are waiting because we requested it asynchronously
177− int m_asyncRequestedIndex;
178−
179− // Used to only give a warning once if the delegate does not return objects
180− bool m_delegateValidated;
181−
182− // Visible indexes, [0] is m_firstValidIndex, [0+1] is m_firstValidIndex +1, ...
183− QList<ListItem *> m_visibleItems;
184− int m_firstVisibleIndex;
185−
186− qreal m_minYExtent;
187−
188− QQuickItem *m_clipItem;
189−
190− // If any of the heights has changed
191− // or new items have been added/removed
192− bool m_contentHeightDirty;
193−
194− QQuickItem *m_headerItem;
195− qreal m_previousContentY;
196− qreal m_previousHeaderImplicitHeight;
197− qreal m_headerItemShownHeight; // The height of header shown when the header is shown outside its topmost position
198− // i.e. it's being shown after dragging down in the middle of the list
199− enum ContentYAnimationType { ContentYAnimationShowHeader, ContentYAnimationMaximizeVisibleArea };
200− ContentYAnimationType contentYAnimationType;
201− QQuickNumberAnimation *m_contentYAnimation;
202−
203− QQmlComponent *m_sectionDelegate;
204− QString m_sectionProperty;
205− QQuickItem *m_topSectionItem;
206−
207− bool m_forceNoClip;
208− bool m_inLayout;
209− bool m_inContentHeightKeepHeaderShown;
210− int m_cacheBuffer;
211−
212− // Qt 5.0 doesn't like releasing the items just after itemCreated
213− // so we delay the releasing until the next updatePolish
214− QList<ListItem *> m_itemsToRelease;
215−};
216−
217−
218−#endif
plugins/Dash/organicgrid.cppdeleted−259
@@ -1,259 +0,0 @@
1−/*
2− * Copyright (C) 2014, 2016 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "organicgrid.h"
18−
19−#include <math.h>
20−
21−#include <private/qquickitem_p.h>
22−
23−OrganicGrid::OrganicGrid()
24− : m_firstVisibleIndex(-1)
25− , m_numberOfModulesPerRow(-1)
26−{
27−}
28−
29−QSizeF OrganicGrid::smallDelegateSize() const
30−{
31− return m_smallDelegateSize;
32−}
33−
34−void OrganicGrid::setSmallDelegateSize(const QSizeF size)
35−{
36− if (m_smallDelegateSize != size) {
37− m_smallDelegateSize = size;
38− Q_EMIT smallDelegateSizeChanged();
39−
40− if (isComponentComplete()) {
41− relayout();
42− }
43− }
44−}
45−
46−QSizeF OrganicGrid::bigDelegateSize() const
47−{
48− return m_bigDelegateSize;
49−}
50−
51−void OrganicGrid::setBigDelegateSize(const QSizeF size)
52−{
53− if (m_bigDelegateSize != size) {
54− m_bigDelegateSize = size;
55− Q_EMIT bigDelegateSizeChanged();
56−
57− if (isComponentComplete()) {
58− relayout();
59− }
60− }
61−}
62−
63−QPointF OrganicGrid::positionForIndex(int modelIndex) const
64−{
65− const qreal moduleHeight = m_smallDelegateSize.height() + rowSpacing() + m_bigDelegateSize.height();
66− const qreal moduleWidth = m_smallDelegateSize.width() * 2 + columnSpacing() * 2 + m_bigDelegateSize.width();
67− const int itemsPerRow = m_numberOfModulesPerRow * 6;
68− const int rowIndex = floor(modelIndex / itemsPerRow);
69− const int columnIndex = floor((modelIndex - rowIndex * itemsPerRow) / 6);
70−
71− qreal yPos = (moduleHeight + rowSpacing()) * rowIndex;
72− const int moduleIndex = modelIndex % 6;
73− if (moduleIndex == 2) {
74− yPos += m_smallDelegateSize.height() + rowSpacing();
75− } else if (moduleIndex == 3 || moduleIndex == 5) {
76− yPos += m_bigDelegateSize.height() + rowSpacing();
77− }
78−
79− qreal xPos = (moduleWidth + columnSpacing()) * columnIndex;
80− if (moduleIndex == 1) {
81− xPos += m_smallDelegateSize.width() + columnSpacing();
82− } else if (moduleIndex == 3) {
83− xPos += m_bigDelegateSize.width() + columnSpacing();
84− } else if (moduleIndex == 4) {
85− xPos += (m_smallDelegateSize.width() + columnSpacing()) * 2;
86− } else if (moduleIndex == 5) {
87− xPos += m_bigDelegateSize.width() + m_smallDelegateSize.width() + columnSpacing() * 2;
88− }
89−
90− return QPointF(xPos, yPos);
91−}
92−
93−QSizeF OrganicGrid::sizeForIndex(int modelIndex) const
94−{
95− const int moduleIndex = modelIndex % 6;
96− if (moduleIndex == 0 || moduleIndex == 1 || moduleIndex == 3 || moduleIndex == 5) {
97− return m_smallDelegateSize;
98− } else {
99− return m_bigDelegateSize;
100− }
101−}
102−
103−void OrganicGrid::findBottomModelIndexToAdd(int *modelIndex, qreal *yPos)
104−{
105− if (m_visibleItems.isEmpty()) {
106− *modelIndex = 0;
107− *yPos = 0;
108− } else {
109− *modelIndex = m_firstVisibleIndex + m_visibleItems.count();
110− // We create stuff in a 6-module basis, so always return back
111− // the y position of the first item
112− const int firstModuleIndex = ((*modelIndex) / 6) * 6;
113− *yPos = positionForIndex(firstModuleIndex).y();
114− }
115−}
116−
117−void OrganicGrid::findTopModelIndexToAdd(int *modelIndex, qreal *yPos)
118−{
119− if (m_visibleItems.isEmpty()) {
120− *modelIndex = 0;
121− *yPos = 0;
122− } else {
123− *modelIndex = m_firstVisibleIndex - 1;
124− // We create stuff in a 6-module basis, so always return back
125− // the y position of the last item bottom
126− const int lastModuleIndex = ((*modelIndex) / 6) * 6 + 5;
127− *yPos = positionForIndex(lastModuleIndex).y();
128− *yPos += sizeForIndex(lastModuleIndex).height();
129− }
130−}
131−
132−void OrganicGrid::addItemToView(int modelIndex, QQuickItem *item)
133−{
134− // modelIndex has to be either m_firstVisibleIndex - 1 or m_firstVisibleIndex + m_visibleItems.count() or the first
135− if (modelIndex == m_firstVisibleIndex + m_visibleItems.count()) {
136− m_visibleItems << item;
137− } else if (modelIndex == m_firstVisibleIndex - 1) {
138− m_firstVisibleIndex = modelIndex;
139− m_visibleItems.prepend(item);
140− } else if (modelIndex == 0) {
141− m_firstVisibleIndex = 0;
142− m_visibleItems << item;
143− } else {
144− qWarning() << "OrganicGrid::addItemToView - Got unexpected modelIndex"
145− << modelIndex << m_firstVisibleIndex << m_visibleItems.count();
146− return;
147− }
148−
149− const QPointF pos = positionForIndex(modelIndex);
150− item->setPosition(pos);
151−
152− item->setSize(sizeForIndex(modelIndex));
153−}
154−
155−bool OrganicGrid::removeNonVisibleItems(qreal bufferFromY, qreal bufferToY)
156−{
157− bool changed = false;
158−
159− // As adding, we also remove in a 6-module basis
160− int lastModuleIndex = (m_firstVisibleIndex / 6) * 6 + 5;
161− bool removeIndex = positionForIndex(lastModuleIndex).y() + sizeForIndex(lastModuleIndex).height() < bufferFromY;
162− while (removeIndex && !m_visibleItems.isEmpty()) {
163− releaseItem(m_visibleItems.takeFirst());
164− changed = true;
165− m_firstVisibleIndex++;
166−
167− lastModuleIndex = (m_firstVisibleIndex / 6) * 6 + 5;
168− removeIndex = positionForIndex(lastModuleIndex).y() + sizeForIndex(lastModuleIndex).height() < bufferFromY;
169− }
170−
171− int firstModuleIndex = ((m_firstVisibleIndex + m_visibleItems.count() - 1) / 6) * 6;
172− removeIndex = positionForIndex(firstModuleIndex).y() > bufferToY;
173− while (removeIndex && !m_visibleItems.isEmpty()) {
174− releaseItem(m_visibleItems.takeLast());
175− changed = true;
176−
177− firstModuleIndex = ((m_firstVisibleIndex + m_visibleItems.count() - 1) / 6) * 6;
178− removeIndex = positionForIndex(firstModuleIndex).y() > bufferToY;
179− }
180−
181− if (m_visibleItems.isEmpty()) {
182− m_firstVisibleIndex = -1;
183− }
184−
185− return changed;
186−}
187−
188−void OrganicGrid::cleanupExistingItems()
189−{
190− Q_FOREACH(QQuickItem *item, m_visibleItems)
191− releaseItem(item);
192− m_visibleItems.clear();
193− m_firstVisibleIndex = -1;
194− setImplicitHeightDirty();
195−}
196−
197−void OrganicGrid::doRelayout()
198−{
199− const qreal moduleWidth = m_smallDelegateSize.width() * 2 + columnSpacing() * 2 + m_bigDelegateSize.width();
200− m_numberOfModulesPerRow = floor((width() + columnSpacing()) / (moduleWidth + columnSpacing()));
201− m_numberOfModulesPerRow = qMax(1, m_numberOfModulesPerRow);
202−
203− int i = m_firstVisibleIndex;
204− const QList<QQuickItem*> allItems = m_visibleItems;
205− m_visibleItems.clear();
206− Q_FOREACH(QQuickItem *item, allItems) {
207− addItemToView(i, item);
208− ++i;
209− }
210−}
211−
212−void OrganicGrid::updateItemCulling(qreal visibleFromY, qreal visibleToY)
213−{
214− Q_FOREACH(QQuickItem *item, m_visibleItems) {
215− QQuickItemPrivate::get(item)->setCulled(item->y() + item->height() <= visibleFromY || item->y() >= visibleToY);
216− }
217−}
218−
219−void OrganicGrid::calculateImplicitHeight()
220−{
221− const qreal moduleHeight = m_smallDelegateSize.height() + rowSpacing() + m_bigDelegateSize.height();
222− const int itemCount = !model() ? 0 : model()->rowCount();
223− const int itemsPerRow = m_numberOfModulesPerRow * 6;
224− const int fullRows = floor(itemCount / itemsPerRow);
225− const qreal fullRowsHeight = fullRows == 0 ? 0 : fullRows * moduleHeight + rowSpacing() * (fullRows - 1);
226−
227− const int remainingItems = itemCount - fullRows * itemsPerRow;
228− if (remainingItems == 0) {
229− setImplicitHeight(fullRowsHeight);
230− } else if (remainingItems <= 2) {
231− setImplicitHeight(fullRowsHeight + m_smallDelegateSize.height() + rowSpacing());
232− } else {
233− setImplicitHeight(fullRowsHeight + rowSpacing() + moduleHeight);
234− }
235−}
236−
237−void OrganicGrid::processModelRemoves(const QVector<QQmlChangeSet::Change> &removes)
238−{
239− Q_FOREACH(const QQmlChangeSet::Change remove, removes) {
240− for (int i = remove.count - 1; i >= 0; --i) {
241− const int indexToRemove = remove.index + i;
242− // We only support removing from the end
243− const int lastIndex = m_firstVisibleIndex + m_visibleItems.count() - 1;
244− if (indexToRemove == lastIndex) {
245− releaseItem(m_visibleItems.takeLast());
246− } else {
247− if (indexToRemove < lastIndex) {
248− qDebug() << "OrganicGrid only supports removal from the end of the model, resetting instead";
249− cleanupExistingItems();
250− break;
251− }
252− }
253− }
254− }
255− if (m_visibleItems.isEmpty()) {
256− m_firstVisibleIndex = -1;
257− }
258− setImplicitHeightDirty();
259−}
plugins/Dash/organicgrid.hdeleted−91
@@ -1,91 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef ORGANICGRID_H
18−#define ORGANICGRID_H
19−
20−#include "abstractdashview.h"
21−
22− /** An Organic Grid is is a view that creates delegates
23− * based on a model and layouts them in groups of six items (called module).
24− *
25− * In each module there are 4 items that are forced to the small delegate size
26− * and two that are forced to the big delegate size.
27− *
28− * Example:
29− *
30− * +---+ +---+ +-----+
31− * | 1 | | 2 | | |
32− * +---+ +---+ | 5 |
33− * +-----+ | |
34− * | | +-----+
35− * | 3 | +---+ +---+
36− * | | | 4 | | 6 |
37− * +-----+ +---+ +---+
38− *
39− * Modules are positioned one after the other in a grid like fashion, i.e.
40− *
41− * +---+ +---+
42− * | 1 | | 2 |
43− * +---+ +---+
44− * +---+ +---+
45− * | 3 | | 4 |
46− * +---+ +---+
47− */
48−
49−class OrganicGrid : public AbstractDashView
50−{
51− Q_OBJECT
52−
53− Q_PROPERTY(QSizeF smallDelegateSize READ smallDelegateSize WRITE setSmallDelegateSize NOTIFY smallDelegateSizeChanged)
54− Q_PROPERTY(QSizeF bigDelegateSize READ bigDelegateSize WRITE setBigDelegateSize NOTIFY bigDelegateSizeChanged)
55−
56−friend class OrganicGridTest;
57−
58−public:
59− OrganicGrid();
60−
61− QSizeF smallDelegateSize() const;
62− void setSmallDelegateSize(const QSizeF size);
63−
64− QSizeF bigDelegateSize() const;
65− void setBigDelegateSize(const QSizeF size);
66−
67−Q_SIGNALS:
68− void smallDelegateSizeChanged();
69− void bigDelegateSizeChanged();
70−private:
71− QPointF positionForIndex(int modelIndex) const;
72− QSizeF sizeForIndex(int modelIndex) const;
73−
74− void findBottomModelIndexToAdd(int *modelIndex, qreal *yPos) override;
75− void findTopModelIndexToAdd(int *modelIndex, qreal *yPos) override;
76− void addItemToView(int modelIndex, QQuickItem *item) override;
77− bool removeNonVisibleItems(qreal bufferFromY, qreal bufferToY) override;
78− void cleanupExistingItems() override;
79− void doRelayout() override;
80− void updateItemCulling(qreal visibleFromY, qreal visibleToY) override;
81− void calculateImplicitHeight() override;
82− void processModelRemoves(const QVector<QQmlChangeSet::Change> &removes) override;
83−
84− QSizeF m_smallDelegateSize;
85− QSizeF m_bigDelegateSize;
86− int m_firstVisibleIndex;
87− int m_numberOfModulesPerRow;
88− QList<QQuickItem*> m_visibleItems;
89−};
90−
91−#endif
plugins/Dash/plugin.cppdeleted−70
@@ -1,70 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− */
17−
18−#include "plugin.h"
19−
20−#include "horizontaljournal.h"
21−#include "listviewwithpageheader.h"
22−#include "organicgrid.h"
23−#include "verticaljournal.h"
24−
25−#include <QAbstractItemModel>
26−#include <QUrlQuery>
27−
28−static QUrl oauthCleanedUrl(QUrl u)
29−{
30− QUrlQuery q(u);
31− q.removeQueryItem(QStringLiteral("oauth_nonce"));
32− q.removeQueryItem(QStringLiteral("oauth_timestamp"));
33− q.removeQueryItem(QStringLiteral("oauth_consumer_key"));
34− q.removeQueryItem(QStringLiteral("oauth_signature_method"));
35− q.removeQueryItem(QStringLiteral("oauth_version"));
36− q.removeQueryItem(QStringLiteral("oauth_signature"));
37− u.setQuery(q);
38− return u;
39−}
40−
41−class AudioComparer : public QObject
42−{
43− Q_OBJECT
44−public:
45− Q_INVOKABLE bool compare(const QUrl &url1, const QUrl &url2)
46− {
47− return oauthCleanedUrl(url1) == oauthCleanedUrl(url2);
48− }
49−};
50−
51−static QObject *audio_comparer_singleton_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
52−{
53− Q_UNUSED(engine)
54− Q_UNUSED(scriptEngine)
55−
56− return new AudioComparer();
57−}
58−
59−void DashPlugin::registerTypes(const char *uri)
60−{
61− Q_ASSERT(uri == QLatin1String("Dash"));
62− qmlRegisterType<QAbstractItemModel>();
63− qmlRegisterType<HorizontalJournal>(uri, 0, 1, "HorizontalJournal");
64− qmlRegisterType<ListViewWithPageHeader>(uri, 0, 1, "ListViewWithPageHeader");
65− qmlRegisterType<OrganicGrid>(uri, 0, 1, "OrganicGrid");
66− qmlRegisterType<VerticalJournal>(uri, 0, 1, "VerticalJournal");
67− qmlRegisterSingletonType<AudioComparer>(uri, 0, 1, "AudioUrlComparer", audio_comparer_singleton_provider);
68−}
69−
70−#include "plugin.moc"
plugins/Dash/plugin.hdeleted−33
@@ -1,33 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− */
17−
18−#ifndef DASH_PLUGIN_H
19−#define DASH_PLUGIN_H
20−
21−#include <QtQml/QQmlEngine>
22−#include <QtQml/QQmlExtensionPlugin>
23−
24−class DashPlugin : public QQmlExtensionPlugin
25−{
26− Q_OBJECT
27− Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
28−
29−public:
30− void registerTypes(const char *uri) override;
31−};
32−
33−#endif
plugins/Dash/qmldirdeleted−11
@@ -1,11 +0,0 @@
1−module Dash
2−plugin Dash-qml
3−typeinfo Dash.qmltypes
4−singleton CardCreatorCache 0.1 CardCreatorCache.qml
5−singleton DashAudioPlayer 0.1 DashAudioPlayer.qml
6−ScopeStyle 0.1 ScopeStyle.qml
7−CardAttributes 0.1 CardAttributes.qml
8−CardSocialActions 0.1 CardSocialActions.qml
9−CroppedImageMinimumSourceSize 0.1 CroppedImageMinimumSourceSize.qml
10−AudioProgressBar 0.1 AudioProgressBar.qml
11−CardAudioProgress 0.1 CardAudioProgress.qml
plugins/Dash/verticaljournal.cppdeleted−281
@@ -1,281 +0,0 @@
1−/*
2− * Copyright (C) 2013, 2016 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−/*
18− * The implementation is centered around m_columnVisibleItems
19− * that holds a vector of lists. There's a list for each of the
20− * columns the view has. In the list the items of the column are
21− * ordered as they appear topdown in the view. m_indexColumnMap is
22− * used when re-building the list up since given a position
23− * in the middle of the list and the need to create the previous does
24− * not give us enough information to know in which column we have
25− * to position the item so that when we reach the item the view is
26− * correctly layouted at 0 for all the columns
27− */
28−#include "verticaljournal.h"
29−
30−#include <math.h>
31−
32−#include <private/qquickitem_p.h>
33−
34−VerticalJournal::VerticalJournal()
35− : m_columnWidth(0)
36−{
37−}
38−
39−qreal VerticalJournal::columnWidth() const
40−{
41− return m_columnWidth;
42−}
43−
44−void VerticalJournal::setColumnWidth(qreal columnWidth)
45−{
46− if (columnWidth != m_columnWidth) {
47− m_columnWidth = columnWidth;
48− Q_EMIT columnWidthChanged();
49−
50− if (isComponentComplete()) {
51− Q_FOREACH(const auto &column, m_columnVisibleItems) {
52− Q_FOREACH(const ViewItem item, column) {
53− item.m_item->setWidth(columnWidth);
54− }
55− }
56− relayout();
57− }
58− }
59−}
60−
61−void VerticalJournal::findBottomModelIndexToAdd(int *modelIndex, qreal *yPos)
62−{
63− *modelIndex = 0;
64− *yPos = std::numeric_limits<qreal>::max();
65−
66− Q_FOREACH(const auto &column, m_columnVisibleItems) {
67− if (!column.isEmpty()) {
68− const ViewItem &item = column.last();
69− *yPos = qMin(*yPos, item.y() + item.height() + rowSpacing());
70− *modelIndex = qMax(*modelIndex, item.m_modelIndex + 1);
71− } else {
72− *yPos = 0;
73− }
74− }
75−}
76−
77−void VerticalJournal::findTopModelIndexToAdd(int *modelIndex, qreal *yPos)
78−{
79− *modelIndex = 0;
80− *yPos = std::numeric_limits<qreal>::lowest();
81− int columnToAddTo = -1;
82−
83− // Find the topmost free column
84− for (int i = 0; i < m_columnVisibleItems.count(); ++i) {
85− const auto &column = m_columnVisibleItems[i];
86− if (!column.isEmpty()) {
87− const ViewItem &item = column.first();
88− const auto itemTopPos = item.y() - rowSpacing();
89− if (itemTopPos > *yPos) {
90− *yPos = itemTopPos;
91− *modelIndex = item.m_modelIndex - 1;
92− columnToAddTo = i;
93− }
94− }
95− }
96−
97− if (*modelIndex > 0) {
98− Q_ASSERT(m_indexColumnMap.contains(*modelIndex));
99− while (*modelIndex > 0 && m_indexColumnMap[*modelIndex] != columnToAddTo) {
100− // We found out that we have to add to columnToAddTo
101− // and thought that we had to add *modelIndex, but history tells
102− // it is not correct, so find up from *modelIndex until we found the index
103− // that has to end up in columnToAddTo
104− *modelIndex = *modelIndex - 1;
105− Q_ASSERT(m_indexColumnMap.contains(*modelIndex));
106− }
107− }
108−}
109−
110−bool VerticalJournal::removeNonVisibleItems(qreal bufferFromY, qreal bufferToY)
111−{
112− bool changed = false;
113−
114− for (int i = 0; i < m_columnVisibleItems.count(); ++i) {
115− QList<ViewItem> &column = m_columnVisibleItems[i];
116− while (!column.isEmpty() && column.first().y() + column.first().height() < bufferFromY) {
117− releaseItem(column.takeFirst().m_item);
118− changed = true;
119− }
120−
121− while (!column.isEmpty() && column.last().y() > bufferToY) {
122− releaseItem(column.takeLast().m_item);
123− changed = true;
124− }
125− }
126−
127− return changed;
128−}
129−
130−void VerticalJournal::addItemToView(int modelIndex, QQuickItem *item)
131−{
132− if (item->width() != m_columnWidth) {
133− qWarning() << "Item" << modelIndex << "width is not the one that the columnWidth mandates, resetting it";
134− item->setWidth(m_columnWidth);
135− }
136−
137− // Check if we add it to the bottom of existing column items
138− const QList<ViewItem> &firstColumn = m_columnVisibleItems[0];
139− qreal columnToAddY = !firstColumn.isEmpty() ? firstColumn.last().y() + firstColumn.last().height() : -rowSpacing();
140− int columnToAddTo = 0;
141− for (int i = 1; i < m_columnVisibleItems.count(); ++i) {
142− const QList<ViewItem> &column = m_columnVisibleItems[i];
143− const qreal iY = !column.isEmpty() ? column.last().y() + column.last().height() : -rowSpacing();
144− if (iY < columnToAddY) {
145− columnToAddTo = i;
146− columnToAddY = iY;
147− }
148− }
149−
150− const QList<ViewItem> &columnToAdd = m_columnVisibleItems[columnToAddTo];
151− if (columnToAdd.isEmpty() || columnToAdd.last().m_modelIndex < modelIndex) {
152− item->setX(columnToAddTo * (m_columnWidth + columnSpacing()));
153− item->setY(columnToAddY + rowSpacing());
154−
155− m_columnVisibleItems[columnToAddTo] << ViewItem(item, modelIndex);
156− m_indexColumnMap[modelIndex] = columnToAddTo;
157− } else {
158− Q_ASSERT(m_indexColumnMap.contains(modelIndex));
159− columnToAddTo = m_indexColumnMap[modelIndex];
160− columnToAddY = m_columnVisibleItems[columnToAddTo].first().y();
161−
162− item->setX(columnToAddTo * (m_columnWidth + columnSpacing()));
163− item->setY(columnToAddY - rowSpacing() - item->height());
164−
165− m_columnVisibleItems[columnToAddTo].prepend(ViewItem(item, modelIndex));
166− }
167−}
168−
169−void VerticalJournal::cleanupExistingItems()
170−{
171− // Cleanup the existing items
172− for (int i = 0; i < m_columnVisibleItems.count(); ++i) {
173− QList<ViewItem> &column = m_columnVisibleItems[i];
174− Q_FOREACH(const ViewItem item, column)
175− releaseItem(item.m_item);
176− column.clear();
177− }
178− m_indexColumnMap.clear();
179− setImplicitHeightDirty();
180−}
181−
182−void VerticalJournal::calculateImplicitHeight()
183−{
184− int lastModelIndex = -1;
185− qreal bottomMostY = 0;
186− Q_FOREACH(const auto &column, m_columnVisibleItems) {
187− if (!column.isEmpty()) {
188− const ViewItem &item = column.last();
189− lastModelIndex = qMax(lastModelIndex, item.m_modelIndex);
190− bottomMostY = qMax(bottomMostY, item.y() + item.height());
191− }
192− }
193− if (lastModelIndex >= 0) {
194− const double averageHeight = bottomMostY / (lastModelIndex + 1);
195− setImplicitHeight(bottomMostY + averageHeight * (model()->rowCount() - lastModelIndex - 1));
196− } else {
197− setImplicitHeight(0);
198− }
199−}
200−
201−void VerticalJournal::doRelayout()
202−{
203− QList<ViewItem> allItems;
204− Q_FOREACH(const auto &column, m_columnVisibleItems)
205− allItems << column;
206−
207− qSort(allItems);
208−
209− const int nColumns = qMax(1., floor((double)(width() + columnSpacing()) / (m_columnWidth + columnSpacing())));
210− m_columnVisibleItems.resize(nColumns);
211− m_indexColumnMap.clear();
212− for (int i = 0; i < nColumns; ++i)
213− m_columnVisibleItems[i].clear();
214−
215− // If the first of allItems doesn't contain index 0 we need to drop them
216− // all since we can't consistently relayout without the first item being there
217−
218− if (!allItems.isEmpty()) {
219− if (allItems.first().m_modelIndex == 0) {
220− Q_FOREACH(const ViewItem item, allItems)
221− addItemToView(item.m_modelIndex, item.m_item);
222− } else {
223− Q_FOREACH(const ViewItem item, allItems)
224− releaseItem(item.m_item);
225− }
226− }
227−}
228−
229−void VerticalJournal::updateItemCulling(qreal visibleFromY, qreal visibleToY)
230−{
231− Q_FOREACH(const auto &column, m_columnVisibleItems) {
232− Q_FOREACH(const ViewItem item, column) {
233− const bool cull = item.y() + item.height() <= visibleFromY || item.y() >= visibleToY;
234− QQuickItemPrivate::get(item.m_item)->setCulled(cull);
235− }
236− }
237−}
238−
239−void VerticalJournal::processModelRemoves(const QVector<QQmlChangeSet::Change> &removes)
240−{
241− Q_FOREACH(const QQmlChangeSet::Change remove, removes) {
242− for (int i = remove.count - 1; i >= 0; --i) {
243− const int indexToRemove = remove.index + i;
244− // Since we only support removing from the end, indexToRemove
245− // must refer to the last item of one of the columns or
246− // be bigger than them (because it's not in the viewport and
247− // thus we have not created a delegate for it)
248− bool found = false;
249− int lastCreatedIndex = INT_MIN;
250− for (int i = 0; !found && i < m_columnVisibleItems.count(); ++i) {
251− QList<ViewItem> &column = m_columnVisibleItems[i];
252− if (!column.isEmpty()) {
253− const int lastColumnIndex = column.last().m_modelIndex;
254− if (lastColumnIndex == indexToRemove) {
255− releaseItem(column.takeLast().m_item);
256− found = true;
257− }
258− lastCreatedIndex = qMax(lastCreatedIndex, lastColumnIndex);
259− }
260− }
261− if (!found) {
262− if (indexToRemove < lastCreatedIndex) {
263− qDebug() << "VerticalJournal only supports removal from the end of the model, resetting instead";
264− cleanupExistingItems();
265− break;
266− } else {
267− setImplicitHeightDirty();
268− }
269− }
270− }
271− }
272−}
273−
274−
275−//void VerticalJournal::itemGeometryChanged(QQuickItem * /*item*/, const QRectF &newGeometry, const QRectF &oldGeometry)
276−//{
277−// const qreal heightDiff = newGeometry.height() - oldGeometry.height();
278−// if (heightDiff != 0) {
279−// relayout();
280−// }
281−//}
plugins/Dash/verticaljournal.hdeleted−103
@@ -1,103 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef VERTICALJOURNAL_H
18−#define VERTICALJOURNAL_H
19−
20−#include "abstractdashview.h"
21−
22− /** A vertical journal is a view that creates delegates
23− * based on a model and layouts them in columns following
24− * a top-left most position rule.
25− *
26− * The number of columns is calculated using the width of
27− * the view itself, the columnWidth (i.e. the width of each individual delegate)
28− * and the columnSpacing between columns.
29− *
30− * All delegates are forced to columnWidth if they don't have it.
31− *
32− * The first nColumns items are layouted at row 0 from column 0
33− * to column nColumns-1 in order. After that every new item
34− * is positioned in the column which provides the free topmost
35− * position as possible. If more than one column tie in providing
36− * the topmost free position the leftmost column will be used.
37− *
38− * Example:
39− *
40− * +-----+ +-----+ +-----+
41− * | | | 2 | | |
42− * | | | | | |
43− * | 1 | +-----+ | 3 |
44− * | | +-----+ | |
45− * | | | | +-----+
46− * +-----+ | 4 | +-----+
47− * +-----+ | | | 5 |
48− * | 6 | +-----+ | |
49− * | | +-----+
50− * +-----+
51− *
52− */
53−
54−class VerticalJournal : public AbstractDashView
55−{
56− Q_OBJECT
57−
58− Q_PROPERTY(qreal columnWidth READ columnWidth WRITE setColumnWidth NOTIFY columnWidthChanged)
59−
60−friend class VerticalJournalTest;
61−
62−public:
63− VerticalJournal();
64−
65− qreal columnWidth() const;
66− void setColumnWidth(qreal columnWidth);
67−
68−protected:
69−// void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) override;
70−
71−Q_SIGNALS:
72− void columnWidthChanged();
73−
74−private:
75− class ViewItem
76− {
77− public:
78− ViewItem(QQuickItem *item, int modelIndex) : m_item(item), m_modelIndex(modelIndex) {}
79− qreal x() const { return m_item->x(); }
80− qreal y() const { return m_item->y(); }
81− qreal height() const { return m_item->height(); }
82− bool operator<(const ViewItem v) const { return m_modelIndex < v.m_modelIndex; }
83−
84− QQuickItem *m_item;
85− int m_modelIndex;
86− };
87−
88− void findBottomModelIndexToAdd(int *modelIndex, qreal *yPos) override;
89− void findTopModelIndexToAdd(int *modelIndex, qreal *yPos) override;
90− bool removeNonVisibleItems(qreal bufferFromY, qreal bufferToY) override;
91− void addItemToView(int modelIndex, QQuickItem *item) override;
92− void cleanupExistingItems() override;
93− void calculateImplicitHeight() override;
94− void doRelayout() override;
95− void updateItemCulling(qreal visibleFromY, qreal visibleToY) override;
96− void processModelRemoves(const QVector<QQmlChangeSet::Change> &removes) override;
97−
98− QVector<QList<ViewItem>> m_columnVisibleItems;
99− QHash<int, int> m_indexColumnMap;
100− int m_columnWidth;
101−};
102−
103−#endif
plugins/Unity/CMakeLists.txt−1
@@ -3,6 +3,5 @@ add_subdirectory(Connectivity)
33add_subdirectory(Indicators)
44add_subdirectory(Launcher)
55add_subdirectory(Session)
6−add_subdirectory(DashCommunicator)
76add_subdirectory(InputInfo)
87add_subdirectory(Platform)
plugins/Unity/DashCommunicator/dashcommunicator.cppdeleted−58
@@ -1,58 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software: you can redistribute it and/or modify it under
5− * the terms of the GNU Lesser General Public License version 3, as published by
6− * the Free Software Foundation.
7− *
8− * This program is distributed in the hope that it will be useful, but WITHOUT
9− * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10− * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11− * 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 "dashcommunicator.h"
18−#include "dashconnection.h"
19−
20−#include <QObject>
21−
22−DashCommunicator::DashCommunicator(QObject *parent):
23− QThread(parent),
24− m_dashConnection(nullptr),
25− m_created(false)
26−{
27− start();
28−}
29−
30−DashCommunicator::~DashCommunicator()
31−{
32− quit();
33− wait();
34−}
35−
36−void DashCommunicator::setCurrentScope(int index, bool animate, bool isSwipe)
37−{
38− m_mutex.lock();
39− if (m_created) {
40− QMetaObject::invokeMethod(m_dashConnection, "setCurrentScope",
41− Q_ARG(int, index),
42− Q_ARG(bool, animate),
43− Q_ARG(bool, isSwipe));
44− }
45− m_mutex.unlock();
46−}
47−
48−void DashCommunicator::run()
49−{
50− m_dashConnection = new DashConnection(QStringLiteral("com.canonical.UnityDash"),
51− QStringLiteral("/com/canonical/UnityDash"),
52− QLatin1String(""), this);
53− m_mutex.lock();
54− m_created = true;
55− m_mutex.unlock();
56−
57− exec();
58−}
plugins/Unity/DashCommunicator/dashcommunicator.hdeleted−45
@@ -1,45 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software: you can redistribute it and/or modify it under
5− * the terms of the GNU Lesser General Public License version 3, as published by
6− * the Free Software Foundation.
7− *
8− * This program is distributed in the hope that it will be useful, but WITHOUT
9− * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10− * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11− * 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 DASHCOMMUNICATOR_H
18−#define DASHCOMMUNICATOR_H
19−
20−// Qt
21−#include <QThread>
22−#include <QMutex>
23−
24−class DashConnection;
25−
26−class DashCommunicator: public QThread
27−{
28− Q_OBJECT
29−public:
30− explicit DashCommunicator(QObject *parent = 0);
31− ~DashCommunicator();
32−
33−public Q_SLOTS:
34− void setCurrentScope(int index, bool animate, bool isSwipe);
35−
36−protected:
37− void run() override;
38−
39−private:
40− DashConnection *m_dashConnection;
41− bool m_created;
42− QMutex m_mutex;
43−};
44−
45−#endif
plugins/Unity/DashCommunicator/dashcommunicatorservice.cppdeleted−30
@@ -1,30 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software: you can redistribute it and/or modify it under
5− * the terms of the GNU Lesser General Public License version 3, as published by
6− * the Free Software Foundation.
7− *
8− * This program is distributed in the hope that it will be useful, but WITHOUT
9− * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10− * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11− * 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 "dashcommunicatorservice.h"
18−
19−DashCommunicatorService::DashCommunicatorService(QObject *parent):
20− QObject(parent),
21− m_dbusService(new DBusDashCommunicatorService(this))
22−{
23− connect(m_dbusService, &DBusDashCommunicatorService::setCurrentScopeRequested, this, &DashCommunicatorService::setCurrentScopeRequested);
24−}
25−
26−
27−DashCommunicatorService::~DashCommunicatorService()
28−{
29−
30−}
plugins/Unity/DashCommunicator/dashcommunicatorservice.hdeleted−38
@@ -1,38 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software: you can redistribute it and/or modify it under
5− * the terms of the GNU Lesser General Public License version 3, as published by
6− * the Free Software Foundation.
7− *
8− * This program is distributed in the hope that it will be useful, but WITHOUT
9− * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10− * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11− * 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 DASHCOMMUNICATORSERVICE_H
18−#define DASHCOMMUNICATORSERVICE_H
19−
20−#include "dbusdashcommunicatorservice.h"
21−
22−#include <QObject>
23−
24−class DashCommunicatorService: public QObject
25−{
26− Q_OBJECT
27−public:
28− DashCommunicatorService(QObject *parent = 0);
29− ~DashCommunicatorService();
30−
31−Q_SIGNALS:
32− void setCurrentScopeRequested(int index, bool animate, bool isSwipe);
33−
34−private:
35− DBusDashCommunicatorService *m_dbusService;
36−};
37−
38−#endif // DBUSUNITYSESSIONSERVICE_H
plugins/Unity/DashCommunicator/dashconnection.cppdeleted−66
@@ -1,66 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software: you can redistribute it and/or modify it under
5− * the terms of the GNU Lesser General Public License version 3, as published by
6− * the Free Software Foundation.
7− *
8− * This program is distributed in the hope that it will be useful, but WITHOUT
9− * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10− * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11− * 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 "dashconnection.h"
18−
19−#include <QDBusInterface>
20−#include <QDBusPendingCall>
21−
22−/* The default implementation of AbstractDBusServiceMonitor creates a QDBusInterface when the service
23− * appears on the bus.
24− *
25− * On construction QDBusInterface synchronously introspects the service, which will block the GUI
26− * thread of this process if the service is busy. QDBusAbstractInterface does not perform this
27− * introspection, so let's subclass that and avoid the blocking scenario.
28− *
29− * However we lose Qt's wrapping of the DBus service with a MetaObject, with the result that we
30− * cannot easily connect to DBus signals with the usual connect() calls. So this approach only
31− * suited to push communication with the DBus service.
32− */
33−class AsyncDBusInterface : public QDBusAbstractInterface
34−{
35− Q_OBJECT
36−public:
37− AsyncDBusInterface(const QString &service, const QString &path,
38− const QString &interface, const QDBusConnection &connection,
39− QObject *parent = 0)
40− : QDBusAbstractInterface(service, path, interface.toLatin1().data(), connection, parent)
41− {}
42− ~AsyncDBusInterface() = default;
43−};
44−
45−
46−DashConnection::DashConnection(const QString &service, const QString &path, const QString &interface, QObject *parent):
47− AbstractDBusServiceMonitor(service, path, interface, SessionBus, parent)
48−{
49−
50−}
51−
52−/* Override the default implementation to create a non-blocking DBus interface (see note above). */
53−QDBusAbstractInterface* DashConnection::createInterface(const QString &service, const QString &path,
54− const QString &interface, const QDBusConnection &connection)
55−{
56− return new AsyncDBusInterface(service, path, interface, connection);
57−}
58−
59−void DashConnection::setCurrentScope(int index, bool animate, bool isSwipe)
60−{
61− if (dbusInterface()) {
62− dbusInterface()->asyncCall(QStringLiteral("SetCurrentScope"), index, animate, isSwipe);
63− }
64−}
65−
66−#include "dashconnection.moc"
plugins/Unity/DashCommunicator/dashconnection.hdeleted−37
@@ -1,37 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software: you can redistribute it and/or modify it under
5− * the terms of the GNU Lesser General Public License version 3, as published by
6− * the Free Software Foundation.
7− *
8− * This program is distributed in the hope that it will be useful, but WITHOUT
9− * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10− * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11− * 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 THREADEDDASHCONNECTION_H
18−#define THREADEDDASHCONNECTION_H
19−
20−// local
21−#include "abstractdbusservicemonitor.h"
22−
23−class DashConnection: public AbstractDBusServiceMonitor
24−{
25− Q_OBJECT
26−public:
27− DashConnection(const QString &service, const QString &path, const QString &interface, QObject *parent = 0);
28−
29−public Q_SLOTS:
30− void setCurrentScope(int index, bool animate, bool isSwipe);
31−
32−private:
33− QDBusAbstractInterface* createInterface(const QString &service, const QString &path,
34− const QString &interface, const QDBusConnection &connection) override;
35−};
36−
37−#endif
plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.cppdeleted−35
@@ -1,35 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software: you can redistribute it and/or modify it under
5− * the terms of the GNU Lesser General Public License version 3, as published by
6− * the Free Software Foundation.
7− *
8− * This program is distributed in the hope that it will be useful, but WITHOUT
9− * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10− * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11− * 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 "dbusdashcommunicatorservice.h"
18−
19−#include <QDBusConnection>
20−#include <QDBusInterface>
21−#include <QDebug>
22−
23−DBusDashCommunicatorService::DBusDashCommunicatorService(QObject *parent):
24− UnityDBusObject(QStringLiteral("/com/canonical/UnityDash"), QStringLiteral("com.canonical.UnityDash"), false, parent)
25−{
26−}
27−
28−DBusDashCommunicatorService::~DBusDashCommunicatorService()
29−{
30−}
31−
32−void DBusDashCommunicatorService::SetCurrentScope(int index, bool animate, bool isSwipe)
33−{
34− Q_EMIT setCurrentScopeRequested(index, animate, isSwipe);
35−}
plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.hdeleted−39
@@ -1,39 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software: you can redistribute it and/or modify it under
5− * the terms of the GNU Lesser General Public License version 3, as published by
6− * the Free Software Foundation.
7− *
8− * This program is distributed in the hope that it will be useful, but WITHOUT
9− * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10− * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11− * 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 DBUSDASHCOMMUNICATORSERVICE_H
18−#define DBUSDASHCOMMUNICATORSERVICE_H
19−
20−#include "unitydbusobject.h"
21−
22−class DBusDashCommunicatorService: public UnityDBusObject
23−{
24− Q_OBJECT
25− Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.DashCommunicator")
26−
27−public:
28− DBusDashCommunicatorService(QObject *parent = 0);
29− ~DBusDashCommunicatorService();
30−
31−Q_SIGNALS:
32− void setCurrentScopeRequested(int index, bool animate, bool isSwipe);
33−
34−public Q_SLOTS:
35− Q_SCRIPTABLE void SetCurrentScope(int index, bool animate, bool isSwipe);
36−
37−};
38−
39−#endif // DBUSDASHCOMMUNICATORSERVICE_H
plugins/Unity/DashCommunicator/plugin.cppdeleted−32
@@ -1,32 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Authors: Michael Zanetti <michael.zanetti@canonical.com>
17− */
18−
19−#include "plugin.h"
20−#include "dashcommunicator.h"
21−#include "dashcommunicatorservice.h"
22−
23−#include <QDBusConnection>
24−#include <QtQml/qqml.h>
25−
26−void DashCommunicatorPlugin::registerTypes(const char *uri)
27−{
28− // @uri Unity.DashCommunicator
29− Q_ASSERT(uri == QStringLiteral("Unity.DashCommunicator"));
30− qmlRegisterType<DashCommunicatorService>(uri, 0, 1, "DashCommunicatorService");
31− qmlRegisterType<DashCommunicator>(uri, 0, 1, "DashCommunicator");
32−}
plugins/Unity/DashCommunicator/plugin.hdeleted−34
@@ -1,34 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Authors: Michael Zanetti <michael.zanetti@canonical.com>
17− */
18−
19−#ifndef DASHCOMMUNICATOR_PLUGIN_H
20−#define DASHCOMMUNICATOR_PLUGIN_H
21−
22−#include <QtQml/QQmlEngine>
23−#include <QtQml/QQmlExtensionPlugin>
24−
25−class DashCommunicatorPlugin : public QQmlExtensionPlugin
26−{
27− Q_OBJECT
28− Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
29−
30−public:
31− void registerTypes(const char *uri) override;
32−};
33−
34−#endif
plugins/Unity/DashCommunicator/qmldirdeleted−3
@@ -1,3 +0,0 @@
1−module Unity.DashCommunicator
2−plugin DashCommunicator-qml
3−typeinfo DashCommunicator.qmltypes
plugins/Unity/Launcher/launchermodel.cpp−5
@@ -521,11 +521,6 @@ void LauncherModel::applicationAdded(const QModelIndex &parent, int row)
521521 return;
522522 }
523523
524− if (app->appId() == QLatin1String("unity8-dash")) {
525− // Not adding the dash app
526− return;
527− }
528−
529524 const int itemIndex = findApplication(app->appId());
530525 if (itemIndex != -1) {
531526 LauncherItem *item = m_list.at(itemIndex);
plugins/Wizard/System.cpp+1−4
@@ -168,13 +168,10 @@ void System::updateSessionLocale(const QString &locale)
168168
169169 // Restart bits of the session to pick up new language.
170170 QProcess::startDetached(QStringLiteral("sh -c \"initctl emit indicator-services-end; \
171− initctl stop scope-registry; \
172− initctl stop smart-scopes-proxy; \
173171 initctl emit --no-wait indicator-services-start; \
174172 initctl restart --no-wait ubuntu-location-service-trust-stored; \
175173 initctl restart --no-wait maliit-server; \
176− initctl restart --no-wait indicator-messages; \
177− initctl restart --no-wait unity8-dash\""));
174+ initctl restart --no-wait indicator-messages"));
178175}
179176
180177void System::skipUntilFinishedPage()
qml/CMakeLists.txt−1
@@ -7,7 +7,6 @@ install(FILES ${QML_JS_FILES}
77set(QML_DIRS
88 ApplicationMenus
99 Components
10− Dash
1110 graphics
1211 Greeter
1312 Launcher
qml/Components/Background.qml+1−1
@@ -31,7 +31,7 @@ Loader {
3131 else if (parsedStyle[1] === "gradient") return Utils.Style.luminance(parsedStyle[2], parsedStyle[3]);
3232 }
3333
34− // FIXME this is only here for highlight purposes (see DashNavigation.qml, too)
34+ // FIXME this is only here for highlight purposes
3535 readonly property color topColor: parsedStyle ? parsedStyle[2] : UbuntuColors.lightGrey
3636
3737 sourceComponent: {
qml/Components/ResponsiveVerticalJournal.qmldeleted−81
@@ -1,81 +0,0 @@
1−/*
2− * Copyright (C) 2013-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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import "../Components"
20−import Dash 0.1
21−
22−/*!
23− \brief A responsive wrapper around VerticalJournal.
24−
25− Based on defined column width, delegates are laid out in columns following
26− a top-left most position rule.
27−
28− Example:
29− +-----+ +-----+ +-----+
30− | | | 2 | | |
31− | | | | | |
32− | 1 | +-----+ | 3 |
33− | | +-----+ | |
34− | | | | +-----+
35− +-----+ | 4 | +-----+
36− +-----+ | | | 5 |
37− | 6 | +-----+ | |
38− | | +-----+
39− +-----+
40−*/
41−Item {
42− id: root
43−
44− property real minimumColumnSpacing: units.gu(1)
45−
46− property alias columnWidth: verticalJournalView.columnWidth
47− property alias rowSpacing: verticalJournalView.rowSpacing
48− property alias model: verticalJournalView.model
49− property alias delegate: verticalJournalView.delegate
50− property alias cacheBuffer: verticalJournalView.cacheBuffer
51− property real displayMarginBeginning: 0
52− property real displayMarginEnd: 0
53−
54− implicitHeight: verticalJournalView.implicitHeight + rowSpacing
55− clip: height < implicitHeight
56−
57− VerticalJournal {
58− id: verticalJournalView
59− objectName: "responsiveVerticalJournalView"
60− anchors {
61− fill: parent
62− leftMargin: columnSpacing / 2
63− rightMargin: columnSpacing / 2
64− topMargin: rowSpacing / 2
65− bottomMargin: rowSpacing / 2
66− }
67−
68− displayMarginBeginning: -Math.max(-root.displayMarginBeginning - anchors.topMargin, 0)
69− displayMarginEnd:-Math.max(-root.displayMarginEnd - anchors.topMargin, 0)
70−
71− function px2gu(pixels) {
72− return Math.floor(pixels / units.gu(1))
73− }
74−
75− columnSpacing: {
76− // parent.width = columns * columnWidth + (columns-1) * spacing + spacing(margins)
77− var expectedColumns = Math.max(1, Math.floor(parent.width / (columnWidth + minimumColumnSpacing)));
78− Math.floor((parent.width - expectedColumns * columnWidth) / expectedColumns);
79− }
80− }
81−}
qml/Dash/CardCarousel.qmldeleted−74
@@ -1,74 +0,0 @@
1−/*
2− * Copyright (C) 2013-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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import "../Components"
20−
21−DashRenderer {
22− id: cardCarousel
23−
24− readonly property real extraHeaderHeight: cardTool.template && cardTool.template["overlay"] === true ? 0 : cardTool.headerHeight
25−
26− expandedHeight: carousel.implicitHeight + units.gu(6) + extraHeaderHeight
27− collapsedHeight: expandedHeight
28− growsVertically: false
29− innerWidth: carousel.innerWidth
30−
31− Carousel {
32− id: carousel
33− anchors.fill: parent
34− tileAspectRatio: cardTool.components && cardTool.components["art"]["aspect-ratio"] || 1.0
35− extraBottomMargin: cardCarousel.extraHeaderHeight
36− // FIXME we need to "reverse" the carousel to make the selected item the size
37− // and push others back.
38− minimumTileWidth: cardTool.cardWidth / selectedItemScaleFactor
39− selectedItemScaleFactor: cardTool.carouselSelectedItemScaleFactor
40− cacheBuffer: cardCarousel.cacheBuffer
41− displayMarginBeginning: cardCarousel.displayMarginBeginning
42− displayMarginEnd: cardCarousel.displayMarginEnd
43− model: cardCarousel.model
44−
45− property real fontScale: 1 / selectedItemScaleFactor
46− property real headerHeight: cardTool.headerHeight / selectedItemScaleFactor
47−
48− itemComponent: Loader {
49− id: loader
50−
51− property bool explicitlyScaled
52− property var model
53− property int index
54− enabled: false
55−
56− objectName: "carouselDelegate" + index
57−
58− function clicked() { cardCarousel.clicked(index, model.result, loader.item, model) }
59− function pressAndHold() { cardCarousel.pressAndHold(index, model.result, model) }
60−
61− sourceComponent: cardTool.cardComponent
62− asynchronous: true
63− onLoaded: {
64− item.fixedHeaderHeight = Qt.binding(function() { return carousel.headerHeight; });
65− item.fixedArtShapeSize = Qt.binding(function() { return Qt.size(cardTool.artShapeSize.width / carousel.selectedItemScaleFactor, cardTool.artShapeSize.height / carousel.selectedItemScaleFactor); });
66− item.height = Qt.binding(function() { return cardTool.cardHeight; });
67− item.cardData = Qt.binding(function() { return model; });
68− item.fontScale = Qt.binding(function() { return carousel.fontScale; });
69− item.showHeader = Qt.binding(function() { return loader.explicitlyScaled; });
70− item.scopeStyle = cardCarousel.scopeStyle;
71− }
72− }
73− }
74−}
qml/Dash/CardGrid.qmldeleted−83
@@ -1,83 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import "../Components"
19−
20−DashRenderer {
21− id: root
22−
23− readonly property int collapsedRows: {
24− if (!cardTool || !cardTool.template || typeof cardTool.template["collapsed-rows"] != "number") return 2;
25− return cardTool.template["collapsed-rows"];
26− }
27−
28− readonly property string backgroundShapeStyle: "flat"
29−
30− expandedHeight: grid.totalContentHeight
31− collapsedHeight: Math.min(grid.contentHeightForRows(collapsedRows, grid.cellHeight), expandedHeight)
32− collapsedItemCount: collapsedRows * grid.columns
33− originY: grid.originY
34−
35− function cardPosition(index) {
36− var pos = {};
37− var row = Math.floor(index / grid.columns);
38− var column = index % grid.columns;
39− // Bit sad this is not symmetrical
40− pos.x = column * grid.cellWidth + grid.margins;
41− pos.y = row * grid.cellHeight;
42− return pos;
43− }
44−
45− ResponsiveGridView {
46− id: grid
47− anchors.fill: parent
48− minimumHorizontalSpacing: cardTool.isWideView ? units.gu(5) : units.gu(1)
49− delegateWidth: cardTool.cardWidth
50− delegateHeight: cardTool.cardHeight
51− verticalSpacing: units.gu(1)
52− model: root.model
53− displayMarginBeginning: root.displayMarginBeginning
54− displayMarginEnd: root.displayMarginEnd
55− cacheBuffer: root.cacheBuffer
56− interactive: false
57− delegate: Item {
58− width: grid.cellWidth
59− height: grid.cellHeight
60− Loader {
61− id: loader
62− sourceComponent: cardTool.cardComponent
63− anchors.horizontalCenter: parent.horizontalCenter
64− onLoaded: {
65− item.objectName = "delegate" + index;
66− item.width = Qt.binding(function() { return cardTool.cardWidth; });
67− item.height = Qt.binding(function() { return cardTool.cardHeight; });
68− item.fixedHeaderHeight = Qt.binding(function() { return cardTool.headerHeight; });
69− item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
70− item.cardData = Qt.binding(function() { return model; });
71− item.scopeStyle = root.scopeStyle;
72− item.backgroundShapeStyle = root.backgroundShapeStyle;
73− }
74− Connections {
75− target: loader.item
76− onClicked: root.clicked(index, result, loader.item, model)
77− onPressAndHold: root.pressAndHold(index, result, model)
78− onAction: root.action(index, result, actionId)
79− }
80− }
81− }
82− }
83−}
qml/Dash/CardHorizontalList.qmldeleted−66
@@ -1,66 +0,0 @@
1−/*
2− * Copyright (C) 2014-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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import "../Components"
20−
21−DashRenderer {
22− id: root
23−
24− expandedHeight: cardTool.cardHeight + units.gu(2)
25− collapsedHeight: expandedHeight
26− growsVertically: false
27− innerWidth: Math.max(0, listView.width)
28− clip: true
29−
30− ListView {
31− id: listView
32− anchors {
33− fill: parent
34− margins: units.gu(1)
35− rightMargin: 0
36− }
37− rightMargin: units.gu(1)
38− spacing: units.gu(1)
39− model: root.model
40− orientation: ListView.Horizontal
41− cacheBuffer: root.cacheBuffer
42− displayMarginBeginning: root.displayMarginBeginning
43− displayMarginEnd: root.displayMarginEnd
44−
45− delegate: Loader {
46− id: loader
47− sourceComponent: cardTool.cardComponent
48− anchors { top: parent.top; bottom: parent.bottom }
49− width: cardTool.cardWidth
50− asynchronous: true
51− onLoaded: {
52− item.objectName = "delegate" + index;
53− item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
54− item.fixedHeaderHeight = Qt.binding(function() { return cardTool.headerHeight; });
55− item.cardData = Qt.binding(function() { return model; });
56− item.scopeStyle = root.scopeStyle;
57− }
58− Connections {
59− target: loader.item
60− onClicked: root.clicked(index, result, loader.item, model)
61− onPressAndHold: root.pressAndHold(index, result, model)
62− onAction: root.action(index, result, actionId)
63− }
64− }
65− }
66−}
qml/Dash/CardTool.qmldeleted−274
@@ -1,274 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Dash 0.1
20−
21−/*!
22− \brief Tool for introspecting Card properties.
23−
24− Some properties of Cards we need to determine category-wide (like card sizes in grid),
25− so we should not do them per-Card but in the category renderer.
26−
27− This component creates an invisible card filled with maximum mapped data and calculates
28− or measures card properties for this configuration.
29− */
30−
31−Item {
32− id: cardTool
33−
34− /*!
35− \brief Number of cards.
36− */
37− property int count
38−
39− /*!
40− \brief Width of the category view.
41− */
42− property real viewWidth
43−
44− /*!
45− \brief Template supplied for the category.
46− */
47− property var template
48−
49− /*!
50− \brief Component mapping supplied for the category.
51− */
52− property var components
53−
54− /*!
55− \brief The Scope this cardTool is representing
56− */
57− property string scopeId
58−
59− /*!
60− \brief The Scope category this cardTool is representing
61− */
62− property string categoryId
63−
64− /*!
65− \brief Scaling factor of selected Carousel item.
66− */
67− readonly property real carouselSelectedItemScaleFactor: 1.38 // XXX assuming 1.38 carousel scaling factor for cards
68−
69− /*!
70− \brief The category layout for this card tool.
71− */
72− readonly property string categoryLayout: {
73− var layout = template["category-layout"];
74−
75− // carousel fallback mode to grid
76− if (layout === "carousel" && count <= Math.ceil(carouselTool.realPathItemCount)) layout = "grid";
77− return layout;
78− }
79−
80− readonly property string artShapeStyle: {
81− return categoryLayout === "carousel" ? "shadow" : "flat"
82− }
83−
84− // FIXME ? This seems like it should not be needed, but on Qt 5.4 + phone
85− // we are doing unneeded calls to getCardComponent with artShapeStyle and categoryLayout being empty
86− // Check when we move to newer Qts on the phone if we still need this
87− readonly property bool askForCardComponent: cardTool.template !== undefined &&
88− cardTool.components !== undefined &&
89− cardTool.artShapeStyle !== "" &&
90− cardTool.categoryLayout !== ""
91−
92− property var cardComponent: askForCardComponent
93− ? CardCreatorCache.getCardComponent(cardTool.template, cardTool.components, false, cardTool.artShapeStyle, cardTool.categoryLayout)
94− : undefined
95−
96− // FIXME: Saviq
97− // Only way for the card below to actually be laid out completely.
98− // If invisible or in "data" array, some components are not taken into account.
99− width: 0
100− height: 0
101− clip: true
102−
103− // We have 3 view "widths"
104− // narrow <= 45gu
105− // normal
106− // wide >= 70gu
107− readonly property bool isWideView: viewWidth >= units.gu(70)
108− readonly property bool isNarrowView: viewWidth <= units.gu(45)
109−
110− /*!
111− type:real \brief Width to be enforced on the card in this configuration.
112−
113− If -1, should use implicit width of the actual card.
114− */
115− readonly property real cardWidth: {
116− switch (categoryLayout) {
117− case "grid":
118− case "vertical-journal":
119− var size = template["card-size"];
120− if (template["card-layout"] === "horizontal") size = "large";
121− switch (size) {
122− case "small": {
123− if (isNarrowView) return units.gu(12);
124− else return units.gu(14);
125− }
126− case "large": {
127− if (isWideView) return units.gu(42);
128− else return viewWidth - units.gu(2);
129− }
130− }
131− if (isNarrowView) return units.gu(18);
132− else if (isWideView) return units.gu(20);
133− else return units.gu(23);
134− case "carousel":
135− case "horizontal-list":
136− return carouselTool.minimumTileWidth;
137− case undefined:
138− case "organic-grid":
139− case "journal":
140− default:
141− return -1;
142− }
143− }
144−
145− /*!
146− type:real \brief Height to be enforced on the card in this configuration.
147−
148− If -1, should use implicit height of the actual card.
149− */
150− readonly property real cardHeight: {
151− switch (categoryLayout) {
152− case "journal":
153− if (template["card-size"] >= 12 && template["card-size"] <= 38) return units.gu(template["card-size"]);
154− return units.gu(18.5);
155− case "grid":
156− case "horizontal-list":
157− return cardLoader.item ? cardLoader.item.implicitHeight : 0
158− case "carousel":
159− return cardWidth / (components ? components["art"]["aspect-ratio"] : 1)
160− case undefined:
161− case "organic-grid":
162− case "vertical-journal":
163− default:
164− return -1;
165− }
166− }
167−
168− /*!
169− type:real \brief Height of the card's header.
170− */
171− readonly property int headerHeight: cardLoader.item ? cardLoader.item.headerHeight : 0
172−
173− readonly property size artShapeSize: {
174− return cardLoader.item ? cardLoader.item.artShapeSize : Qt.size(0, 0)
175− }
176−
177− QtObject {
178− id: carouselTool
179−
180− readonly property real minimumTileWidth: {
181− if (cardTool.viewWidth === undefined) return undefined;
182− if (cardTool.viewWidth <= units.gu(40)) return units.gu(18);
183− if (cardTool.viewWidth >= units.gu(128)) return units.gu(26);
184− return units.gu(18 + Math.round((cardTool.viewWidth - units.gu(40)) / units.gu(11)));
185− }
186−
187− readonly property real pathItemCount: 4.8457 /// (848 / 175) reference values
188−
189− readonly property real realPathItemCount: {
190− var scaledMinimumTileWidth = minimumTileWidth / cardTool.carouselSelectedItemScaleFactor;
191− var tileWidth = Math.max(cardTool.viewWidth / pathItemCount, scaledMinimumTileWidth);
192− return Math.min(cardTool.viewWidth / tileWidth, pathItemCount);
193− }
194− }
195−
196− Item {
197− id: attributesModel
198− property int numOfAttributes: 0
199− property var model: []
200− readonly property bool hasAttributes: {
201− var attributes = components["attributes"];
202− var hasAttributesFlag = (attributes != undefined) && (attributes["field"] != undefined);
203−
204− if (hasAttributesFlag) {
205− if (attributes["max-count"]) {
206− numOfAttributes = attributes["max-count"];
207− }
208− }
209− return hasAttributesFlag
210− }
211−
212− onNumOfAttributesChanged: {
213− model = []
214− for (var i = 0; i < numOfAttributes; i++) {
215− model.push( {"value":"text"+(i+1), "icon":"image://theme/ok" } );
216− }
217− }
218− }
219−
220− Item {
221− id: socialActionsModel
222− property var model: []
223− readonly property bool hasActions: components["social-actions"] != undefined
224−
225− onHasActionsChanged: {
226− model = []
227− if (hasActions) {
228− model.push( {"id":"text", "icon":"image://theme/ok" } );
229− }
230− }
231− }
232−
233− Loader {
234− id: cardLoader
235− readonly property var cfields: ["art", "mascot", "title", "subtitle", "summary", "attributes", "social-actions"]
236− readonly property var dfields: ["art", "mascot", "title", "subtitle", "summary", "attributes", "socialActions"]
237− readonly property var maxData: {
238− "art": Qt.resolvedUrl("graphics/pixel.png"),
239− "mascot": Qt.resolvedUrl("graphics/pixel.png"),
240− "title": "—\n—",
241− "subtitle": "—",
242− "summary": "—\n—\n—\n—\n—",
243− "attributes": attributesModel.model,
244− "socialActions": socialActionsModel.model
245− }
246− sourceComponent: askForCardComponent
247− ? CardCreatorCache.getCardComponent(cardTool.template, cardTool.components, true, cardTool.artShapeStyle, cardTool.categoryLayout)
248− : undefined
249− onLoaded: {
250− item.objectName = "cardToolCard";
251− item.width = Qt.binding(function() { return cardTool.cardWidth !== -1 ? cardTool.cardWidth : item.implicitWidth; });
252− item.height = Qt.binding(function() { return cardTool.cardHeight !== -1 ? cardTool.cardHeight : item.implicitHeight; });
253− }
254− Connections {
255− target: cardTool
256− onTemplateChanged: cardLoader.updateCardData();
257− onComponentsChanged: cardLoader.updateCardData();
258− }
259− function updateCardData() {
260− var data = {};
261− for (var k in cfields) {
262− var ckey = cfields[k];
263− var component = cardTool.components[ckey];
264− if ((typeof component === "string" && component.length > 0) ||
265− (typeof component === "object" && component !== null
266− && typeof component["field"] === "string" && component["field"].length > 0)) {
267− var dkey = dfields[k];
268− data[dkey] = maxData[dkey];
269− }
270− }
271− item.cardData = data;
272− }
273− }
274−}
qml/Dash/CardVerticalJournal.qmldeleted−85
@@ -1,85 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import "../Components"
20−
21−DashRenderer {
22− id: root
23−
24− readonly property double collapseLimit: units.gu(35)
25−
26− expandedHeight: Math.max(cardVerticalJournal.implicitHeight, minHeight)
27− collapsedHeight: Math.max(Math.min(collapseLimit, cardVerticalJournal.implicitHeight), minHeight)
28− // TODO: implement collapsedItemCount
29−
30− // This minHeight is used as bootstrapper for the height. Vertical Journal
31− // is special by the fact that it doesn't know how to calculate its implicit height unless we give it
32− // enough height that it can start creating its children so we make sure it has enough height for that
33− // in case the model is non empty
34− readonly property double minHeight: root.model.count >= 1 ? cardVerticalJournal.rowSpacing + 1 : 0
35−
36− function clearView() {
37− cardVerticalJournal.model = null;
38− cardVerticalJournal.model = root.model;
39− }
40−
41− // Clear the view if the cardTool changes its sizes
42− // means it is still settling. This is
43− // necessary because the VerticalJournal does
44− // not support its elements changing height so
45− // we need to construct all the items with the settled
46− // size of the cardTool
47− Connections {
48− target: cardTool
49− onArtShapeSizeChanged: root.clearView();
50− onHeaderHeightChanged: root.clearView();
51− }
52−
53− ResponsiveVerticalJournal {
54− id: cardVerticalJournal
55−
56− model: root.model
57−
58− anchors.fill: parent
59− rowSpacing: minimumColumnSpacing
60− columnWidth: cardTool.cardWidth
61−
62− cacheBuffer: root.cacheBuffer
63− displayMarginBeginning: root.displayMarginBeginning
64− displayMarginEnd: root.displayMarginEnd
65−
66− delegate: Loader {
67− id: loader
68− sourceComponent: cardTool.cardComponent
69− width: cardTool.cardWidth
70− onLoaded: {
71− item.objectName = "delegate" + index;
72− item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
73− item.fixedHeaderHeight = Qt.binding(function() { return cardTool.headerHeight; });
74− item.cardData = Qt.binding(function() { return model; });
75− item.scopeStyle = root.scopeStyle;
76− }
77− Connections {
78− target: loader.item
79− onClicked: root.clicked(index, result, loader.item, model)
80− onPressAndHold: root.pressAndHold(index, result, model)
81− onAction: root.action(index, result, actionId)
82− }
83− }
84− }
85−}
qml/Dash/Dash.qmldeleted−381
@@ -1,381 +0,0 @@
1−/*
2− * Copyright (C) 2013, 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Ubuntu.Gestures 0.1
20−import Unity 0.2
21−import Utils 0.1
22−import Unity.DashCommunicator 0.1
23−import "../Components"
24−
25−Showable {
26− id: dash
27− objectName: "dash"
28−
29− visible: shown
30−
31− Connections {
32− target: UriHandler
33− onOpened: {
34− backToDashContent()
35− dashContent.currentScope.performQuery(uris[0])
36− }
37− }
38−
39− property bool windowActive: window.active
40− property bool showOverlayScope: false
41−
42− DashCommunicatorService {
43− objectName: "dashCommunicatorService"
44− onSetCurrentScopeRequested: {
45− if (!isSwipe || !windowActive || bottomEdgeController.progress != 0 || scopeItem.scope || dashContent.subPageShown) {
46− if (bottomEdgeController.progress != 0 && window.active) animate = false;
47− dashContent.setCurrentScopeAtIndex(index, animate, true)
48− backToDashContent()
49− }
50− }
51− }
52−
53− function backToDashContent()
54− {
55− // Close dash overview and nested temp scopes in it
56− if (bottomEdgeController.progress != 0) {
57− bottomEdgeController.enableAnimation = window.active;
58− bottomEdgeController.progress = 0;
59− }
60− // Close normal temp scopes (e.g. App Store)
61− if (scopeItem.scope) {
62− scopeItem.backClicked();
63− }
64− // Close previews
65− if (dashContent.subPageShown) {
66− dashContent.closePreview();
67− }
68− }
69−
70− function setCurrentScope(scopeId, animate, reset) {
71− var scopeIndex = -1;
72− for (var i = 0; i < scopes.count; ++i) {
73− if (scopes.getScope(i).id == scopeId) {
74− scopeIndex = i;
75− break;
76− }
77− }
78−
79− if (scopeIndex == -1) {
80− console.warn("No match for scope with id: %1".arg(scopeId))
81− return
82− }
83−
84− dash.showOverlayScope = false;
85−
86− dashContent.closePreview();
87−
88− if (scopeIndex == dashContent.currentIndex && !reset) {
89− // the scope is already the current one
90− return
91− }
92−
93− dashContent.workaroundRestoreIndex = -1;
94− dashContent.setCurrentScopeAtIndex(scopeIndex, animate, reset)
95− }
96−
97− Scopes {
98− id: scopes
99− }
100−
101− QtObject {
102− id: bottomEdgeController
103− objectName: "bottomEdgeController"
104−
105− property alias enableAnimation: progressAnimation.enabled
106− property real progress: 0
107− Behavior on progress {
108− id: progressAnimation
109− UbuntuNumberAnimation { }
110− }
111−
112− onProgressChanged: {
113− // FIXME This is to workaround a Qt bug with the model moving the current item
114− // when the list is ListView.SnapOneItem and ListView.StrictlyEnforceRange
115− // together with the code in DashContent.qml
116− if (dashContent.workaroundRestoreIndex != -1) {
117− dashContent.currentIndex = dashContent.workaroundRestoreIndex;
118− dashContent.workaroundRestoreIndex = -1;
119− }
120− }
121− }
122−
123− DashContent {
124− id: dashContent
125−
126− objectName: "dashContent"
127− width: dash.width
128− height: dash.height
129− scopes: scopes
130− visible: x != -width
131− x: dash.showOverlayScope ? -width : 0
132− onGotoScope: {
133− dash.setCurrentScope(scopeId, true, false);
134− }
135− onOpenScope: {
136− scopeItem.scope = scope;
137− dash.showOverlayScope = true;
138− }
139− Behavior on x {
140− UbuntuNumberAnimation {
141− onRunningChanged: {
142− if (!running && dashContent.x == 0) {
143− scopes.closeScope(scopeItem.scope);
144− scopeItem.scope = null;
145− }
146− }
147− }
148− }
149−
150− // This is to avoid the situation where a bottom-edge swipe would bring up the dash overview
151− // (as expected) but would also cause the dash content flickable to move a bit, because
152− // that flickable was getting the touch events while overviewDragHandle was still undecided
153− // about whether that touch was indeed performing a directional drag gesture.
154− forceNonInteractive: overviewDragHandle.dragging
155−
156− enabled: bottomEdgeController.progress == 0
157− }
158−
159− Rectangle {
160− color: "black"
161− opacity: bottomEdgeController.progress
162− anchors.fill: dashContent
163− }
164−
165− ScopesList {
166− id: scopesList
167− objectName: "scopesList"
168− width: dash.width
169− height: dash.height
170− scope: scopes.overviewScope
171− y: dash.height * (1 - bottomEdgeController.progress)
172− visible: bottomEdgeController.progress != 0
173− onBackClicked: {
174− bottomEdgeController.enableAnimation = true;
175− bottomEdgeController.progress = 0;
176− }
177− onStoreClicked: {
178− bottomEdgeController.enableAnimation = true;
179− bottomEdgeController.progress = 0;
180− scopesList.scope.performQuery("scope://com.canonical.scopes.clickstore");
181− }
182− onRequestFavorite: {
183− scopes.setFavorite(scopeId, favorite);
184− }
185− onRequestFavoriteMoveTo: {
186− scopes.moveFavoriteTo(scopeId, index);
187− }
188− onRequestRestore: {
189− bottomEdgeController.enableAnimation = true;
190− bottomEdgeController.progress = 0;
191− dash.setCurrentScope(scopeId, false, false);
192− }
193−
194− Binding {
195− target: scopesList.scope
196− property: "isActive"
197− value: bottomEdgeController.progress === 1 && (Qt.application.state == Qt.ApplicationActive)
198− }
199−
200− Connections {
201− target: scopesList.scope
202− onOpenScope: {
203− bottomEdgeController.enableAnimation = true;
204− bottomEdgeController.progress = 0;
205− scopeItem.scope = scope;
206− dash.showOverlayScope = true;
207− }
208− onGotoScope: {
209− bottomEdgeController.enableAnimation = true;
210− bottomEdgeController.progress = 0;
211− dashContent.gotoScope(scopeId);
212− }
213− }
214− }
215−
216− DashBackground {
217− anchors.fill: scopeItem
218− visible: scopeItem.visible
219− }
220−
221− GenericScopeView {
222− id: scopeItem
223− objectName: "dashTempScopeItem"
224−
225− x: dash.showOverlayScope ? 0 : width
226− y: dashContent.y
227− width: parent.width
228− height: parent.height
229− visible: scope != null
230− hasBackAction: true
231− isCurrent: visible
232− onBackClicked: {
233− dash.showOverlayScope = false;
234− closePreview();
235− }
236−
237− Connections {
238− target: scopeItem.scope
239− onGotoScope: {
240− dashContent.gotoScope(scopeId);
241− }
242− onOpenScope: {
243− scopeItem.closePreview();
244− var oldScope = scopeItem.scope;
245− scopeItem.scope = scope;
246− scopes.closeScope(oldScope);
247− }
248− }
249−
250− Behavior on x {
251− UbuntuNumberAnimation { }
252− }
253− }
254−
255− Rectangle {
256− id: indicator
257− objectName: "processingIndicator"
258− anchors {
259− left: parent.left
260− right: parent.right
261− bottom: parent.bottom
262− bottomMargin: Qt.inputMethod.keyboardRectangle.height
263− }
264− height: units.dp(3)
265− color: scopeStyle.backgroundLuminance > 0.7 ? "#50000000" : "#50ffffff"
266− opacity: 0
267− visible: opacity > 0
268−
269− readonly property bool processing: dashContent.processing || scopeItem.processing || scopesList.processing
270−
271− Behavior on opacity {
272− UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
273− }
274−
275− onProcessingChanged: {
276− if (processing) delay.start();
277− else if (!persist.running) indicator.opacity = 0;
278− }
279−
280− Timer {
281− id: delay
282− interval: 200
283− onTriggered: if (indicator.processing) {
284− persist.restart();
285− indicator.opacity = 1;
286− }
287− }
288−
289− Timer {
290− id: persist
291− interval: 2 * UbuntuAnimation.SleepyDuration - UbuntuAnimation.FastDuration
292− onTriggered: if (!indicator.processing) indicator.opacity = 0
293− }
294−
295− Rectangle {
296− id: activityPulse
297− anchors { top: parent.top; bottom: parent.bottom }
298− width: parent.width / 4
299− color: theme.palette.normal.activity
300−
301− SequentialAnimation {
302− running: indicator.visible
303− loops: Animation.Infinite
304− XAnimator {
305− from: -activityPulse.width / 2
306− to: indicator.width - activityPulse.width / 2
307− duration: UbuntuAnimation.SleepyDuration
308− easing.type: Easing.InOutSine
309− target: activityPulse
310− }
311− XAnimator {
312− from: indicator.width - activityPulse.width / 2
313− to: -activityPulse.width / 2
314− duration: UbuntuAnimation.SleepyDuration
315− easing.type: Easing.InOutSine
316− target: activityPulse
317− }
318− }
319− }
320− }
321−
322− Image {
323− objectName: "overviewHint"
324− source: "graphics/overview_hint.png"
325− anchors.horizontalCenter: parent.horizontalCenter
326− opacity: !scopeItem.scope && (scopes.count == 0 || dashContent.pageHeaderTotallyVisible) &&
327− (overviewDragHandle.enabled || bottomEdgeController.progress != 0) ? 1 : 0
328− Behavior on opacity {
329− enabled: bottomEdgeController.progress == 0
330− UbuntuNumberAnimation {}
331− }
332− y: parent.height - height * (1 - bottomEdgeController.progress * 4) - units.gu(1)
333− MouseArea {
334− // Eat direct presses on the overview hint so that they do not end up in the card below
335− anchors.fill: parent
336− enabled: parent.opacity != 0
337−
338− // TODO: This is a temporary workaround to allow people opening the
339− // dash overview when there's no touch input around. Will be replaced with
340− // a SDK component once that's available
341− onClicked: bottomEdgeController.progress = 1;
342−
343− // We need to eat touch events here in order to not allow opening the bottom edge with a touch press
344− MultiPointTouchArea {
345− anchors.fill: parent
346− mouseEnabled: false
347− enabled: parent.enabled
348− }
349− }
350− }
351−
352− SwipeArea {
353− id: overviewDragHandle
354− objectName: "overviewDragHandle"
355− z: 1
356− direction: Direction.Upwards
357− enabled: !dashContent.subPageShown &&
358− (scopes.count == 0 || (dashContent.currentScope && dashContent.currentScope.searchQuery == "")) &&
359− !scopeItem.scope &&
360− (bottomEdgeController.progress == 0 || dragging)
361−
362− readonly property real fullMovement: dash.height
363−
364− anchors { left: parent.left; right: parent.right; bottom: parent.bottom }
365− height: units.gu(2)
366−
367− onDistanceChanged: {
368− if (dragging) {
369− bottomEdgeController.enableAnimation = false;
370− bottomEdgeController.progress = Math.max(0, Math.min(1, distance / fullMovement));
371− }
372− }
373−
374− onDraggingChanged: {
375− if (!dragging) {
376− bottomEdgeController.enableAnimation = true;
377− bottomEdgeController.progress = (bottomEdgeController.progress > 0.2) ? 1 : 0;
378− }
379− }
380− }
381−}
qml/Dash/DashApplication.qmldeleted−39
@@ -1,39 +0,0 @@
1−/*
2− * Copyright (C) 2014-2016 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import QtQuick.Window 2.2
19−import Ubuntu.Components 1.3
20−import Ubuntu.Thumbnailer 0.1 // Register support for image://thumbnailer/ and image://albumart/
21−
22−Window {
23− visible: true
24− title: "Scopes" // Intentionally not translated
25−
26− width: initialWidth > 0 ? initialWidth : units.gu(40)
27− height: initialHeight > 0 ? initialHeight : units.gu(68)
28−
29− minimumWidth: units.gu(40)
30− minimumHeight: units.gu(40)
31−
32− MainView {
33− anchors.fill: parent
34−
35− Dash {
36− anchors.fill: parent
37− }
38− }
39−}
qml/Dash/DashBackground.qmldeleted−36
@@ -1,36 +0,0 @@
1−/*
2− * Copyright (C) 2013, 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import AccountsService 0.1
19−import GSettings 1.0
20−
21−Rectangle {
22− GSettings {
23− id: settings
24− schema.id: "com.ubuntu.touch.system-settings"
25− }
26−
27− color: settings.dashBackground ? "black" : "white"
28−
29− Image {
30− visible: settings.dashBackground
31− source: AccountsService.backgroundFile
32− anchors.fill: parent
33− fillMode: Image.PreserveAspectCrop
34− opacity: 0.6
35− }
36−}
qml/Dash/DashCategoryBase.qmldeleted−54
@@ -1,54 +0,0 @@
1−/*
2− * Copyright (C) 2012-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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−
20−Item {
21− width: parent.width
22− height: body.height
23−
24− /* Relevant really only for ListViewWithPageHeader case: specify how many pixels we can overlap with the section header */
25− readonly property int allowedOverlap: units.dp(1)
26−
27− property real heightToClip: 0
28− readonly property real __heightToClip: heightToClip >= allowedOverlap ? heightToClip - allowedOverlap : 0
29−
30−
31− /*!
32− \internal
33− Reparent so that the visuals of the children does not
34− occlude the bottom divider line.
35− */
36− default property alias children: body.children
37−
38− Item {
39− id: clippingContainer
40− height: parent.height - __heightToClip
41− anchors { left: parent.left; right: parent.right; bottom: parent.bottom }
42− clip: __heightToClip > 0
43−
44− Item {
45− id: body
46− anchors {
47− left: parent.left
48− right: parent.right
49− bottom: parent.bottom
50− }
51− height: childrenRect.height
52− }
53− }
54−}
qml/Dash/DashContent.qmldeleted−211
@@ -1,211 +0,0 @@
1−/*
2− * Copyright (C) 2013, 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Unity 0.2
20−import Utils 0.1
21−import "../Components"
22−
23−Item {
24− id: dashContent
25−
26− property bool forceNonInteractive: false
27− property alias scopes: dashContentList.model
28− property alias currentIndex: dashContentList.currentIndex
29− property int workaroundRestoreIndex: -1
30− readonly property string currentScopeId: dashContentList.currentItem ? dashContentList.currentItem.scopeId : ""
31− readonly property var currentScope: dashContentList.currentItem ? dashContentList.currentItem.theScope : null
32− readonly property bool subPageShown: dashContentList.currentItem && dashContentList.currentItem.item ?
33− dashContentList.currentItem.item.subPageShown : false
34− readonly property bool processing: dashContentList.currentItem && dashContentList.currentItem.item
35− && dashContentList.currentItem.item.processing || false
36− readonly property bool pageHeaderTotallyVisible: dashContentList.currentItem && dashContentList.currentItem.item
37− && dashContentList.currentItem.item.pageHeaderTotallyVisible || false
38−
39− signal scopeLoaded(string scopeId)
40− signal gotoScope(string scopeId)
41− signal openScope(var scope)
42− signal closePreview()
43−
44− // If we set the current scope index before the scopes have been added,
45− // then we need to wait until the loaded signals gets emitted from the scopes
46− property var set_current_index: undefined
47− Connections {
48− target: scopes
49− onLoadedChanged: {
50− if (scopes.loaded && set_current_index != undefined) {
51− setCurrentScopeAtIndex(set_current_index[0], set_current_index[1], set_current_index[2]);
52− set_current_index = undefined;
53− }
54− }
55− onRowsMoved: {
56− // FIXME This is to workaround a Qt bug with the model moving the current item
57− // when the list is ListView.SnapOneItem and ListView.StrictlyEnforceRange
58− // together with the code in Dash.qml
59− if (row == dashContentList.currentIndex || start == dashContentList.currentIndex) {
60− dashContent.workaroundRestoreIndex = dashContentList.currentIndex;
61− dashContentList.currentIndex = -1;
62− }
63− }
64− }
65−
66− function setCurrentScopeAtIndex(index, animate, reset) {
67− // if the scopes haven't loaded yet, then wait until they are.
68− if (!scopes.loaded) {
69− set_current_index = [ index, animate, reset ]
70− return;
71− }
72−
73− var storedMoveDuration = dashContentList.highlightMoveDuration
74− var storedMoveSpeed = dashContentList.highlightMoveVelocity
75− if (!animate) {
76− dashContentList.highlightMoveVelocity = units.gu(4167)
77− dashContentList.highlightMoveDuration = 0
78− }
79−
80− set_current_index = undefined;
81−
82− if (dashContentList.count > index) {
83− dashContentList.currentIndex = index
84−
85− if (reset) {
86− dashContentList.currentItem.item.positionAtBeginning()
87− dashContentList.currentItem.item.resetSearch()
88− }
89− }
90−
91− if (!animate) {
92− dashContentList.highlightMoveDuration = storedMoveDuration
93− dashContentList.highlightMoveVelocity = storedMoveSpeed
94− }
95− }
96−
97− Item {
98− id: dashContentListHolder
99−
100− anchors.fill: parent
101−
102− DashBackground {
103− anchors.fill: parent
104− }
105−
106− ListView {
107− id: dashContentList
108− objectName: "dashContentList"
109−
110− interactive: !dashContent.forceNonInteractive && dashContent.scopes.loaded && currentItem
111− && !currentItem.moving && !currentItem.subPageShown && !currentItem.extraPanelShown
112− anchors.fill: parent
113− orientation: ListView.Horizontal
114− boundsBehavior: Flickable.DragAndOvershootBounds
115− snapMode: ListView.SnapOneItem
116− highlightMoveDuration: 250
117− highlightRangeMode: ListView.StrictlyEnforceRange
118− // TODO Investigate if we can switch to a smaller cache buffer when/if UbuntuShape gets more performant
119− // 1073741823 is s^30 -1. A quite big number so that you have "infinite" cache, but not so
120− // big so that if you add if with itself you're outside the 2^31 int range
121− cacheBuffer: 1073741823
122− onMovementStarted: currentItem.item.showHeader();
123− clip: parent.x != 0
124−
125− // TODO QTBUG-40846 and QTBUG-40848
126− // The remove transition doesn't happen when removing the last item
127− // And can't work around it because index is reset to -1 regardless of
128− // ListView.delayRemove
129−
130− remove: Transition {
131− SequentialAnimation {
132− PropertyAction { property: "layer.enabled"; value: true }
133− PropertyAction { property: "ListView.delayRemove"; value: true }
134− ParallelAnimation {
135− PropertyAnimation { properties: "scale"; to: 0.25; duration: UbuntuAnimation.SnapDuration }
136− PropertyAnimation { properties: "y"; to: dashContent.height; duration: UbuntuAnimation.SnapDuration }
137− }
138− PropertyAction { property: "ListView.delayRemove"; value: false }
139− }
140− }
141− removeDisplaced: Transition {
142− PropertyAnimation { property: "x"; duration: UbuntuAnimation.SnapDecision }
143− }
144−
145− // If the number of items is less than the current index, then need to reset to another item.
146− onCountChanged: {
147− if (count > 0) {
148− if (currentIndex >= count) {
149− dashContent.setCurrentScopeAtIndex(count-1, true, true)
150− } else if (currentIndex < 0) {
151− // setting currentIndex directly, cause we don't want to loose set_current_index
152− dashContentList.currentIndex = 0
153− }
154− }
155− }
156−
157− delegate:
158− Loader {
159− id: loader
160− width: ListView.view.width
161− height: ListView.view.height
162− opacity: { // hide delegate if offscreen
163− var xPositionRelativetoView = ListView.view.contentX - x
164− return (xPositionRelativetoView > -width && xPositionRelativetoView < width) ? 1 : 0
165− }
166− asynchronous: true
167− source: "GenericScopeView.qml"
168− objectName: "scopeLoader" + index
169−
170− readonly property bool moving: item ? item.moving : false
171− readonly property bool extraPanelShown: item ? item.extraPanelShown : false
172− readonly property bool subPageShown: item ? item.subPageShown : false
173− readonly property var categoryView: item ? item.categoryView : null
174− readonly property var theScope: scope
175−
176− // these are needed for autopilot tests
177− readonly property string scopeId: scope.id
178− readonly property bool isCurrent: ListView.isCurrentItem
179− readonly property bool isLoaded: status == Loader.Ready
180−
181− onLoaded: {
182− item.objectName = scope.id
183− item.scope = Qt.binding(function() { return scope })
184− item.isCurrent = Qt.binding(function() { return visible && ListView.isCurrentItem })
185− dashContent.scopeLoaded(item.scope.id)
186− item.paginationCount = Qt.binding(function() { return dashContentList.count } )
187− item.paginationIndex = Qt.binding(function() { return dashContentList.currentIndex } )
188− item.visibleToParent = Qt.binding(function() { return loader.opacity != 0 });
189− item.holdingList = dashContentList;
190− item.forceNonInteractive = Qt.binding(function() { return dashContent.forceNonInteractive } )
191− }
192− Connections {
193− target: isCurrent ? scope : null
194− onGotoScope: {
195− // Note here scopeId is the signal parameter and not the loader property
196− dashContent.gotoScope(scopeId);
197− }
198− onOpenScope: {
199− dashContent.openScope(scope);
200− }
201− }
202− Connections {
203− target: dashContent
204− onClosePreview: if (item) item.closePreview()
205− }
206−
207− Component.onDestruction: active = false
208− }
209− }
210− }
211−}
qml/Dash/DashContentTabBarStyle.qmldeleted−24
@@ -1,24 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import Ubuntu.Components.Themes.Ambiance 1.3
18−
19−TabBarStyle {
20− indicatorImageSource: "graphics/tabbarchevron.png"
21− // TODO karni: These should come from updated Ubuntu Palette.
22− headerTextColor: "#88888888"
23− headerTextSelectedColor: "#888888"
24−}
qml/Dash/DashNavigation.qmldeleted−199
@@ -1,199 +0,0 @@
1−/*
2− * Copyright (C) 2014,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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Dash 0.1
20−import "../Components"
21−
22−Item {
23− id: root
24− objectName: "dashNavigation"
25−
26− // set by parent
27− property var scope: null
28− property real availableHeight
29−
30− signal leafClicked()
31−
32− // internal
33− readonly property var currentNavigation: scope && scope.hasNavigation ? scope.getNavigation(scope.currentNavigationId) : null
34− // Are we drilling down the tree or up?
35− property bool isEnteringChildren: false
36−
37− visible: height != 0
38− implicitHeight: scope && scope.hasNavigation ? navigationListView.y + navigationListView.height : 0
39−
40− function resetNavigation() {
41− if (navigationModel.count > 1) {
42− clear();
43− }
44− }
45−
46− Column {
47− id: headersColumn
48− anchors {
49− top: parent.top
50− left: parent.left
51− right: parent.right
52− }
53−
54− function pop(popsNeeded) {
55− if (popsNeeded == 0)
56− return;
57− isEnteringChildren = false;
58− navigationListView.currentIndex = navigationListView.currentIndex - popsNeeded;
59− navigationModel.setProperty(navigationListView.currentIndex, "nullifyNavigation", false);
60− navigationModel.remove(navigationModel.count - popsNeeded, popsNeeded);
61−
62− popsNeeded = Math.min(headersModel.count, popsNeeded);
63− // This is effectively deleting ourselves, so needs to be the last thing of the function
64− headersModel.remove(headersModel.count - popsNeeded, popsNeeded);
65− }
66−
67− Repeater {
68− model: ListModel {
69− id: headersModel
70− // Roles
71− // headerText: the text to show
72− // navigationId: the navigation Id that represents
73− // parentNavigationId: the parent navigation Id
74− }
75− delegate: DashNavigationHeader {
76− objectName: "dashNavigationHeader" + index
77− height: index == 0 && headersModel.count > 1 ? 0 : units.gu(5)
78− width: headersColumn.width
79−
80− backVisible: index != 0
81− text: headerText
82−
83− onBackClicked: {
84− scope.setNavigationState(parentNavigationId);
85−
86− var popsNeeded = headersModel.count - index;
87− headersColumn.pop(popsNeeded);
88− }
89−
90− onTextClicked: {
91− scope.setNavigationState(navigationId);
92−
93− var popsNeeded = headersModel.count - index - 1;
94− headersColumn.pop(popsNeeded);
95−
96− root.leafClicked();
97− }
98− }
99− }
100− }
101−
102− ListView {
103− id: navigationListView
104− objectName: "navigationListView"
105− orientation: ListView.Horizontal
106− interactive: false
107− model: ListModel {
108− id: navigationModel
109− // We have two roles
110− // navigationId: the navigation id of the navigation the list represents
111− // nullifyNavigation: overrides navigationId to be null
112− // This is used to "clear" the delegate when going "right" on the tree
113− }
114− anchors {
115− top: headersColumn.bottom
116− left: parent.left
117− right: parent.right
118− }
119− readonly property int maxHeight: root.availableHeight - navigationListView.y
120− property int prevHeight: maxHeight
121− height: currentItem ? currentItem.height : maxHeight
122−
123− onHeightChanged: {
124− if (currentItem) {
125− prevHeight = currentItem.desiredHeight;
126− }
127− }
128− highlightMoveDuration: UbuntuAnimation.FastDuration
129− delegate: DashNavigationList {
130− objectName: "navigation" + index
131− visible: height > 0
132− width: navigationListView.width
133− property real desiredHeight: {
134− if (navigation && navigation.loaded && x == navigationListView.contentX)
135− {
136− return Math.min(implicitHeight, navigationListView.maxHeight);
137− } else {
138− return navigationListView.prevHeight;
139− }
140− }
141− height: desiredHeight
142− navigation: (nullifyNavigation || !scope) ? null : scope.getNavigation(navigationId)
143− currentNavigation: root.currentNavigation
144− onEnterNavigation: { // var newNavigationId, string newNavigationLabel, bool hasChildren
145− scope.setNavigationState(newNavigationId);
146− // We only need to add a new item to the model
147− // if we have children, otherwise just load it
148− if (hasChildren) {
149− isEnteringChildren = true;
150− navigationModel.append({"navigationId": newNavigationId, "nullifyNavigation": false});
151− headersModel.append({"headerText": newNavigationLabel,
152− "navigationId": newNavigationId,
153− "parentNavigationId": navigationId
154− });
155− navigationListView.currentIndex++;
156− } else {
157− root.leafClicked();
158− }
159− }
160− }
161− onContentXChanged: {
162− if (navigationListView.highlightMoveDuration == 0)
163− return;
164−
165− if (contentX == width * navigationListView.currentIndex) {
166− if (isEnteringChildren) {
167− navigationModel.setProperty(navigationListView.currentIndex - 1, "nullifyNavigation", true);
168− }
169− }
170− }
171− }
172−
173− property bool isFirstLoad: false
174− onScopeChanged: clear();
175− function clear() {
176− navigationModel.clear();
177− headersModel.clear();
178− isFirstLoad = true;
179− }
180− function setNewNavigation() {
181− if (isFirstLoad && currentNavigation && currentNavigation.loaded) {
182− isFirstLoad = false;
183− if (currentNavigation.count > 0) {
184− navigationModel.append({"navigationId": scope.currentNavigationId, "nullifyNavigation": false});
185− } else {
186− navigationModel.append({"navigationId": currentNavigation.parentNavigationId, "nullifyNavigation": false});
187− }
188− headersModel.append({"headerText": currentNavigation.allLabel != "" ? currentNavigation.allLabel : currentNavigation.label,
189− "navigationId": currentNavigation.navigationId,
190− "parentNavigationId": currentNavigation.parentNavigationId
191− });
192− }
193− }
194− Connections {
195− target: currentNavigation
196− onLoadedChanged: setNewNavigation();
197− }
198− onCurrentNavigationChanged: setNewNavigation();
199−}
qml/Dash/DashNavigationHeader.qmldeleted−73
@@ -1,73 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Ubuntu.Components.ListItems 1.3 as ListItem
20−
21−Row {
22− id: root
23−
24− property alias backVisible: backImageItem.visible
25− property alias textEnabled: textItem.enabled
26− property alias text: textLabel.text
27−
28− readonly property alias backButtonWidth: backImageItem.width
29−
30− signal backClicked()
31− signal textClicked()
32−
33− ListItem.Standard {
34− id: backImageItem
35− objectName: "backButton"
36− height: parent.height
37− width: height
38− showDivider: false
39−
40− Icon {
41− id: backImage
42− anchors.centerIn: parent
43− name: "back"
44− height: units.gu(2)
45− width: height
46− }
47−
48− onClicked: root.backClicked();
49− }
50−
51− ListItem.Standard {
52− id: textItem
53− height: parent.height
54− showDivider: false
55−
56− Label {
57− id: textLabel
58− anchors {
59− verticalCenter: parent.verticalCenter
60− left: parent.left
61− right: parent.right
62− leftMargin: backImageItem.visible ? 0 : units.gu(2)
63− rightMargin: units.gu(2)
64− }
65− color: "#5D5D5D"
66− wrapMode: Text.Wrap
67− maximumLineCount: 2
68− elide: Text.ElideMiddle
69− }
70−
71− onClicked: root.textClicked();
72− }
73−}
qml/Dash/DashNavigationList.qmldeleted−118
@@ -1,118 +0,0 @@
1−/*
2− * Copyright (C) 2014,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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Ubuntu.Components.ListItems 1.3 as ListItems
20−import "../Components"
21−
22−Item {
23− id: root
24− property var navigation: null
25− property var currentNavigation: null
26− signal enterNavigation(var newNavigationId, string newNavigationLabel, bool hasChildren)
27−
28− readonly property int itemHeight: units.gu(5)
29− implicitHeight: flickable.contentHeight
30−
31− clip: true
32−
33− Behavior on height {
34− UbuntuNumberAnimation {
35− id: heightAnimation
36− duration: UbuntuAnimation.SnapDuration
37− }
38− }
39−
40− Flickable {
41− id: flickable
42−
43− anchors.fill: parent
44−
45− flickableDirection: Flickable.VerticalFlick
46− contentHeight: column.height
47− contentWidth: width
48−
49− Column {
50− id: column
51− width: parent.width
52−
53− Repeater {
54− model: navigation && navigation.loaded ? navigation : null
55− clip: true
56− delegate: Loader {
57− asynchronous: true
58− height: root.itemHeight
59− width: column.width
60− // FIXME Move to ListItem (and remove import) once 1556971 is fixed
61− sourceComponent: ListItems.Empty {
62− objectName: root.objectName + "child" + index
63− anchors {
64− left: parent.left
65− right: parent.right
66− leftMargin: units.gu(2)
67− rightMargin: units.gu(2)
68− }
69−
70− onClicked: root.enterNavigation(navigationId, allLabel != "" ? allLabel : label, hasChildren)
71−
72− Icon {
73− id: leftIcon
74− anchors {
75− verticalCenter: parent.verticalCenter
76− left: parent.left
77− }
78− height: units.gu(2)
79− width: height
80− name: "tick"
81− color: "#3EB34F"
82− visible: isActive
83− }
84−
85− Label {
86− anchors {
87− verticalCenter: parent.verticalCenter
88− left: leftIcon.right
89− leftMargin: units.gu(1)
90− right: rightIcon.left
91− rightMargin: units.gu(2)
92− }
93− text: label
94− color: isActive ? "#333333" : "#888888"
95− wrapMode: Text.Wrap
96− maximumLineCount: 2
97− elide: Text.ElideMiddle
98− }
99−
100− Icon {
101− id: rightIcon
102− anchors {
103− verticalCenter: parent.verticalCenter
104− right: parent.right
105− }
106− height: units.gu(2)
107− width: height
108− name: "go-next"
109− visible: hasChildren
110− }
111−
112− divider.visible: index != navigation.count - 1
113− }
114− }
115− }
116− }
117− }
118−}
qml/Dash/DashPageHeader.qmldeleted−448
@@ -1,448 +0,0 @@
1−/*
2− * Copyright (C) 2013,2015,2016 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Ubuntu.Components.Popups 1.3
20−import Ubuntu.Components.ListItems 1.3
21−import Utils 0.1
22−import "../Components"
23−
24−Item {
25− id: root
26− objectName: "pageHeader"
27− implicitHeight: headerContainer.height + signatureLineHeight
28− readonly property real signatureLineHeight: showSignatureLine ? units.gu(2.5) : headerBottomLine.height
29−
30− property int activeFiltersCount: 0
31− property bool scopeHasFilters: false
32− property bool showBackButton: false
33− property bool backIsClose: false
34− property string title
35− property var extraPanel
36− property string navigationTag
37−
38− property bool storeEntryEnabled: false
39− property bool searchEntryEnabled: false
40− property bool settingsEnabled: false
41− property bool favoriteEnabled: false
42− property bool favorite: false
43− property ListModel searchHistory
44− property alias searchQuery: searchTextField.text
45− property alias searchHint: searchTextField.placeholderText
46− property bool showSignatureLine: false
47−
48− property int paginationCount: 0
49− property int paginationIndex: -1
50−
51− property var scopeStyle: null
52−
53− signal clearSearch(bool keepPanelOpen)
54− signal backClicked()
55− signal storeClicked()
56− signal settingsClicked()
57− signal favoriteClicked()
58− signal searchTextFieldFocused()
59− signal showFiltersPopup(var item)
60−
61− onScopeStyleChanged: refreshLogo()
62− onSearchQueryChanged: {
63− // Make sure we are at the search page if the search query changes behind our feet
64− if (searchQuery) {
65− headerContainer.showSearch = true;
66− }
67− }
68− onNavigationTagChanged: {
69− // Make sure we are at the search page if the navigation tag changes behind our feet
70− if (navigationTag) {
71− headerContainer.showSearch = true;
72− }
73− }
74−
75− function triggerSearch() {
76− if (searchEntryEnabled) {
77− headerContainer.showSearch = true;
78− searchTextField.forceActiveFocus();
79− }
80− }
81−
82− function closePopup(keepFocus, keepSearch) {
83− if (extraPanel.visible) {
84− extraPanel.visible = false;
85− }
86− if (!keepFocus) {
87− unfocus(keepSearch);
88− }
89− if (!keepSearch && !searchTextField.text && !root.navigationTag && searchHistory.count == 0) {
90− headerContainer.showSearch = false;
91− }
92− }
93−
94− function resetSearch(keepFocus) {
95− if (searchHistory) {
96− searchHistory.addQuery(searchTextField.text);
97− }
98− searchTextField.text = "";
99− closePopup(keepFocus);
100− }
101−
102− function unfocus(keepSearch) {
103− searchTextField.focus = false;
104− if (!keepSearch && !searchTextField.text && !root.navigationTag) {
105− headerContainer.showSearch = false;
106− }
107− }
108−
109− function openPopup() {
110− if (openSearchAnimation.running) {
111− openSearchAnimation.openPopup = true;
112− } else if (extraPanel.hasContents) {
113− // Show extraPanel
114− extraPanel.visible = true;
115− }
116− }
117−
118− function refreshLogo() {
119− if (root.scopeStyle ? root.scopeStyle.headerLogo != "" : false) {
120− header.contents = imageComponent.createObject();
121− } else if (header.contents) {
122− header.contents.destroy();
123− header.contents = null;
124− }
125− }
126−
127− Connections {
128− target: root.scopeStyle
129− onHeaderLogoChanged: root.refreshLogo()
130− }
131−
132− InverseMouseArea {
133− anchors { fill: parent; margins: units.gu(1); bottomMargin: units.gu(3) + (extraPanel ? extraPanel.height : 0) }
134− visible: headerContainer.showSearch
135− onPressed: {
136− closePopup(/* keepFocus */false);
137− mouse.accepted = false;
138− }
139− }
140−
141− Item {
142− id: headerContainer
143− objectName: "headerContainer"
144− anchors { left: parent.left; top: parent.top; right: parent.right }
145− height: header.__styleInstance.contentHeight
146−
147− property bool showSearch: false
148−
149− state: headerContainer.showSearch ? "search" : ""
150−
151− states: State {
152− name: "search"
153−
154− AnchorChanges {
155− target: headersColumn
156− anchors.top: parent.top
157− anchors.bottom: undefined
158− }
159− }
160−
161− transitions: Transition {
162− id: openSearchAnimation
163− AnchorAnimation {
164− duration: UbuntuAnimation.FastDuration
165− easing: UbuntuAnimation.StandardEasing
166− }
167−
168− property bool openPopup: false
169−
170− onRunningChanged: {
171− headerContainer.clip = running;
172− if (!running && openSearchAnimation.openPopup) {
173− openSearchAnimation.openPopup = false;
174− root.openPopup();
175− }
176− }
177− }
178−
179− Background {
180− id: background
181− objectName: "headerBackground"
182− style: scopeStyle.headerBackground
183− }
184−
185− Column {
186− id: headersColumn
187− objectName: "headersColumn"
188− anchors {
189− left: parent.left
190− right: parent.right
191− bottom: parent.bottom
192− }
193−
194− PageHeader {
195− id: searchHeader
196− anchors { left: parent.left; right: parent.right }
197− opacity: headerContainer.clip || headerContainer.showSearch ? 1 : 0 // setting visible false cause column to relayout
198−
199− StyleHints {
200− foregroundColor: root.scopeStyle ? root.scopeStyle.headerForeground : theme.palette.normal.baseText
201− backgroundColor: "transparent"
202− dividerColor: "transparent"
203− }
204−
205− contents: Item {
206− anchors.fill: parent
207−
208− Keys.onEscapePressed: { // clear the search text, dismiss the search in the second step
209− if (searchTextField.text != "") {
210− root.clearSearch(true);
211− } else {
212− root.clearSearch(false);
213− headerContainer.showSearch = false;
214− }
215− }
216−
217− TextField {
218− id: searchTextField
219− objectName: "searchTextField"
220− inputMethodHints: Qt.ImhNoPredictiveText
221− hasClearButton: false
222− anchors {
223− top: parent.top
224− topMargin: units.gu(1)
225− left: parent.left
226− bottom: parent.bottom
227− bottomMargin: units.gu(1)
228− right: settingsButton.left
229− rightMargin: settingsButton.visible ? 0 : units.gu(2)
230− }
231−
232− primaryItem: Rectangle {
233− color: "#F5F4F5"
234− width: root.navigationTag != "" ? tagLabel.width + units.gu(2) : 0
235− height: root.navigationTag != "" ? tagLabel.height + units.gu(1) : 0
236− radius: units.gu(0.5)
237− Label {
238− id: tagLabel
239− text: root.navigationTag
240− anchors.centerIn: parent
241− color: "#333333"
242− }
243− }
244−
245− secondaryItem: AbstractButton {
246− id: clearButton
247− height: searchTextField.height
248− width: height
249− enabled: searchTextField.text.length > 0 || root.navigationTag != ""
250−
251− Image {
252− objectName: "clearIcon"
253− anchors.fill: parent
254− anchors.margins: units.gu(1)
255− source: "image://theme/clear"
256− sourceSize.width: width
257− sourceSize.height: height
258− opacity: parent.enabled
259− visible: opacity > 0
260− Behavior on opacity {
261− UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
262− }
263− }
264−
265− onClicked: {
266− root.clearSearch(true);
267− }
268− }
269−
270− onActiveFocusChanged: {
271− if (activeFocus) {
272− root.searchTextFieldFocused();
273− root.openPopup();
274− }
275− }
276−
277− onTextChanged: {
278− if (text != "") {
279− closePopup(/* keepFocus */true);
280− }
281− }
282− }
283−
284− AbstractButton {
285− id: settingsButton
286− objectName: "settingsButton"
287−
288− width: root.scopeHasFilters ? height : 0
289− visible: width > 0
290− anchors {
291− top: parent.top
292− right: cancelButton.left
293− bottom: parent.bottom
294− rightMargin: units.gu(-1)
295− }
296−
297− Icon {
298− anchors.fill: parent
299− anchors.margins: units.gu(2)
300− name: "filters"
301− color: root.activeFiltersCount > 0 ? theme.palette.normal.positive : header.__styleInstance.foregroundColor
302− }
303−
304− onClicked: {
305− root.showFiltersPopup(settingsButton);
306− }
307− }
308−
309− AbstractButton {
310− id: cancelButton
311− objectName: "cancelButton"
312− width: cancelLabel.width + cancelLabel.anchors.rightMargin + cancelLabel.anchors.leftMargin
313− anchors {
314− top: parent.top
315− right: parent.right
316− bottom: parent.bottom
317− }
318− onClicked: {
319− root.clearSearch(false);
320− headerContainer.showSearch = false;
321− }
322− Label {
323− id: cancelLabel
324− text: i18n.tr("Cancel")
325− color: header.__styleInstance.foregroundColor
326− verticalAlignment: Text.AlignVCenter
327− anchors {
328− verticalCenter: parent.verticalCenter
329− right: parent.right
330− leftMargin: units.gu(1)
331− }
332− }
333− }
334− }
335− }
336−
337− PageHeader {
338− id: header
339− objectName: "innerPageHeader"
340− anchors { left: parent.left; right: parent.right }
341− height: headerContainer.height
342− opacity: headerContainer.clip || !headerContainer.showSearch ? 1 : 0 // setting visible false cause column to relayout
343− title: root.title
344−
345− StyleHints {
346− foregroundColor: root.scopeStyle ? root.scopeStyle.headerForeground : theme.palette.normal.baseText
347− backgroundColor: "transparent"
348− dividerColor: "transparent"
349− }
350−
351− leadingActionBar.actions: Action {
352− iconName: backIsClose ? "close" : "back"
353− visible: root.showBackButton
354− onTriggered: root.backClicked()
355− }
356−
357− trailingActionBar {
358− actions: [
359− Action {
360− objectName: "store"
361− text: i18n.ctr("Button: Open the Ubuntu Store", "Store")
362− iconName: "ubuntu-store-symbolic"
363− visible: root.storeEntryEnabled
364− onTriggered: root.storeClicked();
365− },
366− Action {
367− objectName: "search"
368− text: i18n.ctr("Button: Start a search in the current dash scope", "Search")
369− iconName: "search"
370− visible: root.searchEntryEnabled
371− onTriggered: {
372− headerContainer.showSearch = true;
373− searchTextField.forceActiveFocus();
374− }
375− },
376− Action {
377− objectName: "settings"
378− text: i18n.ctr("Button: Show the current dash scope settings", "Settings")
379− iconName: "settings"
380− visible: root.settingsEnabled
381− onTriggered: root.settingsClicked()
382− },
383− Action {
384− objectName: "favorite"
385− text: root.favorite ? i18n.tr("Remove from Favorites") : i18n.tr("Add to Favorites")
386− iconName: root.favorite ? "starred" : "non-starred"
387− visible: root.favoriteEnabled
388− onTriggered: root.favoriteClicked()
389− }
390− ]
391− }
392−
393− Component.onCompleted: root.refreshLogo()
394−
395− Component {
396− id: imageComponent
397−
398− Item {
399− anchors { fill: parent; topMargin: units.gu(1.5); bottomMargin: units.gu(1.5) }
400− clip: true
401− Image {
402− objectName: "titleImage"
403− anchors.fill: parent
404− source: root.scopeStyle ? root.scopeStyle.headerLogo : ""
405− fillMode: Image.PreserveAspectFit
406− horizontalAlignment: Image.AlignLeft
407− sourceSize.height: height
408− }
409− }
410− }
411− }
412− }
413− }
414−
415− Rectangle {
416− id: headerBottomLine
417− anchors {
418− top: headerContainer.bottom
419− left: parent.left
420− right: parent.right
421− }
422− height: units.dp(1)
423− color: theme.palette.normal.base
424− }
425−
426− Row {
427− anchors {
428− top: headerContainer.bottom
429− horizontalCenter: headerContainer.horizontalCenter
430− topMargin: units.gu(1)
431− }
432− visible: showSignatureLine
433− spacing: units.gu(.5)
434− Repeater {
435− objectName: "paginationRepeater"
436− model: root.paginationCount
437− Rectangle {
438− objectName: "paginationDots_" + index
439− height: units.gu(1)
440− width: height
441− radius: height / 2
442− color: index == root.paginationIndex ? UbuntuColors.blue : "transparent"
443− border.width: index == root.paginationIndex ? 0 : 1 // yes, one pixel and not 1dp
444− border.color: theme.palette.normal.baseText
445− }
446− }
447− }
448−}
qml/Dash/DashRenderer.qmldeleted−66
@@ -1,66 +0,0 @@
1−/*
2− * Copyright (C) 2013-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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−
19−Item {
20− property real collapsedHeight
21−
22− property real expandedHeight
23−
24− property int collapsedItemCount: -1
25−
26− property int cacheBuffer: 0
27−
28− property int displayMarginBeginning: 0
29−
30− property int displayMarginEnd: 0
31−
32− property real originY: 0
33−
34− property bool growsVertically: true
35−
36− // If growsVertically the width of the item inside the renderer
37− property real innerWidth: 0
38−
39− // The model to renderer
40− property var model
41−
42− /// CardTool component.
43− property var cardTool: null
44−
45− /// ScopeStyle component.
46− property var scopeStyle: null
47−
48− /// Emitted when the user clicked on an item
49− /// @param index is the index of the clicked item
50− /// @param result result model of the clicked item, used for activation
51− /// @param item item that has been clicked
52− /// @param itemModel model of the item
53− signal clicked(int index, var result, var item, var itemModel)
54−
55− /// Emitted when the user pressed and held on an item
56− /// @param index is the index of the held item
57− /// @param result result model of the clicked item, used for activation
58− /// @param itemModel model of the item
59− signal pressAndHold(int index, var result, var itemModel)
60−
61− /// Emitted when the user clicked on an item action
62− /// @param index is the index of the clicked item
63− /// @param result result model of the clicked item, used for activation
64− /// @param actionId id of the clicked action
65− signal action(int index, var result, var actionId)
66−}
qml/Dash/DashSectionHeader.qmldeleted−64
@@ -1,64 +0,0 @@
1−/*
2− * Copyright (C) 2013,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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import QtQuick.Layouts 1.1
19−import Ubuntu.Components 1.3
20−
21−Item {
22− property alias text: label.text
23− property alias color: label.color
24− property alias iconName: icon.name
25−
26− signal clicked(variant mouse)
27−
28− height: units.gu(5)
29−
30− Label {
31− id: label
32−
33− anchors {
34− left: parent.left
35− leftMargin: units.gu(2)
36− verticalCenter: parent.verticalCenter
37− }
38−
39− font.family: "Ubuntu"
40− fontSize: "medium"
41− elide: Text.ElideRight
42− maximumLineCount: 1
43− textFormat: Text.PlainText
44− width: Math.min(parent.width - units.gu(4), implicitWidth)
45− }
46−
47− Icon {
48− id: icon
49− visible: name != ""
50− height: units.gu(1.25)
51− width: height
52− color: label.color
53− anchors {
54− left: label.right
55− leftMargin: units.gu(0.25)
56− verticalCenter: parent.verticalCenter
57− }
58− }
59−
60− MouseArea {
61− anchors.fill: parent
62− onClicked: parent.clicked(mouse)
63− }
64−}
qml/Dash/Filters/FilterExpandableWidget.qmldeleted−97
@@ -1,97 +0,0 @@
1−/*
2− * Copyright (C) 2016 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Ubuntu.Components.ListItems 1.3 as ListItems
20−
21−/*! Expandable Filter Widget. */
22−
23−FilterWidget {
24− id: root
25−
26− showsTitleOnItsOwn: true
27−
28− implicitHeight: expandingItem.height
29−
30− ListItems.Expandable {
31− id: expandingItem
32− objectName: "expandingItem"
33−
34− expandedHeight: collapsedHeight + column.height
35− anchors.left: parent.left
36− anchors.right: parent.right
37− showDivider: false
38−
39− onClicked: {
40− expanded = !expanded;
41− forceActiveFocus();
42− }
43− __contentsMargins: 0
44−
45− Item {
46− id: titleHolder
47− anchors.top: parent.top
48− height: expandingItem.collapsedHeight
49− anchors.left: parent.left
50− anchors.right: parent.right
51−
52− Label {
53− anchors.left: parent.left
54− anchors.leftMargin: units.gu(2)
55− anchors.right: dropDown.left
56− anchors.verticalCenter: parent.verticalCenter
57− text: widgetData.title || ""
58− }
59−
60− Image {
61− id: dropDown
62− height: units.gu(3)
63− fillMode: Image.PreserveAspectFit
64− anchors.right: parent.right
65− anchors.rightMargin: units.gu(2)
66− anchors.verticalCenter: parent.verticalCenter
67− source: expandingItem.expanded ? "image://theme/up" : "image://theme/down"
68− sourceSize.height: height
69− }
70− }
71−
72− Column {
73− id: column
74− anchors.left: parent.left
75− anchors.right: parent.right
76− anchors.top: titleHolder.bottom
77−
78− Repeater {
79− id: repeater
80− model: widgetData.filters
81−
82− delegate: FilterWidgetFactory {
83− width: parent.width
84−
85− widgetId: id
86− widgetType: type
87− widgetData: filter
88−
89− ListItems.ThinDivider {
90− anchors.bottom: parent.bottom
91− visible: index !== repeater.count - 1
92− }
93− }
94− }
95− }
96− }
97−}
qml/Dash/Filters/FilterOptionSelector.qmldeleted−97
@@ -1,97 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Ubuntu.Components.ListItems 1.3 as ListItems
20−
21−/*! Option Selector Filter Widget. */
22−
23−FilterWidget {
24− id: root
25−
26− implicitHeight: expandingItem.height
27−
28− signal filterSelected()
29−
30− ListItems.Expandable {
31− id: expandingItem
32− objectName: "expandingItem"
33−
34− expandedHeight: collapsedHeight + column.height
35− width: parent.width
36− showDivider: false
37−
38− onClicked: {
39− expanded = !expanded;
40− forceActiveFocus();
41− }
42−
43− Item {
44− id: holder
45− anchors.top: parent.top
46− height: expandingItem.collapsedHeight
47− width: parent.width
48−
49− Label {
50− anchors.left: parent.left
51− anchors.right: dropDown.left
52− anchors.verticalCenter: parent.verticalCenter
53− text: widgetData.label || ""
54− }
55−
56− Image {
57− id: dropDown
58− height: units.gu(3)
59− fillMode: Image.PreserveAspectFit
60− anchors.right: parent.right
61− anchors.verticalCenter: parent.verticalCenter
62− source: expandingItem.expanded ? "image://theme/up" : "image://theme/down"
63− sourceSize.height: height
64− }
65− }
66−
67− Column {
68− id: column
69− anchors.top: holder.bottom
70− width: parent.width
71− Repeater {
72− model: widgetData.options
73− objectName: "optionsRepeater"
74−
75− ListItems.Standard {
76− text: label
77− objectName: root.objectName + "label" + index;
78−
79− Image {
80− height: units.gu(3)
81− fillMode: Image.PreserveAspectFit
82− anchors.right: parent.right
83− anchors.verticalCenter: parent.verticalCenter
84− source: "image://theme/tick"
85− sourceSize.height: height
86− visible: checked
87− }
88−
89− onClicked: {
90− widgetData.options.setChecked(index, !checked);
91− root.filterSelected()
92− }
93− }
94− }
95− }
96− }
97−}
qml/Dash/Filters/FilterRangeInput.qmldeleted−136
@@ -1,136 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import QtQuick.Layouts 1.1
19−import Ubuntu.Components 1.3
20−
21−/*! Range Input Filter Widget. */
22−
23−FilterWidget {
24− id: root
25−
26− implicitHeight: field1.height + units.gu(2)
27−
28− function setFieldValue(field, hasValue, value) {
29− if (hasValue) {
30− // Need this othewise if we are on 4.5 and backspace instead of
31− // having 4. in the text field we end up with 4 which is confusing
32− if (field.text != value) {
33− field.text = value;
34− }
35− } else {
36− field.text = "";
37− }
38− }
39−
40− Connections {
41− target: widgetData
42− onStartValueChanged: root.setFieldValue(field1, widgetData.hasStartValue, widgetData.startValue);
43− onHasStartValueChanged: root.setFieldValue(field1, widgetData.hasStartValue, widgetData.startValue);
44− onEndValueChanged: root.setFieldValue(field2, widgetData.hasEndValue, widgetData.endValue);
45− onHasEndValueChanged: root.setFieldValue(field2, widgetData.hasEndValue, widgetData.endValue);
46− }
47−
48− onWidgetDataChanged: {
49− if (widgetData) {
50− root.setFieldValue(field1, widgetData.hasStartValue, widgetData.startValue);
51− root.setFieldValue(field2, widgetData.hasEndValue, widgetData.endValue);
52− } else {
53− root.setFieldValue(field1, false, -1);
54− root.setFieldValue(field2, false, -1);
55− }
56− }
57−
58− RowLayout {
59− anchors {
60− fill: parent
61− topMargin: units.gu(1)
62− bottomMargin: units.gu(1)
63− }
64−
65− Item {
66− Layout.fillWidth: true
67− }
68−
69− Label {
70− text: widgetData.startPrefixLabel
71− verticalAlignment: Text.AlignVCenter
72− }
73−
74− TextField {
75− id: field1
76− objectName: "startValueField"
77− implicitWidth: units.gu(9)
78− verticalAlignment: Text.AlignVCenter
79− inputMethodHints: Qt.ImhFormattedNumbersOnly
80− validator: DoubleValidator {
81− notation: DoubleValidator.StandardNotation
82− }
83− onTextChanged: {
84− if (text === "") widgetData.eraseStartValue();
85− else widgetData.startValue = text;
86− }
87− }
88−
89− Label {
90− text: widgetData.startPostfixLabel
91− verticalAlignment: Text.AlignVCenter
92− }
93−
94− Item {
95− Layout.fillWidth: true
96− }
97−
98− Label {
99− text: widgetData.centralLabel
100− verticalAlignment: Text.AlignVCenter
101− }
102−
103− Item {
104− Layout.fillWidth: true
105− }
106−
107− Label {
108− text: widgetData.endPrefixLabel
109− verticalAlignment: Text.AlignVCenter
110− }
111−
112− TextField {
113− id: field2
114− objectName: "endValueField"
115− implicitWidth: units.gu(9)
116− verticalAlignment: Text.AlignVCenter
117− inputMethodHints: Qt.ImhFormattedNumbersOnly
118− validator: DoubleValidator {
119− notation: DoubleValidator.StandardNotation
120− }
121− onTextChanged: {
122− if (text === "") widgetData.eraseEndValue();
123− else widgetData.endValue = text;
124− }
125− }
126−
127− Label {
128− text: widgetData.endPostfixLabel
129− verticalAlignment: Text.AlignVCenter
130− }
131−
132− Item {
133− Layout.fillWidth: true
134− }
135− }
136−}
qml/Dash/Filters/FilterValueSlider.qmldeleted−87
@@ -1,87 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import QtQuick.Layouts 1.1
19−import Ubuntu.Components 1.3
20−
21−/*! Value Slider Filter Widget. */
22−
23−FilterWidget {
24− id: root
25−
26− implicitHeight: childrenRect.height + units.gu(2)
27−
28− Connections {
29− target: widgetData
30− // One would think that this is not needed since
31− // we have value: widgetData.value on the slider
32− // but it is, otherwise reset doesn't seem to work
33− onValueChanged: {
34− if (widgetData.value !== slider.value) {
35− slider.value = widgetData.value;
36− }
37− }
38− }
39−
40− Slider {
41− id: slider
42− objectName: "slider"
43−
44− anchors {
45− top: parent.top
46− topMargin: units.gu(1)
47− left: parent.left
48− leftMargin: units.gu(2)
49− right: parent.right
50− rightMargin: units.gu(2)
51− }
52−
53− minimumValue: widgetData.minValue
54− maximumValue: widgetData.maxValue
55− value: widgetData.value
56− onValueChanged: {
57− widgetData.value = value;
58− }
59− onPressedChanged: {
60− if (pressed) forceActiveFocus();
61− }
62−
63− readonly property Item thumb: __internals.thumb
64− readonly property real barMinusThumb: __internals.barMinusThumb
65− }
66−
67− Repeater {
68− objectName: "repeater"
69− model: widgetData.values
70− delegate: Label {
71− anchors {
72− top: slider.bottom
73− // The slider is too tall, so move a bit up
74− topMargin: -units.gu(1)
75− }
76− text: label
77− visible: value <= widgetData.maxValue && value >= widgetData.minValue
78− x: {
79− var halfThumbDifference = (width - slider.thumb.width) / 2;
80− var result = (value - widgetData.minValue) * slider.barMinusThumb / (widgetData.maxValue - widgetData.minValue) - halfThumbDifference;
81− result = Math.max(result, 0);
82− result = Math.min(result, slider.width - width);
83− return units.gu(2) + result;
84− }
85− }
86− }
87−}
qml/Dash/Filters/FilterWidget.qmldeleted−32
@@ -1,32 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−
19−/*! Interface for filter widgets. */
20−
21−Item {
22− //! The widget identifier
23− property string widgetId
24−
25− //! Variable used to contain widget's data
26− property var widgetData: null
27−
28− //! Does the widget show the title inside?
29− property bool showsTitleOnItsOwn: false
30−
31− objectName: widgetId
32−}
qml/Dash/Filters/FilterWidgetFactory.qmldeleted−89
@@ -1,89 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Unity 0.2
20−
21−//! \brief This component loads the widgets based on widgetType.
22−
23−Item {
24− id: root
25− //! Identifier of the widget.
26− property string widgetId: ""
27−
28− //! Type of the widget to display.
29− property int widgetType
30−
31− //! Widget data, forwarded to the widget as is.
32− property var widgetData: null
33−
34− // Emitted iff filter type is FilterOptionSelector
35− signal singleSelectionFilterSelected()
36−
37− implicitHeight: title.height + title.anchors.topMargin + loader.height
38−
39− Label {
40− id: title
41− text: widgetData && !(loader.item && loader.item.showsTitleOnItsOwn) ? widgetData.title : ""
42− height: text != "" ? implicitHeight : 0
43−
44− anchors {
45− top: parent.top
46− left: parent.left
47− right: parent.right
48−
49− topMargin: height > 0 ? units.gu(1) : 0
50− leftMargin: units.gu(2)
51− rightMargin: anchors.leftMargin
52− }
53− }
54−
55− property alias active: loader.active
56−
57− Loader {
58− id: loader
59− objectName: "loader"
60−
61− anchors {
62− top: title.bottom
63− left: parent.left
64− right: parent.right
65− }
66−
67− source: widgetSource
68−
69− readonly property url widgetSource: {
70− switch (widgetType) {
71− case Filters.OptionSelectorFilter: return "FilterOptionSelector.qml";
72− case Filters.RangeInputFilter: return "FilterRangeInput.qml";
73− case Filters.ValueSliderFilter: return "FilterValueSlider.qml";
74− case Filters.ExpandableFilterWidget: return "FilterExpandableWidget.qml";
75− default: return "";
76− }
77− }
78−
79− onLoaded: {
80− item.widgetId = Qt.binding(function() { return root.widgetId } )
81− item.widgetData = Qt.binding(function() { return root.widgetData } )
82− }
83−
84− Connections {
85− target: widgetType == Filters.OptionSelectorFilter ? loader.item : null
86− onFilterSelected: root.singleSelectionFilterSelected()
87− }
88− }
89−}
qml/Dash/FiltersPopover.qmldeleted−106
@@ -1,106 +0,0 @@
1−/*
2− * Copyright (C) 2013-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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Ubuntu.Components.Popups 1.3
20−import Ubuntu.Components.ListItems 1.3 as ListItems
21−import "Filters" as Filters
22−import "../Components"
23−
24−Popover {
25− id: root
26− objectName: "filtersPopover"
27−
28− Flickable {
29− id: flickable
30− anchors {
31− top: parent.top
32− left: parent.left
33− right: parent.right
34− }
35− height: {
36− // Popover doesn't like being 75% or bigger than the screen (counting the "empty" part on top)
37− var posToRootParent = flickable.mapToItem(null, 0, 0).y;
38− var threeQuartersParent = root.parent.height * 3 / 4 - posToRootParent - 1;
39− var parentAndKeyboard = root.parent.height - posToRootParent - (Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height + units.gu(3) : 0)
40− return Math.min(parentAndKeyboard, Math.min(threeQuartersParent, column.height));
41− }
42− clip: true
43− contentHeight: column.height
44− contentWidth: width
45−
46− Column {
47− id: column
48− width: parent.width
49−
50− Item {
51− width: parent.width
52− height: resetLabel.height + units.gu(3)
53−
54− Label {
55− anchors {
56− left: parent.left
57− right: resetLabel.left
58− margins: units.gu(2)
59− verticalCenter: parent.verticalCenter
60− }
61− text: i18n.tr("Refine your results")
62− }
63− Label {
64− id: resetLabel
65− anchors {
66− right: parent.right
67− rightMargin: units.gu(2)
68− verticalCenter: parent.verticalCenter
69− }
70− text: i18n.tr("Reset")
71−
72− AbstractButton {
73− anchors {
74− fill: parent
75− rightMargin: units.gu(-2)
76− leftMargin: units.gu(-2)
77− topMargin: units.gu(-1)
78− bottomMargin: units.gu(-1)
79− }
80− onClicked: {
81− scopeView.scope.resetFilters();
82− }
83− }
84− }
85− }
86−
87− Repeater {
88− id: repeater
89− model: scopeView.scope.filters
90−
91− delegate: Filters.FilterWidgetFactory {
92− width: parent.width
93−
94− widgetId: id
95− widgetType: type
96− widgetData: filter
97−
98− ListItems.ThinDivider {
99− anchors.bottom: parent.bottom
100− visible: index != repeater.count - 1
101− }
102− }
103− }
104− }
105− }
106−}
qml/Dash/GenericScopeView.qmldeleted−797
@@ -1,797 +0,0 @@
1−/*
2− * Copyright (C) 2013-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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Ubuntu.Components.Popups 1.3
20−import "../Components/SearchHistoryModel"
21−import Utils 0.1
22−import Unity 0.2
23−import Dash 0.1
24−import "../Components"
25−import "Previews/PreviewSingleton"
26−
27−FocusScope {
28− id: scopeView
29−
30− property bool forceNonInteractive: false
31− property var scope: null
32− property UnitySortFilterProxyModel categories: categoryFilter
33− property bool isCurrent: false
34− property alias moving: categoryView.moving
35− property bool hasBackAction: false
36− property bool enableHeightBehaviorOnNextCreation: false
37− property var categoryView: categoryView
38− readonly property alias subPageShown: subPageLoader.subPageShown
39− readonly property alias extraPanelShown: peExtraPanel.visible
40− property int paginationCount: 0
41− property int paginationIndex: 0
42− property bool visibleToParent: false
43− property alias pageHeaderTotallyVisible: categoryView.pageHeaderTotallyVisible
44− property var holdingList: null
45− property bool wasCurrentOnMoveStart: false
46− property var filtersPopover: null
47−
48− property var scopeStyle: ScopeStyle {
49− style: scope ? scope.customizations : {}
50− }
51−
52− readonly property bool processing: scope ? (scope.searchInProgress || scope.activationInProgress || subPageLoader.processing) : false
53−
54− signal backClicked()
55−
56− onScopeChanged: {
57− floatingSeeLess.companionBase = null;
58− }
59−
60− function positionAtBeginning() {
61− categoryView.positionAtBeginning()
62− }
63−
64− function showHeader() {
65− categoryView.showHeader()
66− }
67−
68− function closePreview() {
69− subPageLoader.closeSubPage()
70− }
71−
72− function resetSearch() {
73− categoryView.pageHeader.resetSearch()
74− }
75−
76− property var maybePreviewResult;
77− property string maybePreviewCategoryId;
78−
79− function clearMaybePreviewData() {
80− scopeView.maybePreviewResult = undefined;
81− scopeView.maybePreviewCategoryId = "";
82− }
83−
84− function itemClicked(result, categoryId) {
85− scopeView.maybePreviewResult = result;
86− scopeView.maybePreviewCategoryId = categoryId;
87−
88− scope.activate(result, categoryId);
89− }
90−
91− function itemPressedAndHeld(result, categoryId) {
92− clearMaybePreviewData();
93−
94− openPreview(result, categoryId);
95− }
96−
97− function openPreview(result, categoryId) {
98− var previewModel = scope.preview(result, categoryId);
99− if (previewModel) {
100− subPageLoader.previewModel = previewModel;
101− subPageLoader.openSubPage("preview");
102− }
103− }
104−
105− Binding {
106− target: scope
107− property: "isActive"
108− value: isCurrent && !subPageLoader.open && (Qt.application.state == Qt.ApplicationActive)
109− }
110−
111− UnitySortFilterProxyModel {
112− id: categoryFilter
113− model: scope ? scope.categories : null
114− dynamicSortFilter: true
115− filterRole: Categories.RoleCount
116− filterRegExp: /^0$/
117− invertMatch: true
118− }
119−
120− onIsCurrentChanged: {
121− if (!holdingList || !holdingList.moving) {
122− wasCurrentOnMoveStart = scopeView.isCurrent;
123− }
124− categoryView.pageHeader.resetSearch();
125− subPageLoader.closeSubPage();
126− if (filtersPopover) {
127− PopupUtils.close(filtersPopover)
128− scopeView.filtersPopover = null;
129− }
130− }
131−
132− Binding {
133− target: scopeView.scope
134− property: "searchQuery"
135− value: categoryView.pageHeader.searchQuery
136− when: isCurrent
137− }
138−
139− Binding {
140− target: categoryView.pageHeader
141− property: "searchQuery"
142− value: scopeView.scope ? scopeView.scope.searchQuery : ""
143− when: isCurrent
144− }
145−
146− Connections {
147− target: scopeView.scope
148− onShowDash: subPageLoader.closeSubPage()
149− onHideDash: subPageLoader.closeSubPage()
150− onPreviewRequested: { // (QVariant const& result)
151− if (result === scopeView.maybePreviewResult) {
152− openPreview(result,
153− scopeView.maybePreviewCategoryId);
154−
155− clearMaybePreviewData();
156− }
157− }
158− }
159−
160− Connections {
161− target: holdingList
162− onMovingChanged: {
163− if (!moving) {
164− wasCurrentOnMoveStart = scopeView.isCurrent;
165− }
166− }
167− }
168−
169− Rectangle {
170− anchors.fill: parent
171− color: scopeView.scopeStyle ? scopeView.scopeStyle.background : "transparent"
172− visible: color != "transparent"
173− }
174−
175− ScopeListView {
176− id: categoryView
177− objectName: "categoryListView"
178− interactive: !forceNonInteractive
179−
180− x: subPageLoader.open ? -width : 0
181− visible: x != -width
182− Behavior on x { UbuntuNumberAnimation { } }
183− width: parent.width
184− height: floatingSeeLess.visible ? parent.height - floatingSeeLess.height + floatingSeeLess.yOffset
185− : parent.height
186− clip: height != parent.height
187−
188− model: scopeView.categories
189− forceNoClip: subPageLoader.open
190− pixelAligned: true
191−
192− property string expandedCategoryId: ""
193− property int runMaximizeAfterSizeChanges: 0
194−
195− readonly property bool pageHeaderTotallyVisible:
196− ((headerItemShownHeight == 0 && categoryView.contentY <= categoryView.originY) || (headerItemShownHeight == categoryView.pageHeader.height))
197−
198− onExpandedCategoryIdChanged: {
199− var firstCreated = firstCreatedIndex();
200− var shrinkingAny = false;
201− var shrinkHeightDifference = 0;
202− for (var i = 0; i < createdItemCount(); ++i) {
203− var baseItem = item(firstCreated + i);
204− if (baseItem.expandable) {
205− var shouldExpand = baseItem.category === expandedCategoryId;
206− if (shouldExpand != baseItem.expanded) {
207− var animate = false;
208− if (!subPageLoader.open) {
209− var animateShrinking = !shouldExpand && baseItem.y + baseItem.item.collapsedHeight + baseItem.seeAllButton.height < categoryView.height;
210− var animateGrowing = shouldExpand && baseItem.y + baseItem.height < categoryView.height;
211− animate = shrinkingAny || animateShrinking || animateGrowing;
212− }
213−
214− if (!shouldExpand) {
215− shrinkingAny = true;
216− shrinkHeightDifference = baseItem.item.expandedHeight - baseItem.item.collapsedHeight;
217− }
218−
219− if (shouldExpand && !subPageLoader.open) {
220− if (!shrinkingAny) {
221− categoryView.maximizeVisibleArea(firstCreated + i, baseItem.item.expandedHeight + baseItem.seeAllButton.height);
222− } else {
223− // If the space that shrinking is smaller than the one we need to grow we'll call maximizeVisibleArea
224− // after the shrink/grow animation ends
225− var growHeightDifference = baseItem.item.expandedHeight - baseItem.item.collapsedHeight;
226− if (growHeightDifference > shrinkHeightDifference) {
227− runMaximizeAfterSizeChanges = 2;
228− } else {
229− runMaximizeAfterSizeChanges = 0;
230− }
231− }
232− }
233−
234− baseItem.expand(shouldExpand, animate);
235− }
236− }
237− }
238− }
239−
240− delegate: DashCategoryBase {
241− id: baseItem
242− objectName: "dashCategory" + category
243−
244− property Item seeAllButton: seeAll
245−
246− readonly property bool forceNotExpandable: cardTool.template && cardTool.template["expandable"] === false
247− readonly property bool expandable: {
248− if (categoryView.model.count === 1) return false;
249− if (forceNotExpandable) return false;
250− if (cardTool.template && cardTool.template["collapsed-rows"] === 0) return false;
251− if (item && item.expandedHeight > item.collapsedHeight) return true;
252− return false;
253− }
254− property bool expanded: false
255− readonly property string category: categoryId
256− readonly property string headerLink: model.headerLink
257− readonly property var item: rendererLoader.item
258−
259− function expand(expand, animate) {
260− heightBehaviour.enabled = animate;
261− expanded = expand;
262− }
263−
264− CardTool {
265− id: cardTool
266− objectName: "cardTool"
267− count: results ? results.count : 0
268− template: model.renderer
269− components: model.components
270− viewWidth: parent.width
271− scopeId: scope ? scope.id : ""
272− categoryId: baseItem.category
273− }
274−
275− onExpandableChanged: {
276− // This can happen with the VJ that doesn't know how height it will be on creation
277− // so doesn't set expandable until a bit too late for onLoaded
278− if (expandable) {
279− var shouldExpand = baseItem.category === categoryView.expandedCategoryId;
280− baseItem.expand(shouldExpand, false /*animate*/);
281− }
282− }
283−
284− onHeightChanged: rendererLoader.updateRanges();
285− onYChanged: rendererLoader.updateRanges();
286−
287− Loader {
288− id: rendererLoader
289− anchors {
290− top: parent.top
291− left: parent.left
292− right: parent.right
293− topMargin: name != "" ? 0 : units.gu(2)
294− }
295−
296− Behavior on height {
297− id: heightBehaviour
298− enabled: false
299− animation: UbuntuNumberAnimation {
300− duration: UbuntuAnimation.FastDuration
301− onRunningChanged: {
302− if (!running) {
303− heightBehaviour.enabled = false
304− if (categoryView.runMaximizeAfterSizeChanges > 0) {
305− categoryView.runMaximizeAfterSizeChanges--;
306− if (categoryView.runMaximizeAfterSizeChanges == 0) {
307− var firstCreated = categoryView.firstCreatedIndex();
308− for (var i = 0; i < categoryView.createdItemCount(); ++i) {
309− var baseItem = categoryView.item(firstCreated + i);
310− if (baseItem.category === categoryView.expandedCategoryId) {
311− categoryView.maximizeVisibleArea(firstCreated + i, baseItem.item.expandedHeight + baseItem.seeAllButton.height);
312− break;
313− }
314− }
315− }
316− }
317− }
318− }
319− }
320− }
321−
322− readonly property bool expanded: !baseItem.forceNotExpandable && (baseItem.expanded || !baseItem.expandable)
323− height: expanded ? item.expandedHeight : item.collapsedHeight
324−
325− source: {
326− switch (cardTool.categoryLayout) {
327− case "carousel": return "CardCarousel.qml";
328− case "vertical-journal": return "CardVerticalJournal.qml";
329− case "horizontal-list": return "CardHorizontalList.qml";
330− case "grid":
331− default: return "CardGrid.qml";
332− }
333− }
334−
335− onLoaded: {
336− if (item.enableHeightBehavior !== undefined && item.enableHeightBehaviorOnNextCreation !== undefined) {
337− item.enableHeightBehavior = scopeView.enableHeightBehaviorOnNextCreation;
338− scopeView.enableHeightBehaviorOnNextCreation = false;
339− }
340− item.model = Qt.binding(function() { return results })
341− item.objectName = Qt.binding(function() { return categoryId })
342− item.scopeStyle = scopeView.scopeStyle;
343− if (baseItem.expandable) {
344− var shouldExpand = baseItem.category === categoryView.expandedCategoryId;
345− baseItem.expand(shouldExpand, false /*animate*/);
346− }
347− updateRanges();
348− item.cardTool = cardTool;
349− }
350−
351− Component.onDestruction: {
352− if (item.enableHeightBehavior !== undefined && item.enableHeightBehaviorOnNextCreation !== undefined) {
353− scopeView.enableHeightBehaviorOnNextCreation = item.enableHeightBehaviorOnNextCreation;
354− }
355− }
356−
357− Connections {
358− target: rendererLoader.item
359− onClicked: { // (int index, var result, var item, var itemModel)
360− scopeView.itemClicked(result, baseItem.category);
361− }
362−
363− onPressAndHold: { // (int index, var result, var itemModel)
364− scopeView.itemPressedAndHeld(result, baseItem.category);
365− }
366−
367− onAction: { // (int index, var result, var actionId)
368− scope.activateAction(result, baseItem.category, actionId);
369− }
370−
371− function categoryItemCount() {
372− var categoryItemCount = -1;
373− if (!rendererLoader.expanded && !seeAllLabel.visible && target.collapsedItemCount > 0) {
374− categoryItemCount = target.collapsedItemCount;
375− }
376− return categoryItemCount;
377− }
378− }
379− Connections {
380− target: categoryView
381− onOriginYChanged: rendererLoader.updateRanges();
382− onContentYChanged: rendererLoader.updateRanges();
383− onHeightChanged: rendererLoader.updateRanges();
384− onContentHeightChanged: rendererLoader.updateRanges();
385− }
386− Connections {
387− target: scopeView
388− onIsCurrentChanged: rendererLoader.updateRanges();
389− onVisibleToParentChanged: rendererLoader.updateRanges();
390− }
391− Connections {
392− target: holdingList
393− onMovingChanged: if (!moving) rendererLoader.updateRanges();
394− }
395−
396− function updateRanges() {
397− // Don't want to create stress by requesting more items during scope
398− // changes so unless you're not part of the visible scopes just return.
399− // For the visible scopes we need to do some work, the previously non visible
400− // scope needs to adjust its ranges so that we define the new visible range,
401− // that still means no creation/destruction of delegates, it's just about changing
402− // the culling of the items so they are actually visible
403− if (holdingList && holdingList.moving && !scopeView.visibleToParent) {
404− return;
405− }
406−
407− if (categoryView.moving) {
408− // Do not update the range if we are overshooting up or down, since we'll come back
409− // to the stable position and delete/create items without any reason
410− if (categoryView.contentY < categoryView.originY) {
411− return;
412− } else if (categoryView.contentHeight - categoryView.originY > categoryView.height &&
413− categoryView.contentY + categoryView.height > categoryView.contentHeight) {
414− return;
415− }
416− }
417−
418− if (item && item.hasOwnProperty("displayMarginBeginning")) {
419− var buffer = wasCurrentOnMoveStart ? categoryView.height * 1.5 : 0;
420− var onViewport = baseItem.y + baseItem.height > 0 &&
421− baseItem.y < categoryView.height;
422− var onBufferViewport = baseItem.y + baseItem.height > -buffer &&
423− baseItem.y < categoryView.height + buffer;
424−
425− if (item.growsVertically) {
426− // A item view creates its delegates synchronously from
427− // -displayMarginBeginning
428− // to
429− // height + displayMarginEnd
430− // Around that area it adds the cacheBuffer area where delegates are created async
431− //
432− // We adjust displayMarginBeginning and displayMarginEnd so
433− // * In non visible scopes nothing is considered visible and we set cacheBuffer
434− // so that creates the items that would be in the viewport asynchronously
435− // * For the current scope set the visible range to the viewport and then
436− // use cacheBuffer to create extra items for categoryView.height * 1.5
437− // to make scrolling nicer by mantaining a higher number of
438− // cached items
439− // * For non current but visible scopes (i.e. when the user changes from one scope
440− // to the next, we set the visible range to the viewport so
441− // items are not culled (invisible) but still use no cacheBuffer
442− // (it will be set once the scope is the current one)
443− var displayMarginBeginning = baseItem.y + rendererLoader.anchors.topMargin;
444− displayMarginBeginning = -Math.max(-displayMarginBeginning, 0);
445− displayMarginBeginning = -Math.min(-displayMarginBeginning, baseItem.height);
446− displayMarginBeginning = Math.round(displayMarginBeginning);
447− var displayMarginEnd = -baseItem.height + seeAll.height + categoryView.height - baseItem.y;
448− displayMarginEnd = -Math.max(-displayMarginEnd, 0);
449− displayMarginEnd = -Math.min(-displayMarginEnd, baseItem.height);
450− displayMarginEnd = Math.round(displayMarginEnd);
451−
452− if (onBufferViewport && (scopeView.isCurrent || scopeView.visibleToParent)) {
453− item.displayMarginBeginning = displayMarginBeginning;
454− item.displayMarginEnd = displayMarginEnd;
455− if (holdingList && holdingList.moving) {
456− // If we are moving we need to reset the cache buffer of the
457− // view that was not visible (i.e. !wasCurrentOnMoveStart) to 0 since
458− // otherwise the cache buffer we had set to preload the items of the
459− // visible range will trigger some item creations and we want move to
460− // be as smooth as possible meaning no need creations
461− if (!wasCurrentOnMoveStart) {
462− item.cacheBuffer = 0;
463− }
464− } else {
465− // Protect us against cases where the item hasn't yet been positioned
466− if (!(categoryView.contentY === 0 && baseItem.y === 0 && index !== 0)) {
467− item.cacheBuffer = categoryView.height * 1.5;
468− }
469− }
470− } else {
471− var visibleRange = baseItem.height + displayMarginEnd + displayMarginBeginning;
472− if (visibleRange < 0) {
473− item.displayMarginBeginning = displayMarginBeginning;
474− item.displayMarginEnd = displayMarginEnd;
475− item.cacheBuffer = 0;
476− } else {
477− // This should be visibleRange/2 in each of the properties
478− // but some item views still (like GridView) like creating sync delegates even if
479− // the visible range is 0 so let's make sure the visible range is negative
480− item.displayMarginBeginning = displayMarginBeginning - visibleRange;
481− item.displayMarginEnd = displayMarginEnd - visibleRange;
482− item.cacheBuffer = visibleRange;
483− }
484− }
485− } else {
486− if (!onBufferViewport) {
487− // If not on the buffered viewport, don't load anything
488− item.displayMarginBeginning = 0;
489− item.displayMarginEnd = -item.innerWidth;
490− item.cacheBuffer = 0;
491− } else {
492− if (onViewport && (scopeView.isCurrent || scopeView.visibleToParent)) {
493− // If on the buffered viewport and the viewport and the on a visible scope
494− // Set displayMargin so that cards are rendered
495− // And if not moving the parent list also give it some extra asynchronously
496− // buffering
497− item.displayMarginBeginning = 0;
498− item.displayMarginEnd = 0;
499− if (holdingList && holdingList.moving) {
500− // If we are moving we need to reset the cache buffer of the
501− // view that was not visible (i.e. !wasCurrentOnMoveStart) to 0 since
502− // otherwise the cache buffer we had set to preload the items of the
503− // visible range will trigger some item creations and we want move to
504− // be as smooth as possible meaning no need creations
505− if (!wasCurrentOnMoveStart) {
506− item.cacheBuffer = 0;
507− }
508− } else {
509− item.cacheBuffer = baseItem.width * 1.5;
510− }
511− } else {
512− // If on the buffered viewport but either not in the real viewport
513− // or in the viewport of the non current scope, use displayMargin + cacheBuffer
514− // to render asynchronously the width of cards
515− item.displayMarginBeginning = 0;
516− item.displayMarginEnd = -item.innerWidth;
517− item.cacheBuffer = item.innerWidth;
518− }
519− }
520− }
521− }
522− }
523− }
524−
525− AbstractButton {
526− id: seeAll
527− objectName: "seeAll"
528− anchors {
529− top: rendererLoader.bottom
530− left: parent.left
531− right: parent.right
532− }
533− height: baseItem.expandable && !baseItem.headerLink ? seeAllLabel.font.pixelSize + units.gu(4) : 0
534− visible: height != 0
535−
536− onClicked: {
537− if (categoryView.expandedCategoryId !== baseItem.category) {
538− categoryView.expandedCategoryId = baseItem.category;
539− floatingSeeLess.companionBase = baseItem;
540− } else {
541− categoryView.expandedCategoryId = "";
542− }
543− }
544−
545− Label {
546− id: seeAllLabel
547− text: baseItem.expanded ? i18n.tr("Show less") : i18n.tr("Show all")
548− anchors {
549− centerIn: parent
550− verticalCenterOffset: units.gu(-0.5)
551− }
552− fontSize: "small"
553− font.weight: Font.Bold
554− color: scopeStyle ? scopeStyle.foreground : theme.palette.normal.baseText
555− }
556− }
557− }
558−
559− sectionProperty: "name"
560− sectionDelegate: DashSectionHeader {
561− objectName: "dashSectionHeader" + (delegate ? delegate.category : "")
562− property var delegate: null
563− width: categoryView.width
564− height: text != "" ? units.gu(5) : 0
565− color: scopeStyle ? scopeStyle.foreground : theme.palette.normal.baseText
566− iconName: delegate && delegate.headerLink ? "toolkit_chevron-ltr_1gu" : ""
567− onClicked: {
568− if (delegate.headerLink) scopeView.scope.performQuery(delegate.headerLink);
569− }
570− }
571−
572− pageHeader: DashPageHeader {
573− objectName: "scopePageHeader"
574− width: parent.width
575− title: scopeView.scope ? scopeView.scope.name : ""
576− extraPanel: peExtraPanel
577− searchHistory: SearchHistoryModel
578− searchHint: scopeView.scope && scopeView.scope.searchHint || i18n.ctr("Label: Hint for dash search line edit", "Search")
579− scopeHasFilters: scopeView.scope.filters != null
580− activeFiltersCount: scopeView.scope.activeFiltersCount
581− showBackButton: scopeView.hasBackAction
582− showSignatureLine: !showBackButton
583− searchEntryEnabled: true
584− settingsEnabled: scopeView.scope && scopeView.scope.settings && scopeView.scope.settings.count > 0 || false
585− favoriteEnabled: scopeView.scope
586− favorite: scopeView.scope && scopeView.scope.favorite
587− navigationTag: scopeView.scope ? scopeView.scope.primaryNavigationTag : ""
588− scopeStyle: scopeView.scopeStyle
589− paginationCount: scopeView.paginationCount
590− paginationIndex: scopeView.paginationIndex
591−
592− onBackClicked: scopeView.backClicked()
593− onSettingsClicked: subPageLoader.openSubPage("settings")
594− onFavoriteClicked: scopeView.scope.favorite = !scopeView.scope.favorite
595− onSearchTextFieldFocused: scopeView.showHeader()
596− onClearSearch: { // keepPanelOpen
597− var panelOpen = peExtraPanel.visible;
598− resetSearch(keepPanelOpen);
599− scopeView.scope.resetPrimaryNavigationTag();
600− peExtraPanel.resetNavigation();
601− if ((panelOpen || searchHistory.count > 0) && keepPanelOpen) {
602− openPopup();
603− }
604− }
605− onShowFiltersPopup: { // item
606− extraPanel.visible = false;
607− scopeView.filtersPopover = PopupUtils.open(Qt.resolvedUrl("FiltersPopover.qml"), item, { "contentWidth": Qt.binding(function() { return scopeView.width - units.gu(2); } ) } );
608− scopeView.filtersPopover.Component.onDestruction.connect(function () {
609− categoryView.pageHeader.closePopup(false, true);
610− categoryView.pageHeader.unfocus(true); // remove the focus from the search field
611− })
612− }
613− }
614−
615− PageHeaderExtraPanel {
616− id: peExtraPanel
617− objectName: "peExtraPanel"
618− width: parent.width >= units.gu(60) ? units.gu(40) : parent.width
619− anchors {
620− top: categoryView.pageHeader.bottom
621− topMargin: -categoryView.pageHeader.signatureLineHeight
622− }
623− z: 1
624− visible: false
625−
626− searchHistory: SearchHistoryModel
627− scope: scopeView.scope
628− windowHeight: scopeView.height
629−
630− onHistoryItemClicked: {
631− SearchHistoryModel.addQuery(text);
632− categoryView.pageHeader.searchQuery = text;
633− categoryView.pageHeader.unfocus();
634− }
635−
636− onDashNavigationLeafClicked: {
637− categoryView.pageHeader.closePopup();
638− categoryView.pageHeader.unfocus();
639− }
640−
641− onExtraPanelOptionSelected: {
642− categoryView.pageHeader.closePopup();
643− categoryView.pageHeader.unfocus();
644− }
645− }
646− }
647−
648− Item {
649− id: pullToRefreshClippingItem
650− anchors.left: parent.left
651− anchors.right: parent.right
652− anchors.bottom: parent.bottom
653− height: parent.height - pullToRefresh.contentY - categoryView.pageHeader.height
654− clip: true
655−
656− PullToRefresh {
657− id: pullToRefresh
658− objectName: "pullToRefresh"
659− target: categoryView
660−
661− readonly property real contentY: categoryView.contentY - categoryView.originY
662− readonly property color pullLabelColor: scopeStyle ? scopeStyle.foreground : theme.palette.normal.baseText
663− y: -contentY - units.gu(5)
664−
665− onRefresh: {
666− refreshing = true
667− scopeView.scope.refresh()
668− }
669− anchors.left: parent.left
670− anchors.right: parent.right
671−
672− Connections {
673− target: scopeView
674− onProcessingChanged: if (!scopeView.processing) pullToRefresh.refreshing = false
675− }
676−
677− style: PullToRefreshScopeStyle {
678− anchors.fill: parent
679− activationThreshold: Math.min(units.gu(14), scopeView.height / 5)
680− }
681− }
682− }
683−
684− AbstractButton {
685− id: floatingSeeLess
686− objectName: "floatingSeeLess"
687−
688− property Item companionTo: companionBase ? companionBase.seeAllButton : null
689− property Item companionBase: null
690− property bool showBecausePosition: false
691− property real yOffset: 0
692−
693− anchors {
694− left: categoryView.left
695− right: categoryView.right
696− }
697− y: parent.height - height + yOffset
698− height: seeLessLabel.font.pixelSize + units.gu(4)
699− visible: companionTo && showBecausePosition
700−
701− onClicked: categoryView.expandedCategoryId = "";
702−
703− function updateVisibility() {
704− var companionPos = companionTo.mapToItem(floatingSeeLess, 0, 0);
705− showBecausePosition = Math.round(companionPos.y) > 0;
706−
707− var posToBase = floatingSeeLess.mapToItem(companionBase, 0, -yOffset).y;
708− yOffset = Math.max(0, companionBase.item.collapsedHeight - posToBase);
709− yOffset = Math.min(yOffset, height);
710−
711− if (!showBecausePosition && categoryView.expandedCategoryId === "") {
712− companionBase = null;
713− }
714− }
715−
716− Label {
717− id: seeLessLabel
718− text: i18n.tr("Show less")
719− anchors {
720− centerIn: parent
721− verticalCenterOffset: units.gu(-0.5)
722− }
723− fontSize: "small"
724− font.weight: Font.Bold
725− color: scopeStyle ? scopeStyle.foreground : theme.palette.normal.baseText
726− }
727−
728− Connections {
729− target: floatingSeeLess.companionTo ? categoryView : null
730− onContentYChanged: floatingSeeLess.updateVisibility();
731− }
732−
733− Connections {
734− target: floatingSeeLess.companionTo
735− onYChanged: floatingSeeLess.updateVisibility();
736− }
737− }
738−
739− Loader {
740− id: subPageLoader
741− objectName: "subPageLoader"
742− visible: x != width
743− width: parent.width
744− height: parent.height
745− anchors.left: categoryView.right
746−
747− property bool open: false
748− property var scope: scopeView.scope
749− property var scopeStyle: scopeView.scopeStyle
750− property int initialIndex: -1
751− property var previewModel;
752−
753− readonly property bool processing: item && item.processing || false
754− readonly property int count: item && item.count || 0
755− readonly property var currentItem: item && item.currentItem || null
756−
757− property string subPage: ""
758− readonly property bool subPageShown: visible && status === Loader.Ready
759−
760− function openSubPage(page) {
761− subPage = page;
762− }
763−
764− function closeSubPage() {
765− if (subPage == "preview") {
766− PreviewSingleton.widgetExtraData = new Object();
767− }
768− open = false;
769− }
770−
771− source: switch(subPage) {
772− case "preview": return "PreviewView.qml";
773− case "settings": return "ScopeSettingsPage.qml";
774− default: return "";
775− }
776−
777− onLoaded: {
778− item.scope = Qt.binding(function() { return subPageLoader.scope; } )
779− item.scopeStyle = Qt.binding(function() { return subPageLoader.scopeStyle; } )
780− if (subPage == "preview") {
781− item.open = Qt.binding(function() { return subPageLoader.open; } )
782− item.previewModel = subPageLoader.previewModel;
783− subPageLoader.previewModel = null;
784− }
785− open = true;
786− }
787−
788− onOpenChanged: categoryView.pageHeader.unfocus()
789−
790− onVisibleChanged: if (!visible) subPage = ""
791−
792− Connections {
793− target: subPageLoader.item
794− onBackClicked: subPageLoader.closeSubPage()
795− }
796− }
797−}
qml/Dash/PageHeaderExtraPanel.qmldeleted−201
@@ -1,201 +0,0 @@
1−/*
2− * Copyright (C) 2013-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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Ubuntu.Components.ListItems 1.3 as ListItems
20−import "Filters" as Filters
21−import "../Components"
22−
23−Item {
24− id: root
25−
26− readonly property real searchesHeight: recentSearchesRepeater.count > 0 ? searchColumn.height + recentSearchesLabels.height + recentSearchesLabels.anchors.topMargin : 0
27−
28− implicitHeight: searchesHeight + dashNavigation.implicitHeight + dashNavigation.anchors.topMargin + primaryFilterContainer.height + primaryFilterContainer.anchors.topMargin
29−
30− // Set by parent
31− property ListModel searchHistory
32− property var scope: null
33− property real windowHeight
34−
35− // Used by PageHeader
36− readonly property bool hasContents: searchHistory.count > 0 || scope && scope.hasNavigation || scope && scope.primaryNavigationFilter
37−
38− signal historyItemClicked(string text)
39− signal dashNavigationLeafClicked()
40− signal extraPanelOptionSelected()
41−
42− function resetNavigation() {
43− dashNavigation.resetNavigation();
44− }
45−
46− BorderImage {
47− anchors {
48− fill: parent
49− leftMargin: -units.gu(1)
50− rightMargin: -units.gu(1)
51− bottomMargin: -units.gu(1)
52− }
53− source: "graphics/rectangular_dropshadow.sci"
54− }
55−
56− Rectangle {
57− color: "white"
58− anchors.fill: parent
59− }
60−
61− ListItems.ThinDivider {
62− anchors.top: parent.top
63− }
64−
65− Label {
66− id: recentSearchesLabels
67− text: i18n.tr("Recent Searches")
68− visible: recentSearchesRepeater.count > 0
69− anchors {
70− top: parent.top
71− left: parent.left
72− margins: units.gu(2)
73− topMargin: units.gu(3)
74− }
75− }
76−
77− Label {
78− text: i18n.tr("Clear All")
79− fontSize: "small"
80− visible: recentSearchesRepeater.count > 0
81− anchors {
82− top: parent.top
83− right: parent.right
84− margins: units.gu(2)
85− topMargin: units.gu(3)
86− }
87−
88− AbstractButton {
89− anchors.fill: parent
90− onClicked: searchHistory.clear();
91− }
92− }
93−
94− Column {
95− id: searchColumn
96− anchors {
97− top: recentSearchesLabels.bottom
98− left: parent.left
99− right: parent.right
100− }
101−
102− Repeater {
103− id: recentSearchesRepeater
104− objectName: "recentSearchesRepeater"
105− model: searchHistory
106−
107− // FIXME Move to ListItem once 1556971 is fixed
108− delegate: ListItems.Empty {
109− anchors {
110− left: parent.left
111− right: parent.right
112− leftMargin: units.gu(2)
113− rightMargin: units.gu(2)
114− }
115− height: units.gu(5)
116−
117− Icon {
118− id: searchIcon
119− anchors {
120− verticalCenter: parent.verticalCenter
121− left: parent.left
122− }
123− height: units.gu(1.5)
124− width: height
125− name: "search"
126− }
127−
128− Label {
129− anchors {
130− verticalCenter: parent.verticalCenter
131− left: searchIcon.right
132− leftMargin: units.gu(1)
133− right: parent.right
134− }
135− text: query
136− color: "#888888"
137− elide: Text.ElideRight
138− }
139−
140− divider.visible: index != recentSearchesRepeater.count - 1 || (scope && scope.hasNavigation) || primaryFilter.active
141−
142− onClicked: root.historyItemClicked(query)
143− }
144− }
145− }
146−
147− DashNavigation {
148− id: dashNavigation
149− scope: root.scope
150− anchors {
151− top: recentSearchesRepeater.count > 0 ? searchColumn.bottom : parent.top
152− topMargin: implicitHeight && recentSearchesRepeater.count > 0 ? units.gu(2) : 0
153− left: parent.left
154− right: parent.right
155− }
156− availableHeight: windowHeight * 4 / 6 - searchesHeight
157−
158− onLeafClicked: root.dashNavigationLeafClicked();
159− }
160−
161− Flickable {
162− id: primaryFilterContainer
163− objectName: "primaryFilterContainer"
164−
165− height: {
166− if (!primaryFilter.active) {
167− return 0;
168− } else if (contentHeight > dashNavigation.availableHeight) {
169− return dashNavigation.availableHeight;
170− } else {
171− return contentHeight;
172− }
173− }
174−
175− clip: true
176− contentHeight: primaryFilter.implicitHeight
177−
178− anchors {
179− top: recentSearchesRepeater.count > 0 ? searchColumn.bottom : parent.top
180− topMargin: primaryFilter.active && recentSearchesRepeater.count > 0 ? units.gu(2) : 0
181− left: parent.left
182− right: parent.right
183− }
184−
185− Filters.FilterWidgetFactory {
186− id: primaryFilter
187− objectName: "primaryFilter"
188−
189− active: scope && !scope.hasNavigation
190−
191− anchors.fill: parent
192− property var filter: active ? scope.primaryNavigationFilter : null
193−
194− widgetId: filter ? filter.filterId : ""
195− widgetType: filter ? filter.filterType : -1
196− widgetData: filter
197−
198− onSingleSelectionFilterSelected: extraPanelOptionSelected()
199− }
200− }
201−}
qml/Dash/PreviewView.qmldeleted−76
@@ -1,76 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Unity 0.2
20−import "../Components"
21−import "Previews" as Previews
22−
23−Item {
24− id: root
25−
26− property bool open: false
27− property var scope: null
28− property var scopeStyle: null
29− property alias showSignatureLine: header.showSignatureLine
30− property alias previewModel: preview.previewModel
31− readonly property bool processing: previewModel && (!previewModel.loaded || previewModel.processingAction)
32−
33− signal backClicked()
34−
35− DashPageHeader {
36− id: header
37− objectName: "pageHeader"
38− width: parent.width
39− title: root.scope ? root.scope.name : ""
40− showBackButton: true
41− searchEntryEnabled: false
42− scopeStyle: root.scopeStyle
43−
44− onBackClicked: root.backClicked()
45− }
46−
47− onOpenChanged: {
48− if (!open) {
49− root.scope.cancelActivation();
50− }
51− }
52−
53− Previews.Preview {
54− id: preview
55− objectName: "preview"
56− anchors {
57− top: header.bottom
58− bottom: parent.bottom
59− left: parent.left
60− right: parent.right
61− }
62− scopeStyle: root.scopeStyle
63− }
64−
65− MouseArea {
66− id: processingMouseArea
67− objectName: "processingMouseArea"
68− anchors {
69− top: header.bottom
70− bottom: parent.bottom
71− left: parent.left
72− right: parent.right
73− }
74− enabled: root.processing
75− }
76−}
qml/Dash/Previews/Preview.qmldeleted−145
@@ -1,145 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import "../../Components"
20−
21−/*! \brief This component constructs the Preview UI.
22− *
23− * Currently it displays all the widgets in a flickable column.
24− */
25−
26−Item {
27− id: root
28−
29− /*! \brief Model containing preview widgets.
30− *
31− * The model should expose "widgetId", "type" and "properties" roles, as well as
32− * have a triggered(QString widgetId, QString actionId, QVariantMap data) method,
33− * that's called when actions are executed in widgets.
34− */
35− property var previewModel
36−
37− //! \brief The ScopeStyle component.
38− property var scopeStyle: null
39−
40− //! Should the orientation be locked
41− property int orientationLockCount: 0
42−
43− clip: true
44−
45− Binding {
46− target: previewModel
47− property: "widgetColumnCount"
48− value: row.columns
49− when: root.orientationLockCount === 0
50− }
51−
52− MouseArea {
53− anchors.fill: parent
54− }
55−
56− Row {
57− id: row
58−
59− spacing: units.gu(4)
60− anchors.fill: parent
61−
62− readonly property int columns: width >= units.gu(80) ? 2 : 1
63− readonly property real columnWidth: (width - (spacing * (columns - 1))) / columns
64− readonly property int singleColumnMargin: units.gu(2)
65−
66− Repeater {
67− model: previewModel
68−
69− delegate: ListView {
70− id: column
71− objectName: "previewListRow" + index
72− anchors {
73− top: parent.top
74− bottom: parent.bottom
75− }
76− topMargin: units.gu(2)
77− width: row.columnWidth
78− spacing: units.gu(1)
79−
80− readonly property int columnNumber: index
81−
82− ListViewOSKScroller {
83− id: oskScroller
84− list: column
85− }
86−
87− model: columnModel
88− cacheBuffer: height
89− highlightMoveDuration: 0 // QTBUG-53460
90−
91− Behavior on contentY { UbuntuNumberAnimation { } }
92−
93− delegate: PreviewWidgetFactory {
94− widgetId: model.widgetId
95− widgetType: model.type
96− widgetData: model.properties
97− scopeStyle: root.scopeStyle
98− parentFlickable: column
99−
100− anchors {
101− left: parent.left
102− right: parent.right
103− leftMargin: if (row.columns == 1) {
104− return singleColumnMarginless ? 0 : row.singleColumnMargin;
105− } else {
106− return column.columnNumber == 0 ? row.singleColumnMargin : 0;
107− }
108− rightMargin: if (row.columns == 1) {
109− return singleColumnMarginless ? 0 : row.singleColumnMargin;
110− } else {
111− return column.columnNumber == 1 ? row.singleColumnMargin : 0;
112− }
113− }
114−
115− onTriggered: {
116− previewModel.triggered(widgetId, actionId, data);
117− }
118−
119− onMakeSureVisible: {
120− oskScroller.setMakeSureVisibleItem(item);
121− }
122−
123− onFocusChanged: if (focus) column.positionViewAtIndex(index, ListView.Contain)
124−
125− onHeightChanged: if (focus) {
126− column.forceLayout();
127− column.positionViewAtIndex(index, ListView.Contain)
128− }
129−
130− onOrientationLockChanged: {
131− if (orientationLock)
132− root.orientationLockCount++;
133− else
134− root.orientationLockCount = Math.max(0, root.orientationLockCount--);
135− }
136−
137− Component.onDestruction: {
138− if (orientationLock)
139− root.orientationLockCount = Math.max(0, root.orientationLockCount--);
140− }
141− }
142− }
143− }
144− }
145−}
qml/Dash/Previews/PreviewActionButton.qmldeleted−27
@@ -1,27 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−
20−Button {
21− signal triggeredAction(var actionData)
22−
23− property var data: null
24− objectName: "button" + (data && data.id || "")
25− text: data && data.label || ""
26− onClicked: triggeredAction(data)
27−}
qml/Dash/Previews/PreviewActionCombo.qmldeleted−79
@@ -1,79 +0,0 @@
1−/*
2− * Copyright (C) 2014,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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−
20−Item {
21− id: root
22−
23− implicitHeight: childrenRect.height
24− implicitWidth: Math.max(moreButton.implicitWidth, column.maxButtonImplicitWidth)
25−
26− signal triggeredAction(var actionData)
27−
28− property alias model: actionRepeater.model
29− property alias strokeColor: moreButton.strokeColor
30−
31− Button {
32− id: moreButton
33− property bool expanded: false
34−
35− objectName: "moreLessButton"
36− text: !expanded ? i18n.tr("More...") : i18n.tr("Less...")
37− strokeColor: theme.palette.normal.baseText
38− onClicked: expanded = !expanded
39− width: parent.width
40− }
41−
42− Column {
43− id: column
44− anchors {
45− top: moreButton.bottom
46− topMargin: height > 0 ? spacing : 0
47− }
48− objectName: "buttonColumn"
49− spacing: units.gu(1)
50− height: moreButton.expanded ? implicitHeight : 0
51−
52− property real maxButtonImplicitWidth: 0
53− function calculateImplicitWidth() {
54− maxButtonImplicitWidth = 0;
55− for (var i in children) {
56− maxButtonImplicitWidth = Math.max(maxButtonImplicitWidth, children[i].implicitWidth);
57− }
58− }
59−
60− clip: true
61− Behavior on height {
62− UbuntuNumberAnimation {
63− duration: UbuntuAnimation.SnapDuration
64− }
65− }
66−
67− Repeater {
68− id: actionRepeater
69−
70− delegate: PreviewActionButton {
71− data: modelData
72− width: root.width
73− onImplicitWidthChanged: column.calculateImplicitWidth();
74− onClicked: root.triggeredAction(modelData)
75− strokeColor: moreButton.strokeColor
76− }
77− }
78− }
79−}
qml/Dash/Previews/PreviewActions.qmldeleted−73
@@ -1,73 +0,0 @@
1−/*
2− * Copyright (C) 2014,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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−
20−/*! This preview widget shows either one button, two buttons or one button
21− * and a combo button depending on the number of items in widgetData["actions"].
22− * For each of the items we recognize the fields "label", "icon" and "id".
23− */
24−
25−PreviewWidget {
26− id: root
27−
28− implicitHeight: row.height + units.gu(1)
29− readonly property var actions: root.widgetData ? root.widgetData["actions"] : null
30− readonly property real maxButtonWidth: (width - units.gu(1)) / 2
31−
32− Row {
33− id: row
34− anchors.right: parent.right
35−
36− spacing: units.gu(1)
37−
38− Loader {
39− id: loader
40− objectName: "loader"
41− readonly property bool button: root.actions && root.actions.length == 2
42− readonly property bool combo: root.actions && root.actions.length > 2
43− source: button ? "PreviewActionButton.qml" : (combo ? "PreviewActionCombo.qml" : "")
44− width: Math.min(root.maxButtonWidth, implicitWidth + units.gu(2))
45− onLoaded: {
46− if (button) {
47− item.data = Qt.binding(function() { return root.actions[1]; });
48− } else if (combo) {
49− item.model = Qt.binding(function() { return root.actions.slice(1); });
50− }
51− }
52− Binding {
53− target: loader.item
54− property: "strokeColor"
55− value: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText
56− }
57− Connections {
58− target: loader.item
59− onTriggeredAction: {
60− root.triggered(root.widgetId, actionData.id, actionData);
61− }
62− }
63− }
64−
65− PreviewActionButton {
66− data: visible ? root.actions[0] : null
67− visible: root.actions && root.actions.length > 0
68− onTriggeredAction: root.triggered(root.widgetId, actionData.id, actionData)
69− width: Math.min(root.maxButtonWidth, implicitWidth + units.gu(2))
70− color: root.scopeStyle ? root.scopeStyle.previewButtonColor : theme.palette.normal.positive
71− }
72− }
73−}
qml/Dash/Previews/PreviewAudioPlayback.qmldeleted−152
@@ -1,152 +0,0 @@
1−/*
2− * Copyright (C) 2014,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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Dash 0.1
20−
21−/*! \brief Preview widget for audio tracks.
22−
23− This widget shows tracks contained in widgetData["tracks"], each of which should be of the form:
24−
25− \code{.json}
26− {
27− "source" "uri://to/file",
28− "title": "Title",
29− "subtitle": "Subtitle", // optional
30− "length": 125 // in seconds
31− }
32− \endcode
33− */
34−
35−PreviewWidget {
36− id: root
37− implicitHeight: childrenRect.height
38−
39− Column {
40− anchors { left: parent.left; right: parent.right }
41− visible: trackRepeater.count > 0
42−
43− Repeater {
44− id: trackRepeater
45− objectName: "trackRepeater"
46− model: root.widgetData["tracks"]
47−
48− delegate: Item {
49− id: trackItem
50− objectName: "trackItem" + index
51−
52− readonly property url sourceUrl: modelData["source"]
53− readonly property bool isPlayingItem: AudioUrlComparer.compare(sourceUrl, DashAudioPlayer.currentSource)
54−
55− anchors { left: parent.left; right: parent.right }
56− height: units.gu(5)
57−
58− Row {
59− id: trackRow
60−
61− readonly property int column1Width: units.gu(2)
62− readonly property int column2Width: width - (2 * spacing) - column1Width - column3Width
63− readonly property int column3Width: units.gu(4)
64−
65− anchors.verticalCenter: parent.verticalCenter
66− width: parent.width
67− spacing: units.gu(1)
68−
69− AbstractButton {
70− objectName: "playButton"
71− width: trackRow.column1Width
72− height: width
73− activeFocusOnPress: false
74−
75− onClicked: {
76− if (trackItem.isPlayingItem) {
77− if (DashAudioPlayer.playing) {
78− DashAudioPlayer.pause();
79− } else if (DashAudioPlayer.paused) {
80− DashAudioPlayer.play();
81− }
82− } else {
83− var playlist = [];
84− for (var i = 0; i < trackRepeater.count; ++i) {
85− playlist.push(trackRepeater.itemAt(i).sourceUrl);
86− }
87− DashAudioPlayer.playSource(sourceUrl, playlist);
88− }
89− }
90−
91− Icon {
92− anchors.fill: parent
93− source: DashAudioPlayer.playing && trackItem.isPlayingItem ? "image://theme/media-preview-pause" : "image://theme/media-preview-start"
94− }
95− }
96−
97− Item {
98− anchors.verticalCenter: parent.verticalCenter
99− width: parent.column2Width
100− height: trackSubtitleLabel.visible ? trackTitleLabel.height + trackSubtitleLabel.height : trackTitleLabel.height
101−
102− Label {
103− id: trackTitleLabel
104− objectName: "trackTitleLabel"
105− anchors { top: parent.top; left: parent.left; right: parent.right }
106− opacity: 0.9
107− color: scopeStyle ? scopeStyle.foreground : theme.palette.normal.baseText
108− fontSize: "medium"
109− font.weight: Font.Light
110− horizontalAlignment: Text.AlignLeft
111− text: modelData["title"]
112− elide: Text.ElideRight
113− }
114−
115− Label {
116− id: trackSubtitleLabel
117− objectName: "trackSubtitleLabel"
118− anchors { top: trackTitleLabel.bottom; left: parent.left; right: parent.right }
119− visible: text !== ""
120− opacity: 0.9
121− color: scopeStyle ? scopeStyle.foreground : theme.palette.normal.baseText
122− font.weight: Font.Light
123− fontSize: "small"
124− horizontalAlignment: Text.AlignLeft
125− text: modelData["subtitle"] || ""
126− elide: Text.ElideRight
127− }
128−
129− AudioProgressBar {
130− anchors { left: parent.left; top: parent.bottom; right: parent.right }
131− visible: !DashAudioPlayer.stopped && trackItem.isPlayingItem && modelData["length"] > 0
132− source: sourceUrl
133− }
134− }
135−
136− Label {
137− id: timeLabel
138− objectName: "timeLabel"
139− anchors.verticalCenter: parent.verticalCenter
140− width: parent.column3Width
141− opacity: 0.9
142− color: scopeStyle ? scopeStyle.foreground : theme.palette.normal.baseText
143− fontSize: "small"
144− font.weight: Font.Light
145− horizontalAlignment: Text.AlignRight
146− text: DashAudioPlayer.lengthToString(modelData["length"])
147− }
148− }
149− }
150− }
151− }
152−}
qml/Dash/Previews/PreviewComment.qmldeleted−86
@@ -1,86 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−
20−/*! \brief Preview widget for comments.
21−
22− This widget shows an (optional) avatar contained in widgetData["source"]
23− along with a label that comes from widgetData["author"],
24− a (optional) subtitle from widgetData["subtitle"] and the comment widgetData["comment"].
25−*/
26−
27−PreviewWidget {
28− id: root
29− implicitHeight: Math.max(avatar.height, column.implicitHeight)
30−
31− UbuntuShape {
32− id: avatar
33− objectName: "avatar"
34− anchors {
35− left: parent.left
36− top: parent.top
37− }
38− width: units.gu(6)
39− height: width
40− source: Image {
41− source: widgetData["source"]
42− }
43− radius: "medium"
44− aspect: UbuntuShape.Flat
45− opacity: source.status === Image.Ready ? 1 : 0
46− visible: widgetData["source"] !== ""
47− }
48−
49− Column {
50− id: column
51− objectName: "column"
52− anchors {
53− left: avatar.visible ? avatar.right : parent.left
54− right: parent.right
55− top: parent.top
56− topMargin: units.gu(0.5)
57− leftMargin: avatar.visible ? units.gu(1) : 0
58− }
59− spacing: units.gu(0.24)
60−
61− Label {
62− width: parent.width
63− text: widgetData["author"] || ""
64− fontSize: "small"
65− maximumLineCount: 1
66− elide: Text.ElideRight
67− }
68− Label {
69− objectName: "subtitle"
70− width: parent.width
71− visible: text !== ""
72− text: widgetData["subtitle"] || ""
73− fontSize: "xx-small"
74− font.weight: Font.Light
75− maximumLineCount: 1
76− elide: Text.ElideRight
77− }
78− Label {
79− width: parent.width
80− text: widgetData["comment"] || ""
81− fontSize: "small"
82− font.weight: Font.Light
83− wrapMode: Text.Wrap
84− }
85− }
86−}
qml/Dash/Previews/PreviewCommentInput.qmldeleted−88
@@ -1,88 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import "../../Components"
20−import "PreviewSingleton"
21−
22−/*! \brief Preview widget for commenting.
23−
24− The widget can show a field to enter a comment.
25− It is possible to customise the submit button's label by setting widgetData["submit-label"]
26− The successeful submit emits triggered(widgetId, "commented", data),
27− with data being {"comment": comment}.
28−*/
29−
30−PreviewWidget {
31− id: root
32− implicitHeight: Math.max(commentTextArea.implicitHeight, submitButton.implicitHeight)
33−
34− function submit() {
35− var data = { "comment": commentTextArea.text };
36− triggered(root.widgetId, "commented", data);
37− }
38−
39− property alias commentText: commentTextArea.text
40−
41− onCommentTextChanged: storeCommentState()
42− onWidgetIdChanged: restoreCommentState()
43−
44− function storeCommentState() {
45− PreviewSingleton.widgetExtraData[widgetId] = commentText;
46− }
47−
48− function restoreCommentState() {
49− if (!PreviewSingleton.widgetExtraData[widgetId]) return;
50− if (PreviewSingleton.widgetExtraData[widgetId] != "") commentText = PreviewSingleton.widgetExtraData[widgetId];
51− }
52−
53− TextArea {
54− id: commentTextArea
55− objectName: "commentTextArea"
56−
57− property bool inputMethodVisible: Qt.inputMethod.visible
58− onInputMethodVisibleChanged: {
59− if(inputMethodVisible && activeFocus)
60− root.makeSureVisible(commentTextArea);
61− }
62−
63− anchors {
64− top: parent.top
65− left: parent.left
66− right: submitButton.left
67− rightMargin: units.gu(1)
68− }
69− autoSize: true
70− }
71−
72− Button {
73− id: submitButton
74− objectName: "submitButton"
75−
76− readonly property bool readyToSubmit: commentTextArea.text.trim().length > 0
77−
78− anchors {
79− top: parent.top
80− right: parent.right
81− }
82− color: readyToSubmit ? Theme.palette.selected.base : Theme.palette.normal.base
83− text: widgetData["submit-label"] || i18n.tr("Send")
84− onClicked: {
85− if (readyToSubmit) root.submit()
86− }
87− }
88−}
qml/Dash/Previews/PreviewExpandable.qmldeleted−104
@@ -1,104 +0,0 @@
1−/*
2− * Copyright (C) 2014,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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import "../../Components"
20−
21−/*! \brief Preview widget for expandable widgets.
22−
23− This widget shows a list of widgets defined in widgetData["widgets"]
24− Those widgets can be collapsed or uncollapsed. When uncollapsed
25− all the widgets are shown, when collapsed only the first
26− widgetData["collapsed-widgets"] are shown. It has a title that comes
27− in via widgetData["title"]. This widget expands all child widgets
28− when initialized by specifying widgetData["expanded"] == true.
29− It's in unexpanded mode by default.
30− */
31−
32−PreviewWidget {
33− id: root
34− implicitHeight: childrenRect.height
35−
36− Label {
37− id: titleLabel
38− objectName: "titleLabel"
39− anchors {
40− left: parent.left
41− right: expandButton.left
42− }
43− fontSize: "large"
44− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText
45− visible: text !== ""
46− opacity: .8
47− text: widgetData["title"] || ""
48− wrapMode: Text.Wrap
49− }
50−
51− AbstractButton {
52− id: expandButton
53− objectName: "expandButton"
54− width: titleLabel.height
55− height: titleLabel.height
56− anchors.right: parent.right
57− onClicked: {
58− root.expanded = !root.expanded;
59− }
60− Icon {
61− anchors.fill: parent
62− width: units.gu(3)
63− height: units.gu(3)
64− name: root.expanded ? "view-collapse" : "view-expand"
65− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText
66− }
67− }
68−
69− Column {
70− anchors {
71− top: titleLabel.bottom
72− topMargin: units.gu(1)
73− left: parent.left
74− right: parent.right
75− }
76− spacing: units.gu(1)
77− Repeater {
78− id: repeater
79− objectName: "repeater"
80− model: widgetData["widgets"]
81− delegate: PreviewWidgetFactory {
82− height: visible ? implicitHeight : 0
83− width: parent.width
84− widgetId: model.widgetId
85− widgetType: model.type
86− widgetData: model.properties
87− scopeStyle: root.scopeStyle
88− anchors {
89− left: parent.left
90− right: parent.right
91− }
92− expanded: root.expanded
93− visible: root.expanded || index < root.widgetData["collapsed-widgets"]
94−
95− onTriggered: {
96− root.triggered(widgetId, actionId, data);
97− }
98− onMakeSureVisible: {
99− root.makeSureVisible(item)
100− }
101− }
102− }
103− }
104−}
qml/Dash/Previews/PreviewHeader.qmldeleted−170
@@ -1,170 +0,0 @@
1−/*
2− * Copyright (C) 2014,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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Dash 0.1
20−import "../"
21−
22−/*! This preview widget shows a header
23− * The title comes in widgetData["title"]
24− * The mascot comes in widgetData["mascot"]
25− * The mascot fall back image comes in widgetData["fallback"]
26− * The subtitle comes in widgetData["subtitle"]
27− * The attributes comes in widgetData["attributes"]
28− * The emblem comes in widgetData["emblem"]
29− */
30−
31−PreviewWidget {
32− id: root
33−
34− implicitHeight: childrenRect.height
35−
36− Item {
37− id: headerRoot
38− objectName: "innerPreviewHeader"
39− readonly property url mascot: root.widgetData["mascot"] || fallback
40− readonly property url fallback: root.widgetData["fallback"] || ""
41− readonly property string title: root.widgetData["title"] || ""
42− readonly property string subtitle: root.widgetData["subtitle"] || ""
43− readonly property var attributes: root.widgetData["attributes"] || null
44− readonly property url emblem: root.widgetData["emblem"] || ""
45− readonly property color fontColor: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText
46−
47− // Rewire the source since we may have unwired it on onStatusChanged
48− onMascotChanged: if (mascotShapeLoader.item) mascotShapeLoader.item.source.source = mascot;
49−
50− implicitHeight: row.height + row.margins * 2
51− width: parent.width
52−
53− Row {
54− id: row
55− objectName: "outerRow"
56−
57− property real margins: units.gu(1)
58−
59− spacing: mascotShapeLoader.active ? margins : 0
60− anchors {
61− top: parent.top; left: parent.left; right: parent.right
62− margins: margins
63− topMargin: 0
64− leftMargin: 0
65− rightMargin: spacing
66− }
67−
68− Loader {
69− id: mascotShapeLoader
70− objectName: "mascotShapeLoader"
71− active: headerRoot.mascot != ""
72− visible: active
73−
74− anchors.verticalCenter: parent.verticalCenter
75− // TODO karni: Icon aspect-ratio is 8:7.5. Revisit these values to avoid fraction of pixels.
76− width: units.gu(6)
77− height: units.gu(5.625)
78− readonly property int maxSize: Math.max(width, height) * 4
79− asynchronous: true
80−
81− sourceComponent: UbuntuShape {
82− objectName: "mascotShape"
83− visible: source.status === Image.Ready
84− sourceFillMode: UbuntuShape.PreserveAspectCrop
85− sourceHorizontalAlignment: UbuntuShape.AlignHCenter
86− sourceVerticalAlignment: UbuntuShape.AlignVCenter
87− aspect: UbuntuShape.Flat
88− source: Image {
89− source: headerRoot.mascot
90− width: source ? mascotShapeLoader.width : 0
91− height: mascotShapeLoader.height
92−
93− sourceSize { width: mascotShapeLoader.maxSize; height: mascotShapeLoader.maxSize }
94− onStatusChanged: if (status === Image.Error) source = headerRoot.fallback;
95− }
96− }
97− }
98−
99− Column {
100− objectName: "column"
101− width: parent.width - x
102− spacing: units.dp(2)
103− anchors.verticalCenter: parent.verticalCenter
104−
105− Item {
106− anchors { left: parent.left; right: parent.right }
107− height: titleLabel.height
108−
109− Label {
110− id: titleLabel
111− objectName: "titleLabel"
112− anchors {
113− left: parent.left;
114− right: iconLoader.right
115− rightMargin: iconLoader.width > 0 ? units.gu(0.5) : 0
116− }
117− elide: Text.ElideRight
118− fontSize: "large"
119− font.weight: Font.Light
120− wrapMode: Text.Wrap
121− color: headerRoot.fontColor
122− text: headerRoot.title
123− }
124−
125− Loader {
126− id: iconLoader
127− active: headerRoot.emblem != ""
128− anchors {
129− bottom: titleLabel.baseline
130− right: parent.right
131− }
132− sourceComponent: Icon {
133− objectName: "emblemIcon"
134− source: headerRoot.emblem
135− color: headerRoot.fontColor
136− height: source != "" ? titleLabel.font.pixelSize : 0
137− // FIXME Workaround for bug https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1421293
138− width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth
139− }
140− }
141− }
142−
143− Loader {
144− active: titleLabel.text && headerRoot.subtitle
145− anchors { left: parent.left; right: parent.right }
146− sourceComponent: Label {
147− id: subtitleLabel
148− objectName: "subtitleLabel"
149− elide: Text.ElideRight
150− fontSize: "x-small"
151− font.weight: Font.Light
152− color: headerRoot.fontColor
153− text: headerRoot.subtitle
154− }
155− }
156−
157− Loader {
158− active: titleLabel.text && headerRoot.attributes
159− anchors { left: parent.left; right: parent.right }
160− sourceComponent: CardAttributes {
161− id: previewAttributes
162− objectName: "previewAttributes"
163− model: headerRoot.attributes
164− }
165− }
166− }
167− }
168− }
169−
170−}
qml/Dash/Previews/PreviewIconActions.qmldeleted−88
@@ -1,88 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−
20−/*! This preview widget icons+label for number of items in widgetData["actions"].
21− * For each of the items we recognize the fields "label", "icon", "temporaryIcon" and "id".
22− * temporaryIcon is the icon that will be shown just after the user presses icon until the
23− * scope refreshes the preview
24− */
25−
26−PreviewWidget {
27− id: root
28−
29− implicitHeight: row.height
30−
31− Row {
32− id: row
33− readonly property var actions: root.widgetData ? root.widgetData["actions"] : null
34− width: parent.width
35− onActionsChanged: {
36− // Rewire the source since it may have been unwired on onClicked
37− // but the icon didn't change i.e. the scope updated the results
38− // and the icon needs to go back to the one it was originally
39− for (var i = 0; i < repeater.count; ++i) {
40− var button = repeater.itemAt(i);
41− button.updateIcon();
42− }
43− }
44−
45− spacing: units.gu(2)
46−
47− Repeater {
48− id: repeater
49− model: row.actions
50−
51− AbstractButton {
52− objectName: "button" + modelData.id
53− height: label.height
54− width: childrenRect.width
55−
56− readonly property var iconUrl: modelData.icon;
57− function updateIcon() {
58− icon.source = iconUrl;
59− }
60−
61− Image {
62− id: icon
63− height: parent.height
64− width: height
65− source: modelData.icon
66− sourceSize { width: icon.width; height: icon.height }
67− }
68−
69− Label {
70− id: label
71− anchors.left: icon.right
72− anchors.leftMargin: visible ? units.gu(0.5) : 0
73− text: modelData.label
74− font.weight: Font.Light
75− visible: text !== ""
76− }
77−
78− onClicked: {
79− if (modelData.temporaryIcon) {
80− icon.source = modelData.temporaryIcon;
81− }
82− root.triggered(root.widgetId, modelData.id, modelData);
83− }
84− }
85− }
86− }
87−
88−}
qml/Dash/Previews/PreviewImageGallery.qmldeleted−150
@@ -1,150 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import "../../Components"
20−
21−/*! This preview widget shows a horizontal list of images.
22− * The URIs for the images should be an array in widgetData["sources"].
23− * Images fall back to widgetData["fallback"] if loading fails
24− */
25−
26−PreviewWidget {
27− id: root
28− implicitHeight: units.gu(22)
29−
30− orientationLock: overlay.visible
31−
32− property Item rootItem: QuickUtils.rootItem(root)
33−
34− ListView {
35− id: previewImageListView
36− objectName: "previewImageListView"
37− spacing: units.gu(1)
38− anchors.fill: parent
39− orientation: ListView.Horizontal
40− cacheBuffer: width * 3
41− model: root.widgetData["sources"]
42− clip: true
43− highlightMoveDuration: 0 // QTBUG-53460
44−
45− onCurrentIndexChanged: overlay.updateInitialItem()
46−
47− LazyImage {
48− objectName: "placeholderScreenshot"
49− anchors {
50− top: parent.top
51− bottom: parent.bottom
52− }
53− scaleTo: "height"
54− source: "broken_image"
55− initialWidth: units.gu(13)
56− visible: previewImageListView.count == 0
57− }
58−
59− delegate: LazyImage {
60− objectName: "previewImage" + index
61− anchors {
62− top: parent.top
63− bottom: parent.bottom
64− }
65− source: modelData || root.widgetData["fallback"] || ""
66− scaleTo: "height"
67− initialWidth: units.gu(13)
68− pressed: mouseArea.pressed
69−
70− MouseArea {
71− id: mouseArea
72− anchors.fill: parent
73− onClicked: {
74− previewImageListView.currentIndex = index;
75− overlay.updateInitialItem();
76− overlay.show();
77− }
78− }
79−
80− Connections {
81− target: sourceImage
82− // If modelData would change after failing to load it would not be
83− // reloaded since the source binding is destroyed by the source = fallback
84− // But at the moment the model never changes
85− onStatusChanged: if (sourceImage.status === Image.Error) sourceImage.source = widgetData["fallback"];
86− }
87− }
88− }
89−
90− PreviewOverlay {
91− id: overlay
92− objectName: "overlay"
93− parent: rootItem
94− anchors.fill: parent
95−
96− function updateInitialItem() {
97− initialX = rootItem.mapFromItem(previewImageListView.currentItem, 0, 0).x;
98− initialY = rootItem.mapFromItem(previewImageListView.currentItem, 0, 0).y;
99− initialWidth = previewImageListView.currentItem.width;
100− initialHeight = previewImageListView.currentItem.height;
101− }
102−
103− delegate: ListView {
104− id: overlayListView
105− objectName: "overlayListView"
106− anchors.fill: parent
107− orientation: ListView.Horizontal
108− highlightRangeMode: ListView.StrictlyEnforceRange
109− highlightMoveDuration: 0
110− snapMode: ListView.SnapOneItem
111− boundsBehavior: Flickable.DragAndOvershootBounds
112− model: root.widgetData["sources"]
113− currentIndex: previewImageListView.currentIndex
114−
115− onCurrentIndexChanged: {
116− // if the index changed while overlay is visible, it was from user interaction,
117− // let's update the index of the original listview
118− if (overlay.visible) {
119− previewImageListView.highlightMoveDuration = 0;
120− previewImageListView.highlightResizeDuration = 0;
121− previewImageListView.currentIndex = currentIndex;
122− previewImageListView.highlightMoveDuration = -1;
123− previewImageListView.highlightResizeDuration = -1;
124− }
125− }
126−
127− delegate: Image {
128− id: screenshot
129− anchors {
130− top: parent.top
131− bottom: parent.bottom
132− }
133− width: overlay.width
134− source: modelData || root.widgetData["fallback"] || ""
135− fillMode: Image.PreserveAspectFit
136− sourceSize { width: screenshot.width; height: screenshot.height }
137−
138− // If modelData would change after failing to load it would not be
139− // reloaded since the source binding is destroyed by the source = fallback
140− // But at the moment the model never changes
141− onStatusChanged: if (status === Image.Error) source = widgetData["fallback"];
142− }
143−
144− MouseArea {
145− anchors.fill: parent
146− onClicked: overlay.headerShown = !overlay.headerShown
147− }
148− }
149− }
150−}
qml/Dash/Previews/PreviewInlineVideo.qmldeleted−112
@@ -1,112 +0,0 @@
1−/*
2− * Copyright (C) 2016 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import QtMultimedia 5.0
19−import Ubuntu.Components 1.3
20−import Ubuntu.Thumbnailer 0.1
21−import "PreviewSingleton"
22−import "../../Components"
23−import "../../Components/MediaServices"
24−
25−/*! \brief Preview widget for video.
26−
27− This widget shows video contained in widgetData["source"],
28− with a placeholder screenshot specified by widgetData["screenshot"].
29− */
30−
31−PreviewWidget {
32− id: root
33− implicitWidth: units.gu(35)
34− implicitHeight: services.height
35−
36− singleColumnMarginless: true
37− orientationLock: services.fullscreen
38−
39− property alias rootItem: services.rootItem
40− readonly property string widgetExtraDataKey: services.source.toString()
41−
42− onWidgetExtraDataKeyChanged: {
43− root.restorePlaybackState();
44− }
45−
46− function seek() {
47− services.mediaPlayer.seek(services.initialPosition);
48− services.initialPosition = -1;
49− }
50−
51− function storePlaybackState() {
52− if ((services.mediaPlayer.duration - services.mediaPlayer.position) < 1000) {
53− // we're at the end of the video
54− PreviewSingleton.widgetExtraData[widgetExtraDataKey] = 0;
55− } else {
56− PreviewSingleton.widgetExtraData[widgetExtraDataKey] = services.mediaPlayer.position;
57− }
58− }
59−
60− function restorePlaybackState() {
61− if (PreviewSingleton.widgetExtraData[widgetExtraDataKey] > 0) {
62− services.initialPosition = PreviewSingleton.widgetExtraData[widgetExtraDataKey];
63− }
64− }
65−
66− MediaServices {
67− id: services
68− objectName: "services"
69− width: parent.width
70−
71− actions: sharingAction
72− context: "video"
73− sourceData: widgetData
74− fullscreen: false
75− maximumEmbeddedHeight: rootItem.height / 2
76−
77− property int initialPosition: -1
78−
79− readonly property var mediaPlayer: footer.mediaPlayer
80− readonly property url source: mediaPlayer.source
81− readonly property int position: mediaPlayer.position
82−
83− onClose: fullscreen = false
84−
85− onPositionChanged: {
86− if (mediaPlayer.playbackState === MediaPlayer.StoppedState) return;
87− root.storePlaybackState();
88− }
89−
90− Connections {
91− target: services.mediaPlayer
92− ignoreUnknownSignals: true
93− onPlaying: {
94− // at the first playback of the file, do a seek()
95− if (services.initialPosition > 0) root.seek();
96− }
97− }
98−
99− Action {
100− id: sharingAction
101− iconName: "share"
102− visible: sharingPicker.active
103− onTriggered: sharingPicker.showPeerPicker()
104− }
105− }
106−
107− SharingPicker {
108− id: sharingPicker
109− objectName: "sharingPicker"
110− shareData: widgetData["share-data"]
111− }
112−}
qml/Dash/Previews/PreviewMediaToolbar.qmldeleted−57
@@ -1,57 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import "../../Components"
20−
21−Rectangle {
22− property alias shareData: sharingPicker.shareData
23−
24− implicitHeight: units.gu(6)
25− color: Qt.rgba(0, 0, 0, 0.8)
26− visible: sharingPicker.active
27−
28− Action {
29− id: sharingAction
30− iconName: "share"
31− onTriggered: sharingPicker.showPeerPicker()
32− }
33−
34− AbstractButton {
35− id: button
36− anchors {
37− left: parent.left
38− verticalCenter: parent.verticalCenter
39− leftMargin: units.gu(1)
40− }
41− height: units.gu(4)
42− width: units.gu(4)
43− action: sharingAction
44−
45− Icon {
46− anchors.centerIn: parent
47− height: units.gu(3)
48− width: units.gu(3)
49− source: button.action.iconSource
50− }
51− }
52−
53− SharingPicker {
54− id: sharingPicker
55− objectName: "sharingPicker"
56− }
57−}
qml/Dash/Previews/PreviewOverlay.qmldeleted−166
@@ -1,166 +0,0 @@
1−/*
2− * Copyright (C) 2014,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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import "../../Components"
20−
21−Rectangle {
22− id: overlay
23− objectName: "overlay"
24−
25− readonly property real aspectRatio: width / height
26− readonly property real initialAspectRatio: initialWidth / initialHeight
27− readonly property real initialXScale: initialWidth / width
28− readonly property real initialYScale: initialHeight / height
29−
30− property alias delegate: loader.sourceComponent
31− property alias delegateItem: loader.item
32− property alias headerShown: overlayHeader.shown
33− property real initialX: 0
34− property real initialY: 0
35− property real initialWidth: 1
36− property real initialHeight: 1
37−
38− property real xScale: initialXScale
39− property real yScale: initialYScale
40− property real progress: 0
41−
42− implicitWidth: 1
43− implicitHeight: 1
44− visible: progress > 0
45− clip: progress > 0 && progress < 1
46− color: Qt.rgba(0, 0, 0, progress)
47− transformOrigin: Item.TopLeft
48− transform: [
49− Scale {
50− origin.x: 0
51− origin.y: 0
52− xScale: overlay.xScale
53− yScale: overlay.yScale
54− },
55− Translate {
56− x: overlay.initialX - overlay.initialX * overlay.progress
57− y: overlay.initialY - overlay.initialY * overlay.progress
58− }
59− ]
60− state: "hidden"
61− states: [
62− State {
63− name: "shown"
64− PropertyChanges { target: overlay; progress: 1; xScale: 1; yScale: 1 }
65− },
66− State {
67− name: "hidden"
68− PropertyChanges { target: overlay; progress: 0; xScale: initialXScale; yScale: initialYScale }
69− }
70− ]
71− transitions: [
72− Transition {
73− from: "hidden"
74− to: "shown"
75− UbuntuNumberAnimation {
76− target: overlay
77− properties: "progress,xScale,yScale"
78− duration: UbuntuAnimation.FastDuration
79− }
80− },
81− Transition {
82− from: "shown"
83− to: "hidden"
84− UbuntuNumberAnimation {
85− target: overlay
86− properties: "progress,xScale,yScale"
87− duration: UbuntuAnimation.FastDuration / 2
88− }
89− }
90− ]
91−
92− function show() {
93− state = "shown"
94− }
95−
96− function hide() {
97− state = "hidden"
98− }
99−
100− Loader {
101− id: loader
102− anchors.fill: parent
103−
104− readonly property bool verticalScaling: initialAspectRatio / aspectRatio >= 1
105− readonly property real initialXScale: verticalScaling ? 1 : aspectRatio / initialAspectRatio
106− readonly property real initialYScale: verticalScaling ? initialAspectRatio / aspectRatio : 1
107− readonly property real xScale: verticalScaling ? loader.initialXScale - loader.initialXScale * overlay.progress + overlay.progress :
108− loader.yScale * overlay.yScale / overlay.xScale
109− readonly property real yScale: verticalScaling ? loader.xScale * overlay.xScale / overlay.yScale :
110− loader.initialYScale - loader.initialYScale * overlay.progress + overlay.progress
111−
112− transform: Scale {
113− origin.x: parent.width / 2
114− origin.y: parent.height / 2
115− xScale: loader.xScale
116− yScale: loader.yScale
117− }
118− }
119−
120− Rectangle {
121− id: overlayHeader
122−
123− property bool shown: true
124−
125− anchors {
126− left: parent.left
127− right: parent.right
128− }
129− height: units.gu(7)
130− visible: opacity > 0
131− opacity: overlay.state == "shown" && overlay.progress > 0.8 && shown ? 0.8 : 0
132− color: "black"
133−
134− Behavior on opacity {
135− UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
136− }
137−
138− AbstractButton {
139− id: overlayCloseButton
140− objectName: "overlayCloseButton"
141− anchors {
142− top: parent.top
143− bottom: parent.bottom
144− }
145− width: units.gu(8)
146− height: width
147−
148− onClicked: overlay.hide()
149−
150− Rectangle {
151− anchors.fill: parent
152− color: Qt.rgba(1.0, 1.0, 1.0, 0.3)
153− visible: overlayCloseButton.pressed
154− }
155−
156− Icon {
157− id: icon
158− anchors.centerIn: parent
159− width: units.gu(2.5)
160− height: width
161− color: "white"
162− name: "close"
163− }
164− }
165− }
166−}
qml/Dash/Previews/PreviewProgress.qmldeleted−74
@@ -1,74 +0,0 @@
1−/*
2− * Copyright (C) 2014-2016 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Ubuntu.DownloadDaemonListener 0.1
20−
21−/*! \brief Preview widget for a progress bar.
22− *
23− * It feeds itself from the source determined in widgetData["source"]
24− * At the moment we only support the dbus source defined
25− * by source["dbus-name"] and source["dbus-object"]
26− */
27−
28−PreviewWidget {
29− id: root
30−
31− implicitHeight: progressBar.height
32− implicitWidth: progressBar.implicitWidth
33−
34− ProgressBar {
35− id: progressBar
36− objectName: "progressBar"
37− anchors.right: parent.right
38− value: 0
39− maximumValue: 100
40− height: units.gu(4)
41− width: (root.width - units.gu(1)) / 2
42−
43− property var source: widgetData["source"]
44− // TODO Eventually we will need to support more sources other
45− // than DownloadTracker via dbus so we'll need a Loader based on source contents
46−
47− DownloadTracker {
48− service: progressBar.source["dbus-name"] || ""
49− dbusPath: progressBar.source["dbus-object"] || ""
50−
51− onProgress: {
52− if (total <= 0) {
53− progressBar.indeterminate = true;
54− } else {
55− progressBar.indeterminate = false;
56− var percentage = parseInt(received * 100 / total);
57− progressBar.value = percentage;
58− }
59− }
60−
61− onProcessing: {
62− progressBar.indeterminate = true;
63− }
64−
65− onFinished: {
66− root.triggered(widgetId, "finished", widgetData)
67− }
68−
69− onError: {
70− root.triggered(widgetId, "failed", widgetData)
71− }
72− }
73− }
74−}
qml/Dash/Previews/PreviewRatingDisplay.qmldeleted−117
@@ -1,117 +0,0 @@
1−/*
2− * Copyright (C) 2014,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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import "../../Components"
20−
21−/*! \brief Preview widget for rating display.
22−
23− The widget can show a rating widget and a field showing a comment.
24− The icons used in the rating widget can be customised with
25− widgetData["rating-icon-empty"], widgetData["rating-icon-full"]
26− and widgetData["rating-icon-half"].
27−
28− This widget shows reviews contained in widgetData["reviews"], each of which should be of the form:
29−
30− \code{.json}
31− {
32− "rating": null,
33− "review": null,
34− "author": null
35− }
36− \endcode
37− */
38−
39−PreviewWidget {
40− id: root
41− implicitHeight: childrenRect.height
42−
43− onParentFlickableChanged: ratingsList.updateRanges();
44−
45− Connections {
46− target: parentFlickable
47− onOriginYChanged: ratingsList.updateRanges();
48− onContentYChanged: ratingsList.updateRanges();
49− onHeightChanged: ratingsList.updateRanges();
50− onContentHeightChanged: ratingsList.updateRanges();
51− }
52−
53− ListView {
54− id: ratingsList
55− anchors { left: parent.left; right: parent.right; }
56− height: contentHeight
57− interactive: false
58−
59− model: root.widgetData["reviews"]
60−
61− delegate: PreviewRatingSingleDisplay {
62− id: prsd
63− objectName: "reviewItem" + index
64−
65− anchors { left: parent.left; right: parent.right; }
66−
67− rating: modelData["rating"] || -1
68− author: modelData["author"] || ""
69− review: modelData["review"] || ""
70− urlIconEmpty: widgetData["rating-icon-empty"]
71− urlIconFull: widgetData["rating-icon-full"]
72− urlIconHalf: widgetData["rating-icon-half"]
73− labelColor: scopeStyle ? scopeStyle.foreground : theme.palette.normal.baseText
74− }
75−
76− onContentHeightChanged: ratingsList.updateRanges();
77−
78− function updateRanges() {
79− var baseItem = root.parent;
80− if (!parentFlickable || !baseItem) {
81− ratingsList.displayMarginBeginning = 0;
82− ratingsList.displayMarginEnd = 0;
83− return;
84− }
85−
86− if (parentFlickable.moving) {
87− // Do not update the range if we are overshooting up or down, since we'll come back
88− // to the stable position and delete/create items without any reason
89− if (parentFlickable.contentY < parentFlickable.originY) {
90− return;
91− } else if (parentFlickable.contentHeight - parentFlickable.originY > parentFlickable.height &&
92− parentFlickable.contentY + parentFlickable.height > parentFlickable.contentHeight) {
93− return;
94− }
95− }
96−
97− // A item view creates its delegates synchronously from
98− // -displayMarginBeginning
99− // to
100− // height + displayMarginEnd
101− // Around that area it adds the cacheBuffer area where delegates are created async
102− //
103− // We adjust displayMarginEnd to be negative so that the range of created delegates matches
104− // from the beginning of the list to the end of the viewport.
105− // Ideally we would also use displayMarginBeginning
106− // so that delegates at the beginning get destroyed but that causes issues with
107− // listview and is not really necessary to provide the better experience we're after
108− var itemYOnViewPort = baseItem.y - parentFlickable.contentY;
109− var displayMarginEnd = -ratingsList.contentHeight + parentFlickable.height - itemYOnViewPort;
110− displayMarginEnd = -Math.max(-displayMarginEnd, 0);
111− displayMarginEnd = -Math.min(-displayMarginEnd, ratingsList.contentHeight);
112− displayMarginEnd = Math.round(displayMarginEnd);
113−
114− ratingsList.displayMarginEnd = displayMarginEnd;
115− }
116− }
117−}
qml/Dash/Previews/PreviewRatingEdit.qmldeleted−83
@@ -1,83 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import "../../Components"
20−
21−/*! \brief Preview widget for editable rating.
22−
23− Shows a single display rating that can be switched by the user to edit mode
24− and then behaves as a rating display widget
25−
26− The display part uses widgetData["author"], widgetData["review"] and widgetData["rating"].
27−
28− The edit part uses the same fields as the "rating-input" widget
29−*/
30−
31−PreviewWidget {
32− id: root
33− implicitHeight: display.visible ? display.implicitHeight : input.implicitHeight
34−
35− Button {
36− id: editIcon
37− objectName: "editButton"
38−
39− iconName: "edit"
40− width: height
41− anchors.right: parent.right
42− visible: display.visible
43− onClicked: display.visible = false
44− }
45−
46− PreviewRatingSingleDisplay {
47− id: display
48− objectName: "display"
49−
50− anchors.left: parent.left
51− anchors.right: editIcon.left
52−
53− rating: widgetData["rating"] || -1
54− author: widgetData["author"] || ""
55− review: widgetData["review"] || ""
56− urlIconEmpty: widgetData["rating-icon-empty"]
57− urlIconFull: widgetData["rating-icon-full"]
58− urlIconHalf: widgetData["rating-icon-half"]
59− labelColor: scopeStyle ? scopeStyle.foreground : theme.palette.normal.baseText
60− }
61−
62− PreviewRatingInput {
63− id: input
64− objectName: "input"
65−
66− visible: !display.visible
67− width: parent.width
68−
69− widgetId: root.widgetId
70− widgetData: root.widgetData
71− scopeStyle: root.scopeStyle
72−
73− ratingValue: widgetData["rating"]
74− reviewText: widgetData["review"]
75−
76− onTriggered: {
77− root.triggered(widgetId, actionId, data);
78− display.visible = true;
79− }
80− onMakeSureVisible: root.makeSureVisible(item);
81− }
82−
83−}
qml/Dash/Previews/PreviewRatingInput.qmldeleted−207
@@ -1,207 +0,0 @@
1−/*
2− * Copyright (C) 2014,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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import "../../Components"
20−import "PreviewSingleton"
21−
22−/*! \brief Preview widget for rating.
23−
24− The widget can show a rating widget and a field to enter a comment.
25− The visibility of the two widgets is specified by widgetData["visible"],
26− accepting "both", "rating" or "review".
27− The requirement of the review is specified by widgetData["visible"],
28− accepting "both", "rating" or "review".
29− It is possible to customise labels, widgetData["rating-label"] for the rating,
30− widgetData["rewiew-label"] for the comment field and widgetData["submit-label"]
31− for the submit button.
32− The icons used in the rating widget can be customised with
33− widgetData["rating-icon-empty"] and widgetData["rating-icon-full"].
34− The successeful submit emits triggered(widgetId, widgetData["required"], data),
35− with data being {"rating": rating value, "review": review comment, "author": null (for now)}.
36−*/
37−
38−PreviewWidget {
39− id: root
40− implicitHeight: {
41− switch(widgetData["visible"]) {
42− default:
43− case "both":
44− return ratingLabelAndWidgetContainer.implicitHeight + (reviewContainer.visible ? reviewContainer.implicitHeight : 0);
45− case "rating":
46− return ratingLabelAndWidgetContainer.implicitHeight;
47− case "review":
48− return reviewContainer.implicitHeight;
49− }
50− }
51−
52− clip: reviewContainer.visible
53−
54− property alias ratingValue: rating.value
55− property alias reviewText: reviewTextArea.text
56−
57− onRatingValueChanged: storeRatingState()
58− onReviewTextChanged: storeTextState()
59− onWidgetIdChanged: restoreReviewState()
60−
61− function initializeWidgetExtraData() {
62− if (typeof(PreviewSingleton.widgetExtraData[widgetId]) == "undefined") PreviewSingleton.widgetExtraData[widgetId] = [];
63− }
64−
65− function storeRatingState() {
66− initializeWidgetExtraData();
67− PreviewSingleton.widgetExtraData[widgetId][0] = ratingValue;
68− }
69−
70− function storeTextState() {
71− initializeWidgetExtraData();
72− PreviewSingleton.widgetExtraData[widgetId][1] = reviewText;
73− }
74−
75− function restoreReviewState() {
76− if (!PreviewSingleton.widgetExtraData[widgetId]) return;
77− if (PreviewSingleton.widgetExtraData[widgetId][0] > 0) ratingValue = PreviewSingleton.widgetExtraData[widgetId][0];
78− if (typeof(PreviewSingleton.widgetExtraData[widgetId][1]) != "undefined" &&
79− PreviewSingleton.widgetExtraData[widgetId][1] != "") reviewText = PreviewSingleton.widgetExtraData[widgetId][1];
80− }
81−
82− function submit() {
83− // checks rating-input requirements
84− if (((widgetData["required"] === "both" ||
85− widgetData["required"] === "rating") &&
86− rating.value < 0) ||
87− ((widgetData["required"] === "both" ||
88− widgetData["required"] === "review") &&
89− reviewTextArea.text === "")) return;
90−
91− var data = {"rating": rating.value, "review": reviewTextArea.text, "author": null};
92− triggered(root.widgetId, "rated", data);
93− }
94−
95− Column {
96− id: ratingLabelAndWidgetContainer
97− anchors { left: parent.left; right: parent.right; }
98− spacing: units.gu(0.5)
99− visible: widgetData["visible"] !== "review"
100−
101− Label {
102− id: ratingLabel
103− objectName: "ratingLabel"
104− anchors { left: parent.left; right: parent.right; }
105− fontSize: "large"
106− font.weight: Font.Light
107− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText
108− opacity: .8
109− text: widgetData["rating-label"] || i18n.tr("Rate this")
110− }
111−
112− Rating {
113− id: rating
114− objectName: "rating"
115− anchors.left: parent.left
116− size: 5
117− height: units.gu(4)
118− onValueChanged: {
119− if (widgetData && widgetData["visible"] === "rating") root.submit();
120− }
121−
122− property var urlIconEmpty: widgetData["rating-icon-empty"] || "image://theme/non-starred"
123− property var urlIconFull: widgetData["rating-icon-full"] || "image://theme/starred"
124− }
125− }
126−
127− Item {
128− id: reviewContainer
129− objectName: "reviewContainer"
130− implicitHeight: visible ? reviewSubmitContainer.implicitHeight + anchors.topMargin : 0
131−
132− readonly property real innerMargin: units.gu(1)
133−
134− anchors {
135− left: parent.left
136− right: parent.right
137− top: ratingLabelAndWidgetContainer.visible ? ratingLabelAndWidgetContainer.bottom : parent.top
138− bottom: parent.bottom
139− topMargin: ratingLabelAndWidgetContainer.visible ? innerMargin : 0
140− }
141− visible: {
142− switch(widgetData["visible"]) {
143− default:
144− case "both":
145− return widgetData["required"] === "review" || rating.value > 0;
146− case "rating":
147− return false;
148− case "review":
149− return true;
150− }
151− }
152−
153− Behavior on implicitHeight {
154− UbuntuNumberAnimation {
155− duration: UbuntuAnimation.FastDuration
156− easing.type: Easing.OutCubic
157− }
158− }
159−
160− Item {
161− id: reviewSubmitContainer
162− objectName: "reviewSubmitContainer"
163− anchors.fill: parent
164− implicitHeight: reviewTextArea.implicitHeight + anchors.topMargin
165−
166− TextArea {
167− id: reviewTextArea
168− objectName: "reviewTextArea"
169− property bool inputMethodVisible: Qt.inputMethod.visible
170− onInputMethodVisibleChanged: {
171− if(inputMethodVisible && activeFocus)
172− root.makeSureVisible(reviewTextArea);
173− }
174− onVisibleChanged: {
175− if (visible && widgetData["visible"] !== "review")
176− focus = true;
177− }
178− anchors {
179− top: parent.top
180− left: parent.left
181− right: submitButton.left
182− rightMargin: reviewContainer.innerMargin
183− }
184− placeholderText: widgetData["review-label"] || i18n.tr("Add a review")
185− }
186−
187− Button {
188− id: submitButton
189− objectName: "submitButton"
190−
191− readonly property bool readyToSubmit: {
192− if ((widgetData["required"] !== "review" && rating.value < 0) ||
193− (widgetData["required"] !== "rating" && reviewTextArea.text === "" && !reviewTextArea.inputMethodComposing)) return false;
194− else return true;
195− }
196−
197− anchors {
198− top: parent.top
199− right: parent.right
200− }
201− enabled: readyToSubmit
202− text: widgetData["submit-label"] || i18n.tr("Send")
203− onClicked: root.submit()
204− }
205− }
206− }
207−}
qml/Dash/Previews/PreviewRatingSingleDisplay.qmldeleted−73
@@ -1,73 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import "../../Components"
20−
21−Column {
22− id: reviewItem
23− spacing: units.gu(1)
24−
25− property alias rating: ratingItem.value
26− property alias author: authorLabel.text
27− property alias review: reviewLabel.text
28− property alias urlIconEmpty: ratingItem.urlIconEmpty
29− property alias urlIconFull: ratingItem.urlIconFull
30− property alias urlIconHalf: ratingItem.urlIconHalf
31− property alias labelColor: authorLabel.color
32−
33− Label {
34− id: authorLabel
35− objectName: "authorLabel"
36− anchors { left: parent.left; right: parent.right }
37− opacity: .8
38− fontSize: "small"
39− visible: text !== ""
40− wrapMode: Text.Wrap
41− }
42−
43− Rating {
44− id: ratingItem
45− objectName: "rating"
46− size: 5
47− visible: value >= 0
48− interactive: false
49−
50− property var urlIconEmpty
51− property var urlIconFull
52− property var urlIconHalf
53− }
54−
55− Label {
56− id: reviewLabel
57− objectName: "reviewLabel"
58− anchors { left: parent.left; right: parent.right }
59− color: authorLabel.color
60− opacity: .8
61− fontSize: "x-small"
62− font.weight: Font.Light
63− visible: text !== ""
64− wrapMode: Text.Wrap
65− }
66−
67− Item {
68− id: spacing
69− anchors { left: parent.left; right: parent.right }
70− height: units.gu(2)
71− visible: rating.visible || authorLabel.visible || reviewLabel.visible
72− }
73−}
qml/Dash/Previews/PreviewSingleton/PreviewSingleton.qmldeleted−22
@@ -1,22 +0,0 @@
1−/*
2− * Copyright (C) 2016 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−pragma Singleton
18−import QtQuick 2.4
19−
20−QtObject {
21− property var widgetExtraData: new Object();
22−}
qml/Dash/Previews/PreviewSingleton/qmldirdeleted−1
@@ -1 +0,0 @@
1−singleton PreviewSingleton 1.0 PreviewSingleton.qml
qml/Dash/Previews/PreviewTable.qmldeleted−91
@@ -1,91 +0,0 @@
1−/*
2− * Copyright (C) 2014,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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import QtQuick.Layouts 1.1
19−import Ubuntu.Components 1.3
20−import "../../Components"
21−
22−/*! \brief Preview widget for table.
23−
24− This widget shows two columns contained in widgetData["values"]
25− as arrays of label,value along with a title that comes from widgetData["title"].
26−
27− In case the widget is collapsed it only shows 3 lines of values.
28− */
29−
30−PreviewWidget {
31− id: root
32− implicitHeight: column.implicitHeight
33−
34− readonly property int maximumCollapsedRowCount: 3
35−
36− Column {
37− id: column
38− objectName: "column"
39− spacing: units.gu(1)
40− width: parent.width
41−
42− Label {
43− id: titleLabel
44− objectName: "titleLabel"
45− anchors {
46− left: parent.left
47− right: parent.right
48− }
49− height: visible ? implicitHeight : 0
50− fontSize: "large"
51− font.weight: Font.Light
52− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText
53− visible: text !== ""
54− opacity: .8
55− text: widgetData["title"] || ""
56− elide: Text.ElideRight
57− }
58−
59− GridLayout {
60− objectName: "gridLayout"
61− columns: 2
62− columnSpacing: units.gu(2)
63− Repeater {
64− id: rowsRepeater
65− model: widgetData["values"]
66−
67− delegate: Repeater {
68− id: perRowRepeater
69− readonly property int rowIndex: index
70− model: widgetData["values"][index]
71− delegate: Label {
72− objectName: "label"+rowIndex+index
73− fontSize: "small"
74− text: perRowRepeater.model[index]
75− visible: root.expanded || rowIndex < maximumCollapsedRowCount
76− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText
77− font.weight: index == 0 ? Font.Normal : Font.Light
78− wrapMode: Text.Wrap
79− Layout.alignment: Qt.AlignTop
80− Layout.minimumHeight: Math.max(units.gu(2.75), contentHeight) // FIXME Reevaluate if we need this once we move away from Qt 5.4
81− Layout.maximumWidth: index == 0 ? column.width / 3 : column.width - x
82− Layout.minimumWidth: index == 0 ? column.width / 3 : -1
83− height: -1 // FIXME Qt 5.4 needs this otherwise wrapped columns
84− // get the height wrong and the next row looks weird
85− // remove once we stop supporting Qt 5.4 (if 5.5 doesn't need it)
86− }
87− }
88− }
89− }
90− }
91−}
qml/Dash/Previews/PreviewTextSummary.qmldeleted−78
@@ -1,78 +0,0 @@
1−/*
2− * Copyright (C) 2014,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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import "../../Components"
20−
21−/*! \brief Preview widget for text.
22−
23− This widget shows text contained in widgetData["text"]
24− along with a title that comes from widgetData["title"].
25−
26− In case the widget is collapsed it only shows 3 lines of text.
27− */
28−
29−PreviewWidget {
30− id: root
31− implicitHeight: childrenRect.height
32−
33− Label {
34− id: titleLabel
35− objectName: "titleLabel"
36− anchors {
37− left: parent.left
38− right: parent.right
39− }
40− height: visible ? implicitHeight : 0
41− fontSize: "large"
42− font.weight: Font.Light
43− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText
44− visible: text !== ""
45− opacity: .8
46− text: widgetData["title"] || ""
47− wrapMode: Text.Wrap
48− }
49−
50− Label {
51− id: textLabel
52− objectName: "textLabel"
53−
54− readonly property int maximumCollapsedLineCount: 3
55−
56− anchors {
57− left: parent.left
58− right: parent.right
59− top: titleLabel.visible ? titleLabel.bottom : parent.top
60− topMargin: titleLabel.visible && visible ? units.gu(1.5) : 0
61− }
62− height: visible ? (lineCount <= maximumCollapsedLineCount || root.expanded) ? contentHeight : contentHeight / lineCount * maximumCollapsedLineCount : 0
63− clip: true
64− fontSize: "medium"
65− font.weight: Font.Light
66− lineHeight: 1.2
67− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText
68− visible: text !== ""
69− opacity: .8
70− text: widgetData["text"] || ""
71− wrapMode: Text.Wrap
72−
73− Behavior on height {
74− enabled: textLabel.lineCount > textLabel.maximumCollapsedLineCount
75− UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
76− }
77− }
78−}
qml/Dash/Previews/PreviewVideoPlayback.qmldeleted−87
@@ -1,87 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Ubuntu.Thumbnailer 0.1
20−import "../../Components"
21−
22−/*! \brief Preview widget for video.
23−
24− This widget shows video contained in widgetData["source"],
25− with a placeholder screenshot specified by widgetData["screenshot"].
26− */
27−
28−PreviewWidget {
29− id: root
30− implicitWidth: units.gu(35)
31− implicitHeight: childrenRect.height
32−
33− singleColumnMarginless: true
34−
35− LazyImage {
36− objectName: "screenshot"
37− anchors {
38− left: parent.left
39− right: parent.right
40− }
41− scaleTo: "width"
42− source: {
43− var screenshot = widgetData["screenshot"];
44− if (screenshot) return screenshot;
45−
46− var source = widgetData["source"];
47− if (source) {
48− if (source.toString().indexOf("file://") === 0) {
49− return "image://thumbnailer/" + source.toString().substr(7);
50− }
51− }
52−
53− return "";
54− }
55− initialHeight: width * 10 / 16
56− useUbuntuShape: false
57−
58− Image {
59− objectName: "playButton"
60−
61− readonly property bool bigButton: parent.width > units.gu(40)
62−
63− anchors.centerIn: parent
64− width: bigButton ? units.gu(8) : units.gu(4.5)
65− height: width
66− source: "../graphics/play_button%1%2.png".arg(previewImageMouseArea.pressed ? "_active" : "").arg(bigButton ? "_big" : "")
67− visible: parent.state === "ready"
68− }
69−
70− MouseArea {
71− enabled: parent.state === "ready"
72− id: previewImageMouseArea
73− anchors.fill: parent
74− onClicked: Qt.openUrlExternally(widgetData["source"])
75− }
76−
77− PreviewMediaToolbar {
78− id: toolbar
79− anchors {
80− left: parent.left
81− right: parent.right
82− bottom: parent.bottom
83− }
84− shareData: widgetData["share-data"]
85− }
86− }
87−}
qml/Dash/Previews/PreviewWidget.qmldeleted−60
@@ -1,60 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−
19−/*! Interface for preview widgets. */
20−
21−Item {
22− //! The widget identifier
23− property string widgetId
24−
25− //! Variable used to contain widget's data
26− property var widgetData
27−
28− //! The ScopeStyle component.
29− property var scopeStyle: null
30−
31− //! Should the widget show in expanded mode (For those that support it)
32− property bool expanded: true
33−
34− //! Should the orientation be locked
35− property bool orientationLock: false
36−
37− //! Should it have margins when on a single columns?
38− property bool singleColumnMarginless: false
39−
40− /// The parent (vertical) flickable this widget is in (if any)
41− property var parentFlickable: null
42−
43− /*! \brief This signal should be emitted when a preview action was triggered.
44− *
45− * \param widgetId, actionId Respective identifiers from widgetData.
46− * \param data Optional widget-specific data sent to the scope.
47− */
48− signal triggered(string widgetId, string actionId, var data)
49−
50− /*! \brief This signal should be emitted when widget gains the focus
51− * and input method popups.
52− * And preview widget should reposition in visible area to avoid
53− * keyboard appears over the widget.
54− *
55− * \param item, id of specified item which is needed to reposition.
56− */
57− signal makeSureVisible(var item)
58−
59− objectName: widgetId
60−}
qml/Dash/Previews/PreviewWidgetFactory.qmldeleted−101
@@ -1,101 +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− */
17−
18−import QtQuick 2.4
19−
20−//! \brief This component loads the widgets based on widgetData["type"].
21−
22−Loader {
23− id: root
24−
25− //! Identifier of the widget.
26− property string widgetId: ""
27−
28− //! Type of the widget to display.
29− property string widgetType: ""
30−
31− //! Widget data, forwarded to the widget as is.
32− property var widgetData: null
33−
34− //! The ScopeStyle component.
35− property var scopeStyle: null
36−
37− //! Should the widget show in expanded mode (For those that support it)
38− property bool expanded: widgetType !== "expandable" || widgetData["expanded"] === true
39−
40− //! Should the orientation be locked
41− readonly property bool orientationLock: status === Loader.Ready ? item.orientationLock : false
42−
43− //! Should it have margins when on a single columns?
44− readonly property bool singleColumnMarginless: status === Loader.Ready ? item.singleColumnMarginless : false
45−
46− /// The parent (vertical) flickable this widget is in (if any)
47− property var parentFlickable: null
48−
49− //! Triggered signal forwarded from the widgets.
50− signal triggered(string widgetId, string actionId, var data)
51−
52− //! MakesureVisible signal forwarded from the widgets.
53− signal makeSureVisible(var item)
54−
55− source: widgetSource
56−
57− //! \cond private
58− property url widgetSource: {
59− switch (widgetType) {
60− case "actions": return "PreviewActions.qml";
61− case "audio": return "PreviewAudioPlayback.qml";
62− case "comment": return "PreviewComment.qml";
63− case "comment-input": return "PreviewCommentInput.qml";
64− case "expandable": return "PreviewExpandable.qml";
65− case "gallery": return "PreviewImageGallery.qml";
66− case "header": return "PreviewHeader.qml";
67− case "icon-actions": return "PreviewIconActions.qml";
68− case "image": return "PreviewZoomableImage.qml";
69− case "progress": return "PreviewProgress.qml";
70− case "rating-input": return "PreviewRatingInput.qml";
71− case "rating-edit": return "PreviewRatingEdit.qml";
72− case "reviews": return "PreviewRatingDisplay.qml";
73− case "table": return "PreviewTable.qml";
74− case "text": return "PreviewTextSummary.qml";
75− case "video": {
76− if (!widgetData) return "";
77− var source = widgetData.hasOwnProperty("source") ? widgetData["source"].toString() : "";
78− if (source.match("^https{0,1}\:") !== null) {
79− return "PreviewVideoPlayback.qml";
80− }
81− return "PreviewInlineVideo.qml";
82− }
83− default: return "";
84− }
85− }
86− //! \endcond
87−
88− onLoaded: {
89− item.widgetId = Qt.binding(function() { return root.widgetId } )
90− item.widgetData = Qt.binding(function() { return root.widgetData } )
91− item.expanded = Qt.binding(function() { return root.expanded } )
92− item.scopeStyle = Qt.binding(function() { return root.scopeStyle } )
93− item.parentFlickable = Qt.binding(function() { return root.parentFlickable } )
94− }
95−
96− Connections {
97− target: root.item
98− onTriggered: root.triggered(widgetId, actionId, data)
99− onMakeSureVisible: root.makeSureVisible(item)
100− }
101−}
qml/Dash/Previews/PreviewZoomableImage.qmldeleted−103
@@ -1,103 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import "../../Components"
20−
21−/*! \brief Preview widget for image.
22−
23− This widget shows image contained in widgetData["source"],
24− and falls back to widgetData["fallback"] if loading fails
25− can be zoomable accordingly with widgetData["zoomable"].
26− */
27−
28−PreviewWidget {
29− id: root
30− implicitWidth: units.gu(35)
31− implicitHeight: lazyImage.height
32−
33− singleColumnMarginless: true
34− orientationLock: overlay.visible
35−
36− property Item rootItem: QuickUtils.rootItem(root)
37−
38− readonly property var imageUrl: widgetData["source"] || widgetData["fallback"] || ""
39−
40− LazyImage {
41− id: lazyImage
42− objectName: "lazyImage"
43− anchors {
44− left: parent.left
45− right: parent.right
46− }
47− scaleTo: "width"
48− source: root.imageUrl
49− asynchronous: true
50− useUbuntuShape: false
51− pressed: mouseArea.pressed
52−
53− MouseArea {
54− id: mouseArea
55− anchors.fill: parent
56− onClicked: {
57− overlay.initialX = rootItem.mapFromItem(parent, 0, 0).x;
58− overlay.initialY = rootItem.mapFromItem(parent, 0, 0).y;
59− overlay.show();
60− }
61− }
62−
63− Connections {
64− target: lazyImage.sourceImage
65− onStatusChanged: if (lazyImage.sourceImage.status === Image.Error) lazyImage.sourceImage.source = widgetData["fallback"];
66− }
67− Connections {
68− target: root
69− onImageUrlChanged: lazyImage.sourceImage.source = root.imageUrl;
70− }
71−
72− PreviewMediaToolbar {
73− id: toolbar
74− anchors {
75− left: parent.left
76− right: parent.right
77− bottom: parent.bottom
78− }
79− shareData: widgetData["share-data"]
80− }
81− }
82−
83− PreviewOverlay {
84− id: overlay
85− objectName: "overlay"
86− parent: rootItem
87− anchors.fill: parent
88− initialWidth: lazyImage.width
89− initialHeight: lazyImage.height
90−
91− delegate: ZoomableImage {
92− anchors.fill: parent
93− source: root.imageUrl
94− zoomable: widgetData["zoomable"] ? widgetData["zoomable"] : false
95− onStatusChanged: if (status === Image.Error) source = widgetData["fallback"];
96−
97− Connections {
98− target: root
99− onImageUrlChanged: source = root.imageUrl;
100− }
101− }
102− }
103−}
qml/Dash/PullToRefreshScopeStyle.qmldeleted−83
@@ -1,83 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Ubuntu.Components.Styles 1.3
20−
21−/**
22− * TODO: Once the SDK version of PullToRefreshStyle doesn't have bug 1375799
23− * (https://launchpad.net/bugs/1375799) anymore, we should switch to using a
24− * a subclass of the Ambiance version with a hidden ActivityIndicator.
25− */
26−PullToRefreshStyle {
27− releaseToRefresh: styledItem.target.originY - styledItem.target.contentY > activationThreshold
28−
29− Connections {
30− property bool willRefresh: false
31−
32− target: styledItem.target
33− onDraggingChanged: {
34− if (!styledItem.target.dragging && releaseToRefresh) {
35− willRefresh = true
36− }
37− }
38− onContentYChanged: {
39− if (styledItem.target.originY - styledItem.target.contentY == 0 && willRefresh) {
40− styledItem.refresh()
41− willRefresh = false
42− }
43− }
44− }
45−
46− Label {
47− id: pullLabel
48− anchors.horizontalCenter: parent.horizontalCenter
49− horizontalAlignment: Text.AlignHCenter
50− verticalAlignment: Text.AlignVCenter
51− color: styledItem.pullLabelColor
52− states: [
53− State {
54− name: "pulling"
55− when: styledItem.target.dragging && !releaseToRefresh
56− PropertyChanges { target: pullLabel; text: i18n.tr("Pull to refresh…") }
57− },
58− State {
59− name: "releasable"
60− when: styledItem.target.dragging && releaseToRefresh
61− PropertyChanges { target: pullLabel; text: i18n.tr("Release to refresh…") }
62− }
63− ]
64− transitions: Transition {
65− SequentialAnimation {
66− UbuntuNumberAnimation {
67− target: pullLabel
68− property: "opacity"
69− to: 0.0
70− }
71− PropertyAction {
72− target: pullLabel
73− property: "text"
74− }
75− UbuntuNumberAnimation {
76− target: pullLabel
77− property: "opacity"
78− to: 1.0
79− }
80− }
81− }
82− }
83−}
qml/Dash/ScopeListView.qmldeleted−28
@@ -1,28 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Dash 0.1
20−import "../Components/flickableUtils.js" as FlickableUtilsJS
21−
22−ListViewWithPageHeader {
23− flickDeceleration: FlickableUtilsJS.getFlickDeceleration(units.gridUnit)
24− maximumFlickVelocity: FlickableUtilsJS.getMaximumFlickVelocity(units.gridUnit)
25− // 1073741823 is s^30 -1. A quite big number so that you have "infinite" cache, but not so
26− // big so that if you add if with itself you're outside the 2^31 int range
27− cacheBuffer: 1073741823
28−}
qml/Dash/ScopeSettings/ScopeSetting.qmldeleted−46
@@ -1,46 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−
20−/*! Interface for settings widgets. */
21−
22−Item {
23− //! The ScopeStyle component.
24− property var scopeStyle: null
25−
26− //! Variable used to contain widget's data
27− property var widgetData: null
28−
29− /*! \brief This signal should be emitted when a setting action was updated.
30− *
31− * \param value the new setting value.
32− */
33− signal updated(var value)
34−
35− /*! \brief This signal should be emitted when widget gains the focus
36− * and input method popups.
37− * And preview widget should reposition in visible area to avoid
38− * keyboard appears over the widget.
39− *
40− * \param item, id of specified item which is needed to reposition.
41− */
42− signal makeSureVisible(var item)
43−
44− //! \internal
45− readonly property real settingMargins: units.gu(2)
46−}
qml/Dash/ScopeSettings/ScopeSettingBoolean.qmldeleted−63
@@ -1,63 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Ubuntu.Components.ListItems 1.3 as ListItem
20−
21−ScopeSetting {
22− id: root
23− height: listItem.height
24−
25− ListItem.Empty {
26− id: listItem
27−
28− onClicked: {
29− control.checked = !control.checked;
30− updated(control.checked);
31− }
32−
33− Label {
34− anchors {
35− left: parent.left
36− leftMargin: settingMargins
37− right: control.left
38− rightMargin: units.gu(1)
39− verticalCenter: parent.verticalCenter
40− }
41− // TODO The translation should ideally come from the bottom layers and not be hardcoded here
42− // https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1393438
43− text: widgetData.settingId == "internal.location" ? i18n.tr("Enable location data") : widgetData.displayName
44− elide: Text.ElideMiddle
45− maximumLineCount: 2
46− wrapMode: Text.Wrap
47− color: scopeStyle ? scopeStyle.foreground : theme.palette.normal.baseText
48− }
49−
50− CheckBox {
51− id: control
52− objectName: "control"
53− anchors {
54− right: parent.right
55− rightMargin: settingMargins
56− verticalCenter: parent.verticalCenter
57− }
58− checked: widgetData.value
59−
60− onTriggered: root.updated(checked)
61− }
62− }
63−}
qml/Dash/ScopeSettings/ScopeSettingList.qmldeleted−50
@@ -1,50 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Ubuntu.Components.ListItems 1.3 as ListItem
20−
21−ScopeSetting {
22− id: root
23−
24− // FIXME workaround for: https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1355830
25− height: listItem.currentlyExpanded ? listItem.itemHeight * widgetData.properties["values"].length + units.gu(6) : listItem.height
26−
27− property int initialValue: -1
28−
29− ListItem.ItemSelector {
30− id: listItem
31− objectName: "control"
32− anchors {
33− left: parent.left
34− right: parent.right
35− }
36− text: widgetData.displayName
37− model: widgetData.properties["values"]
38−
39− onSelectedIndexChanged: {
40− if (root.initialValue >= 0) {
41− var tmpValue = root.initialValue;
42− root.initialValue = -1;
43− selectedIndex = tmpValue;
44− return;
45− }
46−
47− root.updated(selectedIndex);
48− }
49− }
50−}
qml/Dash/ScopeSettings/ScopeSettingNumber.qmldeleted−21
@@ -1,21 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−
19−ScopeSettingString {
20− mode: "number"
21−}
qml/Dash/ScopeSettings/ScopeSettingString.qmldeleted−89
@@ -1,89 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Ubuntu.Components.ListItems 1.3 as ListItem
20−
21−ScopeSetting {
22− id: root
23− height: listItem.height
24−
25− property string mode: "string"
26−
27− ListItem.Empty {
28− id: listItem
29− onClicked: {
30− control.forceActiveFocus();
31− control.selectAll();
32− }
33−
34− Label {
35− id: label
36− anchors {
37− left: parent.left
38− leftMargin: settingMargins
39− right: control.left
40− rightMargin: units.gu(1)
41− verticalCenter: parent.verticalCenter
42− }
43− text: widgetData.displayName
44− elide: Text.ElideMiddle
45− maximumLineCount: 2
46− wrapMode: Text.Wrap
47− color: scopeStyle ? scopeStyle.foreground : theme.palette.normal.baseText
48− }
49−
50− TextField {
51− id: control
52− objectName: "control"
53− anchors {
54− right: parent.right
55− rightMargin: settingMargins
56− verticalCenter: parent.verticalCenter
57− }
58− width: root.mode == "number" ? units.gu(8) : units.gu(12)
59− text: widgetData.value
60− color: scopeStyle ? scopeStyle.foreground : theme.palette.normal.fieldText
61− validator: root.mode == "number" ? doubleValidator : null
62− hasClearButton: root.mode == "number" ? false : true
63−
64− DoubleValidator {
65− id: doubleValidator
66− }
67−
68− function updateText() {
69− if (acceptableInput) {
70− text = displayText;
71− root.updated(text);
72− }
73− }
74−
75− onAccepted: updateText()
76− onActiveFocusChanged: {
77− if (!activeFocus) {
78− updateText();
79− }
80− }
81−
82− readonly property bool inputMethodVisible: Qt.inputMethod.visible
83− onInputMethodVisibleChanged: {
84− if(inputMethodVisible && activeFocus)
85− root.makeSureVisible(control);
86− }
87− }
88− }
89−}
qml/Dash/ScopeSettings/ScopeSettingsWidgetFactory.qmldeleted−61
@@ -1,61 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−
19−//! \brief This component loads the widgets based on type.
20−
21−Loader {
22− id: root
23−
24− //! The ScopeStyle component.
25− property var scopeStyle: null
26−
27− //! Variable used to contain widget's data
28− property var widgetData: null
29−
30− //! Triggered signal forwarded from the widgets.
31− signal updated(var value)
32−
33− //! makeSureVisible signal forwarded from the widgets.
34− signal makeSureVisible(var item)
35−
36− source: widgetSource
37−
38− //! \cond private
39− property url widgetSource: {
40− switch (widgetData.type) {
41− case "boolean": return "ScopeSettingBoolean.qml";
42− case "list": return "ScopeSettingList.qml";
43− case "number": return "ScopeSettingNumber.qml";
44− case "string": return "ScopeSettingString.qml";
45− default: return "";
46− }
47− }
48− //! \endcond
49−
50− onLoaded: {
51− if (item.hasOwnProperty("initialValue")) item.initialValue = root.widgetData.value;
52− item.widgetData = Qt.binding(function() { return root.widgetData; } )
53− item.scopeStyle = Qt.binding(function() { return root.scopeStyle; } )
54− }
55−
56− Connections {
57− target: root.item
58− onUpdated: if (value !== widgetData.value) root.updated(value)
59− onMakeSureVisible: root.makeSureVisible(item)
60− }
61−}
qml/Dash/ScopeSettingsPage.qmldeleted−72
@@ -1,72 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Unity 0.2
20−import "../Components"
21−import "ScopeSettings"
22−
23−Item {
24− id: root
25−
26− property var scope: null
27− property var scopeStyle: null
28−
29− signal backClicked()
30−
31− DashPageHeader {
32− id: header
33− objectName: "pageHeader"
34− width: parent.width
35− title: scope ? scope.name : ""
36− showBackButton: true
37− scopeStyle: root.scopeStyle
38−
39− onBackClicked: root.backClicked()
40− }
41−
42− ListView {
43− id: scopeSettings
44− objectName: "scopeSettings"
45− anchors {
46− top: header.bottom
47− bottom: parent.bottom
48− left: parent.left
49− right: parent.right
50− }
51− model: root.scope ? root.scope.settings : null
52− clip: true
53−
54− ListViewOSKScroller {
55− id: oskScroller
56− list: scopeSettings
57− }
58−
59− delegate: ScopeSettingsWidgetFactory {
60− objectName: "scopeSettingItem" + index
61− width: root.width
62− widgetData: model
63− scopeStyle: root.scopeStyle
64−
65− onUpdated: model.value = value;
66−
67− onMakeSureVisible: { // var item
68− oskScroller.setMakeSureVisibleItem(item);
69− }
70− }
71− }
72−}
qml/Dash/ScopesList.qmldeleted−206
@@ -1,206 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Dash 0.1
20−import "../Components"
21−
22−Item {
23− id: root
24−
25− property alias scopesListFlickable: scopesListFlickable
26−
27− // Properties set by parent
28− property var scope: null
29−
30− // Properties used by parent
31− readonly property bool processing: scope ? (scope.searchInProgress || scope.activationInProgress) : false
32−
33− // Signals
34− signal backClicked()
35− signal storeClicked()
36− signal requestFavorite(string scopeId, bool favorite)
37− signal requestFavoriteMoveTo(string scopeId, int index)
38− signal requestRestore(string scopeId)
39−
40− Item {
41− id: autoscroller
42−
43− property bool dragging: false
44− property var dragItem: new Object();
45−
46− readonly property bool fuzzyAtYEnd: {
47− var contentHeight = root.scopesListFlickable.contentHeight
48− var contentY = root.scopesListFlickable.contentY
49− var dragItemHeight = dragItem ? autoscroller.dragItem.height : 0
50− var flickableHeight = root.scopesListFlickable.height
51−
52− if (!dragItem) {
53− return true;
54− } else {
55− return contentY >= (contentHeight - flickableHeight) - dragItemHeight
56− }
57− }
58−
59− readonly property real bottomBoundary: {
60− var contentHeight = root.scopesListFlickable.contentHeight
61− var contentY = root.scopesListFlickable.contentY
62− var dragItemHeight = dragItem ? autoscroller.dragItem.height : 0
63− var heightRatio = root.scopesListFlickable.visibleArea.heightRatio
64−
65− if (!dragItem) {
66− return true;
67− } else {
68− return (heightRatio * contentHeight) -
69− (1.5 * dragItemHeight) + contentY
70− }
71− }
72−
73− readonly property int delayMs: 32
74− readonly property real topBoundary: dragItem ? root.scopesListFlickable.contentY + (.5 * dragItem.height) : 0
75−
76− visible: false
77− readonly property real maxStep: units.dp(10)
78− function stepSize(scrollingUp) {
79− var delta, step;
80− if (scrollingUp) {
81− delta = dragItem.y - topBoundary;
82− delta /= (1.5 * dragItem.height);
83− } else {
84− delta = dragItem.y - bottomBoundary;
85− delta /= (1.5 * dragItem.height);
86− }
87−
88− step = Math.abs(delta) * autoscroller.maxStep
89− return Math.ceil(step);
90− }
91−
92−
93− Timer {
94− interval: autoscroller.delayMs
95− running: autoscroller.dragItem ? (autoscroller.dragging &&
96− autoscroller.dragItem.y < autoscroller.topBoundary &&
97− !root.scopesListFlickable.atYBeginning) : false
98− repeat: true
99− onTriggered: {
100− root.scopesListFlickable.contentY -= autoscroller.stepSize(true);
101− autoscroller.dragItem.y -= autoscroller.stepSize(true);
102− }
103− }
104−
105− Timer {
106− interval: autoscroller.delayMs
107− running: autoscroller.dragItem ? (autoscroller.dragging &&
108− autoscroller.dragItem.y >= autoscroller.bottomBoundary &&
109− !autoscroller.fuzzyAtYEnd) : false
110− repeat: true
111− onTriggered: {
112− root.scopesListFlickable.contentY += autoscroller.stepSize(false);
113− autoscroller.dragItem.y += autoscroller.stepSize(false);
114− }
115− }
116− }
117−
118− function autoscroll(dragging, dragItem) {
119− if (dragging) {
120− autoscroller.dragItem = dragItem
121− autoscroller.dragging = true;
122− } else {
123− autoscroller.dragItem = null;
124− autoscroller.dragging = false
125− }
126− }
127−
128− state: "browse"
129−
130− property var scopeStyle: ScopeStyle {}
131−
132− onStateChanged: {
133− if (state == "edit") {
134− // As per design entering edit mode clears the possible existing search
135− header.resetSearch(false /* false == unfocus */);
136− }
137− }
138−
139− DashBackground {
140− anchors.fill: parent
141− }
142−
143− DashPageHeader {
144− id: header
145− objectName: "pageHeader"
146− title: i18n.tr("Manage")
147− width: parent.width
148− clip: true
149− showBackButton: true
150− backIsClose: root.state == "edit"
151− storeEntryEnabled: root.state == "browse"
152− searchEntryEnabled: false
153− scopeStyle: root.scopeStyle
154− onBackClicked: {
155− if (backIsClose) {
156− root.state = "browse"
157− } else {
158− root.backClicked()
159− }
160− }
161− onStoreClicked: root.storeClicked();
162− z: 1
163− }
164−
165− ListView {
166− id: scopesListFlickable
167− objectName: "scopesListFlickable"
168− anchors {
169− top: header.bottom
170− bottom: parent.bottom
171− left: parent.left
172− right: parent.right
173− }
174− clip: true
175− model: scope ? scope.categories : null
176− delegate: Loader {
177− asynchronous: true
178− width: root.width
179− active: results.count > 0
180− visible: active
181− sourceComponent: ScopesListCategory {
182− objectName: "scopesListCategory" + categoryId
183−
184− model: results
185−
186− title: {
187− if (isFavoritesFeed) return i18n.tr("Home");
188− else if (isAlsoInstalled) return i18n.tr("Also installed");
189− else return name;
190− }
191−
192− editMode: root.state == "edit"
193− scopeStyle: root.scopeStyle
194− isFavoritesFeed: categoryId == "favorites"
195− isAlsoInstalled: categoryId == "other"
196−
197− onItemDragging: autoscroll(dragging, dragItem);
198− onRequestFavorite: root.requestFavorite(scopeId, favorite);
199− onRequestEditMode: root.state = "edit";
200− onRequestScopeMoveTo: root.requestFavoriteMoveTo(scopeId, index);
201− onRequestActivate: root.scope.activate(result, categoryId);
202− onRequestRestore: root.requestRestore(scopeId);
203− }
204− }
205− }
206−}
qml/Dash/ScopesListCategory.qmldeleted−184
@@ -1,184 +0,0 @@
1−/*
2− * Copyright (C) 2014,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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Ubuntu.Components.ListItems 1.3 as ListItems
20−import Dash 0.1
21−import "../Components"
22−
23−Item {
24− id: root
25−
26− property alias model: list.model
27− property alias title: header.text
28− property var scopeStyle
29− property bool editMode: false
30− property bool isFavoritesFeed: false
31− property bool isAlsoInstalled: false
32−
33− visible: !editMode || isFavoritesFeed
34−
35− signal itemDragging(bool dragging, var dragItem)
36− signal requestFavorite(string scopeId, bool favorite)
37− signal requestEditMode()
38− signal requestScopeMoveTo(string scopeId, int index)
39− signal requestActivate(var result)
40− signal requestRestore(string scopeId)
41−
42− implicitHeight: visible ? childrenRect.height : 0
43−
44− DashSectionHeader {
45− id: header
46− width: root.width
47− height: units.gu(5)
48− color: scopeStyle ? scopeStyle.foreground : theme.palette.normal.baseText
49− }
50−
51− readonly property double listItemHeight: units.gu(6)
52−
53− ListView {
54− id: list
55− objectName: "scopesListCategoryInnerList"
56−
57− readonly property double targetHeight: model.count * listItemHeight
58− clip: height != targetHeight
59− height: targetHeight
60− Behavior on height { enabled: visible; UbuntuNumberAnimation { } }
61− width: parent.width
62− interactive: false
63−
64− anchors.top: header.bottom
65− delegate: Loader {
66− id: loader
67− readonly property bool addDropHint: {
68− if (dragMarker.visible) {
69− if (dragItem.originalIndex > index) {
70− return dragMarker.index == index;
71− } else {
72− return dragMarker.index == index - 1;
73− }
74− } else {
75− return false;
76− }
77− }
78− asynchronous: true
79− width: root.width
80− height: listItemHeight + (addDropHint ? units.gu(2) : 0)
81− clip: height < listItemHeight
82− Behavior on height { enabled: visible; UbuntuNumberAnimation { } }
83− sourceComponent: ScopesListCategoryItem {
84− objectName: "delegate" + model.scopeId
85−
86− width: root.width
87− topMargin: height > listItemHeight ? height - listItemHeight : 0
88−
89− icon: model.art || model.mascot || ""
90− text: model.title || ""
91− subtext: model.subtitle || ""
92− showStar: root.isFavoritesFeed || root.isAlsoInstalled
93− isFavorite: root.isFavoritesFeed
94−
95− hideChildren: dragItem.loaderToShrink == loader
96−
97− onClicked: {
98− if (!editMode) {
99− if (root.isFavoritesFeed)
100− root.requestRestore(model.scopeId);
101− else
102− root.requestActivate(result);
103− }
104− }
105− onPressAndHold: {
106− if (!editMode) {
107− root.requestEditMode();
108− }
109− }
110− onRequestFavorite: root.requestFavorite(model.scopeId, favorite);
111− onHandlePressed: {
112− if (editMode) {
113− root.itemDragging(true, dragItem);
114− handle.drag.target = dragItem;
115− handle.drag.maximumX = units.gu(1);
116− handle.drag.minimumX = units.gu(1);
117− handle.drag.minimumY = list.y - dragItem.height / 2;
118− handle.drag.maximumY = list.y + list.height - dragItem.height / 2
119− dragItem.icon = icon;
120− dragItem.text = text;
121− dragItem.subtext = subtext;
122− dragItem.originalY = mapToItem(root, 0, 0).y;
123− dragItem.originalIndex = index;
124− dragItem.y = dragItem.originalY;
125− dragItem.x = units.gu(1);
126− dragItem.visible = true;
127− dragItem.loaderToShrink = loader;
128− }
129− }
130− onHandleReleased: {
131− root.itemDragging(false, dragItem);
132− if (dragItem.visible) {
133− handle.drag.target = undefined;
134− dragItem.visible = false;
135− if (dragMarker.visible && dragMarker.index != index) {
136− root.requestScopeMoveTo(model.scopeId, dragMarker.index);
137− }
138− dragMarker.visible = false;
139− dragItem.loaderToShrink.height = listItemHeight;
140− dragItem.loaderToShrink = null;
141− }
142− }
143− }
144− }
145− }
146−
147− ListItems.ThinDivider {
148− id: dragMarker
149− visible: false
150− anchors {
151− leftMargin: units.gu(1)
152− rightMargin: units.gu(1)
153− }
154− property int index: {
155− var i = Math.round((dragItem.y - list.y + dragItem.height/2) / listItemHeight);
156− if (i < 0) i = 0;
157− if (i >= model.count - 1) i = model.count - 1;
158− return i;
159− }
160− y: list.y + index * listItemHeight + units.gu(1)
161− }
162−
163− ScopesListCategoryItem {
164− id: dragItem
165−
166− property real originalY
167− property int originalIndex
168− property var loaderToShrink: null
169−
170− objectName: "dragItem"
171− visible: false
172− showStar: false
173− width: root.width
174− height: listItemHeight
175− opacity: 0.9
176−
177− onYChanged: {
178− if (!dragMarker.visible && Math.abs(y - originalY) > height / 2) {
179− dragMarker.visible = true;
180− loaderToShrink.height = 0;
181− }
182− }
183− }
184−}
qml/Dash/ScopesListCategoryItem.qmldeleted−115
@@ -1,115 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import QtQuick.Layouts 1.1
19−import Ubuntu.Components 1.3
20−
21−AbstractButton {
22− id: root
23−
24− signal requestFavorite(string scopeId, bool favorite)
25− signal handlePressed(var handle)
26− signal handleReleased(var handle)
27−
28− property real topMargin: 0
29− property alias icon: shapeImage.source
30− property alias text: titleLabel.text
31− property alias subtext: subtitleLabel.text
32−
33− property bool showStar: false
34− property bool isFavorite: false
35− property bool hideChildren: false
36−
37− Item {
38− id: holder
39− anchors.fill: parent
40− anchors.topMargin: root.topMargin
41−
42− UbuntuShape {
43− id: shape
44− anchors {
45− left: parent.left
46− leftMargin: units.gu(1)
47− verticalCenter: parent.verticalCenter
48− }
49− width: units.gu(5)
50− height: units.gu(5)
51− visible: !hideChildren
52− aspect: UbuntuShape.Flat
53− sourceFillMode: UbuntuShape.PreserveAspectCrop
54− source: Image {
55− id: shapeImage
56− cache: true
57− sourceSize { width: shape.width; height: shape.height }
58− }
59− }
60−
61− ColumnLayout {
62− visible: !hideChildren
63− anchors {
64− left: shape.right
65− leftMargin: units.gu(1)
66− right: starArea.left
67− verticalCenter: parent.verticalCenter
68− }
69− Label {
70− id: titleLabel
71− Layout.fillWidth: true
72− elide: Text.ElideRight
73− wrapMode: Text.Wrap
74− maximumLineCount: 1
75− verticalAlignment: Text.AlignHCenter
76− color: scopeStyle ? scopeStyle.foreground : theme.palette.normal.baseText
77− }
78− Label {
79− id: subtitleLabel
80− Layout.fillWidth: true
81− elide: Text.ElideRight
82− fontSize: "xx-small"
83− wrapMode: Text.Wrap
84− maximumLineCount: 1
85− verticalAlignment: Text.AlignHCenter
86− visible: text != ""
87− color: scopeStyle ? scopeStyle.foreground : theme.palette.normal.baseText
88− }
89− }
90− AbstractButton {
91− id: starArea
92− objectName: "starArea"
93− height: parent.height
94− width: height
95− anchors.right: parent.right
96− onClicked: if (!editMode) root.requestFavorite(model.scopeId, !isFavorite);
97− onPressedChanged: {
98− if (editMode) {
99− if (pressed) root.handlePressed(starArea.__mouseArea);
100− else root.handleReleased(starArea.__mouseArea);
101− }
102− }
103− visible: editMode || showStar
104− Icon {
105− id: star
106− anchors.centerIn: parent
107− height: units.gu(2)
108− width: units.gu(2)
109− visible: !hideChildren
110− // TODO is view-grid-symbolic what we really want here? Looks good but seems semantically wrong
111− source: editMode ? "image://theme/view-grid-symbolic" : isFavorite ? "image://theme/starred" : "image://theme/non-starred"
112− }
113− }
114− }
115−}
qml/Dash/graphics/dark_background.jpgdeleted

Binary file not shown.

qml/Dash/graphics/header_handlearrow2@27.pngdeleted

Binary file not shown.

qml/Dash/graphics/header_handlearrow@27.pngdeleted

Binary file not shown.

qml/Dash/graphics/icon_clear@20.pngdeleted

Binary file not shown.

qml/Dash/graphics/icon_search_active@20.pngdeleted

Binary file not shown.

qml/Dash/graphics/icon_search_inactive@20.pngdeleted

Binary file not shown.

qml/Dash/graphics/overview_hint@30.pngdeleted

Binary file not shown.

qml/Dash/graphics/pixel.pngdeleted

Binary file not shown.

qml/Dash/graphics/play_button@18.pngdeleted

Binary file not shown.

qml/Dash/graphics/play_button_active@18.pngdeleted

Binary file not shown.

qml/Dash/graphics/play_button_active_big@20.pngdeleted

Binary file not shown.

qml/Dash/graphics/play_button_big@20.pngdeleted

Binary file not shown.

qml/Dash/graphics/rectangular_dropshadow@30.pngdeleted

Binary file not shown.

qml/Dash/graphics/rectangular_dropshadow@30.scideleted−5
@@ -1,5 +0,0 @@
1−border.left: 30
2−border.top: 30
3−border.bottom: 30
4−border.right: 30
5−source: rectangular_dropshadow@30.png
qml/Dash/graphics/tabbarchevron@27.pngdeleted

Binary file not shown.

qml/Dash/graphics/tablet/icon_close_preview@20.pngdeleted

Binary file not shown.

qml/Dash/graphics/tooltip_arrow@27.pngdeleted

Binary file not shown.

qml/ScopeTool.qmldeleted−165
@@ -1,165 +0,0 @@
1−/*
2−* Copyright (C) 2013 Canonical, Ltd.
3−*
4−* This program is free software; you can redistribute it and/or modify
5−* it under the terms of the GNU 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 General Public License for more details.
12−*
13−* You should have received a copy of the GNU General Public License
14−* along with this program. If not, see <http://www.gnu.org/licenses/>.
15−*/
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import Ubuntu.Components.Popups 1.3
20−import Ubuntu.Thumbnailer 0.1 // Register support for image://thumbnailer/ and image://albumart/
21−import Utils 0.1
22−import Unity 0.2
23−import "Components"
24−import "Dash"
25−
26−Rectangle {
27− id: root
28− width: units.gu(80)
29− height: units.gu(72)
30− color: "#88FFFFFF"
31−
32− // Fake shell object
33− QtObject {
34− id: shell
35− }
36−
37− // Fake greeter object
38− QtObject {
39− id: greeter
40− property bool shown
41− }
42−
43− // Fake panel object
44− QtObject {
45− id: panel
46− signal searchClicked
47− }
48−
49−
50− Rectangle {
51− anchors.fill: dashContent
52− color: "#FCFCFC"
53− }
54−
55− DashContent {
56− id: dashContent
57−
58− property var scope: scopes.getScope(currentIndex)
59− scopes: Scopes { }
60−
61− anchors {
62− top: parent.top
63− bottom: parent.bottom
64− left: parent.left
65− right: controls.left
66− }
67− }
68−
69− Rectangle {
70− id: controls
71− color: "lightgrey"
72− width: units.gu(40)
73− anchors {
74− top: parent.top
75− bottom: parent.bottom
76− right: parent.right
77− }
78−
79− MouseArea {
80− anchors.fill: parent
81− }
82−
83− Column {
84− anchors { fill: parent; margins: units.gu(1) }
85− spacing: units.gu(1)
86−
87− Label {
88− text: "Search query"
89− }
90−
91− TextField {
92− id: searchField
93− anchors { left: parent.left; right: parent.right }
94−
95− onTextChanged: dashContent.scope.searchQuery = text
96−
97− Connections {
98− target: dashContent.scope
99− onSearchQueryChanged: searchField.text = dashContent.scope.searchQuery
100− }
101− }
102−
103− Label {
104− text: "Category"
105− height: units.gu(4)
106− verticalAlignment: Text.AlignBottom
107− }
108−
109− OptionSelector {
110− id: categorySelector
111− anchors { left: parent.left; right: parent.right }
112− model: dashContent.scope ? dashContent.scope.categories : null
113−
114− property Item selectedItem
115−
116− delegate: OptionSelectorDelegate {
117− id: categoryDelegate
118− text: model.name
119− property string categoryId: model.categoryId
120− property string template: JSON.stringify(JSON.parse(model.rawRendererTemplate), null, " ");
121−
122− onSelectedChanged: if (selected) categorySelector.selectedItem = categoryDelegate
123− }
124− }
125−
126− TextArea {
127− id: categoryJson
128− width: parent.width
129− autoSize: true
130− readOnly: true
131− text: categorySelector.selectedItem && categorySelector.selectedItem.template
132− }
133−
134− Button {
135− width: parent.width
136− text: "Override category"
137− onClicked: {
138− PopupUtils.open(categoryEditor)
139− }
140− }
141− }
142− }
143−
144− Component {
145− id: categoryEditor
146−
147− ComposerSheet {
148− id: sheet
149− title: "Editing category definition"
150−
151− TextArea {
152− id: categoryEditorArea
153− anchors.fill: parent
154− wrapMode: Text.WordWrap
155− text: categoryJson.text
156− }
157−
158− onCancelClicked: PopupUtils.close(sheet)
159− onConfirmClicked: {
160− PopupUtils.close(sheet);
161− dashContent.scope.categories.overrideCategoryJson(categorySelector.selectedItem.categoryId, categoryEditorArea.text);
162− }
163− }
164− }
165−}
qml/Shell.qml−6
@@ -40,7 +40,6 @@ import "Tutorial"
4040import "Wizard"
4141import Unity.Notifications 1.0 as NotificationBackend
4242import Unity.Session 0.1
43−import Unity.DashCommunicator 0.1
4443import Unity.Indicators 0.1 as Indicators
4544import Cursor 1.1
4645import WindowManager 1.0
@@ -211,11 +210,6 @@ StyledItem {
211210 id: volumeControl
212211 }
213212
214− DashCommunicator {
215− id: dash
216− objectName: "dashCommunicator"
217− }
218−
219213 PhysicalKeysMapper {
220214 id: physicalKeysMapper
221215 objectName: "physicalKeysMapper"
qml/Stage/AbstractStage.qml−1
@@ -32,7 +32,6 @@ FocusScope {
3232 property real dragProgress // How far left the stage has been dragged, used externally by tutorial code
3333 property bool interactive
3434 property real inverseProgress // This is the progress for left edge drags, in pixels.
35− property bool keepDashRunning: true
3635 property real maximizedAppTopMargin
3736 property real nativeHeight
3837 property real nativeWidth
qml/Stage/PhoneStage.qml+5−22
@@ -136,19 +136,6 @@ AbstractStage {
136136 spreadView.snapTo(priv.indexOf(appId));
137137 }
138138
139− onInverseProgressChanged: {
140− // This can't be a simple binding because that would be triggered after this handler
141− // while we need it active before doing the anition left/right
142− priv.animateX = (inverseProgress == 0)
143− if (inverseProgress == 0 && priv.oldInverseProgress > 0) {
144− // left edge drag released. Minimum distance is given by design.
145− if (priv.oldInverseProgress > units.gu(22)) {
146− applicationManager.requestFocusApplication("unity8-dash");
147− }
148− }
149− priv.oldInverseProgress = inverseProgress;
150− }
151−
152139 // <FIXME-contentX> See rationale in the next comment with this tag
153140 onWidthChanged: {
154141 if (!root.beingResized) {
@@ -222,11 +209,9 @@ AbstractStage {
222209 model: root.applicationManager
223210 delegate: QtObject {
224211 property var stateBinding: Binding {
225− readonly property bool isDash: model.application ? model.application.appId == "unity8-dash" : false
226212 target: model.application
227213 property: "requestedState"
228− value: (isDash && root.keepDashRunning)
229− || (!root.suspended && model.application && priv.focusedAppId === model.application.appId)
214+ value: (!root.suspended && model.application && priv.focusedAppId === model.application.appId)
230215 ? ApplicationInfoInterface.RequestedRunning
231216 : ApplicationInfoInterface.RequestedSuspended
232217 }
@@ -507,8 +492,6 @@ AbstractStage {
507492 focusFirstApp: root.focusFirstApp
508493 highlightShown: root.altTabPressed && index === priv.highlightIndex
509494
510− readonly property bool isDash: model.application.appId == "unity8-dash"
511−
512495 Component.onCompleted: {
513496 // NB: We're differentiating if this delegate was created in response to a new entry in the model
514497 // or if the Repeater is just populating itself with delegates to match the model it received.
@@ -557,17 +540,17 @@ AbstractStage {
557540 }
558541 }
559542
560− z: isDash && !spreadView.active ? -1 : behavioredIndex
543+ z: !spreadView.active ? -1 : behavioredIndex
561544
562545 x: {
563546 // focused app is always positioned at 0 except when following left edge drag
564547 if (isFocused) {
565− if (!isDash && root.inverseProgress > 0 && spreadView.phase === 0) {
548+ if (root.inverseProgress > 0 && spreadView.phase === 0) {
566549 return root.inverseProgress;
567550 }
568551 return 0;
569552 }
570− if (isDash && !spreadView.active && !spreadDragArea.dragging) {
553+ if (!spreadView.active && !spreadDragArea.dragging) {
571554 return 0;
572555 }
573556
@@ -577,7 +560,7 @@ AbstractStage {
577560
578561 application: model.application
579562 surface: model.surface
580− closeable: !isDash
563+ closeable: true
581564
582565 property real behavioredIndex: index
583566 Behavior on behavioredIndex {
qml/Stage/Stage.qml+1−5
@@ -445,7 +445,6 @@ FocusScope {
445445 model: root.applicationManager
446446 delegate: QtObject {
447447 property var stateBinding: Binding {
448− readonly property bool isDash: model.application ? model.application.appId == "unity8-dash" : false
449448 target: model.application
450449 property: "requestedState"
451450
@@ -455,7 +454,6 @@ FocusScope {
455454 // in staged mode, when it switches to Windowed mode it will suddenly
456455 // resume all those apps at once. We might want to avoid that.
457456 value: root.mode === "windowed"
458− || isDash
459457 || (!root.suspended && model.application && priv.focusedAppDelegate &&
460458 (priv.focusedAppDelegate.appId === model.application.appId ||
461459 priv.mainStageAppId === model.application.appId ||
@@ -893,7 +891,6 @@ FocusScope {
893891 readonly property bool dragging: touchControls.overlayShown ? touchControls.dragging : decoratedWindow.dragging
894892
895893 readonly property string appId: model.application.appId
896− readonly property bool isDash: appId == "unity8-dash"
897894 readonly property alias clientAreaItem: decoratedWindow.clientAreaItem
898895
899896 function activate() {
@@ -1128,7 +1125,7 @@ FocusScope {
11281125 function refreshStage() {
11291126 var newStage = ApplicationInfoInterface.MainStage;
11301127 if (priv.sideStageEnabled) { // we're in lanscape rotation.
1131− if (!isDash && application && application.supportedOrientations & (Qt.PortraitOrientation|Qt.InvertedPortraitOrientation)) {
1128+ if (application && application.supportedOrientations & (Qt.PortraitOrientation|Qt.InvertedPortraitOrientation)) {
11321129 var defaultStage = ApplicationInfoInterface.SideStage; // if application supports portrait, it defaults to sidestage.
11331130 if (application.supportedOrientations & (Qt.LandscapeOrientation|Qt.InvertedLandscapeOrientation)) {
11341131 // if it supports lanscape, it defaults to mainstage.
@@ -2111,7 +2108,6 @@ FocusScope {
21112108 // only accept opposite stage.
21122109 Drag.keys: {
21132110 if (!surface) return "Disabled";
2114− if (appDelegate.isDash) return "Disabled";
21152111
21162112 if (appDelegate.stage === ApplicationInfo.MainStage) {
21172113 if (appDelegate.application.supportedOrientations
qml/Stage/TabletStage.qml+5−23
@@ -129,19 +129,6 @@ AbstractStage {
129129 spreadView.contentX = -spreadView.shift;
130130 }
131131
132− onInverseProgressChanged: {
133− // This can't be a simple binding because that would be triggered after this handler
134− // while we need it active before doing the anition left/right
135− spreadView.animateX = (inverseProgress == 0)
136− if (inverseProgress == 0 && priv.oldInverseProgress > 0) {
137− // left edge drag released. Minimum distance is given by design.
138− if (priv.oldInverseProgress > units.gu(22)) {
139− root.applicationManager.requestFocusApplication("unity8-dash");
140− }
141− }
142− priv.oldInverseProgress = inverseProgress;
143− }
144−
145132 onAltTabPressedChanged: {
146133 if (!spreadEnabled) {
147134 return;
@@ -278,16 +265,13 @@ AbstractStage {
278265 model: root.applicationManager
279266 delegate: QtObject {
280267 property var stateBinding: Binding {
281− readonly property bool isDash: model.application ? model.application.appId == "unity8-dash" : false
282268 target: model.application
283269 property: "requestedState"
284270
285271 // NB: the first application clause is just to ensure we never get warnings for trying to access
286272 // members of a null variable.
287273 value: model.application &&
288− (
289− (isDash && root.keepDashRunning)
290− || (!root.suspended && (model.application.appId === priv.mainStageAppId
274+ (!root.suspended && (model.application.appId === priv.mainStageAppId
291275 || model.application.appId === priv.sideStageAppId))
292276 )
293277 ? ApplicationInfoInterface.RequestedRunning
@@ -750,17 +734,16 @@ AbstractStage {
750734 interactive: !spreadView.interactive && spreadView.phase === 0 && root.interactive
751735 swipeToCloseEnabled: spreadView.interactive && !snapAnimation.running
752736 maximizedAppTopMargin: root.maximizedAppTopMargin
753− dragOffset: !isDash && model.id == priv.mainStageItemId && root.inverseProgress > 0
737+ dragOffset: model.id == priv.mainStageItemId && root.inverseProgress > 0
754738 && spreadView.phase === 0 ? root.inverseProgress : 0
755739 application: model.application
756740 surface: model.surface
757− closeable: !isDash
741+ closeable: true
758742 highlightShown: root.altTabPressed && priv.highlightIndex == zIndex
759743 dropShadow: spreadView.active || priv.focusedAppDelegateIsDislocated
760744
761745 readonly property bool wantsMainStage: stage == ApplicationInfoInterface.MainStage
762746
763− readonly property bool isDash: application.appId == "unity8-dash"
764747
765748 onFocusChanged: {
766749 if (focus && !spreadRepeater.startingUp) {
@@ -828,7 +811,7 @@ AbstractStage {
828811 Binding {
829812 target: spreadTile
830813 property: "z"
831− value: (!spreadView.active && isDash && !active) ? -1 : spreadTile.zIndex
814+ value: (!spreadView.active && !active) ? -1 : spreadTile.zIndex
832815 }
833816 x: spreadView.width
834817
@@ -860,7 +843,7 @@ AbstractStage {
860843 function refreshStage() {
861844 var newStage = ApplicationInfoInterface.MainStage;
862845 if (priv.sideStageEnabled) { // we're in lanscape rotation.
863− if (!isDash && application && application.supportedOrientations & (Qt.PortraitOrientation|Qt.InvertedPortraitOrientation)) {
846+ if (application && application.supportedOrientations & (Qt.PortraitOrientation|Qt.InvertedPortraitOrientation)) {
864847 var defaultStage = ApplicationInfoInterface.SideStage; // if application supports portrait, it defaults to sidestage.
865848 if (application.supportedOrientations & (Qt.LandscapeOrientation|Qt.InvertedLandscapeOrientation)) {
866849 // if it supports lanscape, it defaults to mainstage.
@@ -1100,7 +1083,6 @@ AbstractStage {
11001083 // only accept opposite stage.
11011084 Drag.keys: {
11021085 if (!surface) return "Disabled";
1103− if (spreadDelegate.isDash) return "Disabled";
11041086
11051087 if (spreadDelegate.stage === ApplicationInfo.MainStage) {
11061088 if (spreadDelegate.application.supportedOrientations
qml/Stage/TransformedTabletSpreadDelegate.qml+1−2
@@ -143,7 +143,6 @@ SpreadDelegate {
143143 Behavior on xTranslate {
144144 enabled: !spreadView.active &&
145145 !snapAnimation.running &&
146− root.application.appId !== "unity8-dash" &&
147146 spreadView.animateX &&
148147 !spreadView.beingResized &&
149148 priv.state !== "sideStage"
@@ -180,7 +179,7 @@ SpreadDelegate {
180179 newTranslate += linearAnimation(0, spreadView.positionMarker2, 0, -units.gu(4), root.animatedProgress);
181180 }
182181 newTranslate += root.dragOffset;
183− } else if (!spreadView.active && root.application.appId == "unity8-dash") {
182+ } else if (!spreadView.active) {
184183 newTranslate -= root.width;
185184 }
186185
src/CMakeLists.txt−2
@@ -59,5 +59,3 @@ endif()
5959install(TARGETS ${SHELL_APP}
6060 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
6161 )
62−
63−add_subdirectory(Dash)
src/Dash/main.cppdeleted−146
@@ -1,146 +0,0 @@
1−/*
2− * Copyright (C) 2014-2016 Canonical, Ltd.
3− *
4− * Authors:
5− * Michael Zanetti <michael.zanetti@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#include <QtQuick/QQuickView>
21−#include <QtGui/QGuiApplication>
22−#include <QtQml/QQmlEngine>
23−#include <QtQml/QQmlContext>
24−#include <QDebug>
25−#include <QCommandLineParser>
26−#include <QLibrary>
27−#include <libintl.h>
28−#include <QQmlApplicationEngine>
29−#include <QTranslator>
30−#include <QLibraryInfo>
31−#include <QLocale>
32−
33−#include <paths.h>
34−#include "../qmldebuggerutils.h"
35−#ifdef UNITY8_ENABLE_TOUCH_EMULATION
36− #include "../MouseTouchAdaptor.h"
37−#endif
38−#include "../CachingNetworkManagerFactory.h"
39−#include "../UnixSignalHandler.h"
40−
41−int main(int argc, const char *argv[])
42−{
43− qSetMessagePattern("[%{time yyyy-MM-dd:hh:mm:ss.zzz}] %{if-category}%{category}: %{endif}%{message}");
44− if (enableQmlDebugger(argc, argv)) {
45− QQmlDebuggingEnabler qQmlEnableDebuggingHelper(true);
46− }
47−
48− QGuiApplication *application = new QGuiApplication(argc, (char**)argv);
49−
50− QCommandLineParser parser;
51− parser.setApplicationDescription(QStringLiteral("Description: Unity 8 Shell Dash"));
52− parser.addHelpOption();
53−
54− QCommandLineOption mousetouchOption(QStringLiteral("mousetouch"),
55− QStringLiteral("Allow the mouse to provide touch input"));
56− parser.addOption(mousetouchOption);
57−
58− QCommandLineOption windowGeometryOption(QStringList() << QStringLiteral("windowgeometry"),
59− QStringLiteral("Specify the window geometry as [<width>x<height>]"), QStringLiteral("windowgeometry"), QStringLiteral("1"));
60− parser.addOption(windowGeometryOption);
61−
62− // FIXME Remove once we drop the need of the hint
63− QCommandLineOption desktopFileHintOption(QStringLiteral("desktop_file_hint"),
64− QStringLiteral("The desktop_file_hint option for QtMir"), QStringLiteral("hint_file"));
65− parser.addOption(desktopFileHintOption);
66−
67− // Treat args with single dashes the same as arguments with two dashes
68− // Ex: -fullscreen == --fullscreen
69− parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
70− parser.process(*application);
71−
72− if (getenv("QT_LOAD_TESTABILITY")) {
73− QLibrary testLib(QStringLiteral("qttestability"));
74− if (testLib.load()) {
75− typedef void (*TasInitialize)(void);
76− TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
77− if (initFunction) {
78− initFunction();
79− } else {
80− qCritical("Library qttestability resolve failed!");
81− }
82− } else {
83− qCritical("Library qttestability load failed!");
84− }
85− }
86−
87− QTranslator qtTranslator;
88− if (qtTranslator.load(QLocale(), QStringLiteral("qt_"), qgetenv("SNAP"), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
89− application->installTranslator(&qtTranslator);
90− }
91−
92− bindtextdomain("unity8", translationDirectory().toUtf8().data());
93− textdomain("unity8");
94−
95− #ifdef UNITY8_ENABLE_TOUCH_EMULATION
96− // You will need this if you want to interact with touch-only components using a mouse
97− // Needed only when manually testing on a desktop.
98− MouseTouchAdaptor *mouseTouchAdaptor = 0;
99− if (parser.isSet(mousetouchOption)) {
100− mouseTouchAdaptor = MouseTouchAdaptor::instance();
101− }
102− #endif
103−
104− QQmlApplicationEngine *engine = new QQmlApplicationEngine(application);
105−
106− int initialWidth = -1;
107− int initialHeight = -1;
108− if (parser.isSet(windowGeometryOption) &&
109− parser.value(windowGeometryOption).split('x').size() == 2)
110− {
111− QStringList geom = parser.value(windowGeometryOption).split('x');
112− QSize windowSize(geom.at(0).toInt(), geom.at(1).toInt());
113− if (windowSize.isValid()) {
114− initialWidth = windowSize.width();
115− initialHeight = windowSize.height();
116− }
117− }
118− engine->rootContext()->setContextProperty("initialWidth", initialWidth);
119− engine->rootContext()->setContextProperty("initialHeight", initialHeight);
120−
121− QUrl source(::qmlDirectory() + "/Dash/DashApplication.qml");
122− prependImportPaths(engine, ::overrideImportPaths());
123− appendImportPaths(engine, ::fallbackImportPaths());
124−
125− CachingNetworkManagerFactory *managerFactory = new CachingNetworkManagerFactory();
126− engine->setNetworkAccessManagerFactory(managerFactory);
127−
128− engine->load(source);
129−
130− UnixSignalHandler signalHandler([]{
131− QGuiApplication::exit(0);
132− });
133− signalHandler.setupUnixSignalHandlers();
134−
135− int result = application->exec();
136−
137− delete engine;
138−
139− #ifdef UNITY8_ENABLE_TOUCH_EMULATION
140− delete mouseTouchAdaptor;
141− #endif
142−
143− delete application;
144−
145− return result;
146−}
tests/autopilot/unity8/dash.pydeleted−247
@@ -1,247 +0,0 @@
1−# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2−#
3−# Unity Autopilot Test Suite
4−# Copyright (C) 2012, 2013, 2014, 2015 Canonical
5−#
6−# This program is free software: you can redistribute it and/or modify
7−# it under the terms of the GNU General Public License as published by
8−# the Free Software Foundation, either version 3 of the License, or
9−# (at your option) any later version.
10−#
11−# This program is distributed in the hope that it will be useful,
12−# but WITHOUT ANY WARRANTY; without even the implied warranty of
13−# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14−# GNU General Public License for more details.
15−#
16−# You should have received a copy of the GNU General Public License
17−# along with this program. If not, see <http://www.gnu.org/licenses/>.
18−#
19−
20−import logging
21−
22−import ubuntuuitoolkit
23−from autopilot import logging as autopilot_logging
24−from autopilot.introspection import dbus
25−
26−import unity8
27−
28−
29−logger = logging.getLogger(__name__)
30−
31−
32−class DashApp():
33−
34− """Autopilot helper for the Dash app."""
35−
36− def __init__(self, app_proxy):
37− self.app_proxy = app_proxy
38− self.main_view = self.app_proxy.select_single(
39− ubuntuuitoolkit.MainView)
40− self.dash = self.main_view.select_single(Dash)
41−
42−
43−class Dash(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
44− """A helper that understands the Dash."""
45−
46− def __init__(self, *args):
47− super().__init__(*args)
48− self.dash_content_list = self.wait_select_single(
49− 'QQuickListView', objectName='dashContentList')
50−
51− def get_scope(self, scope_name):
52− return self.dash_content_list.wait_select_single(
53− 'QQuickLoader', scopeId=scope_name)
54−
55− def get_scope_by_index(self, scope_index=0):
56− return self.dash_content_list.wait_select_single(
57− 'QQuickLoader', objectName=("scopeLoader%i" % scope_index))
58−
59− @autopilot_logging.log_action(logger.info)
60− def open_scope(self, scope_id):
61− """Open a dash scope.
62−
63− :parameter scope_id: The id of the scope.
64− :return: The scope.
65−
66− """
67− scope_loader = self._get_scope_loader(scope_id)
68− if scope_loader.isCurrent:
69− logger.info('The scope is already open.')
70− return self._get_scope_from_loader(scope_loader)
71− else:
72− return self._open_scope_scrolling(scope_loader)
73−
74− def _get_scope_loader(self, scope_id):
75− try:
76− aux = self.dash_content_list.get_children_by_type('QQuickItem')[0]
77− for l in aux.get_children_by_type('QQuickLoader'):
78− if (l.scopeId == scope_id):
79− return l
80− raise unity8.UnityException(
81− 'No scope found with id {0}'.format(scope_id))
82− except dbus.StateNotFoundError:
83− raise unity8.UnityException(
84− 'No scope found with id {0}'.format(scope_id))
85−
86− def _get_scope_from_loader(self, loader):
87− return loader.wait_select_single('GenericScopeView')
88−
89− def _open_scope_scrolling(self, scope_loader):
90− scroll = self._get_scroll_direction(scope_loader)
91−
92− while not scope_loader.isCurrent:
93− scroll()
94− self.dash_content_list.moving.wait_for(False)
95−
96− scope_loader.isCurrent.wait_for(True)
97− scope = self._get_scope_from_loader(scope_loader)
98− return scope
99−
100− def _get_scroll_direction(self, scope_loader):
101− current_scope_loader = self.dash_content_list.select_single(
102− 'QQuickLoader', isCurrent=True)
103− if scope_loader.globalRect.x < current_scope_loader.globalRect.x:
104− return self._scroll_to_left_scope
105− elif scope_loader.globalRect.x > current_scope_loader.globalRect.x:
106− return self._scroll_to_right_scope
107− else:
108− raise unity8.UnityException('The scope is already open')
109−
110− @autopilot_logging.log_action(logger.info)
111− def _scroll_to_left_scope(self):
112− original_index = self.dash_content_list.currentIndex
113− dash_content = self.select_single(objectName="dashContent")
114− x, y, width, height = dash_content.globalRect
115− # Make the drag range be a multiple of the drag "rate" value.
116− # Workarounds https://bugs.launchpad.net/mir/+bug/1399690
117− rate = 5
118− divisions = 5
119− jump = (width / divisions) // rate * rate
120− start_x = x + jump
121− stop_x = x + jump * (divisions - 1)
122− start_y = stop_y = y + 1
123− self.pointing_device.drag(start_x, start_y, stop_x, stop_y, rate)
124− self.dash_content_list.currentIndex.wait_for(original_index - 1)
125−
126− @autopilot_logging.log_action(logger.info)
127− def _scroll_to_right_scope(self):
128− original_index = self.dash_content_list.currentIndex
129− dash_content = self.select_single(objectName="dashContent")
130− x, y, width, height = dash_content.globalRect
131− # Make the drag range be a multiple of the drag "rate" value.
132− # Workarounds https://bugs.launchpad.net/mir/+bug/1399690
133− rate = 5
134− divisions = 5
135− jump = (width / divisions) // rate * rate
136− start_x = x + jump * (divisions - 1)
137− stop_x = x + jump
138− start_y = stop_y = y + 1
139− self.pointing_device.drag(start_x, start_y, stop_x, stop_y, rate)
140− self.dash_content_list.currentIndex.wait_for(original_index + 1)
141−
142− def enter_search_query(self, query, keyboard):
143− current_header = self._get_current_page_header()
144− search_button = \
145− current_header.select_single(objectName="search_button")
146− self.pointing_device.move(
147− search_button.globalRect.x + search_button.width / 2,
148− search_button.globalRect.y + search_button.height / 2)
149− self.pointing_device.click()
150− headersColumn = current_header.select_single(
151− objectName="headersColumn")
152− headersColumn.y.wait_for(0)
153− keyboard.type(query)
154− self.select_single(
155− objectName="processingIndicator").visible.wait_for(False)
156−
157− def get_search_text_field(self):
158− page_header = self._get_current_page_header()
159− return page_header.select_single(objectName='searchTextField')
160−
161− def _get_current_page_header(self):
162− all_scopes = self.dash_content_list.select_many("GenericScopeView")
163− for i in all_scopes:
164− if i.isCurrent:
165− return i.select_single(objectName="scopePageHeader")
166− return None
167−
168−
169−class ListViewWithPageHeader(ubuntuuitoolkit.QQuickFlickable):
170−
171− margin_to_swipe_from_bottom = ubuntuuitoolkit.units.gu(4)
172−
173−
174−class GenericScopeView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
175− """Autopilot helper for generic scopes."""
176−
177− @autopilot_logging.log_action(logger.info)
178− def open_preview(self, category, app_name, press_duration=0.10):
179− """Open the preview of an application.
180−
181− :parameter category: The name of the category where the application is.
182− :parameter app_name: The name of the application.
183− :return: The opened preview.
184−
185− """
186− # FIXME some categories need a long press in order to see the preview.
187− # Some categories do not show previews, like recent apps.
188− # --elopio - 2014-1-14
189− self.click_scope_item(category, app_name, press_duration)
190− preview_list = self.wait_select_single(
191− 'QQuickLoader', objectName='subPageLoader')
192− preview_list.subPageShown.wait_for(True)
193− preview_list.x.wait_for(0)
194− self.get_root_instance().select_single(
195− objectName='processingIndicator').visible.wait_for(False)
196− return preview_list.select_single(
197− Preview, objectName='preview')
198−
199− @autopilot_logging.log_action(logger.debug)
200− def click_scope_item(self, category, title, press_duration=0.10):
201− """Click an item from the scope.
202−
203− :parameter category: The name of the category where the item is.
204− :parameter title: The title of the item.
205−
206− """
207− category_element = self._get_category_element(category)
208− icon = category_element.wait_select_single(
209− 'UCAbstractButton', title=title)
210− list_view = self.select_single(
211− ListViewWithPageHeader, objectName='categoryListView')
212− list_view.swipe_child_into_view(icon)
213− self.pointing_device.click_object(icon, press_duration=press_duration)
214−
215− def _get_category_element(self, category):
216− try:
217− return self.wait_select_single(
218− 'DashCategoryBase',
219− objectName='dashCategory{}'.format(category))
220− except dbus.StateNotFoundError:
221− raise unity8.UnityException(
222− 'No category found with name {}'.format(category))
223−
224− def get_applications(self, category):
225− """Return the list of applications on a category.
226−
227− :parameter category: The name of the category.
228−
229− """
230− category_element = self._get_category_element(category)
231− see_all = category_element.select_single(objectName='seeAll')
232− application_cards = category_element.select_many('UCAbstractButton')
233−
234− application_cards = sorted(
235− (card for card in application_cards
236− if card.globalRect.y < see_all.globalRect.y),
237− key=lambda card: (card.globalRect.y, card.globalRect.x))
238−
239− result = []
240− for card in application_cards:
241− if card.objectName not in ('cardToolCard', 'seeAll'):
242− result.append(card.title)
243− return result
244−
245−
246−class Preview(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
247− """Autopilot custom proxy object for generic previews."""
tests/autopilot/unity8/shell/fixture_setup.py−26
@@ -28,32 +28,6 @@ import fixtures
2828import unity8
2929
3030
31−class FakeScopes(fixtures.Fixture):
32−
33− def setUp(self):
34− super().setUp()
35− self.useFixture(
36− fixtures.EnvironmentVariable(
37− 'QML2_IMPORT_PATH',
38− newvalue=self._get_fake_scopes_library_path()))
39−
40− def _get_fake_scopes_library_path(self):
41− if unity8.running_installed_tests():
42− mock_path = 'qml/scopefakes/'
43− else:
44− mock_path = os.path.join(
45− '../lib/', sysconfig.get_config_var('MULTIARCH'),
46− 'unity8/qml/scopefakes/')
47− lib_path = unity8.get_lib_path()
48− ld_library_path = os.path.abspath(os.path.join(lib_path, mock_path))
49−
50− if not os.path.exists(ld_library_path):
51− raise RuntimeError(
52− 'Expected library path does not exists: %s.' % (
53− ld_library_path))
54− return ld_library_path
55−
56−
5731class Tutorial(fixtures.Fixture):
5832
5933 def __init__(self, enable):
tests/autopilot/unity8/shell/tests/test_helpers.py−74
@@ -42,77 +42,3 @@ class MainWindowTestCase(tests.UnityTestCase):
4242 super().setUp()
4343 self.launch_unity()
4444 process_helpers.unlock_unity()
45−
46−
47−class DashHelperTestCase(tests.DashBaseTestCase):
48−
49− def test_search(self):
50− self.dash.enter_search_query('Test', self.keyboard)
51− text_field = self.dash.get_search_text_field()
52− self.assertEqual(text_field.text, 'Test')
53−
54− def test_open_scope_to_the_right(self):
55− leftmost_scope = self._get_leftmost_scope_id()
56− self.dash.open_scope(leftmost_scope)
57−
58− scope_id = self._get_rightmost_scope_id()
59− scope = self.dash.open_scope(scope_id)
60− self._assert_scope_is_opened(scope, scope_id)
61−
62− def _assert_scope_is_opened(self, scope, scope_id):
63− self.assertTrue(scope.isCurrent)
64− scope_loader = scope.get_parent()
65− self.assertEqual(scope_loader.scopeId, scope_id)
66−
67− def _get_leftmost_scope_id(self):
68− scope_loaders = self._get_scope_loaders()
69− leftmost_scope_loader = scope_loaders[0]
70− for loader in scope_loaders[1:]:
71− if loader.globalRect.x < leftmost_scope_loader.globalRect.x:
72− leftmost_scope_loader = loader
73− return leftmost_scope_loader.scopeId
74−
75− def _get_scope_loaders(self):
76− item = self.dash.dash_content_list.get_children_by_type(
77− 'QQuickItem')[0]
78− return item.get_children_by_type('QQuickLoader')
79−
80− def _get_rightmost_scope_id(self):
81− scope_loaders = self._get_scope_loaders()
82− rightmost_scope_loader = scope_loaders[0]
83− for loader in scope_loaders[1:]:
84− if loader.globalRect.x > rightmost_scope_loader.globalRect.x:
85− rightmost_scope_loader = loader
86− return rightmost_scope_loader.scopeId
87−
88− def test_open_scope_to_the_left(self):
89− rightmost_scope = self._get_rightmost_scope_id()
90− self.dash.open_scope(rightmost_scope)
91−
92− scope_id = self._get_leftmost_scope_id()
93− scope = self.dash.open_scope(scope_id)
94− self._assert_scope_is_opened(scope, scope_id)
95−
96− def test_open_generic_scope(self):
97− scope_id = 'musicaggregator'
98− scope = self.dash.open_scope(scope_id)
99− self._assert_scope_is_opened(scope, scope_id)
100− self.assertIsInstance(scope, dash_helpers.GenericScopeView)
101−
102−
103−class GenericScopeViewHelperTestCase(tests.DashBaseTestCase):
104−
105− def setUp(self):
106− # Set up the fake scopes before launching unity.
107− self.useFixture(fixture_setup.FakeScopes())
108− super().setUp()
109− self.generic_scope = self.dash.open_scope('MockScope1')
110−
111− def test_open_preview(self):
112− preview = self.generic_scope.open_preview('0', 'Title.0.0')
113− self.assertIsInstance(preview, dash_helpers.Preview)
114−
115− def test_open_preview_of_non_visible_item(self):
116− """Open an item that requires swiping to make it visible."""
117− preview = self.generic_scope.open_preview('2', 'Title.2.0')
118− self.assertIsInstance(preview, dash_helpers.Preview)
tests/mocks/Unity/CMakeLists.txt−72
@@ -5,77 +5,5 @@ add_subdirectory(Indicators)
55add_subdirectory(InputInfo)
66add_subdirectory(Launcher)
77add_subdirectory(Notifications)
8−add_subdirectory(DashCommunicator)
98add_subdirectory(Screens)
109add_subdirectory(Platform)
11−
12−pkg_search_module(GOBJECT gobject-2.0 REQUIRED)
13−pkg_check_modules(SCOPES_API REQUIRED unity-shell-scopes=12)
14−
15−include_directories(
16− ${CMAKE_CURRENT_BINARY_DIR}
17− ${Qt5Core_INCLUDE_DIRS}
18− ${Qt5Quick_INCLUDE_DIRS}
19− ${GOBJECT_INCLUDE_DIRS}
20−)
21−
22−add_definitions(-DQT_NO_KEYWORDS)
23−
24−set(UnityQML_SOURCES
25− fake_scope.cpp
26− fake_scopes.cpp
27− fake_scopesoverview.cpp
28− fake_settingsmodel.cpp
29− fake_categories.cpp
30− fake_navigation.cpp
31− fake_resultsmodel.cpp
32− fake_previewmodel.cpp
33− fake_previewwidgetmodel.cpp
34− fake_filters.cpp
35− fake_optionselectorfilter.cpp
36− fake_optionselectoroptions.cpp
37− fake_rangeinputfilter.cpp
38− fake_valuesliderfilter.cpp
39− fake_expandablefilterwidget.cpp
40− fake_valueslidervalues.cpp
41− fake_unity_plugin.cpp
42− ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/CategoriesInterface.h
43− ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/FilterBaseInterface.h
44− ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/FiltersInterface.h
45− ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/NavigationInterface.h
46− ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/OptionSelectorFilterInterface.h
47− ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/OptionSelectorOptionsInterface.h
48− ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewModelInterface.h
49− ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewWidgetModelInterface.h
50− ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/RangeInputFilterInterface.h
51− ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ResultsModelInterface.h
52− ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ScopeInterface.h
53− ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ScopesInterface.h
54− ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/SettingsModelInterface.h
55− ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ValueSliderFilterInterface.h
56− ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ValueSliderValuesInterface.h
57− ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ExpandableFilterWidgetInterface.h
58−)
59−
60−# Workaround for gcc failure LP: #1417664
61−set_source_files_properties(fake_scopes.cpp PROPERTIES COMPILE_FLAGS -O1)
62−
63−add_library(FakeUnityQml MODULE ${UnityQML_SOURCES})
64−target_link_libraries(FakeUnityQml
65− ${Qt5Core_LIBRARIES}
66− ${Qt5Quick_LIBRARIES}
67− ${GOBJECT_LDFLAGS}
68−)
69−
70−qt5_use_modules(FakeUnityQml Qml)
71−
72−add_unity8_mock(Unity 0.2 Unity TARGETS FakeUnityQml)
73−
74−# and one copy in a separate directory for autopilot
75−add_unity8_mock(Unity 0.2 Unity PREFIX scopefakes TARGETS FakeUnityQml)
76−
77−# Since on build both copy the same file to the same location (not great)
78−# make sure one depends on the other, otherwise when running with make -jX
79−# we can get errors of cp complaining the file has been created while it
80−# was trying to create it
81−add_dependencies(scopefakes-MockUnity-qmlfiles mocks-MockUnity-qmlfiles)
tests/mocks/Unity/DashCommunicator/dashcommunicator.cppdeleted−42
@@ -1,42 +0,0 @@
1−/*
2− * Copyright (C) 2014, 2015 Canonical, Ltd.
3− *
4− * This program is free software: you can redistribute it and/or modify it under
5− * the terms of the GNU Lesser General Public License version 3, as published by
6− * the Free Software Foundation.
7− *
8− * This program is distributed in the hope that it will be useful, but WITHOUT
9− * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10− * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11− * 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 "dashcommunicator.h"
18−
19−#include "dashcommunicatorservice.h"
20−
21−#include <QObject>
22−#include <QDBusConnection>
23−#include <QDBusInterface>
24−#include <QDebug>
25−
26−DashCommunicator::DashCommunicator(QObject *parent):
27− QObject(parent)
28−{
29−}
30−
31−DashCommunicator::~DashCommunicator()
32−{
33−}
34−
35−void DashCommunicator::setCurrentScope(int index, bool animate, bool reset)
36−{
37− Q_EMIT setCurrentScopeCalled(index, animate, reset);
38−
39− if (DashCommunicatorService::theCommunicatorService()) {
40− DashCommunicatorService::theCommunicatorService()->mockSetCurrentScope(index, animate, reset);
41− }
42−}
tests/mocks/Unity/DashCommunicator/dashcommunicator.hdeleted−39
@@ -1,39 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software: you can redistribute it and/or modify it under
5− * the terms of the GNU Lesser General Public License version 3, as published by
6− * the Free Software Foundation.
7− *
8− * This program is distributed in the hope that it will be useful, but WITHOUT
9− * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10− * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11− * 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 DASHCOMMUNICATOR_H
18−#define DASHCOMMUNICATOR_H
19−
20−#include <QObject>
21−
22−class DashCommunicator: public QObject
23−{
24− Q_OBJECT
25− Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.DashCommunicator")
26−
27−public:
28− DashCommunicator(QObject *parent = 0);
29− ~DashCommunicator();
30−
31−public Q_SLOTS:
32− void setCurrentScope(int index, bool animate, bool reset);
33−
34−Q_SIGNALS:
35− // This mock just emits calls back to the QML api for the plugin to verify calls
36− void setCurrentScopeCalled(int index, bool animate, bool reset);
37−};
38−
39−#endif
tests/mocks/Unity/DashCommunicator/dashcommunicatorservice.cppdeleted−46
@@ -1,46 +0,0 @@
1−/*
2− * Copyright (C) 2014, 2015 Canonical, Ltd.
3− *
4− * This program is free software: you can redistribute it and/or modify it under
5− * the terms of the GNU Lesser General Public License version 3, as published by
6− * the Free Software Foundation.
7− *
8− * This program is distributed in the hope that it will be useful, but WITHOUT
9− * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10− * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11− * 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 "dashcommunicatorservice.h"
18−
19−#include <QDebug>
20−
21−DashCommunicatorService *DashCommunicatorService::m_theCommunicatorService = nullptr;
22−
23−DashCommunicatorService::DashCommunicatorService(QObject *parent):
24− QObject(parent)
25−{
26− if (m_theCommunicatorService) {
27− qFatal("There's already a communicator service, this should not happen!");
28− }
29− m_theCommunicatorService = this;
30−}
31−
32−
33−DashCommunicatorService::~DashCommunicatorService()
34−{
35−
36−}
37−
38−DashCommunicatorService *DashCommunicatorService::theCommunicatorService()
39−{
40− return m_theCommunicatorService;
41−}
42−
43−void DashCommunicatorService::mockSetCurrentScope(int index, bool animate, bool isSwipe)
44−{
45− Q_EMIT setCurrentScopeRequested(index, animate, isSwipe);
46−}
tests/mocks/Unity/DashCommunicator/dashcommunicatorservice.hdeleted−41
@@ -1,41 +0,0 @@
1−/*
2− * Copyright (C) 2014, 2015 Canonical, Ltd.
3− *
4− * This program is free software: you can redistribute it and/or modify it under
5− * the terms of the GNU Lesser General Public License version 3, as published by
6− * the Free Software Foundation.
7− *
8− * This program is distributed in the hope that it will be useful, but WITHOUT
9− * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10− * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11− * 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 DASHCOMMUNICATORSERVICE_H
18−#define DASHCOMMUNICATORSERVICE_H
19−
20−#include <QObject>
21−
22−class DashCommunicatorService: public QObject
23−{
24− Q_OBJECT
25−public:
26− DashCommunicatorService(QObject *parent = 0);
27− ~DashCommunicatorService();
28−
29− static DashCommunicatorService *theCommunicatorService();
30−
31−Q_SIGNALS:
32− void setCurrentScopeRequested(int index, bool animate, bool isSwipe);
33−
34−public Q_SLOTS:
35− void mockSetCurrentScope(int index, bool animate, bool isSwipe);
36−
37−private:
38− static DashCommunicatorService *m_theCommunicatorService;
39−};
40−
41−#endif // DBUSUNITYSESSIONSERVICE_H
tests/mocks/Unity/DashCommunicator/plugin.cppdeleted−31
@@ -1,31 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Authors: Michael Zanetti <michael.zanetti@canonical.com>
17− */
18−
19−#include "plugin.h"
20−#include "dashcommunicator.h"
21−#include "dashcommunicatorservice.h"
22−
23−#include <QDBusConnection>
24−#include <QtQml/qqml.h>
25−
26−void DashCommunicatorPlugin::registerTypes(const char *uri)
27−{
28− Q_ASSERT(uri == QStringLiteral("Unity.DashCommunicator"));
29− qmlRegisterType<DashCommunicatorService>(uri, 0, 1, "DashCommunicatorService");
30− qmlRegisterType<DashCommunicator>(uri, 0, 1, "DashCommunicator");
31−}
tests/mocks/Unity/DashCommunicator/plugin.hdeleted−34
@@ -1,34 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Authors: Michael Zanetti <michael.zanetti@canonical.com>
17− */
18−
19−#ifndef DASHCOMMUNICATOR_PLUGIN_H
20−#define DASHCOMMUNICATOR_PLUGIN_H
21−
22−#include <QtQml/QQmlEngine>
23−#include <QtQml/QQmlExtensionPlugin>
24−
25−class DashCommunicatorPlugin : public QQmlExtensionPlugin
26−{
27− Q_OBJECT
28− Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
29−
30−public:
31− void registerTypes(const char *uri) override;
32−};
33−
34−#endif
tests/mocks/Unity/DashCommunicator/qmldirdeleted−3
@@ -1,3 +0,0 @@
1−module Unity.DashCommunicator
2−plugin MockDashCommunicator-qml
3−typeinfo DashCommunicator.qmltypes
tests/mocks/Unity/fake_categories.cppdeleted−165
@@ -1,165 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Author: Nick Dedekind <nick.dedekind@canonical.com>
17− */
18−
19−// self
20−#include "fake_categories.h"
21−
22−#include "fake_resultsmodel.h"
23−
24−Categories::Categories(int category_count, QObject* parent)
25− : unity::shell::scopes::CategoriesInterface(parent)
26− , m_category_count(category_count)
27−{
28−}
29−
30−int Categories::rowCount(const QModelIndex& /*parent*/) const
31−{
32− return m_category_count;
33−}
34−
35−bool Categories::overrideCategoryJson(QString const& /* categoryId */, QString const& /* json */)
36−{
37− qFatal("Using un-implemented Categories::overrideCategoryJson");
38−}
39−
40−QVariant
41−Categories::data(const QModelIndex& index, int role) const
42−{
43− if (!index.isValid()) {
44− return QVariant();
45− }
46−
47− ResultsModel *resultsModel = resultModel(index.row());
48− switch (role) {
49− case RoleCategoryId:
50− if (index.row() == 6) {
51− return QString("predefined");
52− } else if (index.row() == 8) {
53− return QString("local");
54− } else {
55− return QString("%1").arg(index.row());
56− }
57− case RoleName:
58− return QString("Category %1").arg(index.row());
59− case RoleIcon:
60− return "gtk-apply";
61− case RoleRawRendererTemplate:
62− qFatal("Using un-implemented RoleRawRendererTemplate Categories role");
63− return QVariant();
64− case RoleRenderer:
65− {
66− QVariantMap map;
67− if (index.row() % 2 == 0) {
68− map["category-layout"] = "grid";
69− } else {
70− map["category-layout"] = "carousel";
71− }
72− if (index.row() == 16) {
73− map["expandable"] = false;
74− map["collapsed-rows"] = 1;
75− }
76− if (index.row() == 18) {
77− map["category-layout"] = "horizontal-list";
78− }
79− if (index.row() == 19) {
80− map["category-layout"] = "grid";
81− map["collapsed-rows"] = 0;
82− }
83− map["card-size"] = "small";
84−
85− map["category-layout"] = m_layouts.value(index.row(), map["category-layout"].toString());
86−
87− if (map["category-layout"] == "carousel") {
88− map["overlay"] = true;
89− }
90−
91− return map;
92− }
93− case RoleComponents:
94− {
95− QVariantMap map, artMap, attributeMap, socialActionMap;
96− if (index.row() % 2 != 0) {
97− artMap["aspect-ratio"] = QString("1.%1").arg(index.row());
98− } else {
99− artMap["aspect-ratio"] = "1.0";
100− }
101− artMap["field"] = "art";
102− map["art"] = artMap;
103− map["title"] = "HOLA";
104− map["subtitle"] = "HOLA";
105− attributeMap["field"] = "attribute";
106− socialActionMap["icon"] = "icon";
107− socialActionMap["id"] = "socialHola";
108− map["socialActions"] = socialActionMap;
109− map["attributes"] = attributeMap;
110− return map;
111− }
112− case RoleHeaderLink:
113− {
114− QString res;
115− if (index.row() == 1 || index.row() == 4) {
116− res = QString("scope://query/1");
117− }
118− res = m_headerLinks.value(index.row(), res);
119− return res;
120− }
121− case RoleResults:
122− return QVariant::fromValue(resultsModel);
123− case RoleCount:
124− return resultsModel->rowCount();
125− default:
126− qFatal("Using un-implemented Categories role");
127− return QVariant();
128− }
129−}
130−
131−QVariant
132−Categories::data(int row, int role) const
133−{
134− return data(index(row, 0), role);
135−}
136−
137−void Categories::setCount(int count)
138−{
139− if (m_category_count != count) {
140− beginResetModel(); // This is just for test setup so we can be lazy and reset
141− m_category_count = count;
142− endResetModel();
143− }
144−}
145−
146−ResultsModel* Categories::resultModel(int row) const
147−{
148− ResultsModel *result = m_resultsModels[row];
149− if (!result) {
150− Categories *that = const_cast<Categories*>(this);
151− result = new ResultsModel(25, row, that);
152− m_resultsModels[row] = result;
153− }
154− return result;
155−}
156−
157−void Categories::setLayout(int row, const QString &layout)
158−{
159− m_layouts[row] = layout;
160−}
161−
162−void Categories::setHeaderLink(int row, const QString &headerLink)
163−{
164− m_headerLinks[row] = headerLink;
165−}
tests/mocks/Unity/fake_categories.hdeleted−54
@@ -1,54 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef FAKE_CATEGORIES_H
18−#define FAKE_CATEGORIES_H
19−
20−#include <unity/shell/scopes/CategoriesInterface.h>
21−
22−// Qt
23−#include <QList>
24−
25−class ResultsModel;
26−
27−class Categories : public unity::shell::scopes::CategoriesInterface
28−{
29− Q_OBJECT
30−
31−public:
32− Categories(int category_count, QObject* parent = 0);
33−
34− QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
35− int rowCount(const QModelIndex& parent = QModelIndex()) const override;
36−
37− Q_INVOKABLE bool overrideCategoryJson(QString const& categoryId, QString const& json) override;
38−
39− Q_INVOKABLE QVariant data(int row, int role) const;
40−
41− // For testing purposes
42− Q_INVOKABLE void setCount(int count);
43− Q_INVOKABLE ResultsModel* resultModel(int row) const;
44− Q_INVOKABLE void setLayout(int row, const QString &layout);
45− Q_INVOKABLE void setHeaderLink(int row, const QString &headerLink);
46−
47−private:
48− mutable QHash<int, ResultsModel*> m_resultsModels;
49− QHash<int, QString> m_layouts;
50− QHash<int, QString> m_headerLinks;
51− int m_category_count;
52−};
53−
54−#endif // FAKE_CATEGORIES_H
tests/mocks/Unity/fake_expandablefilterwidget.cppdeleted−53
@@ -1,53 +0,0 @@
1−/*
2− * Copyright (C) 2016 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "fake_expandablefilterwidget.h"
18−
19−#include "fake_filters.h"
20−
21−FakeExpandbleFilterWidget::FakeExpandbleFilterWidget(const QString &id, const QString &tag, const QString &title, QObject* parent)
22− : unity::shell::scopes::ExpandableFilterWidgetInterface(parent)
23− , m_filterId(id)
24− , m_filterTag(tag)
25− , m_title(title)
26−{
27− m_filters = new Filters(this);
28−}
29−
30−QString FakeExpandbleFilterWidget::filterId() const
31−{
32− return m_filterId;
33−}
34−
35−QString FakeExpandbleFilterWidget::filterTag() const
36−{
37− return m_filterTag;
38−}
39−
40−QString FakeExpandbleFilterWidget::title() const
41−{
42− return m_title;
43−}
44−
45−unity::shell::scopes::FiltersInterface* FakeExpandbleFilterWidget::filters() const
46−{
47− return m_filters;
48−}
49−
50−void FakeExpandbleFilterWidget::addFilter(unity::shell::scopes::FilterBaseInterface* f)
51−{
52− m_filters->addFilter(f);
53−}
tests/mocks/Unity/fake_expandablefilterwidget.hdeleted−48
@@ -1,48 +0,0 @@
1−/*
2− * Copyright (C) 2016 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef FAKE_EXPANDABLEFILTERWIDGET_H
18−#define FAKE_EXPANDABLEFILTERWIDGET_H
19−
20−#include <unity/shell/scopes/ExpandableFilterWidgetInterface.h>
21−
22−class Filters;
23−
24−class FakeExpandbleFilterWidget : public unity::shell::scopes::ExpandableFilterWidgetInterface
25−{
26− Q_OBJECT
27−
28−public:
29− FakeExpandbleFilterWidget(const QString &id, const QString &tag, const QString &title, QObject* parent);
30−
31− QString filterId() const override;
32− QString filterTag() const override;
33− QString title() const override;
34−
35− unity::shell::scopes::FiltersInterface* filters() const override;
36−
37− // mock API
38− void addFilter(unity::shell::scopes::FilterBaseInterface* f);
39−
40−private:
41− QString m_filterId;
42− QString m_filterTag;
43− QString m_title;
44−
45− Filters *m_filters;
46−};
47−
48−#endif
tests/mocks/Unity/fake_filters.cppdeleted−136
@@ -1,136 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "fake_filters.h"
18−
19−#include "fake_optionselectorfilter.h"
20−#include "fake_rangeinputfilter.h"
21−#include "fake_valuesliderfilter.h"
22−#include "fake_expandablefilterwidget.h"
23−
24−Filters::Filters(QObject* parent)
25− : unity::shell::scopes::FiltersInterface(parent)
26−{
27−}
28−
29−void Filters::addFakeFilters()
30−{
31− addFilter(new FakeOptionSelectorFilter("OSF1", "Tag1", "Which Cake you like More", false, QStringList() << "cheese" << "carrot" << "chocolate", this));
32−
33− FakeRangeInputFilter *rif = new FakeRangeInputFilter("RIF1", "Tag3", this);
34− rif->setTitle("How much do you want to walk?");
35− rif->setCentralLabel("to");
36− rif->setStartPostfixLabel("m");
37− rif->setEndPostfixLabel("m");
38− addFilter(rif);
39−
40− QMap<double, QString> labels;
41− labels[15] = "Default";
42− labels[50] = "50";
43− labels[100] = "100";
44− FakeValueSliderFilter *vsf = new FakeValueSliderFilter("VS1", "Tag4", 15, 10, 150, labels, this);
45− addFilter(vsf);
46−
47− addFilter(new FakeOptionSelectorFilter("OSF2", "Tag2", "Which Countries have you been to?", true, QStringList() << "Germany" << "UK" << "New Zealand", this));
48−
49− auto expandableFilter = new FakeExpandbleFilterWidget("EFW", "Tag5", "Advanced Settings", this);
50− expandableFilter->addFilter(new FakeValueSliderFilter("VS2", "Tag6", 15, 10, 150, labels, this));
51−
52− addFilter(expandableFilter);
53−}
54−
55−void Filters::addFilter(unity::shell::scopes::FilterBaseInterface *f)
56−{
57− switch (f->filterType()) {
58− case FiltersInterface::OptionSelectorFilter: {
59− FakeOptionSelectorFilter *osf = static_cast<FakeOptionSelectorFilter *>(f);
60− connect(osf, &FakeOptionSelectorFilter::isActiveChanged, this, &Filters::activeFiltersCountChanged);
61− }
62− break;
63−
64− case FiltersInterface::RangeInputFilter: {
65− FakeRangeInputFilter *rif = static_cast<FakeRangeInputFilter *>(f);
66− connect(rif, &FakeRangeInputFilter::isActiveChanged, this, &Filters::activeFiltersCountChanged);
67− }
68− break;
69−
70− case FiltersInterface::ExpandableFilterWidget:
71− // Can't be active
72− case FiltersInterface::ValueSliderFilter:
73− // Not counting value as active in the mock
74−
75− case Invalid:
76− break;
77− }
78− m_filters << f;
79−}
80−
81−int Filters::rowCount(const QModelIndex &parent) const
82−{
83− if (parent.isValid())
84− return 0;
85−
86− return m_filters.count();
87−}
88−
89−QVariant Filters::data(const QModelIndex &index, int role) const
90−{
91− const int row = index.row();
92− if (row < 0 || row >= m_filters.count())
93− return QVariant();
94−
95− unity::shell::scopes::FilterBaseInterface *filter = m_filters[row];
96−
97− switch (role) {
98− case RoleFilterId:
99− return filter->filterId();
100− case RoleFilterType:
101− return filter->filterType();
102− case RoleFilter:
103− return QVariant::fromValue<unity::shell::scopes::FilterBaseInterface *>(filter);
104− default:
105− return QVariant();
106− }
107−}
108−
109−int Filters::activeFiltersCount() const
110−{
111− int active = 0;
112− Q_FOREACH(unity::shell::scopes::FilterBaseInterface *f, m_filters) {
113− switch (f->filterType()) {
114− case FiltersInterface::OptionSelectorFilter: {
115− FakeOptionSelectorFilter *osf = static_cast<FakeOptionSelectorFilter *>(f);
116− if (osf->isActive()) ++active;
117− }
118− break;
119−
120− case FiltersInterface::RangeInputFilter: {
121− FakeRangeInputFilter *rif = static_cast<FakeRangeInputFilter *>(f);
122− if (rif->isActive()) ++active;
123− }
124− break;
125−
126− case FiltersInterface::ExpandableFilterWidget:
127− // Can't be active
128− case FiltersInterface::ValueSliderFilter:
129− // Not counting value as active in the mock
130−
131− case Invalid:
132− break;
133− }
134− }
135− return active;
136−}
tests/mocks/Unity/fake_filters.hdeleted−46
@@ -1,46 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef FAKE_FILTERS_H
18−#define FAKE_FILTERS_H
19−
20−#include <unity/shell/scopes/FiltersInterface.h>
21−#include <unity/shell/scopes/FilterBaseInterface.h>
22−
23−class Filters : public unity::shell::scopes::FiltersInterface
24−{
25− Q_OBJECT
26−
27−public:
28− Filters(QObject* parent);
29−
30− int rowCount(const QModelIndex &parent) const override;
31− QVariant data(const QModelIndex &index, int role) const override;
32−
33− // Mock API
34− int activeFiltersCount() const;
35− void addFakeFilters();
36− void addFilter(unity::shell::scopes::FilterBaseInterface* f);
37−
38−Q_SIGNALS:
39− void activeFiltersCountChanged();
40−
41−private:
42−
43− QVector<unity::shell::scopes::FilterBaseInterface*> m_filters;
44−};
45−
46−#endif
tests/mocks/Unity/fake_navigation.cppdeleted−123
@@ -1,123 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "fake_navigation.h"
18−
19−#include "fake_scope.h"
20−
21−#include <QDebug>
22−#include <QTimer>
23−
24−Navigation::Navigation(const QString& navigationId, const QString& label, const QString& allLabel, const QString& parentId, const QString& parentLabel, Scope* scope)
25− : m_navigationId(navigationId)
26− , m_label(label)
27− , m_allLabel(allLabel)
28− , m_parentId(parentId)
29− , m_parentLabel(parentLabel)
30− , m_loaded(false)
31− , m_scope(scope)
32−{
33− QTimer::singleShot(1500, this, &Navigation::slotLoaded);
34− connect(scope, &Scope::currentNavigationIdChanged, this, &Navigation::slotCurrentNavigationChanged);
35−}
36−
37−QString Navigation::navigationId() const
38−{
39− return m_navigationId;
40−}
41−
42−QString Navigation::label() const
43−{
44− return m_label;
45−}
46−
47−QString Navigation::allLabel() const
48−{
49− return m_allLabel;
50−}
51−
52−QString Navigation::parentNavigationId() const
53−{
54− return m_parentId;
55−}
56−
57−QString Navigation::parentLabel() const
58−{
59− return m_parentLabel;
60−}
61−
62−void Navigation::slotLoaded()
63−{
64− m_loaded = true;
65− Q_EMIT loadedChanged();
66−}
67−
68−bool Navigation::loaded() const
69−{
70− return m_loaded;
71−}
72−
73−int Navigation::count() const
74−{
75− return rowCount();
76−}
77−
78−bool Navigation::isRoot() const
79−{
80− return m_navigationId == "root";
81−}
82−
83−bool Navigation::hidden() const
84−{
85− return false;
86−}
87−
88−int Navigation::rowCount(const QModelIndex & /*parent*/) const
89−{
90− if (!m_loaded ||(m_navigationId.startsWith("child") && !m_navigationId.startsWith("childmiddle4")) || m_navigationId == "middle3")
91− return 0;
92− else
93− return 8;
94−}
95−
96−QVariant Navigation::data(const QModelIndex &index, int role) const
97−{
98− switch (role) {
99− case RoleNavigationId:
100− if (m_navigationId == "root")
101− return QString("middle%1").arg(index.row());
102− else if (m_navigationId.startsWith("middle"))
103− return QString("child%1%2").arg(m_navigationId).arg(index.row());
104− else if (m_navigationId.startsWith("childmiddle"))
105− return QString("grandchild%1%2").arg(m_navigationId).arg(index.row());
106− case RoleLabel:
107− return QString("%1Child%2").arg(m_navigationId).arg(index.row());
108− case RoleAllLabel:
109− return QString("all%1Child%2").arg(m_navigationId).arg(index.row());
110− case RoleHasChildren:
111− return (m_navigationId == "root" && index.row() != 3) || (m_navigationId == "middle4");
112− case RoleIsActive:
113− return m_scope->currentNavigationId() == data(index, RoleNavigationId);
114− }
115− return QVariant();
116−}
117−
118−void Navigation::slotCurrentNavigationChanged()
119−{
120− // This is wasteful, should only emit it if really something changed in this
121− // deparment, but this is a mock, so no need to optimize
122− Q_EMIT dataChanged(index(0, 0), index(rowCount() - 1, 0), QVector<int>() << RoleIsActive);
123−}
tests/mocks/Unity/fake_navigation.hdeleted−61
@@ -1,61 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef FAKE_NAVIGATION_H
18−#define FAKE_NAVIGATION_H
19−
20−#include <unity/shell/scopes/NavigationInterface.h>
21−
22−class Scope;
23−
24−class Navigation : public unity::shell::scopes::NavigationInterface
25−{
26− Q_OBJECT
27−
28−public:
29− Navigation(const QString& navigationId, const QString& label, const QString& allLabel, const QString& parentId, const QString& parentLabel, Scope* scope);
30−
31− QString navigationId() const override;
32− QString label() const override;
33− QString allLabel() const override;
34− QString parentNavigationId() const override;
35− QString parentLabel() const override;
36− bool loaded() const override;
37− bool isRoot() const override;
38− bool hidden() const override;
39− int count() const override;
40−
41− int rowCount(const QModelIndex &parent = QModelIndex()) const override;
42− QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
43−
44−public Q_SLOTS:
45− void slotCurrentNavigationChanged();
46−
47−private Q_SLOTS:
48− void slotLoaded();
49−
50−private:
51− QString m_navigationId;
52− QString m_label;
53− QString m_allLabel;
54− QString m_parentId;
55− QString m_parentLabel;
56− bool m_loaded;
57− QString m_currentNavigation;
58− Scope *m_scope;
59−};
60−
61−#endif // FAKE_NAVIGATION_H
tests/mocks/Unity/fake_optionselectorfilter.cppdeleted−70
@@ -1,70 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "fake_optionselectorfilter.h"
18−
19−#include "fake_optionselectoroptions.h"
20−
21−FakeOptionSelectorFilter::FakeOptionSelectorFilter(const QString &id, const QString &tag, const QString &label, bool multiselect, const QStringList &optionLabels, QObject* parent)
22− : unity::shell::scopes::OptionSelectorFilterInterface(parent),
23− m_filterId(id),
24− m_filterTag(tag),
25− m_label(label),
26− m_multiSelect(multiselect)
27−{
28− m_options = new FakeOptionSelectorOptions(optionLabels, this);
29− connect(m_options, &FakeOptionSelectorOptions::anyCheckedChanged, this, &FakeOptionSelectorFilter::isActiveChanged);
30−}
31−
32−QString FakeOptionSelectorFilter::filterId() const
33−{
34− return m_filterId;
35−}
36−
37−QString FakeOptionSelectorFilter::filterTag() const
38−{
39− return m_filterTag;
40−}
41−
42−QString FakeOptionSelectorFilter::title() const
43−{
44− return m_title;
45−}
46−
47−QString FakeOptionSelectorFilter::label() const
48−{
49− return m_label;
50−}
51−
52−bool FakeOptionSelectorFilter::multiSelect() const
53−{
54− return m_multiSelect;
55−}
56−
57−unity::shell::scopes::OptionSelectorOptionsInterface* FakeOptionSelectorFilter::options() const
58−{
59− return m_options;
60−}
61−
62−bool FakeOptionSelectorFilter::isActive() const
63−{
64− return m_options->anyChecked();
65−}
66−
67−void FakeOptionSelectorFilter::clear()
68−{
69− m_options->clear();
70−}
tests/mocks/Unity/fake_optionselectorfilter.hdeleted−54
@@ -1,54 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef FAKE_OPTIONSELECTORFILTER_H
18−#define FAKE_OPTIONSELECTORFILTER_H
19−
20−#include <unity/shell/scopes/OptionSelectorFilterInterface.h>
21−
22−class FakeOptionSelectorOptions;
23−
24−class FakeOptionSelectorFilter : public unity::shell::scopes::OptionSelectorFilterInterface
25−{
26− Q_OBJECT
27−
28−public:
29− FakeOptionSelectorFilter(const QString &id, const QString &tag, const QString &label, bool multiselect, const QStringList &optionLabels, QObject* parent);
30−
31− QString filterId() const override;
32− QString filterTag() const override;
33− QString title() const override;
34− QString label() const override;
35− bool multiSelect() const override;
36− unity::shell::scopes::OptionSelectorOptionsInterface* options() const override;
37−
38− bool isActive() const;
39−
40− void clear();
41−
42−Q_SIGNALS:
43− void isActiveChanged();
44−
45−private:
46− QString m_filterId;
47− QString m_filterTag;
48− QString m_title;
49− QString m_label;
50− bool m_multiSelect;
51− FakeOptionSelectorOptions* m_options;
52−};
53−
54−#endif
tests/mocks/Unity/fake_optionselectoroptions.cppdeleted−90
@@ -1,90 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "fake_optionselectoroptions.h"
18−
19−#include "fake_optionselectorfilter.h"
20−
21−FakeOptionSelectorOptions::FakeOptionSelectorOptions(const QStringList &optionLabels, FakeOptionSelectorFilter* parent)
22− : unity::shell::scopes::OptionSelectorOptionsInterface(parent),
23− m_optionLabels(optionLabels)
24−{
25−}
26−
27−int FakeOptionSelectorOptions::rowCount(const QModelIndex &parent) const
28−{
29− if (parent.isValid())
30− return 0;
31−
32− return m_optionLabels.count();
33−}
34−
35−QVariant FakeOptionSelectorOptions::data(const QModelIndex &index, int role) const
36−{
37− const int row = index.row();
38− if (row < 0 || row >= m_optionLabels.count())
39− return QVariant();
40−
41− switch (role) {
42− case RoleOptionId: {
43− const QString id = static_cast<FakeOptionSelectorFilter*>(parent())->filterId() + QString::number(row);
44− return id;
45− }
46− case RoleOptionLabel:
47− return m_optionLabels[row];
48− case RoleOptionChecked:
49− return m_checkedIndexes.contains(row);
50− default:
51− return QVariant();
52− }
53−
54−}
55−
56−void FakeOptionSelectorOptions::setChecked(int row, bool checked)
57−{
58− if (checked) {
59− if (!static_cast<FakeOptionSelectorFilter*>(parent())->multiSelect()) {
60− if (!m_checkedIndexes.isEmpty()) {
61− setChecked(*m_checkedIndexes.begin(), false);
62− }
63− Q_ASSERT(m_checkedIndexes.isEmpty());
64− }
65− m_checkedIndexes << row;
66− } else {
67− m_checkedIndexes.remove(row);
68− }
69− const QModelIndex idx = index(row, 0);
70− Q_EMIT dataChanged(idx, idx, QVector<int>() << RoleOptionChecked);
71− Q_EMIT anyCheckedChanged();
72−}
73−
74−bool FakeOptionSelectorOptions::anyChecked() const
75−{
76− return !m_checkedIndexes.isEmpty();
77−}
78−
79−void FakeOptionSelectorOptions::clear()
80−{
81− if (!m_checkedIndexes.isEmpty()) {
82− auto checkedIndexes = m_checkedIndexes;
83− m_checkedIndexes.clear();
84− Q_FOREACH(int row, checkedIndexes) {
85− const QModelIndex idx = index(row, 0);
86− Q_EMIT dataChanged(idx, idx, QVector<int>() << RoleOptionChecked);
87− }
88− Q_EMIT anyCheckedChanged();
89− }
90−}
tests/mocks/Unity/fake_optionselectoroptions.hdeleted−49
@@ -1,49 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef FAKE_OPTIONSELECTOROPTIONS_H
18−#define FAKE_OPTIONSELECTOROPTIONS_H
19−
20−#include <unity/shell/scopes/OptionSelectorFilterInterface.h>
21−
22−#include <QSet>
23−
24−class FakeOptionSelectorFilter;
25−
26−class FakeOptionSelectorOptions : public unity::shell::scopes::OptionSelectorOptionsInterface
27−{
28− Q_OBJECT
29−
30−public:
31− FakeOptionSelectorOptions(const QStringList &optionLabels, FakeOptionSelectorFilter* parent);
32−
33− int rowCount(const QModelIndex &parent) const override;
34− QVariant data(const QModelIndex &index, int role) const override;
35− Q_INVOKABLE void setChecked(int index, bool checked) override;
36−
37− bool anyChecked() const;
38−
39− void clear();
40−
41−Q_SIGNALS:
42− void anyCheckedChanged();
43−
44−private:
45− QStringList m_optionLabels;
46− QSet<int> m_checkedIndexes;
47−};
48−
49−#endif
tests/mocks/Unity/fake_previewmodel.cppdeleted−103
@@ -1,103 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * Authors:
5− * Michał Sawicz <michal.sawicz@canonical.com>
6− * Michal Hruby <michal.hruby@canonical.com>
7− *
8− * This program is free software; you can redistribute it and/or modify
9− * it under the terms of the GNU General Public License as published by
10− * the Free Software Foundation; version 3.
11− *
12− * This program is distributed in the hope that it will be useful,
13− * but WITHOUT ANY WARRANTY; without even the implied warranty of
14− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15− * GNU General Public License for more details.
16− *
17− * You should have received a copy of the GNU General Public License
18− * along with this program. If not, see <http://www.gnu.org/licenses/>.
19− */
20−
21−// self
22−#include "fake_previewmodel.h"
23−
24−// local
25−#include "fake_scope.h"
26−#include "fake_scopes.h"
27−#include "fake_previewwidgetmodel.h"
28−
29−// Qt
30−#include <QDebug>
31−
32−PreviewModel::PreviewModel(QObject* parent, Scope* scope)
33− : unity::shell::scopes::PreviewModelInterface(parent)
34− , m_loaded(true)
35− , m_scope(scope)
36−{
37− setWidgetColumnCount(1);
38− connect(this, &PreviewModel::triggered, this, &PreviewModel::triggeredSlot);
39−}
40−
41−void PreviewModel::setWidgetColumnCount(int count)
42−{
43− if (count != widgetColumnCount()) {
44− beginResetModel();
45−
46− m_previewWidgetModels.clear();
47− for (int i = 0; i < count; ++i) {
48− PreviewWidgetModel* columnModel = new PreviewWidgetModel(this);
49− m_previewWidgetModels.append(columnModel);
50− }
51−
52− endResetModel();
53−
54− Q_EMIT widgetColumnCountChanged();
55− }
56−}
57−
58−int PreviewModel::widgetColumnCount() const
59−{
60− return m_previewWidgetModels.size();
61−}
62−
63−bool PreviewModel::loaded() const
64−{
65− return m_loaded;
66−}
67−
68−bool PreviewModel::processingAction() const
69−{
70− return false;
71−}
72−
73−int PreviewModel::rowCount(const QModelIndex&) const
74−{
75− return widgetColumnCount();
76−}
77−
78−QVariant PreviewModel::data(const QModelIndex& index, int role) const
79−{
80− switch (role) {
81− case RoleColumnModel:
82− return QVariant::fromValue(m_previewWidgetModels.at(index.row()));
83− default:
84− return QVariant();
85− }
86−}
87−
88−void PreviewModel::setLoaded(bool loaded)
89−{
90− if (m_loaded != loaded) {
91− m_loaded = loaded;
92− Q_EMIT loadedChanged();
93− }
94−}
95−
96−void PreviewModel::triggeredSlot(QString const&, QString const&, QVariantMap const&) {
97− if (m_scope) {
98− Scopes *scopes = static_cast<Scopes*>(m_scope->parent());
99− Scope* scope = scopes->getScopeFromAll("MockScope9");
100− scopes->addTempScope(scope);
101− Q_EMIT m_scope->openScope(scope);
102− }
103−}
tests/mocks/Unity/fake_previewmodel.hdeleted−58
@@ -1,58 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−
18−#ifndef FAKE_PREVIEWMODEL_H
19−#define FAKE_PREVIEWMODEL_H
20−
21−#include <unity/shell/scopes/PreviewModelInterface.h>
22−
23−#include <QSharedPointer>
24−#include <QVariantMap>
25−
26−class PreviewWidgetModel;
27−
28−class Scope;
29−
30−class PreviewModel : public unity::shell::scopes::PreviewModelInterface
31−{
32− Q_OBJECT
33−
34−public:
35− explicit PreviewModel(QObject* parent = 0, Scope* scope = 0);
36−
37− QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
38− int rowCount(const QModelIndex& parent = QModelIndex()) const override;
39−
40− void setWidgetColumnCount(int count) override;
41− int widgetColumnCount() const override;
42− bool loaded() const override;
43− bool processingAction() const override;
44−
45− Q_INVOKABLE void setLoaded(bool); // Only available for testing
46−
47−private Q_SLOTS:
48− void triggeredSlot(QString const&, QString const&, QVariantMap const&);
49−
50−private:
51− QList<PreviewWidgetModel*> m_previewWidgetModels;
52− bool m_loaded;
53− Scope* m_scope;
54−};
55−
56−Q_DECLARE_METATYPE(PreviewModel*)
57−
58−#endif // FAKE_PREVIEWMODEL_H
tests/mocks/Unity/fake_previewwidgetmodel.cppdeleted−97
@@ -1,97 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * Authors:
5− * Michał Sawicz <michal.sawicz@canonical.com>
6− * Michal Hruby <michal.hruby@canonical.com>
7− *
8− * This program is free software; you can redistribute it and/or modify
9− * it under the terms of the GNU General Public License as published by
10− * the Free Software Foundation; version 3.
11− *
12− * This program is distributed in the hope that it will be useful,
13− * but WITHOUT ANY WARRANTY; without even the implied warranty of
14− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15− * GNU General Public License for more details.
16− *
17− * You should have received a copy of the GNU General Public License
18− * along with this program. If not, see <http://www.gnu.org/licenses/>.
19− */
20−
21−// self
22−#include "fake_previewwidgetmodel.h"
23−
24−// Qt
25−#include <QVariantMap>
26−
27−struct PreviewData
28−{
29− QString id;
30− QString type;
31− QVariantMap data;
32−
33− PreviewData(QString const& id_, QString const& type_, QVariantMap const& data_): id(id_), type(type_), data(data_)
34− {
35− }
36−};
37−
38−PreviewWidgetModel::PreviewWidgetModel(QObject* parent)
39− : unity::shell::scopes::PreviewWidgetModelInterface(parent)
40−{
41− populateWidgets();
42−}
43−
44−void PreviewWidgetModel::populateWidgets()
45−{
46− beginResetModel();
47− m_previewWidgets.clear();
48− for (int i = 0; i <= 20; i++) {
49− // FIXME: the API will expose nicer getters soon, use those!
50− QVariantMap attributes;
51− attributes["text"] = QVariant::fromValue(QString("Widget %1").arg(i));
52− attributes["title"] = QVariant::fromValue(QString("Title %1").arg(i));
53− PreviewData* preview_data = new PreviewData(QString("widget-%1").arg(i), QString("text"), attributes);
54− m_previewWidgets.append(QSharedPointer<PreviewData>(preview_data));
55− }
56−
57− {
58− QVariantMap attributes;
59− attributes["source"] = QVariant("qrc:///Unity/Application/screenshots/browser@12.png");
60− PreviewData* preview_data = new PreviewData(QString("widget-22"), QString("image"), attributes);
61− m_previewWidgets.append(QSharedPointer<PreviewData>(preview_data));
62− }
63−
64− {
65− QVariantMap attributes;
66− QVariantMap buttonData;
67− buttonData["label"] = "Button";
68− buttonData["id"] = "open_click";
69− QVariantList buttons;
70− buttons << buttonData << buttonData << buttonData;
71− attributes["actions"] = QVariant::fromValue(buttons);
72− PreviewData* preview_data = new PreviewData(QString("widget-21"), QString("actions"), attributes);
73− m_previewWidgets.append(QSharedPointer<PreviewData>(preview_data));
74− }
75−
76− endResetModel();
77−}
78−
79−int PreviewWidgetModel::rowCount(const QModelIndex&) const
80−{
81− return m_previewWidgets.size();
82−}
83−
84−QVariant PreviewWidgetModel::data(const QModelIndex& index, int role) const
85−{
86− auto widget_data = m_previewWidgets.at(index.row());
87− switch (role) {
88− case RoleWidgetId:
89− return widget_data->id;
90− case RoleType:
91− return widget_data->type;
92− case RoleProperties:
93− return widget_data->data;
94− default:
95− return QVariant();
96− }
97−}
tests/mocks/Unity/fake_previewwidgetmodel.hdeleted−47
@@ -1,47 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−
18−#ifndef FAKE_PREVIEWWIDGETMODEL_H
19−#define FAKE_PREVIEWWIDGETMODEL_H
20−
21−#include <unity/shell/scopes/PreviewWidgetModelInterface.h>
22−
23−#include <QSharedPointer>
24−#include <QVariantMap>
25−
26−struct PreviewData;
27−
28−class PreviewWidgetModel : public unity::shell::scopes::PreviewWidgetModelInterface
29−{
30− Q_OBJECT
31−
32−public:
33− explicit PreviewWidgetModel(QObject* parent = 0);
34−
35− QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
36− int rowCount(const QModelIndex& parent = QModelIndex()) const override;
37−
38−private:
39− QList<QSharedPointer<PreviewData>> m_previewWidgets;
40−
41− void populateWidgets();
42−
43−};
44−
45−Q_DECLARE_METATYPE(PreviewWidgetModel*)
46−
47−#endif // FAKE_PREVIEWWIDGETMODEL_H
tests/mocks/Unity/fake_rangeinputfilter.cppdeleted−167
@@ -1,167 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "fake_rangeinputfilter.h"
18−
19−FakeRangeInputFilter::FakeRangeInputFilter(const QString &id, const QString &tag, QObject* parent)
20− : unity::shell::scopes::RangeInputFilterInterface(parent),
21− m_filterId(id),
22− m_filterTag(tag),
23− m_hasStartValue(false),
24− m_hasEndValue(false),
25− m_startValue(-1),
26− m_endValue(-1)
27−{
28− connect(this, &FakeRangeInputFilter::hasStartValueChanged, this, &FakeRangeInputFilter::isActiveChanged);
29− connect(this, &FakeRangeInputFilter::hasEndValueChanged, this, &FakeRangeInputFilter::isActiveChanged);
30−}
31−
32−QString FakeRangeInputFilter::filterId() const
33−{
34− return m_filterId;
35−}
36−
37−QString FakeRangeInputFilter::filterTag() const
38−{
39− return m_filterTag;
40−}
41−
42−QString FakeRangeInputFilter::title() const
43−{
44− return m_title;
45−}
46−
47−double FakeRangeInputFilter::startValue() const
48−{
49− return m_startValue;
50−}
51−
52−double FakeRangeInputFilter::endValue() const
53−{
54− return m_endValue;
55−}
56−
57−void FakeRangeInputFilter::setStartValue(double value)
58−{
59− if (m_startValue != value) {
60− m_startValue = value;
61− Q_EMIT startValueChanged();
62− }
63− if (!m_hasStartValue) {
64− m_hasStartValue = true;
65− Q_EMIT hasStartValueChanged();
66− }
67−}
68−
69−void FakeRangeInputFilter::setEndValue(double value)
70−{
71− if (m_endValue != value) {
72− m_endValue = value;
73− Q_EMIT endValueChanged();
74− }
75− if (!m_hasEndValue) {
76− m_hasEndValue = true;
77− Q_EMIT hasEndValueChanged();
78− }
79−}
80−
81−QString FakeRangeInputFilter::startPrefixLabel() const
82−{
83− return m_startPrefixLabel;
84−}
85−
86−QString FakeRangeInputFilter::startPostfixLabel() const
87−{
88− return m_startPostfixLabel;
89−}
90−
91−QString FakeRangeInputFilter::centralLabel() const
92−{
93− return m_centralLabel;
94−}
95−
96−QString FakeRangeInputFilter::endPrefixLabel() const
97−{
98− return m_endPrefixLabel;
99−}
100−
101−QString FakeRangeInputFilter::endPostfixLabel() const
102−{
103− return m_endPostfixLabel;
104−}
105−
106−bool FakeRangeInputFilter::hasStartValue() const
107−{
108− return m_hasStartValue;
109−}
110−
111−bool FakeRangeInputFilter::hasEndValue() const
112−{
113− return m_hasEndValue;
114−}
115−
116−void FakeRangeInputFilter::eraseStartValue()
117−{
118− m_hasStartValue = false;
119− Q_EMIT hasStartValueChanged();
120−}
121−
122−void FakeRangeInputFilter::eraseEndValue()
123−{
124− m_hasEndValue = false;
125− Q_EMIT hasEndValueChanged();
126−}
127−
128−bool FakeRangeInputFilter::isActive() const
129−{
130− return hasStartValue() && hasEndValue();
131−}
132−
133−void FakeRangeInputFilter::setTitle(const QString &title)
134−{
135− m_title = title;
136− Q_EMIT titleChanged();
137−}
138−
139−void FakeRangeInputFilter::setStartPrefixLabel(const QString &startPrefixLabel)
140−{
141− m_startPrefixLabel = startPrefixLabel;
142− Q_EMIT startPrefixLabelChanged();
143−}
144−
145−void FakeRangeInputFilter::setStartPostfixLabel(const QString &startPostfixLabel)
146−{
147− m_startPostfixLabel = startPostfixLabel;
148− Q_EMIT startPostfixLabelChanged();
149−}
150−
151−void FakeRangeInputFilter::setCentralLabel(const QString &centralLabel)
152−{
153− m_centralLabel = centralLabel;
154− Q_EMIT centralLabelChanged();
155−}
156−
157−void FakeRangeInputFilter::setEndPrefixLabel(const QString &endPrefixLabel)
158−{
159− m_endPrefixLabel = endPrefixLabel;
160− Q_EMIT endPrefixLabelChanged();
161−}
162−
163−void FakeRangeInputFilter::setEndPostfixLabel(const QString &endPostfixLabel)
164−{
165− m_endPostfixLabel = endPostfixLabel;
166− Q_EMIT endPostfixLabelChanged();
167−}
tests/mocks/Unity/fake_rangeinputfilter.hdeleted−79
@@ -1,79 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef FAKE_RANGEINPUTFILTER_H
18−#define FAKE_RANGEINPUTFILTER_H
19−
20−#include <unity/shell/scopes/RangeInputFilterInterface.h>
21−
22−class FakeRangeInputFilter : public unity::shell::scopes::RangeInputFilterInterface
23−{
24− Q_OBJECT
25−
26−public:
27− FakeRangeInputFilter(const QString &id, const QString &tag, QObject* parent);
28−
29− QString filterId() const override;
30− QString filterTag() const override;
31− QString title() const override;
32−
33− double startValue() const override;
34− double endValue() const override;
35− void setStartValue(double value) override;
36− void setEndValue(double value) override;
37− QString startPrefixLabel() const override;
38− QString startPostfixLabel() const override;
39− QString centralLabel() const override;
40− QString endPrefixLabel() const override;
41− QString endPostfixLabel() const override;
42− bool hasStartValue() const override;
43− bool hasEndValue() const override;
44−
45− void eraseStartValue() override;
46− void eraseEndValue() override;
47−
48− // Not part of the iface, for mock/testing purposes
49− bool isActive() const;
50−
51− void setTitle(const QString &title);
52− void setStartPrefixLabel(const QString &startPrefixLabel);
53− void setStartPostfixLabel(const QString &startPostfixLabel);
54− void setCentralLabel(const QString &centralLabel);
55− void setEndPrefixLabel(const QString &endPrefixLabel);
56− void setEndPostfixLabel(const QString &endPostfixLabel);
57−
58−Q_SIGNALS:
59− void isActiveChanged();
60−
61−private:
62− QString m_filterId;
63− QString m_filterTag;
64− QString m_title;
65−
66− bool m_hasStartValue;
67− bool m_hasEndValue;
68−
69− double m_startValue;
70− double m_endValue;
71−
72− QString m_startPrefixLabel;
73− QString m_startPostfixLabel;
74− QString m_centralLabel;
75− QString m_endPrefixLabel;
76− QString m_endPostfixLabel;
77−};
78−
79−#endif
tests/mocks/Unity/fake_resultsmodel.cppdeleted−92
@@ -1,92 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Michal Hruby <michal.hruby@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−// self
21−#include "fake_resultsmodel.h"
22−
23−#include <paths.h>
24−
25−ResultsModel::ResultsModel(int result_count, int categoryId, QObject* parent)
26− : unity::shell::scopes::ResultsModelInterface(parent)
27− , m_result_count(result_count)
28− , m_categoryId(categoryId)
29−{
30−}
31−
32−ResultsModel::ResultsModel(QObject *parent)
33− : ResultsModel::ResultsModel(10, 1, parent)
34−{
35−}
36−
37−QString ResultsModel::categoryId() const
38−{
39− return QString::number(m_categoryId);
40−}
41−
42−void ResultsModel::setCategoryId(QString const& /*id*/)
43−{
44− qFatal("Calling un-implemented ResultsModel::setCategoryId");
45−}
46−
47−void ResultsModel::setResultCount(int result_count)
48−{
49− if (m_result_count != result_count) {
50− beginResetModel(); // This is just for test setup so we can be lazy and reset
51− m_result_count = result_count;
52− endResetModel();
53− }
54−}
55−
56−int ResultsModel::rowCount(const QModelIndex& parent) const
57−{
58− Q_UNUSED(parent);
59−
60− return m_result_count;
61−}
62−
63−int ResultsModel::count() const
64−{
65− return rowCount();
66−}
67−
68−QVariant
69−ResultsModel::data(const QModelIndex& index, int role) const
70−{
71− switch (role) {
72− case RoleUri:
73− case RoleCategoryId:
74− case RoleDndUri:
75− case RoleAttributes:
76− case RoleSocialActions:
77− return QString();
78− case RoleResult:
79− return QString("Result.%1.%2").arg(m_categoryId).arg(index.row());
80− case RoleTitle:
81− return QString("Title.%1.%2").arg(m_categoryId).arg(index.row());
82− case RoleArt:
83− return QString("../../../tests/graphics/applicationIcons/dash.png");
84− case RoleSubtitle:
85− return QString("Subtitle.%1.%2").arg(m_categoryId).arg(index.row());
86− case RoleMascot:
87− case RoleEmblem:
88− case RoleSummary:
89− default:
90− return QVariant();
91− }
92−}
tests/mocks/Unity/fake_resultsmodel.hdeleted−52
@@ -1,52 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Michal Hruby <michal.hruby@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−
21−#ifndef FAKE_RESULTS_MODEL_H
22−#define FAKE_RESULTS_MODEL_H
23−
24−#include <unity/shell/scopes/ResultsModelInterface.h>
25−
26−class ResultsModel : public unity::shell::scopes::ResultsModelInterface
27−{
28− Q_OBJECT
29−
30−public:
31− explicit ResultsModel(int result_count, int categoryId, QObject* parent = 0);
32− explicit ResultsModel(QObject* parent = 0);
33−
34− int rowCount(const QModelIndex& parent = QModelIndex()) const override;
35− QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
36−
37− /* getters */
38− QString categoryId() const override;
39− int count() const override;
40−
41− /* setters */
42− void setCategoryId(QString const& id) override;
43−
44− // For testing purposes
45− Q_INVOKABLE void setResultCount(int result_count);
46−
47−private:
48− int m_result_count;
49− int m_categoryId;
50−};
51−
52−#endif // FAKE_RESULTS_MODEL_H
tests/mocks/Unity/fake_scope.cppdeleted−372
@@ -1,372 +0,0 @@
1−/*
2− * Copyright (C) 2013, 2014, 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include <QDebug>
18−#include <QUrl>
19−
20−#include "fake_scope.h"
21−
22−#include "fake_filters.h"
23−#include "fake_navigation.h"
24−#include "fake_optionselectorfilter.h"
25−#include "fake_resultsmodel.h"
26−#include "fake_scopes.h"
27−#include "fake_settingsmodel.h"
28−
29−#include <paths.h> // from unity8/include
30−
31−Scope::Scope(Scopes* parent) : Scope("MockScope5", "Mock Scope", false, parent)
32−{
33−}
34−
35−Scope::Scope(QString const& id, QString const& name, bool favorite, Scopes* parent, int categories, bool returnNullPreview, const QStringList primaryNavigationFilterOptionLabels)
36− : unity::shell::scopes::ScopeInterface(parent)
37− , m_id(id)
38− , m_name(name)
39− , m_searching(false)
40− , m_favorite(favorite)
41− , m_isActive(false)
42− , m_hasBeenActive(false)
43− , m_hasNavigation(true)
44− , m_hasPrimaryFilter(true)
45− , m_currentNavigationId("root")
46− , m_previewRendererName("preview-generic")
47− , m_categories(new Categories(categories, this))
48− , m_openScope(nullptr)
49− , m_settings(new SettingsModel(this))
50− , m_filters(new Filters(this))
51− , m_returnNullPreview(returnNullPreview)
52−{
53− m_primaryNavigationFilter = new FakeOptionSelectorFilter("OSF3", "PFTag", "Which food you like More", false, primaryNavigationFilterOptionLabels, this);
54− m_filters->addFakeFilters();
55− connect(m_filters, &Filters::activeFiltersCountChanged, this, &Scope::activeFiltersCountChanged);
56− connect(m_primaryNavigationFilter, &FakeOptionSelectorFilter::isActiveChanged,
57− this, &unity::shell::scopes::ScopeInterface::primaryNavigationTagChanged);
58−}
59−
60−QString Scope::id() const
61−{
62− return m_id;
63−}
64−
65−QString Scope::name() const
66−{
67− return m_name;
68−}
69−
70−QString Scope::searchQuery() const
71−{
72− return m_searchQuery;
73−}
74−
75−QString Scope::iconHint() const
76−{
77− return m_iconHint;
78−}
79−
80−QString Scope::description() const
81−{
82− return m_description;
83−}
84−
85−QString Scope::searchHint() const
86−{
87− return QString("Search %1").arg(m_name);
88−}
89−
90−QString Scope::shortcut() const
91−{
92− return QString("");
93−}
94−
95−bool Scope::searchInProgress() const
96−{
97− return m_searching;
98−}
99−
100−bool Scope::activationInProgress() const
101−{
102− return false;
103−}
104−
105−bool Scope::favorite() const
106−{
107− return m_favorite;
108−}
109−
110−unity::shell::scopes::CategoriesInterface* Scope::categories() const
111−{
112− return m_hasBeenActive ? m_categories : nullptr;
113−}
114−
115−unity::shell::scopes::SettingsModelInterface* Scope::settings() const
116−{
117− return m_settings;
118−}
119−
120−QString Scope::noResultsHint() const
121−{
122− return m_noResultsHint;
123−}
124−
125−QString Scope::formFactor() const
126−{
127− return m_formFactor;
128−}
129−
130−bool Scope::isActive() const
131−{
132− return m_isActive;
133−}
134−
135−void Scope::setSearchQuery(const QString &str)
136−{
137− if (str != m_searchQuery) {
138− m_searchQuery = str;
139− Q_EMIT searchQueryChanged();
140− }
141−}
142−
143−void Scope::setFormFactor(const QString &str)
144−{
145− if (str != m_formFactor) {
146− m_formFactor = str;
147− Q_EMIT formFactorChanged();
148− }
149−}
150−
151−void Scope::setActive(const bool active)
152−{
153− if (active != m_isActive) {
154− m_isActive = active;
155− Q_EMIT isActiveChanged();
156− }
157− if (active && !m_hasBeenActive) {
158− m_hasBeenActive = true;
159− Q_EMIT categoriesChanged();
160− }
161−}
162−
163−void Scope::setFavorite(const bool favorite)
164−{
165− if (favorite != m_favorite) {
166− m_favorite = favorite;
167− Q_EMIT favoriteChanged();
168− }
169−}
170−
171−void Scope::setId(const QString &id)
172−{
173− if (id != m_id) {
174− m_id = id;
175− Q_EMIT idChanged();
176− }
177−}
178−
179−void Scope::setName(const QString &name)
180−{
181− if (name != m_name) {
182− m_name = name;
183− Q_EMIT nameChanged();
184− }
185−}
186−
187−void Scope::setSearchInProgress(const bool inProg)
188−{
189− if (inProg != m_searching) {
190− m_searching = inProg;
191− Q_EMIT searchInProgressChanged();
192− }
193−}
194−
195−void Scope::setNoResultsHint(const QString& str)
196−{
197− if (str != m_noResultsHint) {
198− m_noResultsHint = str;
199− Q_EMIT noResultsHintChanged();
200− }
201−}
202−
203−void Scope::activate(QVariant const& result, QString const& categoryId)
204−{
205− qDebug() << "Called activate on scope" << m_id << "with result" << result << "and category" << categoryId;
206− if (result.toString() == "Result.2.2") {
207− Scopes *scopes = static_cast<Scopes*>(parent());
208− m_openScope = scopes->getScopeFromAll("MockScope9");
209− scopes->addTempScope(m_openScope);
210− Q_EMIT openScope(m_openScope);
211− } else {
212− Q_EMIT previewRequested(result);
213− }
214−}
215−
216−PreviewModel* Scope::preview(QVariant const& result, QString const& /*categoryId*/)
217−{
218− Q_UNUSED(result);
219−
220− if (m_returnNullPreview) {
221− return nullptr;
222− } else {
223− return new PreviewModel(this, this);
224− }
225−}
226−
227−void Scope::cancelActivation()
228−{
229−}
230−
231−void Scope::closeScope(unity::shell::scopes::ScopeInterface* scope)
232−{
233− Scopes *scopes = dynamic_cast<Scopes*>(parent());
234− if (scopes) {
235− return scopes->closeScope(scope);
236− }
237−}
238−
239−QString Scope::currentNavigationId() const
240−{
241− return m_currentNavigationId;
242−}
243−
244−bool Scope::hasNavigation() const
245−{
246− return m_hasNavigation;
247−}
248−
249−void Scope::setHasNavigation(bool hasNavigation)
250−{
251− m_hasNavigation = hasNavigation;
252− Q_EMIT hasNavigationChanged();
253−}
254−
255−Scope::Status Scope::status() const
256−{
257− return Status::Okay;
258−}
259−
260−QVariantMap Scope::customizations() const
261−{
262− QVariantMap m, h;
263− if (m_id == "clickscope") {
264− h["foreground-color"] = "yellow";
265− m["background-color"] = "red";
266− m["foreground-color"] = "blue";
267− m["page-header"] = h;
268− } else if (m_id == "MockScope4") {
269− h["navigation-background"] = QUrl(testDataDir() + "/qmltests/Dash/artwork/background.png");
270− m["page-header"] = h;
271− } else if (m_id == "MockScope5") {
272− h["background"] = "gradient:///lightgrey/grey";
273− h["logo"] = QUrl(testDataDir() + "/qmltests/Dash/tst_PageHeader/logo-ubuntu-orange.svg");
274− h["divider-color"] = "red";
275− h["navigation-background"] = "color:///black";
276− m["page-header"] = h;
277− } else if (m_id == "MockScope6") {
278− h["navigation-background"] = "gradient:///blue/red";
279− m["page-header"] = h;
280− }
281− return m;
282−}
283−
284−void Scope::refresh()
285−{
286− Q_EMIT refreshed();
287−}
288−
289−void Scope::resetFilters()
290−{
291− qWarning() << "Scope::resetFilters is unimplemented";
292−}
293−
294−void Scope::activateAction(QVariant const& /*result*/, QString const& /*categoryId*/, QString const& /*actionId*/)
295−{
296− qFatal("Using Scope::activateAction");
297−}
298−
299−unity::shell::scopes::NavigationInterface* Scope::getNavigation(const QString& id)
300−{
301− if (id.isEmpty())
302− return nullptr;
303−
304− QString parentId;
305− QString parentLabel;
306− if (id.startsWith("middle")) {
307− parentId = "root";
308− parentLabel = "root";
309− } else if (id.startsWith("child")) {
310− parentId = id.mid(5, 7);
311− parentLabel = parentId;
312− }
313− return new Navigation(id, id, "all"+id, parentId, parentLabel, this);
314−}
315−
316−void Scope::setNavigationState(const QString &navigationId)
317−{
318− m_currentNavigationId = navigationId;
319− Q_EMIT currentNavigationIdChanged();
320− Q_EMIT primaryNavigationTagChanged();
321−}
322−
323−unity::shell::scopes::FilterBaseInterface* Scope::primaryNavigationFilter() const
324−{
325− return m_hasPrimaryFilter ? m_primaryNavigationFilter : nullptr;
326−}
327−
328−unity::shell::scopes::FiltersInterface* Scope::filters() const
329−{
330− return m_filters;
331−}
332−
333−QString Scope::primaryNavigationTag() const
334−{
335− if (m_hasPrimaryFilter && m_primaryNavigationFilter->isActive())
336− return m_primaryNavigationFilter->filterTag();
337− if (m_currentNavigationId == "root")
338− return QString();
339− else
340− return const_cast<Scope*>(this)->getNavigation(m_currentNavigationId)->label();
341−}
342−
343−int Scope::activeFiltersCount() const
344−{
345− return m_filters->activeFiltersCount();
346−}
347−
348−void Scope::resetPrimaryNavigationTag()
349−{
350− if (m_hasPrimaryFilter && m_primaryNavigationFilter->isActive()) {
351− m_primaryNavigationFilter->clear();
352− }
353−
354− if (m_currentNavigationId != "root") {
355− setNavigationState("root");
356− }
357−}
358−
359−void Scope::setHasPrimaryFilter(bool hasPrimaryFilter)
360−{
361− m_hasPrimaryFilter = hasPrimaryFilter;
362− Q_EMIT primaryNavigationFilterChanged();
363−}
364−
365−void Scope::performQuery(const QString& query)
366−{
367− Q_EMIT queryPerformed(query);
368− if (query.startsWith("scopes://")) {
369− QString scopeId = query.mid(9);
370− Q_EMIT gotoScope(scopeId);
371− }
372−}
tests/mocks/Unity/fake_scope.hdeleted−128
@@ -1,128 +0,0 @@
1−/*
2− * Copyright (C) 2013, 2014, 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef FAKE_SCOPE_H
18−#define FAKE_SCOPE_H
19−
20−#include <unity/shell/scopes/ScopeInterface.h>
21−
22−#include "fake_categories.h"
23−#include "fake_previewmodel.h"
24−
25−#include <QTimer>
26−
27−class Filters;
28−class Scopes;
29−class FakeOptionSelectorFilter;
30−
31−class Scope : public unity::shell::scopes::ScopeInterface
32−{
33− Q_OBJECT
34−
35−public:
36− Scope(Scopes* parent = 0);
37− Scope(QString const& id, QString const& name, bool favorite, Scopes* parent = 0, int categories = 20, bool returnNullPreview = false, const QStringList primaryNavigationFilterOptionLabels = QStringList() << "meat" << "vegetables");
38−
39− /* getters */
40− QString id() const override;
41− QString name() const override;
42− QString iconHint() const override;
43− QString description() const override;
44− QString searchHint() const override;
45− QString shortcut() const override;
46− bool searchInProgress() const override;
47− bool activationInProgress() const override;
48− bool favorite() const override;
49− unity::shell::scopes::CategoriesInterface* categories() const override;
50− QString searchQuery() const override;
51− QString noResultsHint() const override;
52− QString formFactor() const override;
53− bool isActive() const override;
54− unity::shell::scopes::SettingsModelInterface* settings() const override;
55−
56− /* setters */
57− void setSearchQuery(const QString& search_query) override;
58− void setNoResultsHint(const QString& hint) override;
59− void setFormFactor(const QString& form_factor) override;
60− void setActive(const bool) override;
61− void setFavorite(const bool) override;
62− Q_INVOKABLE void setId(const QString &id); // This is not invokable in the Interface, here for testing benefits
63− Q_INVOKABLE void setName(const QString &name); // This is not invokable in the Interface, here for testing benefits
64− Q_INVOKABLE void setSearchInProgress(const bool inProg); // This is not invokable in the Interface, here for testing benefits
65−
66− Q_INVOKABLE void activate(QVariant const& result, QString const& categoryId) override;
67− Q_INVOKABLE PreviewModel* preview(QVariant const& result, QString const& categoryId) override;
68− Q_INVOKABLE void cancelActivation() override;
69− Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;
70−
71− QString currentNavigationId() const override;
72− bool hasNavigation() const override;
73− Q_INVOKABLE unity::shell::scopes::NavigationInterface* getNavigation(QString const& navigationId) override;
74− Q_INVOKABLE void setNavigationState(const QString &navigationId) override;
75− Q_INVOKABLE void setHasNavigation(bool hasNavigation); // This is not invokable in the Interface, here for testing benefits
76−
77− unity::shell::scopes::FilterBaseInterface* primaryNavigationFilter() const override;
78− unity::shell::scopes::FiltersInterface* filters() const override;
79− QString primaryNavigationTag() const override;
80− int activeFiltersCount() const override;
81− Q_INVOKABLE void resetPrimaryNavigationTag() override;
82− Q_INVOKABLE void setHasPrimaryFilter(bool hasPrimaryFilter); // This is not invokable in the Interface, here for testing benefits
83−
84− void performQuery(const QString& query) override;
85−
86− Status status() const override;
87− QVariantMap customizations() const override;
88−
89− Q_INVOKABLE void refresh() override;
90−
91− Q_INVOKABLE void resetFilters() override;
92−
93− Q_INVOKABLE void activateAction(QVariant const& result, QString const& categoryId, QString const& actionId) override;
94−
95−Q_SIGNALS:
96− // These are not in the Interface, here for testing benefits
97− void refreshed();
98− void queryPerformed(const QString& query);
99−
100−protected:
101−
102− QString m_id;
103− QString m_iconHint;
104− QString m_description;
105− QString m_name;
106− QString m_searchQuery;
107− QString m_noResultsHint;
108− QString m_formFactor;
109− bool m_searching;
110− bool m_favorite;
111− bool m_isActive;
112− bool m_hasBeenActive;
113− bool m_hasNavigation;
114− bool m_hasPrimaryFilter;
115− QString m_currentNavigationId;
116−
117− QString m_previewRendererName;
118−
119− unity::shell::scopes::CategoriesInterface* m_categories;
120− unity::shell::scopes::ScopeInterface* m_openScope;
121− unity::shell::scopes::SettingsModelInterface* m_settings;
122− Filters* m_filters;
123− FakeOptionSelectorFilter* m_primaryNavigationFilter;
124−
125− bool m_returnNullPreview;
126−};
127−
128−#endif // FAKE_SCOPE_H
tests/mocks/Unity/fake_scopes.cppdeleted−286
@@ -1,286 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Author: Nick Dedekind <nick.dedekind@canonical.com>
17− */
18−
19−// Self
20−#include "fake_scopes.h"
21−#include "fake_scopesoverview.h"
22−
23−// TODO: Implement remaining pieces, like Categories (i.e. LensView now gives warnings)
24−
25−// Qt
26−#include <QDebug>
27−#include <QTimer>
28−
29−Scopes::Scopes(QObject *parent)
30− : unity::shell::scopes::ScopesInterface(parent)
31− , m_scopesOverview(nullptr)
32− , m_loaded(false)
33− , timer(this)
34−{
35− timer.setSingleShot(true);
36− timer.setInterval(100);
37− QObject::connect(&timer, &QTimer::timeout, this, &Scopes::updateScopes);
38−
39− QObject::connect(this, &Scopes::rowsInserted, this, &Scopes::countChanged);
40− QObject::connect(this, &Scopes::rowsRemoved, this, &Scopes::countChanged);
41− QObject::connect(this, &Scopes::modelReset, this, &Scopes::countChanged);
42−
43− load();
44−}
45−
46−Scopes::~Scopes()
47−{
48−}
49−
50−void Scopes::updateScopes()
51−{
52− clear();
53− addScope(new Scope("MockScope1", "People", true, this));
54− addScope(new Scope("MockScope2", "Music", false, this));
55− addScope(new Scope("clickscope", "Apps", true, this));
56− addScope(new Scope("MockScope5", "Videos this is long ab cd ef gh ij kl", true, this));
57− addScope(new Scope("SingleCategoryScope", "Single", true, this, 1));
58− addScope(new Scope("MockScope4", "MS4", true, this));
59− addScope(new Scope("MockScope6", "MS6", true, this));
60− addScope(new Scope("MockScope7", "MS7", false, this));
61− addScope(new Scope("MockScope8", "MS8", false, this));
62− addScope(new Scope("MockScope9", "MS9", false, this));
63−
64− Scope *longNavigationScope = new Scope(
65− "LongPrimaryNavigation", "LongPrimaryNavigation", true, this, 1, false,
66− QStringList() << "Meat" << "Vegetables" << "BBQ" << "Burritos"
67− << "Pasta" << "Pancakes" << "Seafood" << "Soup" << "Bugs"
68− << "Pudding" << "Chocolate" << "Gluten-Free" << "Hamburgers"
69− << "Pho" << "Panang Curry" << "Lumpia" << "Sushi");
70−
71− longNavigationScope->setHasNavigation(false);
72− addScope(longNavigationScope);
73−
74− addScope(new Scope("NullPreviewScope", "NPS", false, this, 1, true));
75−
76− // Add enough scopes to test autoscrolling on the scopes managment page
77− for (int i = 0; i < 20; i++) {
78− addScope(new Scope("UselessScope" + QString::number(i),
79− "US" + QString::number(i), true, this));
80− }
81−
82− m_scopesOverview = new ScopesOverview(this);
83−
84− if (!m_loaded) {
85− m_loaded = true;
86− Q_EMIT loadedChanged();
87− Q_EMIT overviewScopeChanged();
88− }
89−}
90−
91−void Scopes::clear()
92−{
93− timer.stop();
94− if (m_scopes.size() > 0) {
95− beginRemoveRows(QModelIndex(), 0, m_scopes.count()-1);
96− qDeleteAll(m_allScopes);
97− m_allScopes.clear();
98− m_scopes.clear();
99− endRemoveRows();
100− }
101− delete m_scopesOverview;
102− m_scopesOverview = nullptr;
103−
104− if (m_loaded) {
105− m_loaded = false;
106− Q_EMIT loadedChanged();
107− }
108−}
109−
110−void Scopes::clearFavorites()
111−{
112− if (m_scopes.size() > 0) {
113− beginRemoveRows(QModelIndex(), 0, m_scopes.count()-1);
114− Q_FOREACH(Scope *scope, m_scopes) {
115− m_scopesOverview->setFavorite(scope, false);
116− }
117− m_scopes.clear();
118− endRemoveRows();
119− }
120−}
121−
122−void Scopes::load()
123−{
124− timer.start();
125−}
126−
127−int Scopes::rowCount(const QModelIndex&) const
128−{
129− return m_scopes.count();
130−}
131−
132−QVariant Scopes::data(const QModelIndex& index, int role) const
133−{
134− if (!index.isValid() || index.row() >= m_scopes.size()) {
135− return QVariant();
136− }
137−
138− Scope* scope = m_scopes.at(index.row());
139−
140− if (role == Scopes::RoleScope) {
141− return QVariant::fromValue(scope);
142− } else if (role == Scopes::RoleId) {
143− return QVariant::fromValue(scope->id());
144− } else if (role == Scopes::RoleTitle) {
145− return QVariant::fromValue(scope->name());
146− } else {
147− return QVariant();
148− }
149−}
150−
151−unity::shell::scopes::ScopeInterface* Scopes::getScope(int row) const
152−{
153− if (row < 0 || row >= m_scopes.size()) {
154− return nullptr;
155− }
156−
157− return m_scopes[row];
158−}
159−
160−unity::shell::scopes::ScopeInterface* Scopes::getScope(QString const &scope_id) const
161−{
162− // According to mh3 Scopes::getScope should only return favorite scopes (i.e the ones in the model)
163− for (Scope *scope : m_scopes) {
164− if (scope->id() == scope_id)
165− return scope;
166− }
167− return nullptr;
168−}
169−
170−Scope* Scopes::getScopeFromAll(const QString& scope_id) const
171−{
172− for (Scope *scope : m_allScopes) {
173− if (scope->id() == scope_id)
174− return scope;
175− }
176− return nullptr;
177−}
178−
179−QModelIndex Scopes::parent(const QModelIndex&) const
180−{
181− return QModelIndex();
182−}
183−
184−bool Scopes::loaded() const
185−{
186− return m_loaded;
187−}
188−
189−int Scopes::count() const
190−{
191− return rowCount();
192−}
193−
194−unity::shell::scopes::ScopeInterface* Scopes::overviewScope() const
195−{
196− return m_scopesOverview;
197−}
198−
199−void Scopes::addTempScope(unity::shell::scopes::ScopeInterface* scope)
200−{
201− m_tempScopes.insert(scope);
202−}
203−
204−void Scopes::closeScope(unity::shell::scopes::ScopeInterface* scope)
205−{
206− Q_ASSERT(m_tempScopes.contains(scope));
207− m_tempScopes.remove(scope);
208−}
209−
210−void Scopes::setFavorite(const QString& scopeId, bool favorite)
211−{
212− if (favorite) {
213− for (Scope *scope : m_scopes) {
214− // Check it's not already there
215− Q_ASSERT(scope->id() != scopeId);
216− }
217− for (Scope *scope : m_allScopes) {
218− if (scope->id() == scopeId) {
219− const int index = rowCount();
220− beginInsertRows(QModelIndex(), index, index);
221− m_scopes << scope;
222− endInsertRows();
223− m_scopesOverview->setFavorite(scope, true);
224− return;
225− }
226− }
227− Q_ASSERT(false && "Unknown scopeId");
228− } else {
229− for (Scope *scope : m_scopes) {
230− if (scope->id() == scopeId) {
231− const int index = m_scopes.indexOf(scope);
232− beginRemoveRows(QModelIndex(), index, index);
233− m_scopes.removeAt(index);
234− endRemoveRows();
235− m_scopesOverview->setFavorite(scope, false);
236− return;
237− }
238− }
239− Q_ASSERT(false && "Unknown scopeId");
240− }
241−}
242−
243−void Scopes::moveFavoriteTo(const QString& scopeId, int to)
244−{
245− int from = -1;
246− for (int i = 0; i < m_scopes.count(); ++i) {
247− if (m_scopes[i]->id() == scopeId) {
248− from = i;
249− break;
250− }
251− }
252− Q_ASSERT(from != -1);
253− beginMoveRows(QModelIndex(), from, from, QModelIndex(), to + (to > from ? 1 : 0));
254− m_scopes.move(from, to);
255− endMoveRows();
256− m_scopesOverview->moveFavoriteTo(m_scopes[to], to);
257−}
258−
259−QList<Scope*> Scopes::favScopes() const
260−{
261− return m_scopes;
262−}
263−
264−QList<Scope*> Scopes::nonFavScopes() const
265−{
266− QList<Scope*> res;
267− for (Scope *scope : m_allScopes) {
268− if (!m_scopes.contains(scope))
269− res << scope;
270− }
271− return res;
272−}
273−
274−void Scopes::addScope(Scope* scope)
275−{
276− int index = rowCount();
277− if (scope->favorite()) {
278− beginInsertRows(QModelIndex(), index, index);
279− m_scopes.append(scope);
280− endInsertRows();
281− connect(scope, &Scope::favoriteChanged, this, [this, scope]{
282− setFavorite(scope->id(), scope->favorite());
283− });
284− }
285− m_allScopes.append(scope);
286−}
tests/mocks/Unity/fake_scopes.hdeleted−83
@@ -1,83 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Author: Nick Dedekind <nick.dedekind@canonical.com>
17− */
18−
19−#ifndef FAKE_SCOPES_H
20−#define FAKE_SCOPES_H
21−
22−#include <unity/shell/scopes/ScopesInterface.h>
23−
24−// Local
25−#include "fake_scope.h"
26−
27−// Qt
28−#include <QList>
29−#include <QSet>
30−#include <QTimer>
31−
32−class ScopesOverview;
33−
34−class Scopes : public unity::shell::scopes::ScopesInterface
35−{
36− Q_OBJECT
37−
38−public:
39− explicit Scopes(QObject *parent = 0);
40− ~Scopes();
41−
42− Q_INVOKABLE int rowCount(const QModelIndex& parent = QModelIndex()) const override;
43−
44− Q_INVOKABLE unity::shell::scopes::ScopeInterface* getScope(int row) const override;
45− Q_INVOKABLE unity::shell::scopes::ScopeInterface* getScope(const QString& scope_id) const override;
46−
47− Q_INVOKABLE void addScope(Scope* scope);
48−
49− Q_INVOKABLE void clear();
50− Q_INVOKABLE void clearFavorites();
51− Q_INVOKABLE void load();
52−
53− QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
54− QModelIndex parent ( const QModelIndex & index ) const override;
55−
56− bool loaded() const override;
57− int count() const override;
58− unity::shell::scopes::ScopeInterface* overviewScope() const override;
59−
60− Q_INVOKABLE void setFavorite(const QString& scopeId, bool favorite) override;
61− Q_INVOKABLE void moveFavoriteTo(const QString& scopeId, int index) override;
62−
63− void addTempScope(unity::shell::scopes::ScopeInterface* scope);
64− Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;
65−
66− // This is used as part of implementation of the other C++ code, not API
67− QList<Scope*> favScopes() const;
68− QList<Scope*> nonFavScopes() const;
69− Q_INVOKABLE Scope* getScopeFromAll(const QString& scope_id) const;
70−
71−private Q_SLOTS:
72− void updateScopes();
73−
74−private:
75− QList<Scope*> m_scopes; // the favorite ones
76− QList<Scope*> m_allScopes;
77− QSet<unity::shell::scopes::ScopeInterface*> m_tempScopes;
78− ScopesOverview *m_scopesOverview;
79− bool m_loaded;
80− QTimer timer;
81−};
82−
83−#endif // SCOPES_H
tests/mocks/Unity/fake_scopesoverview.cppdeleted−340
@@ -1,340 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "fake_scopesoverview.h"
18−
19−#include "fake_scopes.h"
20−
21−#include <paths.h>
22−
23−ScopesOverview::ScopesOverview(Scopes* parent)
24− : Scope("scopesOverview", "Scopes Overview", false, parent)
25−{
26− delete m_categories; // delete the usual categories, we're not going to use it
27− m_scopesOverviewCategories = new ScopesOverviewCategories(parent, this);
28− m_searchCategories = new ScopesOverviewSearchCategories(parent, this);
29− m_categories = m_scopesOverviewCategories;
30−}
31−
32−void ScopesOverview::setSearchQuery(const QString& search_query)
33−{
34− Scope::setSearchQuery(search_query);
35−
36− auto origCategories = m_categories;
37− if (search_query.isEmpty()) m_categories = m_scopesOverviewCategories;
38− else m_categories = m_searchCategories;
39−
40− if (m_categories != origCategories)
41− Q_EMIT categoriesChanged();
42−}
43−
44−Q_INVOKABLE void ScopesOverview::activate(QVariant const& result, QString const& /*categoryId*/)
45−{
46− Scopes *scopes = static_cast<Scopes*>(parent());
47− if (scopes->getScope(result.toString())) {
48− Q_EMIT gotoScope(result.toString());
49− } else {
50− m_openScope = scopes->getScopeFromAll(result.toString());
51− scopes->addTempScope(m_openScope);
52− Q_EMIT openScope(m_openScope);
53− }
54−}
55−
56−void ScopesOverview::setFavorite(Scope *scope, bool favorite)
57−{
58− m_scopesOverviewCategories->setFavorite(scope, favorite);
59−}
60−
61−void ScopesOverview::moveFavoriteTo(Scope *scope, int index)
62−{
63− m_scopesOverviewCategories->moveFavoriteTo(scope, index);
64−}
65−
66−ScopesOverviewCategories::ScopesOverviewCategories(Scopes *scopes, QObject* parent)
67− : unity::shell::scopes::CategoriesInterface(parent)
68− , m_scopes(scopes)
69−{
70−}
71−
72−int ScopesOverviewCategories::rowCount(const QModelIndex& /*parent*/) const
73−{
74− return 2;
75−}
76−
77−bool ScopesOverviewCategories::overrideCategoryJson(QString const& /* categoryId */, QString const& /* json */)
78−{
79− qFatal("Using un-implemented ScopesOverviewCategories::overrideCategoryJson");
80−}
81−
82−void ScopesOverviewCategories::setFavorite(Scope *scope, bool favorite)
83−{
84− if (m_resultsModels.value(0)) {
85− if (favorite) {
86− m_resultsModels[0]->appendScope(scope);
87− } else {
88− m_resultsModels[0]->removeScope(scope);
89− }
90− }
91− if (m_resultsModels.value(1)) {
92− if (favorite) {
93− m_resultsModels[1]->removeScope(scope);
94− } else {
95− m_resultsModels[1]->appendScope(scope);
96− }
97− }
98−}
99−
100−void ScopesOverviewCategories::moveFavoriteTo(Scope *scope, int index)
101−{
102− m_resultsModels[0]->moveScopeTo(scope, index);
103−}
104−
105−QVariant ScopesOverviewCategories::data(const QModelIndex& index, int role) const
106−{
107− if (!index.isValid()) {
108− return QVariant();
109− }
110−
111− const QString categoryId = index.row() == 0 ? "favorites" : "other";
112−
113− ScopesOverviewResultsModel *resultsModel = m_resultsModels[index.row()];
114− if (!resultsModel) {
115− QObject *that = const_cast<ScopesOverviewCategories*>(this);
116− QList<Scope*> scopes = index.row() == 0 ? m_scopes->favScopes() : m_scopes->nonFavScopes();
117− resultsModel = new ScopesOverviewResultsModel(scopes, categoryId, that);
118− m_resultsModels[index.row()] = resultsModel;
119− }
120− switch (role) {
121− case RoleCategoryId:
122− return categoryId;
123− case RoleName:
124− return index.row() == 0 ? "Favorites" : "Non Favorites";
125− case RoleIcon:
126− return QVariant();
127− case RoleRawRendererTemplate:
128− qFatal("Using un-implemented RoleRawRendererTemplate Categories role");
129− return QVariant();
130− case RoleRenderer:
131− {
132− QVariantMap map;
133− map["category-layout"] = "grid";
134− map["card-size"] = "small";
135− map["overlay"] = true;
136− return map;
137− }
138− case RoleComponents:
139− {
140− QVariantMap map, artMap, attributesMap;
141− artMap["aspect-ratio"] = "0.5";
142− artMap["field"] = "art";
143− map["art"] = artMap;
144− map["title"] = "HOLA";
145− map["attributes"] = attributesMap;
146− return map;
147− }
148− case RoleResults:
149− return QVariant::fromValue(resultsModel);
150− case RoleCount:
151− return resultsModel->rowCount();
152− case RoleHeaderLink:
153− return QString();
154− default:
155− qFatal("Using un-implemented Categories role");
156− return QVariant();
157− }
158−}
159−
160−
161−
162−ScopesOverviewSearchCategories::ScopesOverviewSearchCategories(Scopes *scopes, QObject* parent)
163− : unity::shell::scopes::CategoriesInterface(parent)
164− , m_scopes(scopes)
165−{
166−}
167−
168−int ScopesOverviewSearchCategories::rowCount(const QModelIndex& /*parent*/) const
169−{
170− return 2;
171−}
172−
173−bool ScopesOverviewSearchCategories::overrideCategoryJson(QString const& /* categoryId */, QString const& /* json */)
174−{
175− qFatal("Using un-implemented ScopesOverviewSearchCategories::overrideCategoryJson");
176−}
177−
178−QVariant
179−ScopesOverviewSearchCategories::data(const QModelIndex& index, int role) const
180−{
181− if (!index.isValid()) {
182− return QVariant();
183− }
184−
185− const QString categoryId = index.row() == 0 ? "searchA" : "searchB";
186−
187− ScopesOverviewResultsModel *resultsModel = m_resultsModels[index.row()];
188− if (!resultsModel) {
189− QObject *that = const_cast<ScopesOverviewSearchCategories*>(this);
190− QList<Scope *> scopes;
191− if (index.row() == 0) {
192− scopes << m_scopes->getScopeFromAll("clickscope") << nullptr << m_scopes->getScopeFromAll("MockScope2");
193− } else {
194− scopes << nullptr << m_scopes->getScopeFromAll("MockScope7") << nullptr << m_scopes->getScopeFromAll("MockScope1");
195− }
196− resultsModel = new ScopesOverviewResultsModel(scopes, categoryId, that);
197− m_resultsModels[index.row()] = resultsModel;
198− }
199− switch (role) {
200− case RoleCategoryId:
201− return categoryId;
202− case RoleName:
203− return index.row() == 0 ? "SearchA" : "SearchB";
204− case RoleIcon:
205− return QVariant();
206− case RoleRawRendererTemplate:
207− qFatal("Using un-implemented RoleRawRendererTemplate Categories role");
208− return QVariant();
209− case RoleRenderer:
210− {
211− QVariantMap map;
212− map["category-layout"] = "grid";
213− map["card-size"] = "small";
214− map["overlay"] = true;
215− return map;
216− }
217− case RoleComponents:
218− {
219− QVariantMap map, artMap, attributesMap;
220− artMap["aspect-ratio"] = "1";
221− artMap["field"] = "art";
222− map["art"] = artMap;
223− map["title"] = "HOLA";
224− map["attributes"] = attributesMap;
225− return map;
226− }
227− case RoleResults:
228− return QVariant::fromValue(resultsModel);
229− case RoleCount:
230− return resultsModel->rowCount();
231− case RoleHeaderLink:
232− return QString();
233− default:
234− qFatal("Using un-implemented Categories role");
235− return QVariant();
236− }
237−}
238−
239−
240−ScopesOverviewResultsModel::ScopesOverviewResultsModel(const QList<Scope *> &scopes, const QString &categoryId, QObject* parent)
241− : unity::shell::scopes::ResultsModelInterface(parent)
242− , m_scopes(scopes)
243− , m_categoryId(categoryId)
244−{
245−}
246−
247−QString ScopesOverviewResultsModel::categoryId() const
248−{
249− return m_categoryId;
250−}
251−
252−void ScopesOverviewResultsModel::setCategoryId(QString const& /*id*/)
253−{
254− qFatal("Calling un-implemented ScopesOverviewResultsModel::setCategoryId");
255−}
256−
257−int ScopesOverviewResultsModel::scopeIndex(QString const& id) const
258−{
259− const int scopeCount = count();
260− for (int i = 0; i < scopeCount; ++i) {
261− if (m_scopes[i]->id() == id)
262− return i;
263− }
264− return -1;
265−}
266−
267−QHash<int, QByteArray> ScopesOverviewResultsModel::roleNames() const
268−{
269− QHash<int, QByteArray> roles = unity::shell::scopes::ResultsModelInterface::roleNames();
270− roles[RoleBackground + 1] = "scopeId";
271− return roles;
272−}
273−
274−int ScopesOverviewResultsModel::rowCount(const QModelIndex& parent) const
275−{
276− Q_UNUSED(parent);
277−
278− return m_scopes.count();
279−}
280−
281−int ScopesOverviewResultsModel::count() const
282−{
283− return rowCount();
284−}
285−
286−QVariant ScopesOverviewResultsModel::data(const QModelIndex& index, int role) const
287−{
288− unity::shell::scopes::ScopeInterface *scope = m_scopes[index.row()];
289− switch (role) {
290− case RoleUri:
291− case RoleCategoryId:
292− case RoleDndUri:
293− return QString();
294− case RoleResult:
295− return scope ? scope->id() : QString("Result.%1.%2").arg(categoryId()).arg(index.row());
296− case RoleTitle:
297− return scope ? scope->name() : QString("Title.%1.%2").arg(categoryId()).arg(index.row());
298− case RoleSubtitle:
299− return scope && scope->name() == "Videos this is long ab cd ef gh ij kl" ? "tube, movies, cinema, pictures, art, moving images, magic in a box" : QString();
300− case RoleArt:
301− return QString("../../tests/graphics/applicationIcons/dash.png");
302− case RoleMascot:
303− case RoleEmblem:
304− case RoleSummary:
305− case RoleBackground + 1: // scopeId
306− return scope ? scope->id() : nullptr;
307− break;
308− default:
309− return QVariant();
310− }
311−}
312−
313−void ScopesOverviewResultsModel::appendScope(Scope *scope)
314−{
315− Q_ASSERT(!m_scopes.contains(scope));
316− const int index = rowCount();
317− beginInsertRows(QModelIndex(), index, index);
318− m_scopes << scope;
319− endInsertRows();
320− Q_EMIT countChanged();
321−}
322−
323−void ScopesOverviewResultsModel::removeScope(Scope *scope)
324−{
325− const int index = m_scopes.indexOf(scope);
326− Q_ASSERT(index != -1);
327− beginRemoveRows(QModelIndex(), index, index);
328− m_scopes.removeAt(index);
329− endRemoveRows();
330− Q_EMIT countChanged();
331−}
332−
333−void ScopesOverviewResultsModel::moveScopeTo(Scope *scope, int to)
334−{
335− const int from = m_scopes.indexOf(scope);
336− Q_ASSERT(from!= -1);
337− beginMoveRows(QModelIndex(), from, from, QModelIndex(), to + (to > from ? 1 : 0));
338− m_scopes.move(from, to);
339− endMoveRows();
340−}
tests/mocks/Unity/fake_scopesoverview.hdeleted−119
@@ -1,119 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef FAKE_SCOPESOVERVIEW_H
18−#define FAKE_SCOPESOVERVIEW_H
19−
20−#include "fake_scope.h"
21−#include <unity/shell/scopes/ResultsModelInterface.h>
22−
23−class Scopes;
24−class ScopesOverviewCategories;
25−class ScopesOverviewResultsModel;
26−
27−class ScopesOverview : public Scope
28−{
29− Q_OBJECT
30−
31−public:
32− ScopesOverview(Scopes* parent = 0);
33−
34− void setSearchQuery(const QString& search_query) override;
35− Q_INVOKABLE void activate(QVariant const& result, QString const& categoryId) override;
36−
37− using Scope::setFavorite;
38−
39− // This is implementation detail
40− void setFavorite(Scope *scope, bool favorite);
41− void moveFavoriteTo(Scope *scope, int index);
42−
43−private:
44− ScopesOverviewCategories *m_scopesOverviewCategories;
45− unity::shell::scopes::CategoriesInterface *m_searchCategories;
46−};
47−
48−class ScopesOverviewCategories : public unity::shell::scopes::CategoriesInterface
49−{
50− Q_OBJECT
51−
52−public:
53− ScopesOverviewCategories(Scopes *scopes, QObject* parent = 0);
54−
55− QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
56− int rowCount(const QModelIndex& parent = QModelIndex()) const override;
57−
58− Q_INVOKABLE bool overrideCategoryJson(QString const& categoryId, QString const& json) override;
59−
60− // This is implementation detail
61− void setFavorite(Scope *scope, bool favorite);
62− void moveFavoriteTo(Scope *scope, int index);
63−
64−private:
65− mutable QHash<int, ScopesOverviewResultsModel*> m_resultsModels;
66−
67− Scopes *m_scopes;
68−};
69−
70−class ScopesOverviewSearchCategories : public unity::shell::scopes::CategoriesInterface
71−{
72− Q_OBJECT
73−
74−public:
75− ScopesOverviewSearchCategories(Scopes *scopes, QObject* parent = 0);
76−
77− QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
78− int rowCount(const QModelIndex& parent = QModelIndex()) const override;
79−
80− Q_INVOKABLE bool overrideCategoryJson(QString const& categoryId, QString const& json) override;
81−
82−private:
83− mutable QHash<int, ScopesOverviewResultsModel*> m_resultsModels;
84−
85− Scopes *m_scopes;
86−};
87−
88−class ScopesOverviewResultsModel : public unity::shell::scopes::ResultsModelInterface
89−{
90− Q_OBJECT
91−
92−public:
93− explicit ScopesOverviewResultsModel(const QList<Scope *> &scopes, const QString &categoryId, QObject* parent = 0);
94−
95− int rowCount(const QModelIndex& parent = QModelIndex()) const override;
96− QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
97−
98− /* getters */
99− QString categoryId() const override;
100− int count() const override;
101−
102− /* setters */
103− void setCategoryId(QString const& id) override;
104−
105− /* Special API */
106− Q_INVOKABLE int scopeIndex(QString const& id) const;
107− QHash<int, QByteArray> roleNames() const override;
108−
109− // This is implementation detail
110− void appendScope(Scope *scope);
111− void removeScope(Scope *scope);
112− void moveScopeTo(Scope *scope, int index);
113−
114−private:
115− QList<Scope *> m_scopes;
116− QString m_categoryId;
117−};
118−
119−#endif // FAKE_SCOPESOVERVIEW_H
tests/mocks/Unity/fake_settingsmodel.cppdeleted−95
@@ -1,95 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "fake_settingsmodel.h"
18−
19−SettingsModel::SettingsModel(QObject* parent) :
20− SettingsModelInterface(parent) {
21− {
22− QVariantMap parameters;
23− m_data << QSharedPointer<Data>(new Data("boolean-setting", "Boolean Setting", "boolean", parameters, true));
24− }
25− {
26− QVariantMap parameters;
27− parameters["values"] = QVariantList() << "First" << "Second" << "Third";
28− m_data << QSharedPointer<Data>(new Data("list-setting", "List Setting", "list", parameters, 1));
29− }
30− {
31− QVariantMap parameters;
32− m_data << QSharedPointer<Data>(new Data("number-setting", "Number Setting", "number", parameters, 1.23));
33− }
34− {
35− QVariantMap parameters;
36− m_data << QSharedPointer<Data>(new Data("string-setting", "String Setting", "string", parameters, "flibble"));
37− }
38−}
39−
40−QVariant SettingsModel::data(const QModelIndex& index, int role) const {
41− int row = index.row();
42− QVariant result;
43−
44− if (row < m_data.size()) {
45− auto data = m_data[row];
46−
47− switch (role) {
48− case Roles::RoleSettingId:
49− result = data->id;
50− break;
51− case Roles::RoleDisplayName:
52− result = data->displayName;
53− break;
54− case Roles::RoleType:
55− result = data->type;
56− break;
57− case Roles::RoleProperties:
58− result = data->properties;
59− break;
60− case Roles::RoleValue: {
61− result = data->value;
62− break;
63− }
64− default:
65− break;
66− }
67− }
68−
69− return result;
70−}
71−
72−bool SettingsModel::setData(const QModelIndex &index, const QVariant &value, int role) {
73− int row = index.row();
74− if (row < m_data.size()) {
75− switch (role) {
76− case SettingsModelInterface::RoleValue: {
77− auto data = m_data[row];
78− data->value = value;
79− return true;
80− }
81− default:
82− break;
83− }
84− }
85−
86− return false;
87−}
88−
89−int SettingsModel::rowCount(const QModelIndex&) const {
90− return count();
91−}
92−
93−int SettingsModel::count() const {
94− return m_data.size();
95−}
tests/mocks/Unity/fake_settingsmodel.hdeleted−54
@@ -1,54 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef FAKE_SETTINGSMODEL_H
18−#define FAKE_SETTINGSMODEL_H
19−
20−#include <unity/shell/scopes/SettingsModelInterface.h>
21−
22−#include <QList>
23−#include <QSharedPointer>
24−
25−class SettingsModel: public unity::shell::scopes::SettingsModelInterface {
26−Q_OBJECT
27−
28− struct Data {
29− QString id;
30− QString displayName;
31− QString type;
32− QVariant properties;
33− QVariant value;
34−
35− Data(QString const& id_, QString const& displayName_,
36− QString const& type_, QVariant const& properties_,
37− QVariant const& value_) :
38− id(id_), displayName(displayName_), type(type_),
39− properties(properties_), value(value_) {}
40− };
41−
42−public:
43− explicit SettingsModel(QObject* parent = 0);
44− ~SettingsModel() = default;
45− QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
46− bool setData(const QModelIndex&index, const QVariant& value, int role = Qt::EditRole) override;
47− int rowCount(const QModelIndex& parent = QModelIndex()) const override;
48− int count() const override;
49−
50−protected:
51− QList<QSharedPointer<Data>> m_data;
52−};
53−
54−#endif // FAKE_SETTINGSMODEL_H
tests/mocks/Unity/fake_unity_plugin.cppdeleted−62
@@ -1,62 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Author: Nick Dedekind <nick.dedekind@canonical.com>
17− */
18−
19−// Self
20−#include "fake_unity_plugin.h"
21−
22−// local
23−#include "fake_scopes.h"
24−#include "fake_categories.h"
25−#include "fake_filters.h"
26−#include "fake_navigation.h"
27−#include "fake_optionselectoroptions.h"
28−#include "fake_previewmodel.h"
29−#include "fake_previewwidgetmodel.h"
30−#include "fake_resultsmodel.h"
31−#include "fake_settingsmodel.h"
32−#include "fake_valueslidervalues.h"
33−
34−// External
35−#include <glib-object.h>
36−
37−#include <QtQml/qqml.h>
38−
39−void FakeUnityPlugin::registerTypes(const char *uri)
40−{
41−#ifndef GLIB_VERSION_2_36
42− g_type_init();
43−#endif
44−
45− Q_ASSERT(uri == QLatin1String("Unity"));
46−
47− qmlRegisterType<Scopes>(uri, 0, 2, "Scopes");
48− qmlRegisterType<Scope>(uri, 0, 2, "MockScope");
49− qmlRegisterUncreatableType<unity::shell::scopes::ScopeInterface>(uri, 0, 2, "Scope", "Can't create Scope object in QML.");
50− qmlRegisterUncreatableType<unity::shell::scopes::SettingsModelInterface>(uri, 0, 2, "SettingsModel", "Can't create SettingsModel object in QML.");
51− qmlRegisterUncreatableType<unity::shell::scopes::NavigationInterface>(uri, 0, 2, "Navigation", "Can't create Navigation object in QML.");
52− qmlRegisterUncreatableType<unity::shell::scopes::CategoriesInterface>(uri, 0, 2, "Categories", "Can't create Categories object in QML.");
53− qmlRegisterUncreatableType<unity::shell::scopes::PreviewModelInterface>(uri, 0, 2, "PreviewModel", "Can't create new PreviewModel in QML. Get them from Scope instance.");
54− qmlRegisterUncreatableType<ResultsModel>(uri, 0, 2, "ResultsModel", "Can't create ResultsModel object in QML.");
55− qmlRegisterType<ResultsModel>(uri, 0, 2, "FakeResultsModel");
56− qmlRegisterType<PreviewModel>(uri, 0, 2, "FakePreviewModel");
57− qmlRegisterUncreatableType<PreviewWidgetModel>(uri, 0, 2, "PreviewWidgetModel", "Can't create new PreviewWidgetModel in QML. Get them from PreviewModel instance.");
58− qmlRegisterUncreatableType<unity::shell::scopes::FiltersInterface>(uri, 0, 2, "Filters", "Can't create Filters object in QML. Get them from Scope instance.");
59− qmlRegisterUncreatableType<unity::shell::scopes::FilterBaseInterface>(uri, 0, 2, "Filter", "Can't create Filter object in QML. Get them from Scope instance.");
60− qmlRegisterUncreatableType<unity::shell::scopes::OptionSelectorOptionsInterface>(uri, 0, 2, "OptionSelectorOptions", "Can't create OptionSelectorOptions object in QML");
61− qmlRegisterUncreatableType<unity::shell::scopes::ValueSliderValuesInterface>(uri, 0, 2, "ValueSliderValues", "Can't create ValueSliderValuesInterface object in QML");
62−}
tests/mocks/Unity/fake_unity_plugin.hdeleted−34
@@ -1,34 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Author: Nick Dedekind <nick.dedekind@canonical.com>
17− */
18−
19−#ifndef FAKE_UNITY_PLUGIN_H
20−#define FAKE_UNITY_PLUGIN_H
21−
22−// Qt
23−#include <QtQml/QQmlExtensionPlugin>
24−
25−class FakeUnityPlugin : public QQmlExtensionPlugin
26−{
27− Q_OBJECT
28− Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
29−
30−public:
31− void registerTypes(const char *uri) override;
32−};
33−
34−#endif
tests/mocks/Unity/fake_valuesliderfilter.cppdeleted−84
@@ -1,84 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "fake_valuesliderfilter.h"
18−#include "fake_valueslidervalues.h"
19−
20−FakeValueSliderFilter::FakeValueSliderFilter(const QString &id, const QString &tag, double value, double minValue, double maxValue, const QMap<double, QString> &labels, QObject* parent)
21− : unity::shell::scopes::ValueSliderFilterInterface(parent),
22− m_filterId(id),
23− m_filterTag(tag),
24− m_value(value),
25− m_minValue(minValue),
26− m_maxValue(maxValue),
27− m_values(new FakeValueSliderValues(labels, this))
28−{
29−}
30−
31−QString FakeValueSliderFilter::filterId() const
32−{
33− return m_filterId;
34−}
35−
36−QString FakeValueSliderFilter::filterTag() const
37−{
38− return m_filterTag;
39−}
40−
41−QString FakeValueSliderFilter::title() const
42−{
43− return m_title;
44−}
45−
46−double FakeValueSliderFilter::value() const
47−{
48− return m_value;
49−}
50−
51−void FakeValueSliderFilter::setValue(double value)
52−{
53− if (value != m_value) {
54− m_value = value;
55− Q_EMIT valueChanged();
56− }
57−}
58−
59−double FakeValueSliderFilter::minValue() const
60−{
61− return m_minValue;
62−}
63−
64−double FakeValueSliderFilter::maxValue() const
65−{
66− return m_maxValue;
67−}
68−
69−unity::shell::scopes::ValueSliderValuesInterface* FakeValueSliderFilter::values() const
70−{
71− return m_values;
72−}
73−
74−bool FakeValueSliderFilter::isActive() const
75−{
76− // Doesn't really matter
77− return false;
78−}
79−
80−void FakeValueSliderFilter::setTitle(const QString &title)
81−{
82− m_title = title;
83− Q_EMIT titleChanged();
84−}
tests/mocks/Unity/fake_valuesliderfilter.hdeleted−55
@@ -1,55 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef FAKE_VALUESLIDERFILTER_H
18−#define FAKE_VALUESLIDERFILTER_H
19−
20−#include <unity/shell/scopes/ValueSliderFilterInterface.h>
21−
22−class FakeValueSliderFilter : public unity::shell::scopes::ValueSliderFilterInterface
23−{
24− Q_OBJECT
25−
26−public:
27− FakeValueSliderFilter(const QString &id, const QString &tag, double value, double minValue, double maxValue, const QMap<double, QString> &labels, QObject* parent);
28−
29− QString filterId() const override;
30− QString filterTag() const override;
31− QString title() const override;
32−
33− double value() const override;
34− void setValue(double value) override;
35− double minValue() const override;
36− double maxValue() const override;
37− unity::shell::scopes::ValueSliderValuesInterface* values() const override;
38−
39− // Not part of the iface, for mock/testing purposes
40− bool isActive() const;
41−
42− void setTitle(const QString &title);
43−
44−private:
45− QString m_filterId;
46− QString m_filterTag;
47− QString m_title;
48−
49− double m_value;
50− double m_minValue;
51− double m_maxValue;
52− unity::shell::scopes::ValueSliderValuesInterface *m_values;
53−};
54−
55−#endif
tests/mocks/Unity/fake_valueslidervalues.cppdeleted−51
@@ -1,51 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "fake_valueslidervalues.h"
18−
19−FakeValueSliderValues::FakeValueSliderValues(const QMap<double, QString> &labels, QObject* parent)
20− : unity::shell::scopes::ValueSliderValuesInterface(parent)
21− , m_labels(labels)
22−{
23−}
24−
25−int FakeValueSliderValues::rowCount(const QModelIndex &parent) const
26−{
27− if (parent.isValid())
28− return 0;
29−
30− return m_labels.count();
31−}
32−
33−QVariant FakeValueSliderValues::data(const QModelIndex &index, int role) const
34−{
35− if (!index.isValid())
36− return QVariant();
37−
38− const int row = index.row();
39− auto it = m_labels.begin();
40− it += row;
41−
42− switch (role) {
43− case RoleValue:
44− return it.key();
45−
46− case RoleLabel:
47− return it.value();
48− }
49−
50− return QVariant();
51−}
tests/mocks/Unity/fake_valueslidervalues.hdeleted−36
@@ -1,36 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef FAKE_VALUESLIDERVALUES_H
18−#define FAKE_VALUESLIDERVALUES_H
19−
20−#include <unity/shell/scopes/ValueSliderValuesInterface.h>
21−
22−class FakeValueSliderValues : public unity::shell::scopes::ValueSliderValuesInterface
23−{
24− Q_OBJECT
25−
26−public:
27− FakeValueSliderValues(const QMap<double, QString> &labels, QObject* parent);
28−
29− int rowCount(const QModelIndex &parent) const override;
30− QVariant data(const QModelIndex &index, int role) const override;
31−
32−private:
33− const QMap<double, QString> m_labels;
34−};
35−
36−#endif
tests/mocks/Unity/qmldirdeleted−3
@@ -1,3 +0,0 @@
1−module Unity
2−plugin FakeUnityQml
3−typeinfo Unity.qmltypes
tests/plugins/CMakeLists.txt−1
@@ -1,6 +1,5 @@
11add_subdirectory(AccountsService)
22add_subdirectory(Cursor)
3−add_subdirectory(Dash)
43add_subdirectory(GlobalShortcut)
54add_subdirectory(Greeter)
65add_subdirectory(ImageCache)
tests/plugins/Dash/cardcreator/1.resdeleted−82
@@ -1,82 +0,0 @@
1−AbstractButton {
2− id: root;
3− property var cardData;
4− property string backgroundShapeStyle: "flat";
5− property real fontScale: 1.0;
6− property var scopeStyle: null;
7− readonly property string title: cardData && cardData["title"] || "";
8− property bool showHeader: true;
9− implicitWidth: childrenRect.width;
10− enabled: true;
11− property int fixedHeaderHeight: -1;
12− property size fixedArtShapeSize: Qt.size(-1, -1);
13−signal action(var actionId);
14−Loader {
15− id: artShapeLoader;
16− height: root.fixedArtShapeSize.height;
17− width: root.fixedArtShapeSize.width;
18− anchors { horizontalCenter: parent.horizontalCenter; }
19− objectName: "artShapeLoader";
20− readonly property string cardArt: cardData && cardData["art"] || "";
21− onCardArtChanged: { if (item) { item.image.source = cardArt; } }
22− active: cardArt != "";
23− asynchronous: true;
24− visible: status === Loader.Ready;
25− sourceComponent: Item {
26− id: artShape;
27− objectName: "artShape";
28− visible: image.status === Image.Ready;
29− readonly property alias image: artImage;
30− UbuntuShape {
31− anchors.fill: parent;
32− source: artImage;
33− sourceFillMode: UbuntuShape.PreserveAspectCrop;
34− radius: "small";
35− aspect: UbuntuShape.Flat;
36− }
37− width: root.fixedArtShapeSize.width;
38− height: root.fixedArtShapeSize.height;
39− CroppedImageMinimumSourceSize {
40− id: artImage;
41− objectName: "artImage";
42− source: artShapeLoader.cardArt;
43− asynchronous: true;
44− visible: false;
45− width: root.width;
46− height: width / (root.fixedArtShapeSize.width / root.fixedArtShapeSize.height);
47− }
48− }
49− }
50−readonly property int headerHeight: titleLabel.height;
51−Label {
52− id: titleLabel;
53− objectName: "titleLabel";
54− anchors { right: parent.right;
55− left: parent.left;
56− top: artShapeLoader.bottom;
57− topMargin: units.gu(1);
58− }
59− elide: Text.ElideRight;
60− fontSize: "small";
61− wrapMode: Text.Wrap;
62− maximumLineCount: 2;
63− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
64− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
65− visible: showHeader ;
66− width: undefined;
67− text: root.title;
68− font.weight: Font.Normal;
69− horizontalAlignment: Text.AlignHCenter;
70− }
71−Loader {
72− active: root.pressed;
73− anchors { fill: artShapeLoader }
74− sourceComponent: UbuntuShape {
75− objectName: "touchdown";
76− anchors.fill: parent;
77− radius: "small";
78− borderSource: "radius_pressed.sci"
79− }
80−}
81−implicitHeight: titleLabel.y + titleLabel.height + units.gu(1);
82−}
tests/plugins/Dash/cardcreator/1.res.cardcreatordeleted−69
@@ -1,69 +0,0 @@
1−AbstractButton {
2− id: root;
3− property var cardData;
4− property string backgroundShapeStyle: "flat";
5− property real fontScale: 1.0;
6− property var scopeStyle: null;
7− readonly property string title: cardData && cardData["title"] || "";
8− property bool showHeader: true;
9− implicitWidth: childrenRect.width;
10− enabled: true;
11−signal action(var actionId);
12−readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
13−Loader {
14− id: artShapeLoader;
15− anchors { horizontalCenter: parent.horizontalCenter; }
16− objectName: "artShapeLoader";
17− readonly property string cardArt: cardData && cardData["art"] || "";
18− onCardArtChanged: { if (item) { item.image.source = cardArt; } }
19− active: cardArt != "";
20− asynchronous: false;
21− visible: status === Loader.Ready;
22− sourceComponent: Item {
23− id: artShape;
24− objectName: "artShape";
25− visible: image.status === Image.Ready;
26− readonly property alias image: artImage;
27− UbuntuShape {
28− anchors.fill: parent;
29− source: artImage;
30− sourceFillMode: UbuntuShape.PreserveAspectCrop;
31− radius: "small";
32− aspect: UbuntuShape.Flat;
33− }
34− width: image.status !== Image.Ready ? 0 : image.width;
35− height: image.status !== Image.Ready ? 0 : image.height;
36− CroppedImageMinimumSourceSize {
37− id: artImage;
38− objectName: "artImage";
39− source: artShapeLoader.cardArt;
40− asynchronous: false;
41− visible: false;
42− width: root.width;
43− height: width / 1.6;
44− }
45− }
46− }
47−readonly property int headerHeight: titleLabel.height;
48−Label {
49− id: titleLabel;
50− objectName: "titleLabel";
51− anchors { right: parent.right;
52− left: parent.left;
53− top: artShapeLoader.bottom;
54− topMargin: units.gu(1);
55− }
56− elide: Text.ElideRight;
57− fontSize: "small";
58− wrapMode: Text.Wrap;
59− maximumLineCount: 2;
60− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
61− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
62− visible: showHeader ;
63− width: undefined;
64− text: root.title;
65− font.weight: Font.Normal;
66− horizontalAlignment: Text.AlignHCenter;
67− }
68−implicitHeight: titleLabel.y + titleLabel.height + units.gu(1);
69−}
tests/plugins/Dash/cardcreator/1.tstdeleted−4
@@ -1,4 +0,0 @@
1−template: {"card-layout":"vertical","card-size":"small","category-layout":"grid","collapsed-rows":2}
2−components: {"art":{"aspect-ratio":1.6,"field":"art"},"title":{"field":"title"},"attributes":{}}
3−artShapeStyle: flat
4−result: 1.res
tests/plugins/Dash/cardcreator/10.resdeleted−129
@@ -1,129 +0,0 @@
1−AbstractButton {
2− id: root;
3− property var cardData;
4− property string backgroundShapeStyle: "flat";
5− property real fontScale: 1.0;
6− property var scopeStyle: null;
7− readonly property string title: cardData && cardData["title"] || "";
8− property bool showHeader: true;
9− implicitWidth: childrenRect.width;
10− enabled: true;
11− property int fixedHeaderHeight: -1;
12− property size fixedArtShapeSize: Qt.size(-1, -1);
13−signal action(var actionId);
14−Loader {
15− id: backgroundLoader;
16− objectName: "backgroundLoader";
17− anchors.fill: parent;
18− asynchronous: true;
19− visible: status === Loader.Ready;
20− sourceComponent: UbuntuShape {
21− objectName: "background";
22− radius: "small";
23− aspect: {
24− switch (root.backgroundShapeStyle) {
25− case "inset": return UbuntuShape.Inset;
26− case "shadow": return UbuntuShape.DropShadow;
27− default:
28− case "flat": return UbuntuShape.Flat;
29− }
30− }
31− backgroundColor: getColor(0) || "white";
32− secondaryBackgroundColor: getColor(1) || backgroundColor;
33− backgroundMode: UbuntuShape.VerticalGradient;
34− anchors.fill: parent;
35− source: backgroundImage.source ? backgroundImage : null;
36− property real luminance: Style.luminance(backgroundColor);
37− property Image backgroundImage: Image {
38− objectName: "backgroundImage";
39− source: {
40− if (cardData && typeof cardData["background"] === "string") return cardData["background"];
41− else return "";
42− }
43− }
44− function getColor(index) {
45− if (cardData && typeof cardData["background"] === "object"
46− && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
47− return cardData["background"]["elements"][index];
48− } else return index === 0 ? "" : "";
49− }
50− }
51− }
52−readonly property int headerHeight: row.height;
53−Row {
54− id: row;
55− objectName: "outerRow";
56− property real margins: units.gu(1);
57− spacing: margins;
58− height: root.fixedHeaderHeight;
59− anchors { top: parent.top;
60− topMargin: units.gu(1);
61−left: parent.left;
62− }
63− anchors.right: parent.right;
64− anchors.margins: margins;
65− anchors.rightMargin: 0;
66− data: [
67− CroppedImageMinimumSourceSize {
68− id: mascotImage;
69− objectName: "mascotImage";
70− anchors { verticalCenter: parent.verticalCenter; }
71− source: cardData && cardData["mascot"] || "";
72− width: units.gu(6);
73− height: units.gu(5.625);
74− horizontalAlignment: Image.AlignHCenter;
75− verticalAlignment: Image.AlignVCenter;
76− visible: showHeader;
77−
78− }
79−,Item {
80− id: headerTitleContainer;
81− anchors { verticalCenter: parent.verticalCenter; }
82− width: parent.width - x;
83− implicitHeight: titleLabel.height + subtitleLabel.height;
84− data: [
85− Label {
86− id: titleLabel;
87− objectName: "titleLabel";
88− anchors { right: parent.right;
89−rightMargin: units.gu(1);
90−left: parent.left;
91− top: parent.top; }
92− elide: Text.ElideRight;
93− fontSize: "small";
94− wrapMode: Text.Wrap;
95− maximumLineCount: 2;
96− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
97− color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white");
98− visible: showHeader ;
99− width: undefined;
100− text: root.title;
101− font.weight: Font.Normal;
102− horizontalAlignment: Text.AlignLeft;
103− }
104−,Label {
105− id: subtitleLabel;
106− objectName: "subtitleLabel";
107− anchors { right: parent.right;
108− left: parent.left;
109−rightMargin: units.gu(1);
110−top: titleLabel.bottom;
111− }
112− anchors.topMargin: units.dp(2);
113− elide: Text.ElideRight;
114− maximumLineCount: 1;
115− fontSize: "x-small";
116− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
117− color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white");
118− visible: titleLabel.visible && titleLabel.text;
119− text: cardData && cardData["subtitle"] || "";
120− font.weight: Font.Light;
121− }
122−
123− ]
124− }
125−
126− ]
127− }
128−implicitHeight: row.y + row.height + units.gu(1);
129−}
tests/plugins/Dash/cardcreator/10.res.cardcreatordeleted−127
@@ -1,127 +0,0 @@
1−AbstractButton {
2− id: root;
3− property var cardData;
4− property string backgroundShapeStyle: "flat";
5− property real fontScale: 1.0;
6− property var scopeStyle: null;
7− readonly property string title: cardData && cardData["title"] || "";
8− property bool showHeader: true;
9− implicitWidth: childrenRect.width;
10− enabled: true;
11−signal action(var actionId);
12−Loader {
13− id: backgroundLoader;
14− objectName: "backgroundLoader";
15− anchors.fill: parent;
16− asynchronous: false;
17− visible: status === Loader.Ready;
18− sourceComponent: UbuntuShape {
19− objectName: "background";
20− radius: "small";
21− aspect: {
22− switch (root.backgroundShapeStyle) {
23− case "inset": return UbuntuShape.Inset;
24− case "shadow": return UbuntuShape.DropShadow;
25− default:
26− case "flat": return UbuntuShape.Flat;
27− }
28− }
29− backgroundColor: getColor(0) || "white";
30− secondaryBackgroundColor: getColor(1) || backgroundColor;
31− backgroundMode: UbuntuShape.VerticalGradient;
32− anchors.fill: parent;
33− source: backgroundImage.source ? backgroundImage : null;
34− property real luminance: Style.luminance(backgroundColor);
35− property Image backgroundImage: Image {
36− objectName: "backgroundImage";
37− source: {
38− if (cardData && typeof cardData["background"] === "string") return cardData["background"];
39− else return "";
40− }
41− }
42− function getColor(index) {
43− if (cardData && typeof cardData["background"] === "object"
44− && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
45− return cardData["background"]["elements"][index];
46− } else return index === 0 ? "" : "";
47− }
48− }
49− }
50−readonly property size artShapeSize: Qt.size(-1, -1);
51−readonly property int headerHeight: row.height;
52−Row {
53− id: row;
54− objectName: "outerRow";
55− property real margins: units.gu(1);
56− spacing: margins;
57− anchors { top: parent.top;
58− topMargin: units.gu(1);
59−left: parent.left;
60− }
61− anchors.right: parent.right;
62− anchors.margins: margins;
63− anchors.rightMargin: 0;
64− data: [
65− CroppedImageMinimumSourceSize {
66− id: mascotImage;
67− objectName: "mascotImage";
68− anchors { verticalCenter: parent.verticalCenter; }
69− source: cardData && cardData["mascot"] || "";
70− width: units.gu(6);
71− height: units.gu(5.625);
72− horizontalAlignment: Image.AlignHCenter;
73− verticalAlignment: Image.AlignVCenter;
74− visible: showHeader;
75−
76− }
77−,Item {
78− id: headerTitleContainer;
79− anchors { verticalCenter: parent.verticalCenter; }
80− width: parent.width - x;
81− implicitHeight: titleLabel.height + subtitleLabel.height;
82− data: [
83− Label {
84− id: titleLabel;
85− objectName: "titleLabel";
86− anchors { right: parent.right;
87−rightMargin: units.gu(1);
88−left: parent.left;
89− top: parent.top; }
90− elide: Text.ElideRight;
91− fontSize: "small";
92− wrapMode: Text.Wrap;
93− maximumLineCount: 2;
94− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
95− color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white");
96− visible: showHeader ;
97− width: undefined;
98− text: root.title;
99− font.weight: Font.Normal;
100− horizontalAlignment: Text.AlignLeft;
101− }
102−,Label {
103− id: subtitleLabel;
104− objectName: "subtitleLabel";
105− anchors { right: parent.right;
106− left: parent.left;
107−rightMargin: units.gu(1);
108−top: titleLabel.bottom;
109− }
110− anchors.topMargin: units.dp(2);
111− elide: Text.ElideRight;
112− maximumLineCount: 1;
113− fontSize: "x-small";
114− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
115− color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white");
116− visible: titleLabel.visible && titleLabel.text;
117− text: cardData && cardData["subtitle"] || "";
118− font.weight: Font.Light;
119− }
120−
121− ]
122− }
123−
124− ]
125− }
126−implicitHeight: row.y + row.height + units.gu(1);
127−}
tests/plugins/Dash/cardcreator/10.tstdeleted−4
@@ -1,4 +0,0 @@
1−template: {"card-background":{"elements":["#E9E9E9"],"type":"color"},"card-layout":"vertical","card-size":"medium","category-layout":"grid","collapsed-rows":2, "card-background": { "type": "color", "elements": [ "\\", ": 3; } Item { } function moo () { \"" ] } }
2−components: {"art":{"aspect-ratio":1},"background":{"field":"background"},"mascot":{"field":"icon"},"subtitle":{"field":"author"},"title":{"field":"title"},"attributes":{}}
3−artShapeStyle: shadow
4−result: 10.res
tests/plugins/Dash/cardcreator/11.resdeleted−176
@@ -1,176 +0,0 @@
1−AbstractButton {
2− id: root;
3− property var cardData;
4− property string backgroundShapeStyle: "flat";
5− property real fontScale: 1.0;
6− property var scopeStyle: null;
7− readonly property string title: cardData && cardData["title"] || "";
8− property bool showHeader: true;
9− implicitWidth: childrenRect.width;
10− enabled: true;
11− property int fixedHeaderHeight: -1;
12− property size fixedArtShapeSize: Qt.size(-1, -1);
13−signal action(var actionId);
14−Loader {
15− id: backgroundLoader;
16− objectName: "backgroundLoader";
17− anchors.fill: parent;
18− asynchronous: true;
19− visible: status === Loader.Ready;
20− sourceComponent: UbuntuShape {
21− objectName: "background";
22− radius: "small";
23− aspect: {
24− switch (root.backgroundShapeStyle) {
25− case "inset": return UbuntuShape.Inset;
26− case "shadow": return UbuntuShape.DropShadow;
27− default:
28− case "flat": return UbuntuShape.Flat;
29− }
30− }
31− backgroundColor: getColor(0) || "white";
32− secondaryBackgroundColor: getColor(1) || backgroundColor;
33− backgroundMode: UbuntuShape.VerticalGradient;
34− anchors.fill: parent;
35− source: backgroundImage.source ? backgroundImage : null;
36− property real luminance: Style.luminance(backgroundColor);
37− property Image backgroundImage: Image {
38− objectName: "backgroundImage";
39− source: {
40− if (cardData && typeof cardData["background"] === "string") return cardData["background"];
41− else return "";
42− }
43− }
44− function getColor(index) {
45− if (cardData && typeof cardData["background"] === "object"
46− && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
47− return cardData["background"]["elements"][index];
48− } else return index === 0 ? "#E9E9E9" : undefined;
49− }
50− }
51− }
52−Loader {
53− id: artShapeLoader;
54− height: root.fixedArtShapeSize.height;
55− width: root.fixedArtShapeSize.width;
56− anchors { horizontalCenter: parent.horizontalCenter; }
57− objectName: "artShapeLoader";
58− readonly property string cardArt: cardData && cardData["art"] || decodeURI("%5C");
59− onCardArtChanged: { if (item) { item.image.source = cardArt; } }
60− active: cardArt != "";
61− asynchronous: true;
62− visible: status === Loader.Ready;
63− sourceComponent: Item {
64− id: artShape;
65− objectName: "artShape";
66− visible: image.status === Image.Ready;
67− readonly property alias image: artImage;
68− UbuntuShape {
69− anchors.fill: parent;
70− source: artImage;
71− sourceFillMode: UbuntuShape.PreserveAspectCrop;
72− radius: "small";
73− aspect: UbuntuShape.Flat;
74− }
75− width: root.fixedArtShapeSize.width;
76− height: root.fixedArtShapeSize.height;
77− CroppedImageMinimumSourceSize {
78− id: artImage;
79− objectName: "artImage";
80− source: artShapeLoader.cardArt;
81− asynchronous: true;
82− visible: false;
83− width: root.width;
84− height: width / (root.fixedArtShapeSize.width / root.fixedArtShapeSize.height);
85− onStatusChanged: if (status === Image.Error) source = decodeURI("%5C");
86− }
87− }
88− }
89−readonly property int headerHeight: row.height;
90−Row {
91− id: row;
92− objectName: "outerRow";
93− property real margins: units.gu(1);
94− spacing: margins;
95− height: root.fixedHeaderHeight;
96− anchors { top: artShapeLoader.bottom;
97− topMargin: units.gu(1);
98−left: parent.left;
99− }
100− anchors.right: parent.right;
101− anchors.margins: margins;
102− anchors.rightMargin: 0;
103− data: [
104− CroppedImageMinimumSourceSize {
105− id: mascotImage;
106− objectName: "mascotImage";
107− anchors { verticalCenter: parent.verticalCenter; }
108− source: cardData && cardData["mascot"] || decodeURI("%22");
109− width: units.gu(6);
110− height: units.gu(5.625);
111− horizontalAlignment: Image.AlignHCenter;
112− verticalAlignment: Image.AlignVCenter;
113− visible: showHeader;
114− onStatusChanged: if (status === Image.Error) source = decodeURI("%22");
115− }
116−,Item {
117− id: headerTitleContainer;
118− anchors { verticalCenter: parent.verticalCenter; }
119− width: parent.width - x;
120− implicitHeight: titleLabel.height + subtitleLabel.height;
121− data: [
122− Label {
123− id: titleLabel;
124− objectName: "titleLabel";
125− anchors { right: parent.right;
126−rightMargin: units.gu(1);
127−left: parent.left;
128− top: parent.top; }
129− elide: Text.ElideRight;
130− fontSize: "small";
131− wrapMode: Text.Wrap;
132− maximumLineCount: 2;
133− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
134− color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white");
135− visible: showHeader ;
136− width: undefined;
137− text: root.title;
138− font.weight: Font.Normal;
139− horizontalAlignment: Text.AlignLeft;
140− }
141−,Label {
142− id: subtitleLabel;
143− objectName: "subtitleLabel";
144− anchors { right: parent.right;
145− left: parent.left;
146−rightMargin: units.gu(1);
147−top: titleLabel.bottom;
148− }
149− anchors.topMargin: units.dp(2);
150− elide: Text.ElideRight;
151− maximumLineCount: 1;
152− fontSize: "x-small";
153− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
154− color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white");
155− visible: titleLabel.visible && titleLabel.text;
156− text: cardData && cardData["subtitle"] || "";
157− font.weight: Font.Light;
158− }
159−
160− ]
161− }
162−
163− ]
164− }
165−Loader {
166− active: root.pressed;
167− anchors { fill: backgroundLoader }
168− sourceComponent: UbuntuShape {
169− objectName: "touchdown";
170− anchors.fill: parent;
171− radius: "small";
172− borderSource: "radius_pressed.sci"
173− }
174−}
175−implicitHeight: row.y + row.height + units.gu(1);
176−}
tests/plugins/Dash/cardcreator/11.res.cardcreatordeleted−160
@@ -1,160 +0,0 @@
1−AbstractButton {
2− id: root;
3− property var cardData;
4− property string backgroundShapeStyle: "flat";
5− property real fontScale: 1.0;
6− property var scopeStyle: null;
7− readonly property string title: cardData && cardData["title"] || "";
8− property bool showHeader: true;
9− implicitWidth: childrenRect.width;
10− enabled: true;
11−signal action(var actionId);
12−Loader {
13− id: backgroundLoader;
14− objectName: "backgroundLoader";
15− anchors.fill: parent;
16− asynchronous: false;
17− visible: status === Loader.Ready;
18− sourceComponent: UbuntuShape {
19− objectName: "background";
20− radius: "small";
21− aspect: {
22− switch (root.backgroundShapeStyle) {
23− case "inset": return UbuntuShape.Inset;
24− case "shadow": return UbuntuShape.DropShadow;
25− default:
26− case "flat": return UbuntuShape.Flat;
27− }
28− }
29− backgroundColor: getColor(0) || "white";
30− secondaryBackgroundColor: getColor(1) || backgroundColor;
31− backgroundMode: UbuntuShape.VerticalGradient;
32− anchors.fill: parent;
33− source: backgroundImage.source ? backgroundImage : null;
34− property real luminance: Style.luminance(backgroundColor);
35− property Image backgroundImage: Image {
36− objectName: "backgroundImage";
37− source: {
38− if (cardData && typeof cardData["background"] === "string") return cardData["background"];
39− else return "";
40− }
41− }
42− function getColor(index) {
43− if (cardData && typeof cardData["background"] === "object"
44− && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
45− return cardData["background"]["elements"][index];
46− } else return index === 0 ? "#E9E9E9" : undefined;
47− }
48− }
49− }
50−readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
51−Loader {
52− id: artShapeLoader;
53− anchors { horizontalCenter: parent.horizontalCenter; }
54− objectName: "artShapeLoader";
55− readonly property string cardArt: cardData && cardData["art"] || "";
56− onCardArtChanged: { if (item) { item.image.source = cardArt; } }
57− active: cardArt != "";
58− asynchronous: false;
59− visible: status === Loader.Ready;
60− sourceComponent: Item {
61− id: artShape;
62− objectName: "artShape";
63− visible: image.status === Image.Ready;
64− readonly property alias image: artImage;
65− UbuntuShape {
66− anchors.fill: parent;
67− source: artImage;
68− sourceFillMode: UbuntuShape.PreserveAspectCrop;
69− radius: "small";
70− aspect: UbuntuShape.Flat;
71− }
72− width: image.status !== Image.Ready ? 0 : image.width;
73− height: image.status !== Image.Ready ? 0 : image.height;
74− CroppedImageMinimumSourceSize {
75− id: artImage;
76− objectName: "artImage";
77− source: artShapeLoader.cardArt;
78− asynchronous: false;
79− visible: false;
80− width: root.width;
81− height: width / 1;
82− }
83− }
84− }
85−readonly property int headerHeight: row.height;
86−Row {
87− id: row;
88− objectName: "outerRow";
89− property real margins: units.gu(1);
90− spacing: margins;
91− anchors { top: artShapeLoader.bottom;
92− topMargin: units.gu(1);
93−left: parent.left;
94− }
95− anchors.right: parent.right;
96− anchors.margins: margins;
97− anchors.rightMargin: 0;
98− data: [
99− CroppedImageMinimumSourceSize {
100− id: mascotImage;
101− objectName: "mascotImage";
102− anchors { verticalCenter: parent.verticalCenter; }
103− source: cardData && cardData["mascot"] || "";
104− width: units.gu(6);
105− height: units.gu(5.625);
106− horizontalAlignment: Image.AlignHCenter;
107− verticalAlignment: Image.AlignVCenter;
108− visible: showHeader;
109− }
110−,Item {
111− id: headerTitleContainer;
112− anchors { verticalCenter: parent.verticalCenter; }
113− width: parent.width - x;
114− implicitHeight: titleLabel.height + subtitleLabel.height;
115− data: [
116− Label {
117− id: titleLabel;
118− objectName: "titleLabel";
119− anchors { right: parent.right;
120−rightMargin: units.gu(1);
121−left: parent.left;
122− top: parent.top; }
123− elide: Text.ElideRight;
124− fontSize: "small";
125− wrapMode: Text.Wrap;
126− maximumLineCount: 2;
127− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
128− color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white");
129− visible: showHeader ;
130− width: undefined;
131− text: root.title;
132− font.weight: Font.Normal;
133− horizontalAlignment: Text.AlignLeft;
134− }
135−,Label {
136− id: subtitleLabel;
137− objectName: "subtitleLabel";
138− anchors { right: parent.right;
139− left: parent.left;
140−rightMargin: units.gu(1);
141−top: titleLabel.bottom;
142− }
143− anchors.topMargin: units.dp(2);
144− elide: Text.ElideRight;
145− maximumLineCount: 1;
146− fontSize: "x-small";
147− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
148− color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white");
149− visible: titleLabel.visible && titleLabel.text;
150− text: cardData && cardData["subtitle"] || "";
151− font.weight: Font.Light;
152− }
153−
154− ]
155− }
156−
157− ]
158− }
159−implicitHeight: row.y + row.height + units.gu(1);
160−}
tests/plugins/Dash/cardcreator/11.tstdeleted−4
@@ -1,4 +0,0 @@
1−template: {"card-background":{"elements":["#E9E9E9"],"type":"color"},"card-layout":"vertical","card-size":"medium","category-layout":"grid","collapsed-rows":2 }
2−components: {"art":{"aspect-ratio":1,"field":"art","fallback":"\\"},"background":{"field":"background"},"mascot":{"field":"icon","fallback":"\""},"subtitle":{"field":"author"},"title":{"field":"title"},"attributes":{}}
3−artShapeStyle: flat
4−result: 11.res
tests/plugins/Dash/cardcreator/12.resdeleted−108
@@ -1,108 +0,0 @@
1−AbstractButton {
2− id: root;
3− property var cardData;
4− property string backgroundShapeStyle: "flat";
5− property real fontScale: 1.0;
6− property var scopeStyle: null;
7− readonly property string title: cardData && cardData["title"] || "";
8− property bool showHeader: true;
9− implicitWidth: childrenRect.width;
10− enabled: true;
11− property int fixedHeaderHeight: -1;
12− property size fixedArtShapeSize: Qt.size(-1, -1);
13−signal action(var actionId);
14−Loader {
15− id: artShapeLoader;
16− height: root.fixedArtShapeSize.height;
17− width: root.fixedArtShapeSize.width;
18− anchors { horizontalCenter: parent.horizontalCenter; }
19− objectName: "artShapeLoader";
20− readonly property string cardArt: cardData && cardData["art"] || "";
21− onCardArtChanged: { if (item) { item.image.source = cardArt; } }
22− active: cardArt != "";
23− asynchronous: true;
24− visible: status === Loader.Ready;
25− sourceComponent: Item {
26− id: artShape;
27− objectName: "artShape";
28− visible: image.status === Image.Ready;
29− readonly property alias image: artImage;
30− UbuntuShape {
31− anchors.fill: parent;
32− source: artImage;
33− sourceFillMode: UbuntuShape.PreserveAspectCrop;
34− radius: "small";
35− aspect: UbuntuShape.Flat;
36− }
37− width: root.fixedArtShapeSize.width;
38− height: root.fixedArtShapeSize.height;
39− CroppedImageMinimumSourceSize {
40− id: artImage;
41− objectName: "artImage";
42− source: artShapeLoader.cardArt;
43− asynchronous: true;
44− visible: false;
45− width: root.width;
46− height: width / (root.fixedArtShapeSize.width / root.fixedArtShapeSize.height);
47− }
48− }
49− }
50−readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;
51−Label {
52− id: titleLabel;
53− objectName: "titleLabel";
54− anchors { right: parent.right;
55− left: parent.left;
56− top: artShapeLoader.bottom;
57− topMargin: units.gu(1);
58− }
59− elide: Text.ElideRight;
60− fontSize: "small";
61− wrapMode: Text.Wrap;
62− maximumLineCount: 2;
63− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
64− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
65− visible: showHeader ;
66− width: undefined;
67− text: root.title;
68− font.weight: Font.Normal;
69− horizontalAlignment: Text.AlignLeft;
70− }
71−Label {
72− id: subtitleLabel;
73− objectName: "subtitleLabel";
74− anchors { left: titleLabel.left;
75− leftMargin: titleLabel.leftMargin;
76− right: titleLabel.right;
77− top: titleLabel.bottom;
78− }
79− anchors.topMargin: units.dp(2);
80− elide: Text.ElideRight;
81− maximumLineCount: 1;
82− fontSize: "x-small";
83− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
84− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
85− visible: titleLabel.visible && titleLabel.text;
86− text: cardData && cardData["subtitle"] || "";
87− font.weight: Font.Light;
88− }
89−CardSocialActions {
90− id: socialActionsRow;
91− objectName: "socialActionsRow";
92− anchors { top: subtitleLabel.bottom; left: parent.left; right: parent.right; topMargin: units.gu(1); }
93− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
94− model: cardData && cardData["socialActions"];
95− onClicked: root.action(actionId);
96−}
97−Loader {
98− active: root.pressed;
99− anchors { fill: artShapeLoader }
100− sourceComponent: UbuntuShape {
101− objectName: "touchdown";
102− anchors.fill: parent;
103− radius: "small";
104− borderSource: "radius_pressed.sci"
105− }
106−}
107−implicitHeight: socialActionsRow.y + socialActionsRow.height + units.gu(1);
108−}
tests/plugins/Dash/cardcreator/12.res.cardcreatordeleted−95
@@ -1,95 +0,0 @@
1−AbstractButton {
2− id: root;
3− property var cardData;
4− property string backgroundShapeStyle: "flat";
5− property real fontScale: 1.0;
6− property var scopeStyle: null;
7− readonly property string title: cardData && cardData["title"] || "";
8− property bool showHeader: true;
9− implicitWidth: childrenRect.width;
10− enabled: true;
11−signal action(var actionId);
12−readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
13−Loader {
14− id: artShapeLoader;
15− anchors { horizontalCenter: parent.horizontalCenter; }
16− objectName: "artShapeLoader";
17− readonly property string cardArt: cardData && cardData["art"] || "";
18− onCardArtChanged: { if (item) { item.image.source = cardArt; } }
19− active: cardArt != "";
20− asynchronous: false;
21− visible: status === Loader.Ready;
22− sourceComponent: Item {
23− id: artShape;
24− objectName: "artShape";
25− visible: image.status === Image.Ready;
26− readonly property alias image: artImage;
27− UbuntuShape {
28− anchors.fill: parent;
29− source: artImage;
30− sourceFillMode: UbuntuShape.PreserveAspectCrop;
31− radius: "small";
32− aspect: UbuntuShape.Flat;
33− }
34− width: image.status !== Image.Ready ? 0 : image.width;
35− height: image.status !== Image.Ready ? 0 : image.height;
36− CroppedImageMinimumSourceSize {
37− id: artImage;
38− objectName: "artImage";
39− source: artShapeLoader.cardArt;
40− asynchronous: false;
41− visible: false;
42− width: root.width;
43− height: width / 0.75;
44− }
45− }
46− }
47−readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;
48−Label {
49− id: titleLabel;
50− objectName: "titleLabel";
51− anchors { right: parent.right;
52− left: parent.left;
53− top: artShapeLoader.bottom;
54− topMargin: units.gu(1);
55− }
56− elide: Text.ElideRight;
57− fontSize: "small";
58− wrapMode: Text.Wrap;
59− maximumLineCount: 2;
60− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
61− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
62− visible: showHeader ;
63− width: undefined;
64− text: root.title;
65− font.weight: Font.Normal;
66− horizontalAlignment: Text.AlignLeft;
67− }
68−Label {
69− id: subtitleLabel;
70− objectName: "subtitleLabel";
71− anchors { left: titleLabel.left;
72− leftMargin: titleLabel.leftMargin;
73− right: titleLabel.right;
74− top: titleLabel.bottom;
75− }
76− anchors.topMargin: units.dp(2);
77− elide: Text.ElideRight;
78− maximumLineCount: 1;
79− fontSize: "x-small";
80− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
81− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
82− visible: titleLabel.visible && titleLabel.text;
83− text: cardData && cardData["subtitle"] || "";
84− font.weight: Font.Light;
85− }
86−CardSocialActions {
87− id: socialActionsRow;
88− objectName: "socialActionsRow";
89− anchors { top: subtitleLabel.bottom; left: parent.left; right: parent.right; topMargin: units.gu(1); }
90− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
91− model: cardData && cardData["socialActions"];
92− onClicked: root.action(actionId);
93−}
94−implicitHeight: socialActionsRow.y + socialActionsRow.height + units.gu(1);
95−}
tests/plugins/Dash/cardcreator/12.tstdeleted−4
@@ -1,4 +0,0 @@
1−template: {"card-layout":"vertical","card-size":"small","category-layout":"grid","collapsed-rows":2}
2−components: {"art":{"aspect-ratio":0.75,"field":"art"},"subtitle":{"field":"price"},"title":{"field":"title"},"attributes":{},"social-actions":{}}
3−artShapeStyle: flat
4−result: 12.res
tests/plugins/Dash/cardcreator/2.resdeleted−128
@@ -1,128 +0,0 @@
1−AbstractButton {
2− id: root;
3− property var cardData;
4− property string backgroundShapeStyle: "flat";
5− property real fontScale: 1.0;
6− property var scopeStyle: null;
7− readonly property string title: cardData && cardData["title"] || "";
8− property bool showHeader: true;
9− implicitWidth: childrenRect.width;
10− enabled: true;
11− property int fixedHeaderHeight: -1;
12− property size fixedArtShapeSize: Qt.size(-1, -1);
13−signal action(var actionId);
14−Loader {
15− id: backgroundLoader;
16− objectName: "backgroundLoader";
17− anchors.fill: parent;
18− asynchronous: true;
19− visible: status === Loader.Ready;
20− sourceComponent: UbuntuShape {
21− objectName: "background";
22− radius: "small";
23− aspect: {
24− switch (root.backgroundShapeStyle) {
25− case "inset": return UbuntuShape.Inset;
26− case "shadow": return UbuntuShape.DropShadow;
27− default:
28− case "flat": return UbuntuShape.Flat;
29− }
30− }
31− backgroundColor: getColor(0) || "white";
32− secondaryBackgroundColor: getColor(1) || backgroundColor;
33− backgroundMode: UbuntuShape.VerticalGradient;
34− anchors.fill: parent;
35− source: backgroundImage.source ? backgroundImage : null;
36− property real luminance: Style.luminance(backgroundColor);
37− property Image backgroundImage: Image {
38− objectName: "backgroundImage";
39− source: {
40− if (cardData && typeof cardData["background"] === "string") return cardData["background"];
41− else return "";
42− }
43− }
44− function getColor(index) {
45− if (cardData && typeof cardData["background"] === "object"
46− && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
47− return cardData["background"]["elements"][index];
48− } else return index === 0 ? "#E9E9E9" : undefined;
49− }
50− }
51− }
52−readonly property int headerHeight: row.height;
53−Row {
54− id: row;
55− objectName: "outerRow";
56− property real margins: units.gu(1);
57− spacing: margins;
58− height: root.fixedHeaderHeight;
59− anchors { top: parent.top;
60− topMargin: units.gu(1);
61− left: parent.left;
62− }
63− anchors.right: parent.right;
64− anchors.margins: margins;
65− anchors.rightMargin: 0;
66− data: [
67−CroppedImageMinimumSourceSize {
68− id: mascotImage;
69− objectName: "mascotImage";
70− anchors { verticalCenter: parent.verticalCenter; }
71− source: cardData && cardData["mascot"] || "";
72− width: units.gu(6);
73− height: units.gu(5.625);
74− horizontalAlignment: Image.AlignHCenter;
75− verticalAlignment: Image.AlignVCenter;
76− visible: showHeader;
77− }
78−,Item {
79− id: headerTitleContainer;
80− anchors { verticalCenter: parent.verticalCenter; }
81− width: parent.width - x;
82− implicitHeight: titleLabel.height + subtitleLabel.height;
83− data: [
84− Label {
85− id: titleLabel;
86− objectName: "titleLabel";
87− anchors { right: parent.right;
88− rightMargin: units.gu(1);
89− left: parent.left;
90− top: parent.top; }
91− elide: Text.ElideRight;
92− fontSize: "small";
93− wrapMode: Text.Wrap;
94− maximumLineCount: 2;
95− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
96− color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white");
97− visible: showHeader ;
98− width: undefined;
99− text: root.title;
100− font.weight: Font.Normal;
101− horizontalAlignment: Text.AlignLeft;
102− }
103− ,Label {
104− id: subtitleLabel;
105− objectName: "subtitleLabel";
106− anchors { right: parent.right;
107− left: parent.left;
108− rightMargin: units.gu(1);
109− top: titleLabel.bottom;
110− }
111− anchors.topMargin: units.dp(2);
112− elide: Text.ElideRight;
113− maximumLineCount: 1;
114− fontSize: "x-small";
115− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
116− color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white");
117− visible: titleLabel.visible && titleLabel.text;
118− text: cardData && cardData["subtitle"] || "";
119− font.weight: Font.Light;
120− }
121−
122− ]
123− }
124−
125− ]
126− }
127−implicitHeight: row.y + row.height + units.gu(1);
128−}
tests/plugins/Dash/cardcreator/2.res.cardcreatordeleted−126
@@ -1,126 +0,0 @@
1−AbstractButton {
2− id: root;
3− property var cardData;
4− property string backgroundShapeStyle: "flat";
5− property real fontScale: 1.0;
6− property var scopeStyle: null;
7− readonly property string title: cardData && cardData["title"] || "";
8− property bool showHeader: true;
9− implicitWidth: childrenRect.width;
10− enabled: true;
11−signal action(var actionId);
12−Loader {
13− id: backgroundLoader;
14− objectName: "backgroundLoader";
15− anchors.fill: parent;
16− asynchronous: false;
17− visible: status === Loader.Ready;
18− sourceComponent: UbuntuShape {
19− objectName: "background";
20− radius: "small";
21− aspect: {
22− switch (root.backgroundShapeStyle) {
23− case "inset": return UbuntuShape.Inset;
24− case "shadow": return UbuntuShape.DropShadow;
25− default:
26− case "flat": return UbuntuShape.Flat;
27− }
28− }
29− backgroundColor: getColor(0) || "white";
30− secondaryBackgroundColor: getColor(1) || backgroundColor;
31− backgroundMode: UbuntuShape.VerticalGradient;
32− anchors.fill: parent;
33− source: backgroundImage.source ? backgroundImage : null;
34− property real luminance: Style.luminance(backgroundColor);
35− property Image backgroundImage: Image {
36− objectName: "backgroundImage";
37− source: {
38− if (cardData && typeof cardData["background"] === "string") return cardData["background"];
39− else return "";
40− }
41− }
42− function getColor(index) {
43− if (cardData && typeof cardData["background"] === "object"
44− && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
45− return cardData["background"]["elements"][index];
46− } else return index === 0 ? "#E9E9E9" : undefined;
47− }
48− }
49− }
50−readonly property size artShapeSize: Qt.size(-1, -1);
51−readonly property int headerHeight: row.height;
52−Row {
53− id: row;
54− objectName: "outerRow";
55− property real margins: units.gu(1);
56− spacing: margins;
57− anchors { top: parent.top;
58− topMargin: units.gu(1);
59− left: parent.left;
60− }
61− anchors.right: parent.right;
62− anchors.margins: margins;
63− anchors.rightMargin: 0;
64− data: [
65−CroppedImageMinimumSourceSize {
66− id: mascotImage;
67− objectName: "mascotImage";
68− anchors { verticalCenter: parent.verticalCenter; }
69− source: cardData && cardData["mascot"] || "";
70− width: units.gu(6);
71− height: units.gu(5.625);
72− horizontalAlignment: Image.AlignHCenter;
73− verticalAlignment: Image.AlignVCenter;
74− visible: showHeader;
75− }
76−,Item {
77− id: headerTitleContainer;
78− anchors { verticalCenter: parent.verticalCenter; }
79− width: parent.width - x;
80− implicitHeight: titleLabel.height + subtitleLabel.height;
81− data: [
82− Label {
83− id: titleLabel;
84− objectName: "titleLabel";
85− anchors { right: parent.right;
86− rightMargin: units.gu(1);
87− left: parent.left;
88− top: parent.top; }
89− elide: Text.ElideRight;
90− fontSize: "small";
91− wrapMode: Text.Wrap;
92− maximumLineCount: 2;
93− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
94− color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white");
95− visible: showHeader ;
96− width: undefined;
97− text: root.title;
98− font.weight: Font.Normal;
99− horizontalAlignment: Text.AlignLeft;
100− }
101− ,Label {
102− id: subtitleLabel;
103− objectName: "subtitleLabel";
104− anchors { right: parent.right;
105− left: parent.left;
106− rightMargin: units.gu(1);
107− top: titleLabel.bottom;
108− }
109− anchors.topMargin: units.dp(2);
110− elide: Text.ElideRight;
111− maximumLineCount: 1;
112− fontSize: "x-small";
113− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
114− color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white");
115− visible: titleLabel.visible && titleLabel.text;
116− text: cardData && cardData["subtitle"] || "";
117− font.weight: Font.Light;
118− }
119−
120− ]
121− }
122−
123− ]
124− }
125−implicitHeight: row.y + row.height + units.gu(1);
126−}
tests/plugins/Dash/cardcreator/2.tstdeleted−4
@@ -1,4 +0,0 @@
1−template: {"card-background":{"elements":["#E9E9E9"],"type":"color"},"card-layout":"vertical","card-size":"medium","category-layout":"grid","collapsed-rows":2}
2−components: {"art":{"aspect-ratio":1},"background":{"field":"background"},"mascot":{"field":"icon"},"subtitle":{"field":"author"},"title":{"field":"title"},"attributes":{}}
3−artShapeStyle: icon
4−result: 2.res
tests/plugins/Dash/cardcreator/3.resdeleted−90
@@ -1,90 +0,0 @@
1−AbstractButton {
2− id: root;
3− property var cardData;
4− property string backgroundShapeStyle: "flat";
5− property real fontScale: 1.0;
6− property var scopeStyle: null;
7− readonly property string title: cardData && cardData["title"] || "";
8− property bool showHeader: true;
9− implicitWidth: childrenRect.width;
10− enabled: true;
11− property int fixedHeaderHeight: -1;
12− property size fixedArtShapeSize: Qt.size(-1, -1);
13−signal action(var actionId);
14−Loader {
15− id: artShapeLoader;
16− height: root.fixedArtShapeSize.height;
17− width: root.fixedArtShapeSize.width;
18− anchors { horizontalCenter: parent.horizontalCenter; }
19− objectName: "artShapeLoader";
20− readonly property string cardArt: cardData && cardData["art"] || decodeURI("IHAVE%5C%22ESCAPED%5C%22QUOTES%5C%22");
21− onCardArtChanged: { if (item) { item.image.source = cardArt; } }
22− active: cardArt != "";
23− asynchronous: true;
24− visible: status === Loader.Ready;
25− sourceComponent: Item {
26− id: artShape;
27− objectName: "artShape";
28− visible: image.status === Image.Ready;
29− readonly property alias image: artImage;
30− ProportionalShape {
31− anchors.left: parent.left;
32− anchors.right: parent.right;
33− source: artImage;
34− aspect: UbuntuShape.DropShadow;
35− }
36− width: root.fixedArtShapeSize.width;
37− height: root.fixedArtShapeSize.height;
38− CroppedImageMinimumSourceSize {
39− id: artImage;
40− objectName: "artImage";
41− source: artShapeLoader.cardArt;
42− asynchronous: true;
43− visible: false;
44− width: root.width;
45− height: width / (root.fixedArtShapeSize.width / root.fixedArtShapeSize.height);
46− onStatusChanged: if (status === Image.Error) source = decodeURI("IHAVE%5C%22ESCAPED%5C%22QUOTES%5C%22");
47− }
48− }
49− }
50−readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;
51−Label {
52− id: titleLabel;
53− objectName: "titleLabel";
54− anchors { right: parent.right;
55− left: parent.left;
56− top: artShapeLoader.bottom;
57− topMargin: units.gu(1);
58− }
59− elide: Text.ElideRight;
60− fontSize: "small";
61− wrapMode: Text.Wrap;
62− maximumLineCount: 2;
63− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
64− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
65− visible: showHeader ;
66− width: undefined;
67− text: root.title;
68− font.weight: Font.Normal;
69− horizontalAlignment: Text.AlignLeft;
70− }
71−Label {
72− id: subtitleLabel;
73− objectName: "subtitleLabel";
74− anchors { left: titleLabel.left;
75− leftMargin: titleLabel.leftMargin;
76− right: titleLabel.right;
77− top: titleLabel.bottom;
78− }
79− anchors.topMargin: units.dp(2);
80− elide: Text.ElideRight;
81− maximumLineCount: 1;
82− fontSize: "x-small";
83− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
84− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
85− visible: titleLabel.visible && titleLabel.text;
86− text: cardData && cardData["subtitle"] || "";
87− font.weight: Font.Light;
88− }
89−implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
90−}
tests/plugins/Dash/cardcreator/3.res.cardcreatordeleted−86
@@ -1,86 +0,0 @@
1−AbstractButton {
2− id: root;
3− property var cardData;
4− property string backgroundShapeStyle: "flat";
5− property real fontScale: 1.0;
6− property var scopeStyle: null;
7− readonly property string title: cardData && cardData["title"] || "";
8− property bool showHeader: true;
9− implicitWidth: childrenRect.width;
10− enabled: true;
11−signal action(var actionId);
12−readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
13−Loader {
14− id: artShapeLoader;
15− anchors { horizontalCenter: parent.horizontalCenter; }
16− objectName: "artShapeLoader";
17− readonly property string cardArt: cardData && cardData["art"] || "";
18− onCardArtChanged: { if (item) { item.image.source = cardArt; } }
19− active: cardArt != "";
20− asynchronous: false;
21− visible: status === Loader.Ready;
22− sourceComponent: Item {
23− id: artShape;
24− objectName: "artShape";
25− visible: image.status === Image.Ready;
26− readonly property alias image: artImage;
27− ProportionalShape {
28− anchors.left: parent.left;
29− anchors.right: parent.right;
30− source: artImage;
31− aspect: UbuntuShape.DropShadow;
32− }
33− width: image.status !== Image.Ready ? 0 : image.width;
34− height: image.status !== Image.Ready ? 0 : image.height;
35− CroppedImageMinimumSourceSize {
36− id: artImage;
37− objectName: "artImage";
38− source: artShapeLoader.cardArt;
39− asynchronous: false;
40− visible: false;
41− width: root.width;
42− height: width / 0.75;
43− }
44− }
45− }
46−readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;
47−Label {
48− id: titleLabel;
49− objectName: "titleLabel";
50− anchors { right: parent.right;
51− left: parent.left;
52− top: artShapeLoader.bottom;
53− topMargin: units.gu(1);
54− }
55− elide: Text.ElideRight;
56− fontSize: "small";
57− wrapMode: Text.Wrap;
58− maximumLineCount: 2;
59− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
60− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
61− visible: showHeader ;
62− width: undefined;
63− text: root.title;
64− font.weight: Font.Normal;
65− horizontalAlignment: Text.AlignLeft;
66− }
67−Label {
68− id: subtitleLabel;
69− objectName: "subtitleLabel";
70− anchors { left: titleLabel.left;
71− leftMargin: titleLabel.leftMargin;
72− right: titleLabel.right;
73− top: titleLabel.bottom;
74− }
75− anchors.topMargin: units.dp(2);
76− elide: Text.ElideRight;
77− maximumLineCount: 1;
78− fontSize: "x-small";
79− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
80− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
81− visible: titleLabel.visible && titleLabel.text;
82− text: cardData && cardData["subtitle"] || "";
83− font.weight: Font.Light;
84− }
85−implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
86−}
tests/plugins/Dash/cardcreator/3.tstdeleted−4
@@ -1,4 +0,0 @@
1−template: {"card-layout":"vertical","card-size":"small","category-layout":"grid","collapsed-rows":2}
2−components: {"art":{"aspect-ratio":0.75,"field":"art","fallback":"IHAVE\\\"ESCAPED\\\"QUOTES\\\""},"subtitle":{"field":"price"},"title":{"field":"title"},"attributes":{}}
3−artShapeStyle: icon
4−result: 3.res
tests/plugins/Dash/cardcreator/4.resdeleted−111
@@ -1,111 +0,0 @@
1−AbstractButton {
2− id: root;
3− property var cardData;
4− property string backgroundShapeStyle: "flat";
5− property real fontScale: 1.0;
6− property var scopeStyle: null;
7− readonly property string title: cardData && cardData["title"] || "";
8− property bool showHeader: true;
9− implicitWidth: childrenRect.width;
10− enabled: true;
11− property int fixedHeaderHeight: -1;
12− property size fixedArtShapeSize: Qt.size(-1, -1);
13−signal action(var actionId);
14−readonly property int headerHeight: row.height;
15−Row {
16− id: row;
17− objectName: "outerRow";
18− property real margins: units.gu(1);
19− spacing: margins;
20− height: root.fixedHeaderHeight;
21− anchors { top: parent.top;
22− topMargin: units.gu(1);
23− left: parent.left;
24−}
25− anchors.right: parent.right;
26− anchors.margins: margins;
27− anchors.rightMargin: 0;
28−data: [
29−Loader {
30− id: mascotShapeLoader;
31− objectName: "mascotShapeLoader";
32− asynchronous: true;
33− active: mascotImage.status === Image.Ready;
34− visible: showHeader && active && status === Loader.Ready;
35− width: units.gu(6);
36− height: units.gu(5.625);
37− sourceComponent: UbuntuShape { aspect: UbuntuShape.Flat; image: mascotImage }
38− anchors { verticalCenter: parent.verticalCenter; }
39− }
40−
41−,CroppedImageMinimumSourceSize {
42− id: mascotImage;
43− objectName: "mascotImage";
44− anchors { verticalCenter: parent.verticalCenter; }
45− source: cardData && cardData["mascot"] || "";
46− width: units.gu(6);
47− height: units.gu(5.625);
48− horizontalAlignment: Image.AlignHCenter;
49− verticalAlignment: Image.AlignVCenter;
50− visible: false;
51− }
52−
53−,Item {
54− id: headerTitleContainer;
55− anchors { verticalCenter: parent.verticalCenter; }
56− width: parent.width - x;
57− implicitHeight: titleLabel.height + subtitleLabel.height;
58− data: [
59−Label {
60− id: titleLabel;
61− objectName: "titleLabel";
62− anchors { right: parent.right;
63− rightMargin: units.gu(1);
64− left: parent.left;
65− top: parent.top; }
66− elide: Text.ElideRight;
67− fontSize: "small";
68− wrapMode: Text.Wrap;
69− maximumLineCount: 2;
70− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
71− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
72− visible: showHeader ;
73− width: undefined;
74− text: root.title;
75− font.weight: Font.Normal;
76− horizontalAlignment: Text.AlignLeft;
77− }
78−,Label {
79− id: subtitleLabel;
80− objectName: "subtitleLabel";
81− anchors { right: parent.right;
82− left: parent.left;
83− rightMargin: units.gu(1);
84− top: titleLabel.bottom;
85− }
86− anchors.topMargin: units.dp(2);
87− elide: Text.ElideRight;
88− maximumLineCount: 1;
89− fontSize: "x-small";
90− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
91− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
92− visible: titleLabel.visible && titleLabel.text;
93− text: cardData && cardData["subtitle"] || "";
94− font.weight: Font.Light;
95− }
96−]
97−}
98−]
99−}
100−Loader {
101− active: root.pressed;
102− anchors { fill: root }
103− sourceComponent: UbuntuShape {
104− objectName: "touchdown";
105− anchors.fill: parent;
106− radius: "small";
107− borderSource: "radius_pressed.sci"
108− }
109−}
110−implicitHeight: row.y + row.height + units.gu(1);
111−}
tests/plugins/Dash/cardcreator/4.res.cardcreatordeleted−99
@@ -1,99 +0,0 @@
1−AbstractButton {
2− id: root;
3− property var cardData;
4− property string backgroundShapeStyle: "flat";
5− property real fontScale: 1.0;
6− property var scopeStyle: null;
7− readonly property string title: cardData && cardData["title"] || "";
8− property bool showHeader: true;
9− implicitWidth: childrenRect.width;
10− enabled: true;
11−signal action(var actionId);
12−readonly property size artShapeSize: Qt.size(-1, -1);
13−readonly property int headerHeight: row.height;
14−Row {
15− id: row;
16− objectName: "outerRow";
17− property real margins: units.gu(1);
18− spacing: margins;
19− anchors { top: parent.top;
20− topMargin: units.gu(1);
21− left: parent.left;
22−}
23− anchors.right: parent.right;
24− anchors.margins: margins;
25− anchors.rightMargin: 0;
26−data: [
27−Loader {
28− id: mascotShapeLoader;
29− objectName: "mascotShapeLoader";
30− asynchronous: false;
31− active: mascotImage.status === Image.Ready;
32− visible: showHeader && active && status === Loader.Ready;
33− width: units.gu(6);
34− height: units.gu(5.625);
35− sourceComponent: UbuntuShape { aspect: UbuntuShape.Flat; image: mascotImage }
36− anchors { verticalCenter: parent.verticalCenter; }
37− }
38−
39−,CroppedImageMinimumSourceSize {
40− id: mascotImage;
41− objectName: "mascotImage";
42− anchors { verticalCenter: parent.verticalCenter; }
43− source: cardData && cardData["mascot"] || "";
44− width: units.gu(6);
45− height: units.gu(5.625);
46− horizontalAlignment: Image.AlignHCenter;
47− verticalAlignment: Image.AlignVCenter;
48− visible: false;
49− }
50−
51−,Item {
52− id: headerTitleContainer;
53− anchors { verticalCenter: parent.verticalCenter; }
54− width: parent.width - x;
55− implicitHeight: titleLabel.height + subtitleLabel.height;
56− data: [
57−Label {
58− id: titleLabel;
59− objectName: "titleLabel";
60− anchors { right: parent.right;
61− rightMargin: units.gu(1);
62− left: parent.left;
63− top: parent.top; }
64− elide: Text.ElideRight;
65− fontSize: "small";
66− wrapMode: Text.Wrap;
67− maximumLineCount: 2;
68− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
69− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
70− visible: showHeader ;
71− width: undefined;
72− text: root.title;
73− font.weight: Font.Normal;
74− horizontalAlignment: Text.AlignLeft;
75− }
76−,Label {
77− id: subtitleLabel;
78− objectName: "subtitleLabel";
79− anchors { right: parent.right;
80− left: parent.left;
81− rightMargin: units.gu(1);
82− top: titleLabel.bottom;
83− }
84− anchors.topMargin: units.dp(2);
85− elide: Text.ElideRight;
86− maximumLineCount: 1;
87− fontSize: "x-small";
88− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
89− color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
90− visible: titleLabel.visible && titleLabel.text;
91− text: cardData && cardData["subtitle"] || "";
92− font.weight: Font.Light;
93− }
94−]
95−}
96−]
97−}
98−implicitHeight: row.y + row.height + units.gu(1);
99−}
tests/plugins/Dash/cardcreator/4.tstdeleted−4
@@ -1,4 +0,0 @@
1−template: {"card-layout":"horizontal","card-size":"large","category-layout":"grid","collapsed-rows":2}
2−components: {"art":{"aspect-ratio":1},"mascot":{"field":"mascot"},"subtitle":{"field":"domain"},"title":{"field":"title"},"attributes":{}}
3−artShapeStyle: flat
4−result: 4.res
tests/plugins/Dash/cardcreator/5.resdeleted−102
@@ -1,102 +0,0 @@
1−AbstractButton {
2− id: root;
3− property var cardData;
4− property string backgroundShapeStyle: "flat";
5− property real fontScale: 1.0;
6− property var scopeStyle: null;
7− readonly property string title: cardData && cardData["title"] || "";
8− property bool showHeader: true;
9− implicitWidth: childrenRect.width;
10− enabled: false;
11− property int fixedHeaderHeight: -1;
12− property size fixedArtShapeSize: Qt.size(-1, -1);
13−signal action(var actionId);
14−Loader {
15− id: artShapeLoader;
16− height: root.fixedArtShapeSize.height;
17− width: root.fixedArtShapeSize.width;
18− anchors { horizontalCenter: parent.horizontalCenter; }
19− objectName: "artShapeLoader";
20− readonly property string cardArt: cardData && cardData["art"] || "";
21− onCardArtChanged: { if (item) { item.image.source = cardArt; } }
22− active: cardArt != "";
23− asynchronous: true;
24− visible: status === Loader.Ready;
25− sourceComponent: Item {
26− id: artShape;
27− objectName: "artShape";
28− visible: image.status === Image.Ready;
29− readonly property alias image: artImage;
30− width: root.fixedArtShapeSize.width;
31− height: root.fixedArtShapeSize.height;
32− CroppedImageMinimumSourceSize {
33− id: artImage;
34− objectName: "artImage";
35− source: artShapeLoader.cardArt;
36− asynchronous: true;
37− visible: true;
38− width: root.width;
39− height: width / (root.fixedArtShapeSize.width / root.fixedArtShapeSize.height);
40− }
41− }
42− }
43−Loader {
44− id: overlayLoader;
45− readonly property real overlayHeight: root.fixedHeaderHeight + units.gu(2);
46− anchors.fill: artShapeLoader;
47− active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false;
48− asynchronous: true;
49− visible: showHeader && status === Loader.Ready;
50− sourceComponent: UbuntuShapeOverlay {
51− id: overlay;
52− property real luminance: Style.luminance(overlayColor);
53− aspect: UbuntuShape.Flat;
54− radius: "small";
55− overlayColor: cardData && cardData["overlayColor"] || "#99000000";
56− overlayRect: Qt.rect(0, 1 - overlayLoader.overlayHeight / height, 1, 1);
57− }
58− }
59−readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;
60−Label {
61− id: titleLabel;
62− objectName: "titleLabel";
63− anchors { right: parent.right;
64− rightMargin: units.gu(1);
65− left: parent.left;
66− leftMargin: units.gu(1);
67− top: overlayLoader.top;
68− topMargin: units.gu(1) + overlayLoader.height - overlayLoader.overlayHeight;
69− }
70− elide: Text.ElideRight;
71− fontSize: "small";
72− wrapMode: Text.Wrap;
73− maximumLineCount: 2;
74− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
75− color: root.scopeStyle && overlayLoader.item ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item && overlayLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white");
76− visible: showHeader && overlayLoader.active;
77− width: undefined;
78− text: root.title;
79− font.weight: Font.Normal;
80− horizontalAlignment: Text.AlignLeft;
81− }
82−Label {
83− id: subtitleLabel;
84− objectName: "subtitleLabel";
85− anchors { left: titleLabel.left;
86− leftMargin: titleLabel.leftMargin;
87− rightMargin: units.gu(1);
88− right: titleLabel.right;
89− top: titleLabel.bottom;
90− }
91− anchors.topMargin: units.dp(2);
92− elide: Text.ElideRight;
93− maximumLineCount: 1;
94− fontSize: "x-small";
95− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
96− color: root.scopeStyle && overlayLoader.item ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item && overlayLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white");
97− visible: titleLabel.visible && titleLabel.text;
98− text: cardData && cardData["subtitle"] || "";
99− font.weight: Font.Light;
100− }
101−implicitHeight: artShapeLoader.height;
102−}
tests/plugins/Dash/cardcreator/5.res.cardcreatordeleted−99
@@ -1,99 +0,0 @@
1−AbstractButton {
2− id: root;
3− property var cardData;
4− property string backgroundShapeStyle: "flat";
5− property real fontScale: 1.0;
6− property var scopeStyle: null;
7− readonly property string title: cardData && cardData["title"] || "";
8− property bool showHeader: true;
9− implicitWidth: childrenRect.width;
10− enabled: false;
11−signal action(var actionId);
12−readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
13−Loader {
14− id: artShapeLoader;
15− anchors { horizontalCenter: parent.horizontalCenter; }
16− objectName: "artShapeLoader";
17− readonly property string cardArt: cardData && cardData["art"] || "";
18− onCardArtChanged: { if (item) { item.image.source = cardArt; } }
19− active: cardArt != "";
20− asynchronous: false;
21− visible: status === Loader.Ready;
22− sourceComponent: Item {
23− id: artShape;
24− objectName: "artShape";
25− visible: image.status === Image.Ready;
26− readonly property alias image: artImage;
27− width: image.status !== Image.Ready ? 0 : image.width;
28− height: image.status !== Image.Ready ? 0 : image.height;
29− CroppedImageMinimumSourceSize {
30− id: artImage;
31− objectName: "artImage";
32− source: artShapeLoader.cardArt;
33− asynchronous: false;
34− visible: true;
35− width: root.width;
36− height: width / 1;
37− }
38− }
39− }
40−Loader {
41− id: overlayLoader;
42− readonly property real overlayHeight: headerHeight + units.gu(2);
43− anchors.fill: artShapeLoader;
44− active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false;
45− asynchronous: false;
46− visible: showHeader && status === Loader.Ready;
47− sourceComponent: UbuntuShapeOverlay {
48− id: overlay;
49− property real luminance: Style.luminance(overlayColor);
50− aspect: UbuntuShape.Flat;
51− radius: "small";
52− overlayColor: cardData && cardData["overlayColor"] || "#99000000";
53− overlayRect: Qt.rect(0, 1 - overlayLoader.overlayHeight / height, 1, 1);
54− }
55− }
56−readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;
57−Label {
58− id: titleLabel;
59− objectName: "titleLabel";
60− anchors { right: parent.right;
61− rightMargin: units.gu(1);
62− left: parent.left;
63− leftMargin: units.gu(1);
64− top: overlayLoader.top;
65− topMargin: units.gu(1) + overlayLoader.height - overlayLoader.overlayHeight;
66− }
67− elide: Text.ElideRight;
68− fontSize: "small";
69− wrapMode: Text.Wrap;
70− maximumLineCount: 2;
71− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
72− color: root.scopeStyle && overlayLoader.item ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item && overlayLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white");
73− visible: showHeader && overlayLoader.active;
74− width: undefined;
75− text: root.title;
76− font.weight: Font.Normal;
77− horizontalAlignment: Text.AlignLeft;
78− }
79−Label {
80− id: subtitleLabel;
81− objectName: "subtitleLabel";
82− anchors { left: titleLabel.left;
83− leftMargin: titleLabel.leftMargin;
84− rightMargin: units.gu(1);
85− right: titleLabel.right;
86− top: titleLabel.bottom;
87− }
88− anchors.topMargin: units.dp(2);
89− elide: Text.ElideRight;
90− maximumLineCount: 1;
91− fontSize: "x-small";
92− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
93− color: root.scopeStyle && overlayLoader.item ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item && overlayLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white");
94− visible: titleLabel.visible && titleLabel.text;
95− text: cardData && cardData["subtitle"] || "";
96− font.weight: Font.Light;
97− }
98−implicitHeight: artShapeLoader.height;
99−}
tests/plugins/Dash/cardcreator/5.tstdeleted−4
@@ -1,4 +0,0 @@
1−template: {"non-interactive":true,"card-layout":"vertical","card-size":"medium","category-layout":"carousel","collapsed-rows":2,"overlay":true}
2−components: {"art":{"aspect-ratio":1,"field":"art","conciergeMode":true},"subtitle":{"field":"artist"},"title":{"field":"title"},"attributes":{}}
3−artShapeStyle: shadow
4−result: 5.res
tests/plugins/Dash/cardcreator/6.resdeleted−127

This diff is too big to show here.

tests/plugins/Dash/cardcreator/6.res.cardcreatordeleted−116

This diff is too big to show here.

tests/plugins/Dash/cardcreator/6.tstdeleted−4

This diff is too big to show here.

tests/plugins/Dash/cardcreator/7.resdeleted−141

This diff is too big to show here.

tests/plugins/Dash/cardcreator/7.res.cardcreatordeleted−139

This diff is too big to show here.

tests/plugins/Dash/cardcreator/7.tstdeleted−4

This diff is too big to show here.

tests/plugins/Dash/cardcreator/8.resdeleted−109

This diff is too big to show here.

tests/plugins/Dash/cardcreator/8.res.cardcreatordeleted−97

This diff is too big to show here.

tests/plugins/Dash/cardcreator/8.tstdeleted−4

This diff is too big to show here.

tests/plugins/Dash/cardcreator/9.resdeleted−120

This diff is too big to show here.

tests/plugins/Dash/cardcreator/9.res.cardcreatordeleted−109

This diff is too big to show here.

tests/plugins/Dash/cardcreator/9.tstdeleted−4

This diff is too big to show here.

tests/plugins/Dash/cardcreatortest.cppdeleted−126

This diff is too big to show here.

tests/plugins/Dash/cardcreatortest.qmldeleted−29

This diff is too big to show here.

tests/plugins/Dash/horizontaljournaltest.cppdeleted−490

This diff is too big to show here.

tests/plugins/Dash/horizontaljournaltest.qmldeleted−44

This diff is too big to show here.

tests/plugins/Dash/horizontaljournaltry.cppdeleted−91

This diff is too big to show here.

tests/plugins/Dash/horizontaljournaltry.qmldeleted−120

This diff is too big to show here.

tests/plugins/Dash/listviewwithpageheadersectionexternalmodeltest.cppdeleted−246

This diff is too big to show here.

tests/plugins/Dash/listviewwithpageheadersectiontest.cppdeleted−2212

This diff is too big to show here.

tests/plugins/Dash/listviewwithpageheadertest.cppdeleted−2038

This diff is too big to show here.

tests/plugins/Dash/listviewwithpageheadertest.qmldeleted−96

This diff is too big to show here.

tests/plugins/Dash/listviewwithpageheadertestsection.qmldeleted−119

This diff is too big to show here.

tests/plugins/Dash/listviewwithpageheadertestsectionexternalmodel.qmldeleted−76

This diff is too big to show here.

tests/plugins/Dash/organicgridtest.cppdeleted−533

This diff is too big to show here.

tests/plugins/Dash/organicgridtest.qmldeleted−44

This diff is too big to show here.

tests/plugins/Dash/organicgridtry.cppdeleted−99

This diff is too big to show here.

tests/plugins/Dash/organicgridtry.qmldeleted−114

This diff is too big to show here.

tests/plugins/Dash/tst_CardAttributes.qmldeleted−57

This diff is too big to show here.

tests/plugins/Dash/tst_CroppedImageMinimumSourceSize.qmldeleted−56

This diff is too big to show here.

tests/plugins/Dash/tst_ListViewWithPageHeaderQML.qmldeleted−140

This diff is too big to show here.

tests/plugins/Dash/tst_ScopeStyle.qmldeleted−188

This diff is too big to show here.

tests/plugins/Dash/verticaljournaltest.cppdeleted−564

This diff is too big to show here.

tests/plugins/Dash/verticaljournaltest.qmldeleted−45

This diff is too big to show here.

tests/plugins/Dash/verticaljournaltry.cppdeleted−91

This diff is too big to show here.

tests/plugins/Dash/verticaljournaltry.qmldeleted−121

This diff is too big to show here.

tests/qmltests/CMakeLists.txt−46

This diff is too big to show here.

tests/qmltests/Components/tst_ResponsiveVerticalJournal.qmldeleted−183

This diff is too big to show here.

tests/qmltests/Dash/CardHelpers.jsdeleted−115

This diff is too big to show here.

tests/qmltests/Dash/Filters/tst_FilterExpandableWidget.qmldeleted−99

This diff is too big to show here.

tests/qmltests/Dash/Filters/tst_FilterOptionSelector.qmldeleted−96

This diff is too big to show here.

tests/qmltests/Dash/Filters/tst_FilterRangeInput.qmldeleted−247

This diff is too big to show here.

tests/qmltests/Dash/Filters/tst_FilterValueSlider.qmldeleted−101

This diff is too big to show here.

tests/qmltests/Dash/Filters/tst_FilterWidgetFactory.qmldeleted−59

This diff is too big to show here.

tests/qmltests/Dash/Previews/MockPreviewWidget.qmldeleted−27

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_Preview.qmldeleted−214

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_PreviewActions.qmldeleted−262

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_PreviewAudioPlayback.qmldeleted−182

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_PreviewComment.qmldeleted−84

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_PreviewCommentInput.qmldeleted−113

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_PreviewExpandable.qmldeleted−353

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_PreviewHeader.qmldeleted−183

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_PreviewIconActions.qmldeleted−136

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_PreviewImageGallery.qmldeleted−147

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_PreviewInlineVideo.qmldeleted−155

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_PreviewMediaToolbar.qmldeleted−69

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_PreviewProgress.qmldeleted−100

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_PreviewRatingDisplay.qmldeleted−123

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_PreviewRatingDisplayCreationRanges.qmldeleted−131

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_PreviewRatingEdit.qmldeleted−87

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_PreviewRatingInput.qmldeleted−246

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_PreviewTable.qmldeleted−147

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_PreviewTextSummary.qmldeleted−87

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_PreviewVideoPlayback.qmldeleted−61

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qmldeleted−104

This diff is too big to show here.

tests/qmltests/Dash/Previews/tst_PreviewZoomableImage.qmldeleted−138

This diff is too big to show here.

tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingBoolean.qmldeleted−62

This diff is too big to show here.

tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingList.qmldeleted−84

This diff is too big to show here.

tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingNumber.qmldeleted−98

This diff is too big to show here.

tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingString.qmldeleted−88

This diff is too big to show here.

tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingsWidgetFactory.qmldeleted−65

This diff is too big to show here.

tests/qmltests/Dash/artwork/avatar@12.pngdeleted

Binary file not shown.

tests/qmltests/Dash/artwork/background.pngdeleted

Binary file not shown.

tests/qmltests/Dash/artwork/checkers.pngdeleted

Binary file not shown.

tests/qmltests/Dash/artwork/emblem.pngdeleted

Binary file not shown.

tests/qmltests/Dash/artwork/music-player-design.pngdeleted

Binary file not shown.

tests/qmltests/Dash/tst_Card.qmldeleted−682

This diff is too big to show here.

tests/qmltests/Dash/tst_CardBenchmark.qmldeleted−95

This diff is too big to show here.

tests/qmltests/Dash/tst_CardCarousel.qmldeleted−111

This diff is too big to show here.

tests/qmltests/Dash/tst_CardTool.qmldeleted−379

This diff is too big to show here.

tests/qmltests/Dash/tst_Dash.qmldeleted−648

This diff is too big to show here.

tests/qmltests/Dash/tst_DashContent.qmldeleted−730

This diff is too big to show here.

tests/qmltests/Dash/tst_DashPageHeader.qmldeleted−357

This diff is too big to show here.

tests/qmltests/Dash/tst_DashShell.qmldeleted−84

This diff is too big to show here.

tests/qmltests/Dash/tst_GenericScopeView.qmldeleted−706

This diff is too big to show here.

tests/qmltests/Dash/tst_PageHeader/logo-ubuntu-orange.svgdeleted−60

This diff is too big to show here.

tests/qmltests/Dash/tst_PreviewView.qmldeleted−122

This diff is too big to show here.

tools/CMakeLists.txt−1

This diff is too big to show here.

tools/scopetool/registry-tracker.cppdeleted−146

This diff is too big to show here.

tools/scopetool/registry-tracker.hdeleted−49

This diff is too big to show here.

tools/scopetool/scopetool.cppdeleted−116

This diff is too big to show here.