Commit 3b2dc8d2 authored by Aleksi Suomalainen's avatar Aleksi Suomalainen

[rotation] Rotate homescreen by device orientation (by filippz).

parent 471a66cd
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <QQmlEngine> #include <QQmlEngine>
#include <QQmlContext> #include <QQmlContext>
#include "glacierwindowmodel.h" #include "glacierwindowmodel.h"
#include <QScreen>
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
...@@ -36,6 +37,27 @@ int main(int argc, char **argv) ...@@ -36,6 +37,27 @@ int main(int argc, char **argv)
QGuiApplication::setFont(QFont("Open Sans")); QGuiApplication::setFont(QFont("Open Sans"));
app.setCompositorPath("/usr/share/lipstick-glacier-home-qt5/qml/compositor.qml"); app.setCompositorPath("/usr/share/lipstick-glacier-home-qt5/qml/compositor.qml");
Qt::ScreenOrientation nativeOrientation = app.primaryScreen()->nativeOrientation();
QByteArray v = qgetenv("GLACIER_NATIVEORIENTATION");
if (!v.isEmpty()) {
switch (v.toInt()) {
case 1:
nativeOrientation = Qt::PortraitOrientation;
break;
case 2:
nativeOrientation = Qt::LandscapeOrientation;
break;
case 4:
nativeOrientation = Qt::InvertedPortraitOrientation;
break;
case 8:
nativeOrientation = Qt::InvertedLandscapeOrientation;
break;
default:
nativeOrientation = app.primaryScreen()->nativeOrientation();
}
}
app.engine()->rootContext()->setContextProperty("nativeOrientation", v);
qmlRegisterType<GlacierWindowModel>("org.nemomobile.glacier", 1, 0 ,"GlacierWindowModel"); qmlRegisterType<GlacierWindowModel>("org.nemomobile.glacier", 1, 0 ,"GlacierWindowModel");
app.setQmlPath("/usr/share/lipstick-glacier-home-qt5/qml/MainScreen.qml"); app.setQmlPath("/usr/share/lipstick-glacier-home-qt5/qml/MainScreen.qml");
// Give these to the environment inside the lipstick homescreen // Give these to the environment inside the lipstick homescreen
......
QT_QUICK_CONTROLS_STYLE=Nemo QT_QUICK_CONTROLS_STYLE=Nemo
GLACIER_NATIVEORIENTATION=1
...@@ -36,10 +36,11 @@ import QtQuick.Controls.Styles.Nemo 1.0 ...@@ -36,10 +36,11 @@ import QtQuick.Controls.Styles.Nemo 1.0
import QtQuick.Window 2.1 import QtQuick.Window 2.1
import org.nemomobile.time 1.0 import org.nemomobile.time 1.0
import org.nemomobile.configuration 1.0 import org.nemomobile.configuration 1.0
import org.nemomobile.lipstick 0.1
import "scripts/desktop.js" as Desktop import "scripts/desktop.js" as Desktop
import "scripts/rotation.js" as Rotation
Page { Page {
// This is used in the favorites page and in the lock screen // This is used in the favorites page and in the lock screen
WallClock { WallClock {
id: wallClock id: wallClock
...@@ -56,6 +57,7 @@ Page { ...@@ -56,6 +57,7 @@ Page {
property alias lockscreen: lockScreen property alias lockscreen: lockScreen
property alias switcher: switcher property alias switcher: switcher
// Implements back key navigation // Implements back key navigation
Keys.onReleased: { Keys.onReleased: {
if (event.key === Qt.Key_Back) { if (event.key === Qt.Key_Back) {
if (pageStack.depth > 1) { if (pageStack.depth > 1) {
...@@ -69,6 +71,15 @@ Page { ...@@ -69,6 +71,15 @@ Page {
id: statusbar id: statusbar
} }
orientation: Lipstick.compositor.screenOrientation
onOrientationChanged: {
Rotation.rotateObject(desktop.parent, Screen.angleBetween(orientation,Screen.primaryOrientation), Screen.angleBetween(nativeOrientation, Screen.primaryOrientation))
}
onParentChanged: {
Rotation.rotateObject(desktop.parent, Screen.angleBetween(nativeOrientation, Screen.primaryOrientation), Screen.angleBetween(nativeOrientation, Screen.primaryOrientation))
}
Component.onCompleted: { Component.onCompleted: {
Desktop.instance = desktop Desktop.instance = desktop
} }
......
...@@ -43,7 +43,8 @@ qmlcompositor.files = qml/compositor/WindowWrapperMystic.qml \ ...@@ -43,7 +43,8 @@ qmlcompositor.files = qml/compositor/WindowWrapperMystic.qml \
qml/compositor/ScreenGestureArea.qml qml/compositor/ScreenGestureArea.qml
scripts.path = /usr/share/lipstick-glacier-home-qt5/qml/scripts scripts.path = /usr/share/lipstick-glacier-home-qt5/qml/scripts
scripts.files = qml/scripts/desktop.js scripts.files = qml/scripts/desktop.js \
qml/scripts/rotation.js
system.path = /usr/share/lipstick-glacier-home-qt5/qml/system system.path = /usr/share/lipstick-glacier-home-qt5/qml/system
system.files = qml/ShutdownScreen.qml system.files = qml/ShutdownScreen.qml
...@@ -104,6 +105,7 @@ OTHER_FILES += qml/*.qml \ ...@@ -104,6 +105,7 @@ OTHER_FILES += qml/*.qml \
qml/VolumeControl.qml \ qml/VolumeControl.qml \
qml/BatteryPanel.qml \ qml/BatteryPanel.qml \
qml/CommonPanel.qml \ qml/CommonPanel.qml \
qml/ShutdownScreen.qml qml/ShutdownScreen.qml \
qml/scripts/rotation.js
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment