on xenial help sign in
Make -windowgeometry work again
015ddf9Daniel d'Andrada
qml/Dash/DashApplication.qml+3−3
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014,2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -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: applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
22+ implicitWidth: units.gu(40)
23− height: applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(68)
23+ implicitHeight: units.gu(68)
24
24
25 useDeprecatedToolbar: false
25 useDeprecatedToolbar: false
26
26
qml/OrientedShell.qml+3
@@ -25,6 +25,9 @@ Rectangle {
25 id: root
25 id: root
26 color: "black"
26 color: "black"
27
27
28+ implicitWidth: units.gu(40)
29+ implicitHeight: units.gu(71)
30+
28 // NB: native and primary orientations here don't map exactly to their QScreen counterparts
31 // NB: native and primary orientations here don't map exactly to their QScreen counterparts
29 readonly property int nativeOrientation: width > height ? Qt.LandscapeOrientation : Qt.PortraitOrientation
32 readonly property int nativeOrientation: width > height ? Qt.LandscapeOrientation : Qt.PortraitOrientation
30
33
src/ApplicationArguments.h−9
@@ -31,18 +31,9 @@ public:
31 ApplicationArguments(QObject *parent = nullptr);
31 ApplicationArguments(QObject *parent = nullptr);
32
32
33 void setDeviceName(QString deviceName) { m_deviceName = deviceName; }
33 void setDeviceName(QString deviceName) { m_deviceName = deviceName; }
34−
35− void setSize(const QSize &size) {
36− m_size = size;
37− }
38−
39− Q_INVOKABLE int width() const { return m_size.width(); }
40− Q_INVOKABLE int height() const { return m_size.height(); }
41−
42 QString deviceName() const { return m_deviceName; }
34 QString deviceName() const { return m_deviceName; }
43
35
44private:
36private:
45− QSize m_size;
46 QString m_deviceName;
37 QString m_deviceName;
47};
38};
48
39
src/Dash/main.cpp+12−6
@@ -61,12 +61,6 @@ int main(int argc, const char *argv[])
61 parser.process(*application);
61 parser.process(*application);
62
62
63 ApplicationArguments qmlArgs;
63 ApplicationArguments qmlArgs;
64− if (parser.isSet(windowGeometryOption) &&
65− parser.value(windowGeometryOption).split('x').size() == 2)
66− {
67− QStringList geom = parser.value(windowGeometryOption).split('x');
68− qmlArgs.setSize(QSize(geom.at(0).toInt(), geom.at(1).toInt()));
69− }
70
64
71 if (getenv("QT_LOAD_TESTABILITY")) {
65 if (getenv("QT_LOAD_TESTABILITY")) {
72 QLibrary testLib(QLatin1String("qttestability"));
66 QLibrary testLib(QLatin1String("qttestability"));
@@ -88,6 +82,18 @@ int main(int argc, const char *argv[])
88
82
89 QQuickView* view = new QQuickView();
83 QQuickView* view = new QQuickView();
90 view->setResizeMode(QQuickView::SizeRootObjectToView);
84 view->setResizeMode(QQuickView::SizeRootObjectToView);
85+
86+ if (parser.isSet(windowGeometryOption) &&
87+ parser.value(windowGeometryOption).split('x').size() == 2)
88+ {
89+ QStringList geom = parser.value(windowGeometryOption).split('x');
90+ QSize windowSize(geom.at(0).toInt(), geom.at(1).toInt());
91+ if (windowSize.isValid()) {
92+ view->setWidth(windowSize.width());
93+ view->setHeight(windowSize.height());
94+ }
95+ }
96+
91 view->setTitle("Scopes");
97 view->setTitle("Scopes");
92 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
98 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
93
99
src/main.cpp+6−1
@@ -54,7 +54,6 @@ int main(int argc, const char *argv[])
54 UnityCommandLineParser parser(*application);
54 UnityCommandLineParser parser(*application);
55
55
56 ApplicationArguments qmlArgs;
56 ApplicationArguments qmlArgs;
57− qmlArgs.setSize(parser.windowGeometry());
58
57
59 if (!parser.deviceName().isEmpty()) {
58 if (!parser.deviceName().isEmpty()) {
60 qmlArgs.setDeviceName(parser.deviceName());
59 qmlArgs.setDeviceName(parser.deviceName());
@@ -88,6 +87,12 @@ int main(int argc, const char *argv[])
88 view->setResizeMode(QQuickView::SizeRootObjectToView);
87 view->setResizeMode(QQuickView::SizeRootObjectToView);
89 view->setColor("black");
88 view->setColor("black");
90 view->setTitle("Unity8 Shell");
89 view->setTitle("Unity8 Shell");
90+
91+ if (parser.windowGeometry().isValid()) {
92+ view->setWidth(parser.windowGeometry().width());
93+ view->setHeight(parser.windowGeometry().height());
94+ }
95+
91 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
96 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
92 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
97 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
93 view->rootContext()->setContextProperty("shellMode", parser.mode());
98 view->rootContext()->setContextProperty("shellMode", parser.mode());