on xenial help sign in
Rotate shell is landscape mode specified with "NATIVE_ORIENTATION=landscape" env var
commitcc8051f66bf3569eb2dd6824d7c630a4d6f5a169 authorGerry Boland <gerry.boland@canonical.com> dateWed 12 Feb 2014, 13:46 (13 years ago) parent919a212
2 files changed+49−1
qml/ShellOrientator.qml+38 src/main.cpp+11−1
qml/ShellOrientator.qmlnew file+38
@@ -0,0 +1,38 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
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
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.0
18+import QtQuick.Window 2.0
19+import Ubuntu.Components 0.1
20+import Ubuntu.Gestures 0.1
21+
22+Item {
23+ id: orientator
24+
25+ // this is only here to select the width / height of the window if not running fullscreen
26+ property bool tablet: false
27+ width: tablet ? units.gu(160) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
28+ height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
29+
30+ OrientationHelper {
31+ orientationAngle: Screen.angleBetween(nativeOrientation, Screen.primaryOrientation)
32+ transitionEnabled: false
33+ ShellContents {
34+ anchors.fill: parent
35+ }
36+ }
37+}
38+
src/main.cpp+11−1
@@ -92,6 +92,16 @@ int startShell(int argc, const char** argv, void* server)
9292 view->setFlags(Qt::FramelessWindowHint);
9393 }
9494
95+ const QByteArray orientation = qgetenv("NATIVE_ORIENTATION");
96+ Qt::ScreenOrientation orientationAngle = Qt::PortraitOrientation;
97+ if (orientation == "landscape") {
98+ orientationAngle = Qt::LandscapeOrientation;
99+ } else if (!orientation.isEmpty() && orientation != "portrait") {
100+ qDebug() << "Unknown NATIVE_ORIENTATION setting, ignoring";
101+ }
102+
103+ view->rootContext()->setContextProperty("nativeOrientation", orientationAngle);
104+
95105 // You will need this if you want to interact with touch-only components using a mouse
96106 // Needed only when manually testing on a desktop.
97107 MouseTouchAdaptor *mouseTouchAdaptor = 0;
@@ -109,7 +119,7 @@ int startShell(int argc, const char** argv, void* server)
109119 nativeInterface->setProperty("ubuntuSessionType", 1);
110120 view->setProperty("role", 2); // INDICATOR_ACTOR_ROLE
111121
112− QUrl source(::qmlDirectory()+"Shell.qml");
122+ QUrl source(::qmlDirectory()+"ShellOrientator.qml");
113123 prependImportPaths(view->engine(), ::overrideImportPaths());
114124 appendImportPaths(view->engine(), ::fallbackImportPaths());
115125