Rename widgets/mainwindow to widgets/mainbase.
authorAkos Polster <akos@pipacs.com>
Sun, 5 Dec 2010 00:37:37 +0000 (01:37 +0100)
committerAkos Polster <akos@pipacs.com>
Sun, 5 Dec 2010 00:37:37 +0000 (01:37 +0100)
dorian.pro
widgets/mainbase.cpp [new file with mode: 0755]
widgets/mainbase.h [new file with mode: 0755]
widgets/mainwindow.cpp [deleted file]
widgets/mainwindow.h [deleted file]

index 48ef01f..6911270 100644 (file)
@@ -40,7 +40,7 @@ SOURCES += \
     searchresultinfodialog.cpp \\r
     widgets/progressdialog.cpp \\r
     widgets/splash.cpp \\r
-    widgets/mainwindow.cpp\r
+    widgets/mainbase.cpp\r
 \r
 HEADERS += \\r
     mainwindow.h \\r
@@ -82,7 +82,7 @@ HEADERS += \
     searchresultinfodialog.h \\r
     widgets/progressdialog.h \\r
     widgets/splash.h \\r
-    widgets/mainwindow.h\r
+    widgets/mainbase.h\r
 \r
 RESOURCES += \\r
     dorian.qrc\r
diff --git a/widgets/mainbase.cpp b/widgets/mainbase.cpp
new file mode 100755 (executable)
index 0000000..f3d176d
--- /dev/null
@@ -0,0 +1,146 @@
+#include <QtGui>\r
+\r
+#include "mainwindow.h"\r
+#include "trace.h"\r
+#include "platform.h"\r
+\r
+MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), toolBar(0)\r
+{\r
+    TRACE;\r
+\r
+#ifdef Q_WS_MAEMO_5\r
+    setAttribute(Qt::WA_Maemo5StackedWindow, true);\r
+#endif\r
+\r
+    QFrame *frame = new QFrame(this);\r
+    QVBoxLayout *layout = new QVBoxLayout(frame);\r
+    layout->setMargin(0);\r
+    frame->setLayout(layout);\r
+    //frame->show();\r
+    setCentralWidget(frame);\r
+\r
+#ifdef Q_OS_SYMBIAN\r
+    QAction *closeAction = new QAction(parent? tr("Back"): tr("Exit"), this);\r
+    closeAction->setSoftKeyRole(QAction::NegativeSoftKey);\r
+    connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));\r
+    QMainWindow::addAction(closeAction);\r
+#else\r
+    // Tool bar\r
+    setUnifiedTitleAndToolBarOnMac(true);\r
+    toolBar = addToolBar("");\r
+    toolBar->setMovable(false);\r
+    toolBar->setFloatable(false);\r
+    toolBar->toggleViewAction()->setVisible(false);\r
+#if defined(Q_WS_X11) && !defined(Q_WS_MAEMO_5)\r
+    toolBar->setIconSize(QSize(42, 42));\r
+#endif\r
+#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
+{\r
+    TRACE;\r
+    qDebug() << "icon" << iconName << "text" << text;\r
+    QAction *action;\r
+#ifndef Q_OS_SYMBIAN\r
+    Q_UNUSED(important);\r
+    action = toolBar->addAction(QIcon(Platform::instance()->icon(iconName)),\r
+                                text, receiver, member);\r
+#else\r
+    if (!toolBar && important) {\r
+        // Create tool bar if needed\r
+        toolBar = new QToolBar("", this);\r
+        // toolBar->setFixedHeight(63);\r
+        toolBar->setStyleSheet("margin:0; border:0; padding:0");\r
+        toolBar->setSizePolicy(QSizePolicy::MinimumExpanding,\r
+                               QSizePolicy::Maximum);\r
+        addToolBar(Qt::BottomToolBarArea, toolBar);\r
+    }\r
+    if (important) {\r
+        // Add tool bar action\r
+        QPushButton *button = new QPushButton(this);\r
+        button->setIconSize(QSize(60, 60));\r
+        button->setFixedSize(89, 60);\r
+        button->setIcon(QIcon(Platform::instance()->icon(iconName)));\r
+        button->setSizePolicy(QSizePolicy::MinimumExpanding,\r
+                              QSizePolicy::Maximum);\r
+        connect(button, SIGNAL(clicked()), receiver, member);\r
+        toolBar->addWidget(button);\r
+    }\r
+    // Add menu action, too\r
+    action = new QAction(text, this);\r
+    menuBar()->addAction(action);\r
+    connect(action, SIGNAL(triggered()), receiver, member);\r
+#endif\r
+\r
+    action->setText("");\r
+    action->setToolTip("");\r
+\r
+    return action;\r
+}\r
+\r
+void MainWindow::addToolBarSpace()\r
+{\r
+#ifndef Q_OS_SYMBIAN\r
+    QFrame *frame = new QFrame(toolBar);\r
+    frame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);\r
+    toolBar->addWidget(frame);\r
+#endif\r
+}\r
+\r
+#ifdef Q_OS_SYMBIAN\r
+\r
+void MainWindow::updateToolBar()\r
+{\r
+    TRACE;\r
+    if (toolBar) {\r
+        QRect geometry = QApplication::desktop()->geometry();\r
+        bool isPortrait = geometry.width() < geometry.height();\r
+        bool isToolBarHidden = toolBar->isHidden();\r
+        if (isPortrait && isToolBarHidden) {\r
+            qDebug() << "Show tool bar";\r
+            toolBar->setVisible(true);\r
+        } else if (!isPortrait && !isToolBarHidden) {\r
+            qDebug() << "Hide tool bar";\r
+            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
+void MainWindow::showEvent(QShowEvent *e)\r
+{\r
+    Trace t("MainWindow::showEvent");\r
+\r
+#ifdef Q_OS_SYMBIAN\r
+    updateToolBar();\r
+#endif\r
+    QMainWindow::showEvent(e);\r
+}\r
+\r
+void MainWindow::resizeEvent(QResizeEvent *event)\r
+{\r
+    Trace t("MainWindow::resizeEvent");\r
+#ifdef Q_OS_SYMBIAN\r
+    updateToolBar();\r
+#endif\r
+    QMainWindow::resizeEvent(event);\r
+}\r
+\r
+void MainWindow::hideToolBar()\r
+{\r
+    if (toolBar) {\r
+        toolBar->hide();\r
+    }\r
+}\r
diff --git a/widgets/mainbase.h b/widgets/mainbase.h
new file mode 100755 (executable)
index 0000000..62b1ba3
--- /dev/null
@@ -0,0 +1,61 @@
+#ifndef MAINWINDOW_H\r
+#define MAINWINDOW_H\r
+\r
+#include <QMainWindow>\r
+\r
+class QToolBar;\r
+\r
+/**\r
+ * Main window with a toolbar.\r
+ */\r
+class MainWindow: public QMainWindow\r
+{\r
+    Q_OBJECT\r
+\r
+public:\r
+    explicit MainWindow(QWidget *parent = 0);\r
+\r
+    /**\r
+     * Add action that is visible on the tool bar.\r
+     * @param   receiver    Object receiving "activated" signal.\r
+     * @param   slot        Slot receiving "activated" signal.\r
+     * @param   iconName    Base name of tool bar icon in resource file.\r
+     * @param   text        Tool bar item text.\r
+     * @param   important   On Symbian, only "important" actions are added to\r
+     *                      the tool bar. All actions are added to the Options\r
+     *                      menu though.\r
+     */\r
+    QAction *addToolBarAction(QObject *receiver, const char *slot,\r
+                              const QString &iconName, const QString &text,\r
+                              bool important = false);\r
+\r
+    /** Add spacing to tool bar. */\r
+    void addToolBarSpace();\r
+\r
+signals:\r
+\r
+public slots:\r
+\r
+protected:\r
+    /** Handle resize event: Manage tool bar visibility. */\r
+    void resizeEvent(QResizeEvent *event);\r
+\r
+    /** Handle show event: Manage tool bar visibility. */\r
+    void showEvent(QShowEvent *event);\r
+\r
+#ifdef Q_OS_SYMBIAN\r
+    /** Update toolbar visibility. */\r
+    void updateToolBar();\r
+\r
+    /** Return true in portrait mode. */\r
+    bool portrait();\r
+#endif // Q_OS_SYMBIAN\r
+\r
+    /** Hide tool bar if visible. */\r
+    void hideToolBar();\r
+\r
+private:\r
+    QToolBar *toolBar;      /**< Tool bar. */\r
+};\r
+\r
+#endif // MAINWINDOW_H\r
diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp
deleted file mode 100755 (executable)
index f3d176d..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-#include <QtGui>\r
-\r
-#include "mainwindow.h"\r
-#include "trace.h"\r
-#include "platform.h"\r
-\r
-MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), toolBar(0)\r
-{\r
-    TRACE;\r
-\r
-#ifdef Q_WS_MAEMO_5\r
-    setAttribute(Qt::WA_Maemo5StackedWindow, true);\r
-#endif\r
-\r
-    QFrame *frame = new QFrame(this);\r
-    QVBoxLayout *layout = new QVBoxLayout(frame);\r
-    layout->setMargin(0);\r
-    frame->setLayout(layout);\r
-    //frame->show();\r
-    setCentralWidget(frame);\r
-\r
-#ifdef Q_OS_SYMBIAN\r
-    QAction *closeAction = new QAction(parent? tr("Back"): tr("Exit"), this);\r
-    closeAction->setSoftKeyRole(QAction::NegativeSoftKey);\r
-    connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));\r
-    QMainWindow::addAction(closeAction);\r
-#else\r
-    // Tool bar\r
-    setUnifiedTitleAndToolBarOnMac(true);\r
-    toolBar = addToolBar("");\r
-    toolBar->setMovable(false);\r
-    toolBar->setFloatable(false);\r
-    toolBar->toggleViewAction()->setVisible(false);\r
-#if defined(Q_WS_X11) && !defined(Q_WS_MAEMO_5)\r
-    toolBar->setIconSize(QSize(42, 42));\r
-#endif\r
-#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
-{\r
-    TRACE;\r
-    qDebug() << "icon" << iconName << "text" << text;\r
-    QAction *action;\r
-#ifndef Q_OS_SYMBIAN\r
-    Q_UNUSED(important);\r
-    action = toolBar->addAction(QIcon(Platform::instance()->icon(iconName)),\r
-                                text, receiver, member);\r
-#else\r
-    if (!toolBar && important) {\r
-        // Create tool bar if needed\r
-        toolBar = new QToolBar("", this);\r
-        // toolBar->setFixedHeight(63);\r
-        toolBar->setStyleSheet("margin:0; border:0; padding:0");\r
-        toolBar->setSizePolicy(QSizePolicy::MinimumExpanding,\r
-                               QSizePolicy::Maximum);\r
-        addToolBar(Qt::BottomToolBarArea, toolBar);\r
-    }\r
-    if (important) {\r
-        // Add tool bar action\r
-        QPushButton *button = new QPushButton(this);\r
-        button->setIconSize(QSize(60, 60));\r
-        button->setFixedSize(89, 60);\r
-        button->setIcon(QIcon(Platform::instance()->icon(iconName)));\r
-        button->setSizePolicy(QSizePolicy::MinimumExpanding,\r
-                              QSizePolicy::Maximum);\r
-        connect(button, SIGNAL(clicked()), receiver, member);\r
-        toolBar->addWidget(button);\r
-    }\r
-    // Add menu action, too\r
-    action = new QAction(text, this);\r
-    menuBar()->addAction(action);\r
-    connect(action, SIGNAL(triggered()), receiver, member);\r
-#endif\r
-\r
-    action->setText("");\r
-    action->setToolTip("");\r
-\r
-    return action;\r
-}\r
-\r
-void MainWindow::addToolBarSpace()\r
-{\r
-#ifndef Q_OS_SYMBIAN\r
-    QFrame *frame = new QFrame(toolBar);\r
-    frame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);\r
-    toolBar->addWidget(frame);\r
-#endif\r
-}\r
-\r
-#ifdef Q_OS_SYMBIAN\r
-\r
-void MainWindow::updateToolBar()\r
-{\r
-    TRACE;\r
-    if (toolBar) {\r
-        QRect geometry = QApplication::desktop()->geometry();\r
-        bool isPortrait = geometry.width() < geometry.height();\r
-        bool isToolBarHidden = toolBar->isHidden();\r
-        if (isPortrait && isToolBarHidden) {\r
-            qDebug() << "Show tool bar";\r
-            toolBar->setVisible(true);\r
-        } else if (!isPortrait && !isToolBarHidden) {\r
-            qDebug() << "Hide tool bar";\r
-            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
-void MainWindow::showEvent(QShowEvent *e)\r
-{\r
-    Trace t("MainWindow::showEvent");\r
-\r
-#ifdef Q_OS_SYMBIAN\r
-    updateToolBar();\r
-#endif\r
-    QMainWindow::showEvent(e);\r
-}\r
-\r
-void MainWindow::resizeEvent(QResizeEvent *event)\r
-{\r
-    Trace t("MainWindow::resizeEvent");\r
-#ifdef Q_OS_SYMBIAN\r
-    updateToolBar();\r
-#endif\r
-    QMainWindow::resizeEvent(event);\r
-}\r
-\r
-void MainWindow::hideToolBar()\r
-{\r
-    if (toolBar) {\r
-        toolBar->hide();\r
-    }\r
-}\r
diff --git a/widgets/mainwindow.h b/widgets/mainwindow.h
deleted file mode 100755 (executable)
index 62b1ba3..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef MAINWINDOW_H\r
-#define MAINWINDOW_H\r
-\r
-#include <QMainWindow>\r
-\r
-class QToolBar;\r
-\r
-/**\r
- * Main window with a toolbar.\r
- */\r
-class MainWindow: public QMainWindow\r
-{\r
-    Q_OBJECT\r
-\r
-public:\r
-    explicit MainWindow(QWidget *parent = 0);\r
-\r
-    /**\r
-     * Add action that is visible on the tool bar.\r
-     * @param   receiver    Object receiving "activated" signal.\r
-     * @param   slot        Slot receiving "activated" signal.\r
-     * @param   iconName    Base name of tool bar icon in resource file.\r
-     * @param   text        Tool bar item text.\r
-     * @param   important   On Symbian, only "important" actions are added to\r
-     *                      the tool bar. All actions are added to the Options\r
-     *                      menu though.\r
-     */\r
-    QAction *addToolBarAction(QObject *receiver, const char *slot,\r
-                              const QString &iconName, const QString &text,\r
-                              bool important = false);\r
-\r
-    /** Add spacing to tool bar. */\r
-    void addToolBarSpace();\r
-\r
-signals:\r
-\r
-public slots:\r
-\r
-protected:\r
-    /** Handle resize event: Manage tool bar visibility. */\r
-    void resizeEvent(QResizeEvent *event);\r
-\r
-    /** Handle show event: Manage tool bar visibility. */\r
-    void showEvent(QShowEvent *event);\r
-\r
-#ifdef Q_OS_SYMBIAN\r
-    /** Update toolbar visibility. */\r
-    void updateToolBar();\r
-\r
-    /** Return true in portrait mode. */\r
-    bool portrait();\r
-#endif // Q_OS_SYMBIAN\r
-\r
-    /** Hide tool bar if visible. */\r
-    void hideToolBar();\r
-\r
-private:\r
-    QToolBar *toolBar;      /**< Tool bar. */\r
-};\r
-\r
-#endif // MAINWINDOW_H\r