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

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

parent 471a66cd
......@@ -28,6 +28,7 @@
#include <QQmlEngine>
#include <QQmlContext>
#include "glacierwindowmodel.h"
#include <QScreen>
int main(int argc, char **argv)
{
......@@ -36,6 +37,27 @@ int main(int argc, char **argv)
QGuiApplication::setFont(QFont("Open Sans"));
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");
app.setQmlPath("/usr/share/lipstick-glacier-home-qt5/qml/MainScreen.qml");
// Give these to the environment inside the lipstick homescreen
......
QT_QUICK_CONTROLS_STYLE=Nemo
GLACIER_NATIVEORIENTATION=1
......@@ -36,10 +36,11 @@ import QtQuick.Controls.Styles.Nemo 1.0
import QtQuick.Window 2.1
import org.nemomobile.time 1.0
import org.nemomobile.configuration 1.0
import org.nemomobile.lipstick 0.1
import "scripts/desktop.js" as Desktop
import "scripts/rotation.js" as Rotation
Page {
// This is used in the favorites page and in the lock screen
WallClock {
id: wallClock
......@@ -56,6 +57,7 @@ Page {
property alias lockscreen: lockScreen
property alias switcher: switcher
// Implements back key navigation
Keys.onReleased: {
if (event.key === Qt.Key_Back) {
if (pageStack.depth > 1) {
......@@ -69,6 +71,15 @@ Page {
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: {
Desktop.instance = desktop
}
......
......@@ -43,7 +43,8 @@ qmlcompositor.files = qml/compositor/WindowWrapperMystic.qml \
qml/compositor/ScreenGestureArea.qml
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.files = qml/ShutdownScreen.qml
......@@ -104,6 +105,7 @@ OTHER_FILES += qml/*.qml \
qml/VolumeControl.qml \
qml/BatteryPanel.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