#include "poialerts.h"
#include "speedalarm.h"
#include "mediaplayer.h"
+#include "orientation.h"
+#include "settings.h"
+#include <QOrientationSensor>
+#include <QSensor>
-MainWindow::MainWindow(): QMainWindow(0), menu_(0), themeLoader_(0), mainScreen_(0)
+
+MainWindow::MainWindow(): QMainWindow(0), menu_(0), themeLoader_(0),
+mainScreen_(0), orientation_(0)
{
setWindowTitle(tr("jSpeed"));
showFullScreen();
+ orientation_ = new Orientation(this);
+ orientation_->start();
addScreens();
QTimer::singleShot(500, this, SLOT(loadServices()));
}
return false;
}
- if(mainScreen_->orientationEnabled(WidgetScreen::LANDSCAPE) &&
- mainScreen_->orientationEnabled(WidgetScreen::PORTRAIT))
- {
- setAttribute(Qt::WA_Maemo5AutoOrientation, true);
- }
- else if(mainScreen_->orientationEnabled(WidgetScreen::PORTRAIT))
+ int orientations = 0;
+
+ if(mainScreen_->orientationEnabled(WidgetScreen::LANDSCAPE))
{
- setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
+ orientations |= Orientation::LANDSCAPE;
}
- else
+ if(mainScreen_->orientationEnabled(WidgetScreen::PORTRAIT))
{
- setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);
+ orientations |= Orientation::PORTRAIT;
}
+ orientation_->setSupportedOrientations(orientations);
+ onOrientationChanged();
+ orientation_->update();
+
return true;
}
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();
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);
+ }
+}