Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #30 from bzeller/qt5
[orientation] Enable rotation handling
  • Loading branch information
sledges committed Nov 19, 2013
2 parents 104c873 + a46d979 commit 956ec93
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 51 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -10,3 +10,6 @@
*.lai
*.la
*.a

# Creator user file
*.pro.user
9 changes: 9 additions & 0 deletions src/main.cpp
Expand Up @@ -23,12 +23,21 @@

#include <homeapplication.h>
#include <QFont>
#include <QScreen>
#include <homewindow.h>

int main(int argc, char **argv)
{
HomeApplication app(argc, argv, QString());

QScreen *sc = app.primaryScreen();
if (sc) {
sc->setOrientationUpdateMask(Qt::LandscapeOrientation
| Qt::PortraitOrientation
| Qt::InvertedLandscapeOrientation
| Qt::InvertedPortraitOrientation);
}

QGuiApplication::setFont(QFont("Open Sans"));
setenv("EGL_PLATFORM", "wayland", 1);
setenv("QT_QPA_PLATFORM", "wayland", 1);
Expand Down
45 changes: 25 additions & 20 deletions src/qml/NotificationPreview.qml
Expand Up @@ -25,6 +25,7 @@
import QtQuick 2.0
//import org.freedesktop.contextkit 1.0
import org.nemomobile.lipstick 0.1
import QtQuick.Window 2.1

Item {
id: notificationWindow
Expand All @@ -34,22 +35,14 @@ Item {
width: initialSize.width
height: initialSize.height

/*
TODO
ContextProperty {
id: orientationAngleContextProperty
key: "/Screen/CurrentWindow/OrientationAngle"
}
*/

QtObject {
id: orientationAngleContextProperty
property int value: 0
property int orientationAngle : Screen.angleBetween(Screen.primaryOrientation,Screen.orientation)
onOrientationAngleChanged: {
console.debug("Changed to Value: "+orientationAngle)
}

MouseArea {
id: notificationArea
property bool isPortrait: (orientationAngleContextProperty.value == 90 || orientationAngleContextProperty.value == 270)
property bool isPortrait: (orientationAngle == 90 || orientationAngle == 270)
property int notificationHeight: 102
property int notificationMargin: 14
property int notificationIconSize: 60
Expand All @@ -58,25 +51,37 @@ Item {
width: isPortrait ? notificationWindow.height : notificationWindow.width
height: notificationArea.notificationHeight
transform: Rotation {
origin.x: { switch(orientationAngleContextProperty.value) {
case 270:
return notificationWindow.height / 2
origin.x: { switch(orientationAngle) {
case 180:
case 90:
case 270:
return notificationWindow.width / 2
case 90:
return notificationWindow.height / 2
default:
return 0
} }
origin.y: { switch(orientationAngleContextProperty.value) {
origin.y: { switch(orientationAngle) {
case 270:
return notificationWindow.width / 2
case 180:
return notificationWindow.height / 2
case 90:
return notificationWindow.width / 2
return notificationWindow.height / 2
default:
return 0
} }
angle: (orientationAngleContextProperty.value === undefined || orientationAngleContextProperty.value == 0) ? 0 : -360 + orientationAngleContextProperty.value
angle: {
switch (orientationAngle) {
case undefined:
case 0:
return 0;
case 180:
return -180;
case 90:
return -90;
case 270:
return 90;
}
}
}

onClicked: if (notificationPreviewPresenter.notification != null) notificationPreviewPresenter.notification.actionInvoked("default")
Expand Down
44 changes: 25 additions & 19 deletions src/qml/USBModeSelector.qml
Expand Up @@ -2,23 +2,17 @@ import QtQuick 2.0
import org.nemomobile.lipstick 0.1
//import org.freedesktop.contextkit 1.0
import com.nokia.meego 2.0
import QtQuick.Window 2.1

Item {
property bool isPortrait: (orientationAngleContextProperty.value == 90 || orientationAngleContextProperty.value == 270)
property bool isPortrait: (orientationAngle == 90 || orientationAngle == 270)
id: usbWindow
width: initialSize.width
height: initialSize.height

/*
TODO
ContextProperty {
id: orientationAngleContextProperty
key: "/Screen/CurrentWindow/OrientationAngle"
}
*/
QtObject {
id: orientationAngleContextProperty
property int value: 0
property int orientationAngle : Screen.angleBetween(Screen.primaryOrientation,Screen.orientation)
onOrientationAngleChanged: {
console.debug("Changed to Value: "+orientationAngle)
}

Item {
Expand All @@ -27,25 +21,37 @@ Item {
width: usbWindow.isPortrait ? usbWindow.height : usbWindow.width
height: usbWindow.isPortrait ? usbWindow.width : usbWindow.height
transform: Rotation {
origin.x: { switch(orientationAngleContextProperty.value) {
case 270:
return usbWindow.height / 2
origin.x: { switch(orientationAngle) {
case 180:
case 90:
case 270:
return usbWindow.width / 2
case 90:
return usbWindow.height / 2
default:
return 0
} }
origin.y: { switch(orientationAngleContextProperty.value) {
origin.y: { switch(orientationAngle) {
case 270:
return usbWindow.width / 2
case 180:
return usbWindow.height / 2
case 90:
return usbWindow.width / 2
return usbWindow.height / 2
default:
return 0
} }
angle: (orientationAngleContextProperty.value === undefined || orientationAngleContextProperty.value == 0) ? 0 : -360 + orientationAngleContextProperty.value
angle: {
switch (orientationAngle) {
case undefined:
case 0:
return 0;
case 180:
return -180;
case 90:
return -90;
case 270:
return 90;
}
}
}
opacity: shouldBeVisible ? 1 : 0

Expand Down
17 changes: 5 additions & 12 deletions src/qml/VolumeControl.qml
Expand Up @@ -2,27 +2,20 @@ import QtQuick 2.0
import org.nemomobile.lipstick 0.1
//import org.freedesktop.contextkit 1.0
import com.nokia.meego 2.0
import QtQuick.Window 2.1

Item {
id: volumeWindow

property bool isPortrait: (orientationAngleContextProperty.value == 90 || orientationAngleContextProperty.value == 270)
property bool isPortrait: (orientationAngle == 90 || orientationAngle == 270)

width: initialSize.width
height: initialSize.height

/*
TODO
ContextProperty {
id: orientationAngleContextProperty
key: "/Screen/CurrentWindow/OrientationAngle"
property int orientationAngle : Screen.angleBetween(Screen.primaryOrientation,Screen.orientation)
onOrientationAngleChanged: {
console.debug("Changed to Value: "+orientationAngle)
}
*/
QtObject {
id: orientationAngleContextProperty
property int value: 0
}


Item {
anchors.centerIn: parent
Expand Down

0 comments on commit 956ec93

Please sign in to comment.