Added altitude display to detail screen. Added option to disable auto rotation.
[jspeed] / src / mainwindow.cpp
index f67121d..f8e9185 100644 (file)
@@ -33,6 +33,7 @@
 #include "speedalarm.h"
 #include "mediaplayer.h"
 #include "orientation.h"
+#include "settings.h"
 #include <QOrientationSensor>
 #include <QSensor>
 
@@ -113,6 +114,7 @@ bool MainWindow::loadTheme()
     }
 
     orientation_->setSupportedOrientations(orientations);
+    onOrientationChanged();
     orientation_->update();
 
     return true;
@@ -137,6 +139,7 @@ void MainWindow::openMenu()
         connect(menu_, SIGNAL(flip()), stack_, SLOT(flip()));
         connect(menu_, SIGNAL(themeChanged()), this, SLOT(loadTheme()));
         connect(menu_, SIGNAL(unitChanged()), &(Odometer::instance()), SLOT(updateUnit()));
+        connect(menu_, SIGNAL(orientationChanged()), this, SLOT(onOrientationChanged()));
     }
 
     menu_->show();
@@ -160,3 +163,21 @@ void MainWindow::keepBacklightOn()
 
     connection.call(msg);
 }
+
+void MainWindow::onOrientationChanged()
+{
+    QString value = Settings::instance().value("orientation").toString();
+
+    if(value == "auto")
+    {
+        orientation_->setOrientationType(Orientation::TYPE_AUTO);
+    }
+    else if(value == "landscape")
+    {
+        orientation_->setOrientationType(Orientation::TYPE_LANDSCAPE);
+    }
+    else if(value == "portrait")
+    {
+        orientation_->setOrientationType(Orientation::TYPE_PORTRAIT);
+    }
+}