Fix popup button geometries.
[dorian] / mainwindow.cpp
index eadf5e3..4172e68 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"));
@@ -192,6 +192,7 @@ void MainWindow::showRegular()
     // Adjust geometry of decorations
 
     QRect geo = geometry();
+    qDebug() << geo;
     int y = geo.height() - progress->thickness();
 #if defined(Q_WS_MAEMO_5)
     y -= toolBar->height();
@@ -312,7 +313,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
 {
     TRACE;
     view->setLastBookmark();
-    event->accept();
+    AdopterWindow::closeEvent(event);
 }
 
 void MainWindow::onSettingsChanged(const QString &key)
@@ -428,41 +429,18 @@ void MainWindow::resizeEvent(QResizeEvent *e)
 {
     TRACE;
 
-    if (hasChild(progress)) {
-        qDebug() << "To" << e->size();
-        int y = e->size().height() - progress->thickness();
-#if defined(Q_WS_MAEMO_5)
-        y -= toolBar->height();
-#endif
-        progress->setGeometry(0, y, e->size().width(), y + progress->thickness());
-
-#if defined(Q_WS_MAEMO_5)
-        previousButton->setGeometry(0,
-            e->size().height() - toolBar->height() - TranslucentButton::pixels,
-            TranslucentButton::pixels, TranslucentButton::pixels);
-        nextButton->setGeometry(e->size().width() - TranslucentButton::pixels, 0,
-            TranslucentButton::pixels, TranslucentButton::pixels);
-#elif defined(Q_OS_SYMBIAN)
-        previousButton->setGeometry(0, e->size().height() - TranslucentButton::pixels,
+    if (bookView) {
+        qDebug() << "BookView geometry" << bookView->geometry();
+        QRect geo = bookView->geometry();
+        progress->setGeometry(geo.x(),
+            geo.y() + geo.height() - progress->thickness(), geo.width(),
+            progress->thickness());
+        previousButton->setGeometry(geo.x(),
+            geo.y() + geo.height() - TranslucentButton::pixels,
             TranslucentButton::pixels, TranslucentButton::pixels);
-        nextButton->setGeometry(e->size().width() - TranslucentButton::pixels,
-            0, TranslucentButton::pixels, TranslucentButton::pixels);
-#else
-        previousButton->setGeometry(0,
-            e->size().height() - TranslucentButton::pixels,
-            TranslucentButton::pixels, TranslucentButton::pixels);
-        nextButton->setGeometry(e->size().width() - TranslucentButton::pixels - 25,
-            toolBar->height(), TranslucentButton::pixels,
-            TranslucentButton::pixels);
-#endif // Q_WS_MAEMO_5
-
-#ifdef Q_WS_MAEMO_5
-        // This is needed on Maemo, in order not to lose current reading position
-        // after orientation change
-        QTimer::singleShot(250, view, SLOT(restoreLastBookmark()));
-#endif
-        previousButton->flash();
-        nextButton->flash();
+        nextButton->setGeometry(
+            geo.x() + geo.width() - TranslucentButton::pixels,
+            geo.y(), TranslucentButton::pixels, TranslucentButton::pixels);
     }
     QMainWindow::resizeEvent(e);
 }