Struggle with tool bar and heap size on Symbian.
authorAkos Polster <akos@pipacs.com>
Mon, 22 Nov 2010 00:03:45 +0000 (01:03 +0100)
committerAkos Polster <akos@pipacs.com>
Mon, 22 Nov 2010 00:03:45 +0000 (01:03 +0100)
adopterwindow.cpp
adopterwindow.h
dorian.pro
mainwindow.cpp

index 6a33cf8..2c4bf8f 100644 (file)
@@ -20,7 +20,7 @@ AdopterWindow::AdopterWindow(QWidget *parent):
 
 #ifdef Q_WS_MAEMO_5
     setAttribute(Qt::WA_Maemo5StackedWindow, true);
-#endif // Q_WS_MAEMO_5
+#endif
 
     QFrame *frame = new QFrame(this);
     QVBoxLayout *layout = new QVBoxLayout(frame);
@@ -33,10 +33,19 @@ AdopterWindow::AdopterWindow(QWidget *parent):
     closeAction->setSoftKeyRole(QAction::NegativeSoftKey);
     connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
     QMainWindow::addAction(closeAction);
+
+    // toolBar = new QToolBar(this);
+    // toolBar->setFixedWidth(QApplication::desktop()->
+    //                        availableGeometry().width());
+    // toolBar->setFixedHeight(70);
+    // toolBar->setIconSize(QSize(90, 70));
+    // toolBar->setFloatable(false);
+    // toolBar->setMovable(false);
+    // addToolBar(Qt::BottomToolBarArea, toolBar);
 #else
     // Tool bar
     setUnifiedTitleAndToolBarOnMac(true);
-    toolBar = addToolBar("controls");
+    toolBar = addToolBar("");
     toolBar->setMovable(false);
     toolBar->setFloatable(false);
     toolBar->toggleViewAction()->setVisible(false);
@@ -57,8 +66,8 @@ void AdopterWindow::takeChildren(BookView *view, const QList<QWidget *> &others)
     if (view) {
         bookView = view;
         bookView->setParent(centralWidget());
-        centralWidget()->layout()->addWidget(bookView);
         bookView->show();
+        centralWidget()->layout()->addWidget(bookView);
     }
     foreach (QWidget *child, others) {
         if (child) {
@@ -100,16 +109,26 @@ void AdopterWindow::show()
 QAction *AdopterWindow::addToolBarAction(QObject *receiver,
                                          const char *member,
                                          const QString &iconName,
-                                         const QString &text)
+                                         const QString &text,
+                                         bool important)
 {
     TRACE;
     qDebug() << "icon" << iconName << "text" << text;
     QAction *action;
 #ifndef Q_OS_SYMBIAN
+    Q_UNUSED(important);
     action = toolBar->addAction(QIcon(Platform::instance()->icon(iconName)),
                                 text, receiver, member);
 #else
-    Q_UNUSED(iconName);
+    if (0) { // if (important) {
+        qDebug() << "Add Symbian tool bar action";
+        QAction *toolBarAction = toolBar->addAction(
+            QIcon(Platform::instance()->icon(iconName)),
+            text, receiver, member);
+        toolBarAction->setText("");
+        toolBarAction->setToolTip("");
+        connect(toolBarAction, SIGNAL(triggered()), receiver, member);
+    }
     action = new QAction(text, this);
     menuBar()->addAction(action);
     connect(action, SIGNAL(triggered()), receiver, member);
@@ -119,6 +138,7 @@ QAction *AdopterWindow::addToolBarAction(QObject *receiver,
     action->setText("");
     action->setToolTip("");
 #endif
+
     return action;
 }
 
index e50667e..d4631f4 100644 (file)
@@ -8,6 +8,7 @@ class QWidget;
 class QToolBar;
 class QAction;
 class BookView;
+class QVBoxLayout;
 
 /**
  * A toplevel window that can adopt a BookView and other children.
@@ -30,11 +31,18 @@ public:
     bool hasChild(QWidget *child);
 
     /**
-     * Add action that is visible on the tool bar (except on Symbian, where
-     * it is visible on the Options menu).
+     * Add action that is visible on the tool bar.
+     * @param   receiver    Object receiving "activated" signal.
+     * @param   slot        Slot receiving "activated" signal.
+     * @param   iconName    Base name of tool bar icon in resource file.
+     * @param   text        Tool bar item text.
+     * @param   important   On Symbian, only "important" actions are added to
+     *                      the tool bar. All actions are added to the Options
+     *                      menu though.
      */
     QAction *addToolBarAction(QObject *receiver, const char *slot,
-                              const QString &iconName, const QString &text);
+                              const QString &iconName, const QString &text,
+                              bool important = false);
 
     /** Add spacing to tool bar. */
     void addToolBarSpace();
@@ -42,7 +50,7 @@ public:
     /** Show window. */
     void show();
 
-    /** If grab is true, volume keys will generate pageUp/Down keys. */
+    /** If grab is true, volume keys will generate pageUp/Down key events. */
     void grabVolumeKeys(bool grab);
 
 public slots:
@@ -57,9 +65,7 @@ protected:
 #endif
     BookView *bookView;
     bool grabbingVolumeKeys;/**< True, if volume keys should be grabbed. */
-#ifndef Q_OS_SYMBIAN
     QToolBar *toolBar;
-#endif
 };
 
 #endif // ADOPTERWINDOW_H
index f028d7a..8bc2821 100644 (file)
@@ -136,7 +136,7 @@ symbian {
     TARGET.UID3 = 0xA89FC85B\r
     TARGET.CAPABILITY = UserEnvironment NetworkServices ReadUserData \\r
         WriteUserData\r
-    TARGET.EPOCHEAPSIZE = 0x080000 0x8000000\r
+    TARGET.EPOCHEAPSIZE = 0x080000 0x4000000\r
     ICON = $$PWD/pkg/symbian/book.svg\r
 \r
     # FIXME: Package header for Qt 4.6.2:\r
index eadf5e3..9d047a9 100755 (executable)
@@ -68,13 +68,13 @@ MainWindow::MainWindow(QWidget *parent):
 #endif
 
     chaptersAction = addToolBarAction(this, SLOT(showChapters()),
-                                      "chapters", tr("Chapters"));
+                                      "chapters", tr("Chapters"), true);
     bookmarksAction = addToolBarAction(this, SLOT(showBookmarks()),
-                                       "bookmarks", tr("Bookmarks"));
+                                       "bookmarks", tr("Bookmarks"), true);
     infoAction = addToolBarAction(this, SLOT(showInfo()),
-                                  "info", tr("Book info"));
+                                  "info", tr("Book info"), true);
     libraryAction = addToolBarAction(this, SLOT(showLibrary()),
-                                     "library", tr("Library"));
+                                     "library", tr("Library"), true);
 
 #ifdef Q_WS_MAEMO_5
     settingsAction = menuBar()->addAction(tr("Settings"));
@@ -312,7 +312,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
 {
     TRACE;
     view->setLastBookmark();
-    event->accept();
+    AdopterWindow::closeEvent(event);
 }
 
 void MainWindow::onSettingsChanged(const QString &key)