Commit e9156fc8 authored by Aleksi Suomalainen's avatar Aleksi Suomalainen

Merge pull request #30 from locusf/master

Orientation and small fixes
parents 6a3fc00e 797b89ee
......@@ -9,7 +9,7 @@ Name: lipstick-glacier-home-qt5
# << macros
Summary: A nice homescreen for Glacier experience
Version: 0.15
Version: 0.16
Release: 1
Group: System/GUI/Other
License: BSD
......
Name: lipstick-glacier-home-qt5
Summary: A nice homescreen for Glacier experience
Version: 0.15
Version: 0.16
Release: 1
Group: System/GUI/Other
License: BSD
......
......@@ -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
}
......
......@@ -125,7 +125,7 @@ Item {
font.pointSize: 6
font.bold: true
wrapMode: Text.ElideRight
text: (cellularNetworkName !== "") ? cellularNetworkName.value.substring(0,3).toUpperCase() : "N/A"
text: (cellularNetworkName.value !== "") ? cellularNetworkName.value.substring(0,3).toUpperCase() : "NA"
}
Label {
......@@ -136,7 +136,7 @@ Item {
font.pointSize: 6
text: {
var techToG = {gprs: "2", egprs: "2.5", umts: "3", hspa: "3.5", lte: "4", unknown: "0"}
return techToG[cellularDataTechnology.value] + "G"
return techToG[cellularDataTechnology.value ? cellularDataTechnology.value : "unknown"] + "G"
}
}
panel: SimPanel {}
......@@ -212,6 +212,8 @@ Item {
return "qrc:/qml/images/battery4.png"
} else if (batteryChargePercentage.value <= 80) {
return "qrc:/qml/images/battery5.png"
} else {
return "qrc:/qml/images/battery6.png"
}
}
}
......
......@@ -70,6 +70,10 @@ Compositor {
}
}
onSensorOrientationChanged: {
screenOrientation = sensorOrientation
}
Connections {
target: root
onActiveFocusItemChanged: {
......
/****************************************************************************************
**
** Copyright (C) 2014 Aleksi Suomalainen <suomalainen.aleksi@gmail.com>
** All rights reserved.
**
** You may use this file under the terms of BSD license as follows:
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** * Neither the name of the author nor the
** names of its contributors may be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
****************************************************************************************/
function rotateObject(obj, r, nr) {
if (obj.rotation !== r) {
var nativeIsPortrait = ((nr === 0) || (nr === 180))
var isPortrait = ((r === 0) || (r === 180))
var correction = 0
var isNative=((nativeIsPortrait || isPortrait) && !(nativeIsPortrait && isPortrait)) //xor
//xor
if ((isNative || !nativeIsPortrait) && !(isNative && !nativeIsPortrait)) {
correction = obj.width / 2 - obj.height / 2
}
var diff = Math.abs(r - obj.rotation)
obj.rotation = r
if ((diff === 90) || (diff === 270)) {
console.log("rotateObject swapping w,h")
var w = obj.width
obj.width = obj.height
obj.height = w
}
obj.x = correction
obj.y = -correction
}
}
......@@ -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