Commit 5d4042ed authored by Andrew Flegg's avatar Andrew Flegg

Refactor code, ensure full screen on devices other than Maemo 5

parent aa45acc3
......@@ -35,7 +35,14 @@ OTHER_FILES += \
qtc_packaging/debian_harmattan/copyright \
qtc_packaging/debian_harmattan/control \
qtc_packaging/debian_harmattan/compat \
qtc_packaging/debian_harmattan/changelog
qtc_packaging/debian_harmattan/changelog \
attitude.desktop \
qtc_packaging/debian_fremantle/changelog \
qtc_packaging/debian_fremantle/compat \
qtc_packaging/debian_fremantle/control \
qtc_packaging/debian_fremantle/copyright \
qtc_packaging/debian_fremantle/README \
qtc_packaging/debian_fremantle/rules
unix:!symbian:!maemo5 {
desktopfile.files = $${TARGET}.desktop
......
......@@ -2,7 +2,7 @@
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
......@@ -162,7 +162,7 @@
<value type="QString"></value>
</valuelist>
<valuelist key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedTimes" type="QVariantList">
<value type="QDateTime">2011-06-24T00:31:25</value>
<value type="QDateTime">2011-06-26T14:00:57</value>
</valuelist>
</valuemap>
<value key="ProjectExplorer.BuildStepList.StepsCount" type="int">2</value>
......@@ -615,7 +615,7 @@
<value type="QString"></value>
</valuelist>
<valuelist key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedTimes" type="QVariantList">
<value type="QDateTime">2011-06-26T11:14:12</value>
<value type="QDateTime">2011-06-27T21:02:26</value>
</valuelist>
</valuemap>
<value key="ProjectExplorer.BuildStepList.StepsCount" type="int">2</value>
......
......@@ -8,12 +8,19 @@ int main(int argc, char *argv[])
{
// This doesn't work; so let's get hacky later on...
// qputenv("N900_PORTRAIT_SENSORS", "1");
#if defined(Q_WS_MAEMO_5)
bool portrait = false;
bool fullscreen = false;
#else
bool portrait = true;
bool fullscreen = true;
#endif
QApplication app(argc, argv);
app.setProperty("NoMStyle", true);
QmlApplicationViewer viewer;
viewer.engine()->addImportPath("/opt/qtm11/imports");
/**
* Qt Quick 1.0 does not have the possibility to tell the QML if
......@@ -28,18 +35,25 @@ int main(int argc, char *argv[])
monitor, SLOT(activeChanged(bool)));
viewer.rootContext()->setContextProperty("activeMonitor", monitor);
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);
viewer.engine()->addImportPath(QString("/opt/qtm11/imports"));
#if defined(Q_WS_MAEMO_5)
viewer.engine()->rootContext()->setContextProperty("rotateFudge", 90);
viewer.engine()->rootContext()->setContextProperty("portraitDevice", portrait);
// Ideally, we'd work out is Qt Components was available, but that seems too tricky
#if defined(USE_QTC)
printf("Using the Qt Quick Components root...\n");
viewer.setMainQmlFile("qml/attitude/qtc-root.qml");
#else
viewer.engine()->rootContext()->setContextProperty("rotateFudge", 0);
printf("Using the pure QML root...\n");
viewer.setMainQmlFile("qml/attitude/Main.qml");
#endif
viewer.setMainQmlFile(QString("qml/attitude/Main.qml"));
// viewer.setMainQmlFile(QString("qml/attitude/qtc-root.qml"));
viewer.showFullScreen();
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);
if (fullscreen) {
viewer.showFullScreen();
} else {
viewer.show();
}
return app.exec();
app.exec();
}
......@@ -44,7 +44,11 @@ Accelerometer {
* Consider the current position as our default centre.
*/
function calibrate() {
calibration = [dip, angle]
if (calibration[0] == 0.0 || calibration[1] == 0.0) {
calibration = [dip, angle]
} else {
calibration = [0.0, 0.0]
}
}
......@@ -53,7 +57,7 @@ Accelerometer {
*/
Component.onCompleted: {
start();
console.log("Rotate fudge: " + rotateFudge + " deg")
console.log("Portrait = " + portraitDevice)
P.priv(self).previousDip = []
P.priv(self).previousAngle = []
}
......@@ -64,7 +68,7 @@ Accelerometer {
*/
onReadingChanged: {
var rawDip = Math.max(Math.min(reading.z / 9.8, 1), -1)
var rawAngle = rotateFudge + Math.atan2(-reading.y, reading.x) * 180/Math.PI
var rawAngle = (portraitDevice ? Math.atan2(-reading.y, reading.x) : Math.atan2(reading.x, reading.y)) * 180/Math.PI
var newDip = _updateList(P.priv(self).previousDip, rawDip, 1, 1000) - calibration[0]
var newAngle = _updateList(P.priv(self).previousAngle, rawAngle, 360.0, 100.0) - calibration[1]
......
......@@ -33,7 +33,7 @@ Item {
gradient: Gradient {
GradientStop { position: 0; color: "#006bd6" }
GradientStop { position: 0.66; color: "#1e94ff" }
GradientStop { position: 1; color: "#fe94ff" }
GradientStop { position: 1; color: "#1e94ff" }
}
}
......
......@@ -7,9 +7,18 @@ PageStackWindow {
showToolBar: false
showStatusBar: false
/**
* Contains the ground and the sky, and the pivot around which
* we rotate.
*/
initialPage: Main {}
Connections {
target: platformWindow
// onViewModeChanged: updateViewMode()
onVisibleChanged: updateVisible()
// onActiveChanged: updateActive()
}
function updateVisible() {
console.log(platformWindow.visible)
}
}
qtc_packaging/debian_fremantle/README
\ No newline at end of file
../debian_fremantle/README
\ No newline at end of file
qtc_packaging/debian_fremantle/changelog
\ No newline at end of file
../debian_fremantle/changelog
\ No newline at end of file
qtc_packaging/debian_fremantle/control
\ No newline at end of file
../debian_fremantle/control
\ No newline at end of file
qtc_packaging/debian_fremantle/copyright
\ No newline at end of file
../debian_fremantle/copyright
\ No newline at end of file
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