Added zpos attribute to all elements. Changed architecture to allow detailscreen...
[jspeed] / src / mainwindow.cpp
index f383234..39b41b3 100644 (file)
 #include <QMaemo5InformationBox>
 #include "mainwindow.h"
 #include "mainwindowstack.h"
-#include "theme.h"
-#include "detailwidget.h"
-#include "detailscreen.h"
+#include "themeloader.h"
 #include "mainmenu.h"
 #include "odometer.h"
+#include "widgetscreen.h"
 
-MainWindow::MainWindow(): QMainWindow(0), menu_(0), theme_(0)
+MainWindow::MainWindow(): QMainWindow(0), menu_(0), themeLoader_(0), mainScreen_(0)
 {
     setWindowTitle(tr("jSpeed"));
     showFullScreen();
@@ -42,6 +41,7 @@ MainWindow::MainWindow(): QMainWindow(0), menu_(0), theme_(0)
 
 MainWindow::~MainWindow()
 {
+    delete themeLoader_;
 }
 
 void MainWindow::addScreens()
@@ -52,17 +52,18 @@ void MainWindow::addScreens()
     connect(stack_, SIGNAL(settingsPressed()), this, SLOT(openMenu()));
     connect(stack_, SIGNAL(closePressed()), this, SIGNAL(quit()));
 
-    DetailWidget* details = new DetailWidget(this);
+    mainScreen_ = new WidgetScreen(this);
+    WidgetScreen* detailScreen = new WidgetScreen(this);
 
-    theme_ = new Theme(details->getScreen());
+    themeLoader_ = new ThemeLoader(mainScreen_, detailScreen);
 
     if(!loadTheme())
     {
         return;
     }
 
-    stack_->addScreen(theme_);
-    stack_->addScreen(details);
+    stack_->addScreen(mainScreen_);
+    stack_->addScreen(detailScreen);
 
     connect(QApplication::desktop(), SIGNAL(resized(int)), stack_, SLOT(reArrange()));
 
@@ -71,18 +72,19 @@ void MainWindow::addScreens()
 
 bool MainWindow::loadTheme()
 {
-    if(!theme_->load())
+    if(!themeLoader_->load())
     {
-        QMaemo5InformationBox::information(this, tr("Unable to load theme: %1").arg(theme_->error()));
+        QMaemo5InformationBox::information(this, tr("Unable to load theme: %1").arg(themeLoader_->error()));
         close();
         return false;
     }
 
-    if(theme_->landscapeEnabled() && theme_->portraitEnabled())
+    if(mainScreen_->orientationEnabled(WidgetScreen::LANDSCAPE) &&
+       mainScreen_->orientationEnabled(WidgetScreen::PORTRAIT))
     {
         setAttribute(Qt::WA_Maemo5AutoOrientation, true);
     }
-    else if(theme_->portraitEnabled())
+    else if(mainScreen_->orientationEnabled(WidgetScreen::PORTRAIT))
     {
         setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
     }