on xenial help sign in
Fixes for dash as app

Load i18n catalog Process command line options Add the posibility to have a mouse touch adaptor Fixes: 1353351 Approved by: Michał Sawicz, PS Jenkins bot

commite9cd5c85eba18b95802388b04f74893bc3e82e0f authorAlbert Astals <albert.astals@canonical.com> dateWed 6 Aug 2014, 19:39 (12 years ago) parentb0f3e583b5087a
7 files changed+60−42
qml/Components/EdgeDemo.qml+15−15 qml/Dash/Dash.qml+8 qml/Dash/DashApplication.qml+6 qml/Greeter/Greeter.qml+1−1 qml/Shell.qml+3−22 src/Dash/CMakeLists.txt+1 src/Dash/main.cpp+26−4
qml/Components/EdgeDemo.qml+15−15
@@ -24,13 +24,13 @@ Item {
2424 property Item greeter
2525 property Item launcher
2626 property Item indicators
27− property Item underlay
27+ property Item stages
2828
2929 property bool launcherEnabled: true
30− property bool dashEnabled: true
30+ property bool stagesEnabled: true
3131 property bool panelEnabled: true
3232 property bool panelContentEnabled: true
33− property bool running: !launcherEnabled || !dashEnabled || !panelEnabled || !panelContentEnabled
33+ property bool running: !launcherEnabled || !stagesEnabled || !panelEnabled || !panelContentEnabled
3434
3535 property bool paused: false
3636
@@ -58,7 +58,7 @@ Item {
5858
5959 function stopDemo() {
6060 launcherEnabled = true
61− dashEnabled = true
61+ stagesEnabled = true
6262 panelEnabled = true
6363 panelContentEnabled = true
6464 if (d.rightEdgeDemo) d.rightEdgeDemo.destroy()
@@ -74,11 +74,11 @@ Item {
7474 }
7575
7676 launcherEnabled = false;
77− dashEnabled = false;
77+ stagesEnabled = false;
7878 panelEnabled = false;
7979 panelContentEnabled = false;
8080
81− // Begin with either greeter or dash, depending on which is visible
81+ // Begin with either greeter or top, depending on which is visible
8282 if (greeter && greeter.shown) {
8383 startRightEdgeDemo()
8484 } else {
@@ -138,12 +138,12 @@ Item {
138138
139139 function startTopEdgeDemo() {
140140 demo.panelEnabled = true;
141− if (demo.dash && demo.underlay) {
142− d.topEdgeDemo = d.overlay.createObject(demo.underlay, {
141+ if (demo.stages) {
142+ d.topEdgeDemo = d.overlay.createObject(demo.stages, {
143143 "edge": "top",
144144 "title": i18n.tr("Top edge"),
145145 "text": i18n.tr("Try swiping from the top edge to access the indicators"),
146− "anchors.fill": demo.underlay,
146+ "anchors.fill": demo.stages,
147147 });
148148 }
149149 if (d.topEdgeDemo) {
@@ -192,12 +192,12 @@ Item {
192192 function startLeftEdgeDemo() {
193193 demo.panelEnabled = false;
194194 demo.launcherEnabled = true;
195− if (demo.underlay) {
196− d.leftEdgeDemo = d.overlay.createObject(demo.underlay, {
195+ if (demo.stages) {
196+ d.leftEdgeDemo = d.overlay.createObject(demo.stages, {
197197 "edge": "left",
198198 "title": i18n.tr("Left edge"),
199199 "text": i18n.tr("Swipe from the left to reveal the launcher for quick access to apps"),
200− "anchors.fill": demo.underlay,
200+ "anchors.fill": demo.stages,
201201 });
202202 }
203203 if (d.leftEdgeDemo) {
@@ -220,12 +220,12 @@ Item {
220220
221221 function startFinalEdgeDemo() {
222222 demo.launcherEnabled = false;
223− if (demo.underlay) {
224− d.finalEdgeDemo = d.overlay.createObject(demo.underlay, {
223+ if (demo.stages) {
224+ d.finalEdgeDemo = d.overlay.createObject(demo.stages, {
225225 "edge": "none",
226226 "title": i18n.tr("Well done"),
227227 "text": i18n.tr("You have now mastered the edge gestures and can start using the phone<br><br>Tap on the screen to start"),
228− "anchors.fill": demo.underlay,
228+ "anchors.fill": demo.stages,
229229 "showSkip": false,
230230 });
231231 }
qml/Dash/Dash.qml+8
@@ -73,6 +73,14 @@ Showable {
7373 id: scopes
7474 }
7575
76+ Image {
77+ anchors.fill: parent
78+ source: parent.width > parent.height ? "graphics/paper_landscape.png" : "graphics/paper_portrait.png"
79+ fillMode: Image.PreserveAspectCrop
80+ horizontalAlignment: Image.AlignRight
81+ verticalAlignment: Image.AlignTop
82+ }
83+
7684 DashContent {
7785 id: dashContent
7886 objectName: "dashContent"
qml/Dash/DashApplication.qml+6
@@ -23,6 +23,12 @@ MainView {
2323
2424 useDeprecatedToolbar: false
2525
26+ Binding {
27+ target: i18n
28+ property: "domain"
29+ value: "unity8"
30+ }
31+
2632 Dash {
2733 anchors.fill: parent
2834 }
qml/Greeter/Greeter.qml+1−1
@@ -70,7 +70,7 @@ Showable {
7070 DraggingArea {
7171 id: dragHandle
7272 anchors.fill: parent
73− enabled: (greeter.narrowMode || !greeter.locked) && greeter.enabled
73+ enabled: (greeter.narrowMode || !greeter.locked) && greeter.enabled && greeter.shown
7474 orientation: Qt.Horizontal
7575 propagateComposedEvents: true
7676
qml/Shell.qml+3−22
@@ -112,25 +112,6 @@ Item {
112112 }
113113 }
114114
115− Item {
116− id: underlay
117− objectName: "underlay"
118− anchors.fill: parent
119−
120− // Whether the underlay is fully covered by opaque UI elements.
121− property bool fullyCovered: (panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth)
122− || stages.fullyShown || greeterWrapper.fullyShown
123− visible: !fullyCovered
124−
125− Image {
126− anchors.fill: underlay
127− source: shell.width > shell.height ? "Dash/graphics/paper_landscape.png" : "Dash/graphics/paper_portrait.png"
128− fillMode: Image.PreserveAspectCrop
129− horizontalAlignment: Image.AlignRight
130− verticalAlignment: Image.AlignTop
131− }
132− }
133−
134115 Item {
135116 id: stages
136117 objectName: "stages"
@@ -186,12 +167,12 @@ Item {
186167 Binding {
187168 target: applicationsDisplayLoader.item
188169 property: "interactive"
189− value: !greeter.shown && !lockscreen.shown && panel.indicators.fullyClosed && launcher.progress == 0
170+ value: edgeDemo.stagesEnabled && !greeter.shown && !lockscreen.shown && panel.indicators.fullyClosed && launcher.progress == 0
190171 }
191172 Binding {
192173 target: applicationsDisplayLoader.item
193174 property: "spreadEnabled"
194− value: greeter.fakeActiveForApp === "" // to support emergency dialer hack
175+ value: edgeDemo.stagesEnabled && greeter.fakeActiveForApp === "" // to support emergency dialer hack
195176 }
196177 Binding {
197178 target: applicationsDisplayLoader.item
@@ -580,7 +561,7 @@ Item {
580561 greeter: greeter
581562 launcher: launcher
582563 indicators: panel.indicators
583− underlay: underlay
564+ stages: stages
584565 }
585566
586567 Connections {
src/Dash/CMakeLists.txt+1
@@ -1,5 +1,6 @@
11set(DASH_SRCS
22 main.cpp
3+ ../MouseTouchAdaptor.cpp
34)
45
56add_executable(unity8-dash ${DASH_SRCS})
src/Dash/main.cpp+26−4
@@ -24,8 +24,10 @@
2424#include <QDebug>
2525#include <QCommandLineParser>
2626#include <QLibrary>
27+#include <libintl.h>
2728
2829#include <paths.h>
30+#include "../MouseTouchAdaptor.h"
2931
3032int main(int argc, const char *argv[])
3133{
@@ -35,11 +37,21 @@ int main(int argc, const char *argv[])
3537 parser.setApplicationDescription("Description: Unity 8 Shell Dash");
3638 parser.addHelpOption();
3739
38− QCommandLineOption testabilityOption("testability",
39− "Load the testability driver (Alternatively export QT_LOAD_TESTABILITY");
40− parser.addOption(testabilityOption);
40+ QCommandLineOption mousetouchOption("mousetouch",
41+ "Allow the mouse to provide touch input");
42+ parser.addOption(mousetouchOption);
4143
42− if (parser.isSet(testabilityOption) || getenv("QT_LOAD_TESTABILITY")) {
44+ // FIXME Remove once we drop the need of the hint
45+ QCommandLineOption desktopFileHintOption("desktop_file_hint",
46+ "The desktop_file_hint option for QtMir", "hint_file");
47+ parser.addOption(desktopFileHintOption);
48+
49+ // Treat args with single dashes the same as arguments with two dashes
50+ // Ex: -fullscreen == --fullscreen
51+ parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
52+ parser.process(*application);
53+
54+ if (getenv("QT_LOAD_TESTABILITY")) {
4355 QLibrary testLib(QLatin1String("qttestability"));
4456 if (testLib.load()) {
4557 typedef void (*TasInitialize)(void);
@@ -54,10 +66,20 @@ int main(int argc, const char *argv[])
5466 }
5567 }
5668
69+ bindtextdomain("unity8", translationDirectory().toUtf8().data());
70+
5771 QQuickView* view = new QQuickView();
5872 view->setResizeMode(QQuickView::SizeRootObjectToView);
5973 view->setTitle("Unity Dash");
6074
75+ // You will need this if you want to interact with touch-only components using a mouse
76+ // Needed only when manually testing on a desktop.
77+ MouseTouchAdaptor *mouseTouchAdaptor = 0;
78+ if (parser.isSet(mousetouchOption)) {
79+ mouseTouchAdaptor = new MouseTouchAdaptor;
80+ application->installNativeEventFilter(mouseTouchAdaptor);
81+ }
82+
6183 QUrl source(::qmlDirectory()+"Dash/DashApplication.qml");
6284 prependImportPaths(view->engine(), ::overrideImportPaths());
6385 appendImportPaths(view->engine(), ::fallbackImportPaths());