on xenial help sign in
Add support for -windowgeometry in dash
commitb41eead1977d9306769297f2d004600ee681d1e0 authorMichał Sawicz <michal.sawicz@canonical.com> dateThu 4 Sep 2014, 15:15 (12 years ago) parente805fc5
3 files changed+18−3
qml/Dash/DashApplication.qml+2−2 src/Dash/CMakeLists.txt+1 src/Dash/main.cpp+15−1
qml/Dash/DashApplication.qml+2−2
@@ -19,8 +19,8 @@ import Ubuntu.Components 1.0
1919import Ubuntu.Thumbnailer 0.1 // Register support for image://thumbnailer/ and image://albumart/
2020
2121MainView {
22− width: units.gu(40)
23− height: units.gu(71)
22+ width: applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
23+ height: applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(68)
2424
2525 useDeprecatedToolbar: false
2626
src/Dash/CMakeLists.txt+1
@@ -1,5 +1,6 @@
11set(DASH_SRCS
22 main.cpp
3+ ../ApplicationArguments.h
34 ../MouseTouchAdaptor.cpp
45 ../CachingNetworkManagerFactory.cpp
56)
src/Dash/main.cpp+15−1
@@ -28,6 +28,7 @@
2828
2929#include <paths.h>
3030#include "../MouseTouchAdaptor.h"
31+#include "../ApplicationArguments.h"
3132#include "../CachingNetworkManagerFactory.h"
3233
3334int main(int argc, const char *argv[])
@@ -42,7 +43,11 @@ int main(int argc, const char *argv[])
4243 "Allow the mouse to provide touch input");
4344 parser.addOption(mousetouchOption);
4445
45− // FIXME Remove once we drop the need of the hint
46+ QCommandLineOption windowGeometryOption(QStringList() << "windowgeometry",
47+ "Specify the window geometry as [<width>x<height>]", "windowgeometry", "1");
48+ parser.addOption(windowGeometryOption);
49+
50+ // FIXME Remove once we drop the need of the hint
4651 QCommandLineOption desktopFileHintOption("desktop_file_hint",
4752 "The desktop_file_hint option for QtMir", "hint_file");
4853 parser.addOption(desktopFileHintOption);
@@ -52,6 +57,14 @@ int main(int argc, const char *argv[])
5257 parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
5358 parser.process(*application);
5459
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+
5568 if (getenv("QT_LOAD_TESTABILITY")) {
5669 QLibrary testLib(QLatin1String("qttestability"));
5770 if (testLib.load()) {
@@ -72,6 +85,7 @@ int main(int argc, const char *argv[])
7285 QQuickView* view = new QQuickView();
7386 view->setResizeMode(QQuickView::SizeRootObjectToView);
7487 view->setTitle("Unity Dash");
88+ view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
7589
7690 // You will need this if you want to interact with touch-only components using a mouse
7791 // Needed only when manually testing on a desktop.