on xenial help sign in
set minimum window sizes on dash
34b3f60Michael Zanetti
qml/Dash/DashApplication.qml+18−7
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014,2015 Canonical, Ltd.
2+ * Copyright (C) 2014-2016 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
@@ -17,15 +17,26 @@
17import QtQuick 2.4
17import QtQuick 2.4
18import Ubuntu.Components 1.3
18import Ubuntu.Components 1.3
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+import QtQuick.Window 2.0
20
21
21−MainView {
22+Window {
22− implicitWidth: units.gu(40)
23+ visible: true
23− implicitHeight: units.gu(68)
24+ title: i18n.tr("Scopes")
24
25
25− // Workaround bug #1475643
26+ width: initialWidth > 0 ? initialWidth : units.gu(40)
26− headerColor: Qt.rgba(0, 0, 0, 0)
27+ height: initialHeight > 0 ? initialHeight : units.gu(68)
27
28
28− Dash {
29+ minimumWidth: units.gu(40)
30+ minimumHeight: units.gu(40)
31+
32+ MainView {
29 anchors.fill: parent
33 anchors.fill: parent
34+
35+ // Workaround bug #1475643
36+ headerColor: Qt.rgba(0, 0, 0, 0)
37+
38+ Dash {
39+ anchors.fill: parent
40+ }
30 }
41 }
31}
42}
src/Dash/main.cpp+21−22
@@ -25,6 +25,7 @@
25#include <QCommandLineParser>
25#include <QCommandLineParser>
26#include <QLibrary>
26#include <QLibrary>
27#include <libintl.h>
27#include <libintl.h>
28+#include <QQmlApplicationEngine>
28
29
29#include <paths.h>
30#include <paths.h>
30#include "../qmldebuggerutils.h"
31#include "../qmldebuggerutils.h"
@@ -81,45 +82,43 @@ int main(int argc, const char *argv[])
81 bindtextdomain("unity8", translationDirectory().toUtf8().data());
82 bindtextdomain("unity8", translationDirectory().toUtf8().data());
82 textdomain("unity8");
83 textdomain("unity8");
83
84
84− QQuickView* view = new QQuickView();
85+ #ifdef UNITY8_ENABLE_TOUCH_EMULATION
85− view->setResizeMode(QQuickView::SizeRootObjectToView);
86+ // You will need this if you want to interact with touch-only components using a mouse
87+ // Needed only when manually testing on a desktop.
88+ MouseTouchAdaptor *mouseTouchAdaptor = 0;
89+ if (parser.isSet(mousetouchOption)) {
90+ mouseTouchAdaptor = MouseTouchAdaptor::instance();
91+ }
92+ #endif
86
93
94+ QQmlApplicationEngine engine;
95+
96+ int initialWidth = -1;
97+ int initialHeight = -1;
87 if (parser.isSet(windowGeometryOption) &&
98 if (parser.isSet(windowGeometryOption) &&
88 parser.value(windowGeometryOption).split('x').size() == 2)
99 parser.value(windowGeometryOption).split('x').size() == 2)
89 {
100 {
90 QStringList geom = parser.value(windowGeometryOption).split('x');
101 QStringList geom = parser.value(windowGeometryOption).split('x');
91 QSize windowSize(geom.at(0).toInt(), geom.at(1).toInt());
102 QSize windowSize(geom.at(0).toInt(), geom.at(1).toInt());
92 if (windowSize.isValid()) {
103 if (windowSize.isValid()) {
93− view->setWidth(windowSize.width());
104+ initialWidth = windowSize.width();
94− view->setHeight(windowSize.height());
105+ initialHeight = windowSize.height();
95 }
106 }
96 }
107 }
97−
108+ engine.rootContext()->setContextProperty("initialWidth", initialWidth);
98− view->setTitle(QStringLiteral("Scopes"));
109+ engine.rootContext()->setContextProperty("initialHeight", initialHeight);
99−
100− #ifdef UNITY8_ENABLE_TOUCH_EMULATION
101− // You will need this if you want to interact with touch-only components using a mouse
102− // Needed only when manually testing on a desktop.
103− MouseTouchAdaptor *mouseTouchAdaptor = 0;
104− if (parser.isSet(mousetouchOption)) {
105− mouseTouchAdaptor = MouseTouchAdaptor::instance();
106− }
107− #endif
108
110
109 QUrl source(::qmlDirectory() + "/Dash/DashApplication.qml");
111 QUrl source(::qmlDirectory() + "/Dash/DashApplication.qml");
110− prependImportPaths(view->engine(), ::overrideImportPaths());
112+ prependImportPaths(&engine, ::overrideImportPaths());
111− appendImportPaths(view->engine(), ::fallbackImportPaths());
113+ appendImportPaths(&engine, ::fallbackImportPaths());
112
114
113 CachingNetworkManagerFactory *managerFactory = new CachingNetworkManagerFactory();
115 CachingNetworkManagerFactory *managerFactory = new CachingNetworkManagerFactory();
114− view->engine()->setNetworkAccessManagerFactory(managerFactory);
116+ engine.setNetworkAccessManagerFactory(managerFactory);
115
117
116− view->setSource(source);
118+ engine.load(source);
117− view->show();
118
119
119 int result = application->exec();
120 int result = application->exec();
120
121
121− delete view;
122−
123 #ifdef UNITY8_ENABLE_TOUCH_EMULATION
122 #ifdef UNITY8_ENABLE_TOUCH_EMULATION
124 delete mouseTouchAdaptor;
123 delete mouseTouchAdaptor;
125 #endif
124 #endif