on xenial help sign in
Add support for -windowgeometry in dash
b41eeadMichał Sawicz
qml/Dash/DashApplication.qml+2−2
@@ -19,8 +19,8 @@ import Ubuntu.Components 1.0
19import Ubuntu.Thumbnailer 0.1 // Register support for image://thumbnailer/ and image://albumart/
19import Ubuntu.Thumbnailer 0.1 // Register support for image://thumbnailer/ and image://albumart/
20
20
21MainView {
21MainView {
22− width: units.gu(40)
22+ width: applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
23− height: units.gu(71)
23+ height: applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(68)
24
24
25 useDeprecatedToolbar: false
25 useDeprecatedToolbar: false
26
26
src/Dash/CMakeLists.txt+1
@@ -1,5 +1,6 @@
1set(DASH_SRCS
1set(DASH_SRCS
2 main.cpp
2 main.cpp
3+ ../ApplicationArguments.h
3 ../MouseTouchAdaptor.cpp
4 ../MouseTouchAdaptor.cpp
4 ../CachingNetworkManagerFactory.cpp
5 ../CachingNetworkManagerFactory.cpp
5)
6)
src/Dash/main.cpp+15−1
@@ -28,6 +28,7 @@
28
28
29#include <paths.h>
29#include <paths.h>
30#include "../MouseTouchAdaptor.h"
30#include "../MouseTouchAdaptor.h"
31+#include "../ApplicationArguments.h"
31#include "../CachingNetworkManagerFactory.h"
32#include "../CachingNetworkManagerFactory.h"
32
33
33int main(int argc, const char *argv[])
34int main(int argc, const char *argv[])
@@ -42,7 +43,11 @@ int main(int argc, const char *argv[])
42 "Allow the mouse to provide touch input");
43 "Allow the mouse to provide touch input");
43 parser.addOption(mousetouchOption);
44 parser.addOption(mousetouchOption);
44
45
46+ QCommandLineOption windowGeometryOption(QStringList() << "windowgeometry",
47+ "Specify the window geometry as [<width>x<height>]", "windowgeometry", "1");
48+ parser.addOption(windowGeometryOption);
49+
45− // FIXME Remove once we drop the need of the hint
50+ // FIXME Remove once we drop the need of the hint
46 QCommandLineOption desktopFileHintOption("desktop_file_hint",
51 QCommandLineOption desktopFileHintOption("desktop_file_hint",
47 "The desktop_file_hint option for QtMir", "hint_file");
52 "The desktop_file_hint option for QtMir", "hint_file");
48 parser.addOption(desktopFileHintOption);
53 parser.addOption(desktopFileHintOption);
@@ -52,6 +57,14 @@ int main(int argc, const char *argv[])
52 parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
57 parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
53 parser.process(*application);
58 parser.process(*application);
54
59
60+ ApplicationArguments qmlArgs;
61+ if (parser.isSet(windowGeometryOption) &&
62+ parser.value(windowGeometryOption).split('x').size() == 2)
63+ {
64+ QStringList geom = parser.value(windowGeometryOption).split('x');
65+ qmlArgs.setSize(geom.at(0).toInt(), geom.at(1).toInt());
66+ }
67+
55 if (getenv("QT_LOAD_TESTABILITY")) {
68 if (getenv("QT_LOAD_TESTABILITY")) {
56 QLibrary testLib(QLatin1String("qttestability"));
69 QLibrary testLib(QLatin1String("qttestability"));
57 if (testLib.load()) {
70 if (testLib.load()) {
@@ -72,6 +85,7 @@ int main(int argc, const char *argv[])
72 QQuickView* view = new QQuickView();
85 QQuickView* view = new QQuickView();
73 view->setResizeMode(QQuickView::SizeRootObjectToView);
86 view->setResizeMode(QQuickView::SizeRootObjectToView);
74 view->setTitle("Unity Dash");
87 view->setTitle("Unity Dash");
88+ view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
75
89
76 // You will need this if you want to interact with touch-only components using a mouse
90 // You will need this if you want to interact with touch-only components using a mouse
77 // Needed only when manually testing on a desktop.
91 // Needed only when manually testing on a desktop.