AdopterWindow to inherit from MainBase.
[dorian] / widgets / mainbase.cpp
index f3d176d..1869d14 100755 (executable)
@@ -1,10 +1,10 @@
 #include <QtGui>\r
 \r
-#include "mainwindow.h"\r
+#include "mainbase.h"\r
 #include "trace.h"\r
 #include "platform.h"\r
 \r
-MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), toolBar(0)\r
+MainBase::MainBase(QWidget *parent): QMainWindow(parent), toolBar(0)\r
 {\r
     TRACE;\r
 \r
@@ -37,11 +37,11 @@ MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), toolBar(0)
 #endif // Q_OS_SYMBIAN\r
 }\r
 \r
-QAction *MainWindow::addToolBarAction(QObject *receiver,\r
-                                      const char *member,\r
-                                      const QString &iconName,\r
-                                      const QString &text,\r
-                                      bool important)\r
+QAction *MainBase::addToolBarAction(QObject *receiver,\r
+                                    const char *member,\r
+                                    const QString &iconName,\r
+                                    const QString &text,\r
+                                    bool important)\r
 {\r
     TRACE;\r
     qDebug() << "icon" << iconName << "text" << text;\r
@@ -83,7 +83,7 @@ QAction *MainWindow::addToolBarAction(QObject *receiver,
     return action;\r
 }\r
 \r
-void MainWindow::addToolBarSpace()\r
+void MainBase::addToolBarSpace()\r
 {\r
 #ifndef Q_OS_SYMBIAN\r
     QFrame *frame = new QFrame(toolBar);\r
@@ -92,10 +92,9 @@ void MainWindow::addToolBarSpace()
 #endif\r
 }\r
 \r
-#ifdef Q_OS_SYMBIAN\r
-\r
-void MainWindow::updateToolBar()\r
+void MainBase::updateToolBar()\r
 {\r
+#ifdef Q_OS_SYMBIAN\r
     TRACE;\r
     if (toolBar) {\r
         QRect geometry = QApplication::desktop()->geometry();\r
@@ -109,38 +108,49 @@ void MainWindow::updateToolBar()
             toolBar->setVisible(false);\r
         }\r
     }\r
-}\r
-\r
-bool MainWindow::portrait()\r
-{\r
-    QRect geometry = QApplication::desktop()->geometry();\r
-    return geometry.width() < geometry.height();\r
-}\r
-\r
 #endif // Q_OS_SYMBIAN\r
+}\r
 \r
-void MainWindow::showEvent(QShowEvent *e)\r
+void MainBase::showEvent(QShowEvent *event)\r
 {\r
-    Trace t("MainWindow::showEvent");\r
-\r
-#ifdef Q_OS_SYMBIAN\r
+    Trace t("MainBase::showEvent");\r
     updateToolBar();\r
-#endif\r
-    QMainWindow::showEvent(e);\r
+    QMainWindow::showEvent(event);\r
 }\r
 \r
-void MainWindow::resizeEvent(QResizeEvent *event)\r
+void MainBase::resizeEvent(QResizeEvent *event)\r
 {\r
-    Trace t("MainWindow::resizeEvent");\r
-#ifdef Q_OS_SYMBIAN\r
+    Trace t("MainBase::resizeEvent");\r
     updateToolBar();\r
-#endif\r
     QMainWindow::resizeEvent(event);\r
 }\r
 \r
-void MainWindow::hideToolBar()\r
+void MainBase::hideToolBar()\r
 {\r
     if (toolBar) {\r
         toolBar->hide();\r
     }\r
 }\r
+\r
+bool MainBase::isToolBarHidden()\r
+{\r
+    return toolBar && toolBar->isHidden();\r
+}\r
+\r
+int MainBase::toolBarHeight()\r
+{\r
+    return toolBar? toolBar->height(): 0;\r
+}\r
+\r
+void MainBase::show()\r
+{\r
+    Trace t("MainBase::show");\r
+#ifdef Q_OS_SYMBIAN\r
+    foreach (QWidget *w, QApplication::allWidgets()) {\r
+        w->setContextMenuPolicy(Qt::NoContextMenu);\r
+    }\r
+    showMaximized();\r
+#else\r
+    QMainWindow::show();\r
+#endif\r
+}\r