Move progress bar to the bottom. Fix disappearing "exit full screen"
authorAkos Polster <akos@pipacs.com>
Mon, 15 Nov 2010 23:48:36 +0000 (00:48 +0100)
committerAkos Polster <akos@pipacs.com>
Mon, 15 Nov 2010 23:48:36 +0000 (00:48 +0100)
button.

adopterwindow.cpp
adopterwindow.h
fullscreenwindow.cpp
mainwindow.cpp
pkg/changelog
pkg/version.txt
widgets/listwindow.cpp
widgets/progress.cpp
widgets/progress.h
widgets/translucentbutton.cpp

index 3775155..6a33cf8 100644 (file)
@@ -76,6 +76,14 @@ void AdopterWindow::leaveChildren()
     }
 }
 
+bool AdopterWindow::hasChild(QWidget *child)
+{
+    if (child == bookView) {
+        return true;
+    }
+    return this == child->parent();
+}
+
 void AdopterWindow::show()
 {
 #ifdef Q_OS_SYMBIAN
@@ -96,16 +104,22 @@ QAction *AdopterWindow::addToolBarAction(QObject *receiver,
 {
     TRACE;
     qDebug() << "icon" << iconName << "text" << text;
+    QAction *action;
 #ifndef Q_OS_SYMBIAN
-    return toolBar->addAction(QIcon(Platform::instance()->icon(iconName)),
-                              text, receiver, member);
+    action = toolBar->addAction(QIcon(Platform::instance()->icon(iconName)),
+                                text, receiver, member);
 #else
     Q_UNUSED(iconName);
-    QAction *action = new QAction(text, this);
+    action = new QAction(text, this);
     menuBar()->addAction(action);
     connect(action, SIGNAL(triggered()), receiver, member);
-    return action;
 #endif
+
+#if defined Q_WS_MAEMO_5
+    action->setText("");
+    action->setToolTip("");
+#endif
+    return action;
 }
 
 void AdopterWindow::addToolBarSpace()
index d2e3fe9..e50667e 100644 (file)
@@ -26,6 +26,9 @@ public:
     /** Release current children (adopted in @see takeChildren). */
     void leaveChildren();
 
+    /** Return true if a child is currently adopted. */
+    bool hasChild(QWidget *child);
+
     /**
      * Add action that is visible on the tool bar (except on Symbian, where
      * it is visible on the Options menu).
index 507600b..46742c7 100644 (file)
@@ -3,6 +3,8 @@
 #include "fullscreenwindow.h"
 #include "translucentbutton.h"
 #include "trace.h"
+#include "settings.h"
+#include "platform.h"
 
 FullScreenWindow::FullScreenWindow(QWidget *parent): AdopterWindow(parent)
 {
@@ -22,7 +24,7 @@ FullScreenWindow::FullScreenWindow(QWidget *parent): AdopterWindow(parent)
     setCentralWidget(frame);
     restoreButton = new TranslucentButton("view-normal", this);
     QRect screen = QApplication::desktop()->screenGeometry();
-    restoreButton->setGeometry((screen.width() - TranslucentButton::pixels) / 2,
+    restoreButton->setGeometry(screen.width() - TranslucentButton::pixels - 9,
         screen.height() - TranslucentButton::pixels - 9,
         TranslucentButton::pixels, TranslucentButton::pixels);
     connect(restoreButton, SIGNAL(triggered()), this, SIGNAL(restore()));
@@ -31,23 +33,33 @@ FullScreenWindow::FullScreenWindow(QWidget *parent): AdopterWindow(parent)
 void FullScreenWindow::showFullScreen()
 {
     TRACE;
-#ifdef Q_WS_MAEMO_5
-    setAttribute(Qt::WA_Maemo5PortraitOrientation, parentWidget()->
-                 testAttribute(Qt::WA_Maemo5PortraitOrientation));
-    setAttribute(Qt::WA_Maemo5LandscapeOrientation, parentWidget()->
-                 testAttribute(Qt::WA_Maemo5LandscapeOrientation));
-#endif // Q_WS_MAEMO_5
-    QWidget::showFullScreen();
+    AdopterWindow::showFullScreen();
     restoreButton->flash(3000);
 }
 
 void FullScreenWindow::resizeEvent(QResizeEvent *e)
 {
     TRACE;
-    Q_UNUSED(e);
-    restoreButton->raise();
+
     QRect screen = QApplication::desktop()->screenGeometry();
-    restoreButton->setGeometry(screen.width() - TranslucentButton::pixels - 9,
-        screen.height() - TranslucentButton::pixels - 9,
-        TranslucentButton::pixels, TranslucentButton::pixels);
+    int w = screen.width();
+    int h = screen.height();
+
+#ifdef Q_WS_MAEMO_5
+    // Hack: FullScreenWindow can lose orientation on Maemo...
+    QString orientation = Settings::instance()->value("orientation",
+        Platform::instance()->defaultOrientation()).toString();
+    if (((orientation == "portrait") && (w > h)) ||
+        ((orientation == "landscape") && (w < h))) {
+        int tmp = w;
+        w = h;
+        h = tmp;
+    }
+#endif // Q_WS_MAEMO_5
+
+    restoreButton->setGeometry(w - TranslucentButton::pixels - 9,
+        h - TranslucentButton::pixels - 9,  TranslucentButton::pixels,
+        TranslucentButton::pixels);
+    restoreButton->flash(3000);
+    AdopterWindow::resizeEvent(e);
 }
index 4a5f266..9712cef 100755 (executable)
@@ -34,8 +34,6 @@
 #   include "modeltest.h"
 #endif
 
-const int DORIAN_PROGRESS_HEIGHT = 17;
-
 MainWindow::MainWindow(QWidget *parent):
     AdopterWindow(parent), view(0), preventBlankingTimer(-1)
 {
@@ -190,8 +188,14 @@ void MainWindow::showRegular()
     takeChildren(view, otherChildren);
 
     // Adjust geometry of decorations
+
     QRect geo = geometry();
-    progress->setGeometry(0, 0, geo.width(), DORIAN_PROGRESS_HEIGHT);
+    int y = geo.height() - progress->thickness();
+#if defined(Q_WS_MAEMO_5)
+    y -= toolBar->height();
+#endif
+    progress->setGeometry(0, y, geo.width(), y + progress->thickness());
+
 #if defined(Q_WS_MAEMO_5)
     previousButton->setGeometry(0,
         geo.height() - toolBar->height() - TranslucentButton::pixels,
@@ -234,7 +238,8 @@ void MainWindow::showBig()
 
     // Adjust geometry of decorations
     QRect screen = QApplication::desktop()->screenGeometry();
-    progress->setGeometry(0, 0, screen.width(), DORIAN_PROGRESS_HEIGHT);
+    int y = screen.height() - progress->thickness();
+    progress->setGeometry(0, y, screen.width(), y + progress->thickness());
 #if defined(Q_WS_MAEMO_5)
     nextButton->setGeometry(screen.width() - TranslucentButton::pixels, 0,
         TranslucentButton::pixels, TranslucentButton::pixels);
@@ -319,9 +324,16 @@ void MainWindow::onSettingsChanged(const QString &key)
         if (value == "portrait") {
             setAttribute(Qt::WA_Maemo5LandscapeOrientation, false);
             setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
+            fullScreenWindow->setAttribute(Qt::WA_Maemo5LandscapeOrientation,
+                                           false);
+            fullScreenWindow->setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
         } else {
             setAttribute(Qt::WA_Maemo5PortraitOrientation, false);
             setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);
+            fullScreenWindow->setAttribute(Qt::WA_Maemo5PortraitOrientation,
+                                           false);
+            fullScreenWindow->setAttribute(Qt::WA_Maemo5LandscapeOrientation,
+                                           true);
         }
     } else if (key == "lightson") {
         bool enable = Settings::instance()->value(key, false).toBool();
@@ -415,33 +427,43 @@ void MainWindow::timerEvent(QTimerEvent *event)
 void MainWindow::resizeEvent(QResizeEvent *e)
 {
     TRACE;
-    progress->setGeometry(QRect(0, 0, e->size().width(), DORIAN_PROGRESS_HEIGHT));
+
+    if (hasChild(progress)) {
+        qDebug() << "To" << e->size();
+        int y = e->size().height() - 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);
+        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,
-        TranslucentButton::pixels, TranslucentButton::pixels);
-    nextButton->setGeometry(e->size().width() - TranslucentButton::pixels,
-        0, TranslucentButton::pixels, TranslucentButton::pixels);
+        previousButton->setGeometry(0, e->size().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);
+        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
-    qDebug() << "previousButton geometry" << previousButton->geometry();
 
 #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()));
+        // 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();
+        previousButton->flash();
+        nextButton->flash();
+    }
     QMainWindow::resizeEvent(e);
 }
 
index bf269d6..588092e 100644 (file)
@@ -1,3 +1,10 @@
+dorian (0.3.8-1) unstable; urgency=low
+
+  * Move progress bar to the bottom
+  * Fix disappearing "exit full screen" button [#6391]
+
+ -- Akos Polster <akos@pipacs.com>  Mon, 15 Nov 2010 02:00:00 +0100
+
 dorian (0.3.7-1) unstable; urgency=low
 
   * Sort library by title or author
index fa19453..3a5ff99 100644 (file)
@@ -1 +1 @@
-"0.3.7"
+"0.3.8"
index 219f208..a35d4e6 100644 (file)
@@ -148,7 +148,7 @@ QAction *ListWindow::addMenuAction(const QString &title, QObject *receiver,
     Q_UNUSED(title);
     Q_UNUSED(receiver);
     Q_UNUSED(slot);
-    QAction = new QAction(this);
+    action = new QAction(this);
 #endif
     action->setCheckable(true);
     return action;
index 0ca4790..6621acb 100644 (file)
@@ -3,7 +3,8 @@
 #include "progress.h"
 #include "trace.h"
 
-Progress::Progress(QWidget *parent): QLabel(parent), progress(-1.0), timer(-1)
+Progress::Progress(QWidget *parent):
+        QLabel(parent), progress(-1.0), timer(-1), mThickness(15)
 {
     hide();
 }
@@ -26,10 +27,9 @@ void Progress::paintEvent(QPaintEvent *e)
     painter.setBrush(QBrush(QColor(100, 100, 100, 177)));
     painter.setPen(Qt::NoPen);
     int w = int(width() * progress);
-    int h = height();
-    painter.drawRect(0, 0, w, h);
+    painter.drawRect(0, 0, w, mThickness);
     painter.setBrush(QBrush(QColor(100, 100, 100, 50)));
-    painter.drawRect(w, 0, width(), h);
+    painter.drawRect(w, 0, width() - w, mThickness);
 }
 
 void Progress::flash()
@@ -48,3 +48,8 @@ void Progress::timerEvent(QTimerEvent *e)
     }
     QLabel::timerEvent(e);
 }
+
+int Progress::thickness() const
+{
+    return mThickness;
+}
index 630bc4f..8bbd91c 100644 (file)
@@ -17,6 +17,7 @@ signals:
 public slots:
     void setProgress(qreal p);
     void flash();
+    int thickness() const;
 
 protected:
     void paintEvent(QPaintEvent *e);
@@ -25,6 +26,7 @@ protected:
 private:
     qreal progress;
     int timer;
+    int mThickness;
 };
 
 #endif // PROGRESS_H
index a80e8fc..3b4121e 100644 (file)
@@ -9,7 +9,7 @@ const int TranslucentButton::elevatorInterval = 750;
 TranslucentButton::TranslucentButton(const QString &name_, QWidget *parent):
     QLabel(parent), name(name_), transparent(true)
 {
-    setGeometry(0, 0, pixels, pixels);
+    setFixedSize(pixels, pixels);
     elevatorTimer = startTimer(elevatorInterval);
 }
 
@@ -33,8 +33,8 @@ void TranslucentButton::paintEvent(QPaintEvent *)
 
 void TranslucentButton::flash(int duration)
 {
-    show();
     raise();
+    show();
     transparent = false;
     update();
     QTimer::singleShot(duration, this, SLOT(stopFlash()));
@@ -58,4 +58,5 @@ void TranslucentButton::timerEvent(QTimerEvent *e)
     if (e->timerId() == elevatorTimer) {
         raise();
     }
+    QLabel::timerEvent(e);
 }