Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[orientation] Enable rotation handling #30

Merged
merged 2 commits into from Nov 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this only true on devices where landscape is the default fb orientation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to think of a mechanism to handle any device regardless of its default orientation.
I vote for let's pull the trigger this time and have nice lipstick rotations on N9, because this change is not what @bzeller introduced (see the deleted line).
When we jump aboard another device with differing default orientation, will solve then

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