Add some documentation. Fix popup button locations on Maemo. Ensure popup buttons...
authorAkos Polster <polster@marzipan.pipacs.com>
Wed, 1 Sep 2010 21:32:36 +0000 (23:32 +0200)
committerAkos Polster <polster@marzipan.pipacs.com>
Wed, 1 Sep 2010 21:32:36 +0000 (23:32 +0200)
21 files changed:
bookmarkinfodialog.h
bookview.cpp
bookview.h
devtools.h
dorian.pro
infodialog.h
librarydialog.h
mainwindow.cpp
mainwindow.h
settingswindow.h
trace.h
widgets/adopterwindow.cpp [new file with mode: 0644]
widgets/adopterwindow.h [new file with mode: 0644]
widgets/bookwindow.cpp [deleted file]
widgets/bookwindow.h [deleted file]
widgets/fullscreenwindow.cpp
widgets/fullscreenwindow.h
widgets/listview.h
widgets/progress.h
widgets/translucentbutton.cpp
widgets/translucentbutton.h

index d656701..610b8a9 100644 (file)
@@ -5,6 +5,7 @@
 
 class Book;
 
+/** Show bookmark info. */
 class BookmarkInfoDialog: public Dyalog
 {
     Q_OBJECT
index 0acbdb3..840f878 100644 (file)
@@ -25,7 +25,7 @@
 BookView::BookView(QWidget *parent):
     QWebView(parent), contentIndex(-1), mBook(0),
     restorePositionAfterLoad(false), positionAfterLoad(0), loaded(false),
-    contentsHeight(0), decorated(false), scrollerMonitor(-1)
+    contentsHeight(0), scrollerMonitor(-1)
 {
     Trace t("BookView::BookView");
     settings()->setAttribute(QWebSettings::AutoLoadImages, true);
@@ -104,7 +104,6 @@ void BookView::loadContent(int index)
     }
     else {
         loaded = false;
-        decorated = false;
         emit partLoadStart(index);
         load(QUrl(contentFile));
     }
@@ -205,7 +204,6 @@ void BookView::onLoadFinished(bool ok)
         return;
     }
     loaded = true;
-    addNavigationBar();
     onSettingsChanged("scheme");
     emit partLoadEnd(contentIndex);
     showProgress();
@@ -295,11 +293,6 @@ void BookView::addBookmark()
     update();
 }
 
-void BookView::addNavigationBar()
-{
-    decorated = true;
-}
-
 QString BookView::tmpPath()
 {
     return QDir::tempPath() + "/dorian";
@@ -348,12 +341,10 @@ void BookView::addJavaScriptObjects()
 void BookView::onContentsSizeChanged(const QSize &size)
 {
     contentsHeight = size.height();
-    if (decorated) {
-        if (restorePositionAfterLoad) {
-            qDebug() << "BookView::onContentSizeChanged: Time to restore";
-            restorePositionAfterLoad = false;
-            goToPosition(positionAfterLoad);
-        }
+    if (restorePositionAfterLoad) {
+        qDebug() << "BookView::onContentSizeChanged: Time to restore";
+        restorePositionAfterLoad = false;
+        goToPosition(positionAfterLoad);
     }
 }
 
index 4202ac1..50be62d 100644 (file)
@@ -74,9 +74,6 @@ private:
     /** Load given part. */
     void loadContent(int index);
 
-    /** Decorate web page frame with navigation icons. */
-    void addNavigationBar();
-
     /** Get temporary directory for extracting book contents. */
     QString tmpPath();
 
@@ -97,7 +94,6 @@ private:
     bool loaded;        /**< True if content has been loaded. */
     bool mousePressed;
     int contentsHeight; /**< Last know height of the frame. */
-    bool decorated;     /**< True after adding the arrows to the frame contents. */
 
     int scrollerMonitor;
 #ifdef Q_WS_MAEMO_5
index 040c22b..e9d7215 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <QtGui>
 
+/** Display developer tools. */
 class DevTools: public QDialog
 {
     Q_OBJECT
index 1656cd8..8c26e30 100644 (file)
@@ -30,7 +30,7 @@ SOURCES += \
     model/bookfinder.cpp \
     widgets/listwindow.cpp \
     widgets/progress.cpp \
-    widgets/bookwindow.cpp
+    widgets/adopterwindow.cpp
 
 HEADERS += \
     mainwindow.h \
@@ -61,7 +61,7 @@ HEADERS += \
     model/bookfinder.h \
     widgets/listwindow.h \
     widgets/progress.h \
-    widgets/bookwindow.h \
+    widgets/adopterwindow.h \
     widgets/listview.h
 
 RESOURCES += \
index 71492de..67c05cb 100644 (file)
@@ -6,6 +6,7 @@
 class QWidget;
 class Book;
 
+/** Display book information. */
 class InfoDialog: public Dyalog
 {
     Q_OBJECT
index ca0e452..ccbe43f 100644 (file)
@@ -16,6 +16,7 @@ class Book;
 class InfoWindow;
 class SortedLibrary;
 
+/** Manage library. */
 class LibraryDialog: public ListWindow
 {
     Q_OBJECT
index 1d647ff..74c0f4b 100755 (executable)
@@ -49,7 +49,7 @@ const char *DORIAN_VERSION =
 ;
 
 MainWindow::MainWindow(QWidget *parent):
-    BookWindow(parent), view(0), preventBlankingTimer(-1)
+    AdopterWindow(parent), view(0), preventBlankingTimer(-1)
 {
     Trace t("MainWindow::MainWindow");
 #ifdef Q_WS_MAEMO_5
@@ -74,6 +74,7 @@ MainWindow::MainWindow(QWidget *parent):
     progress = new Progress(central);
 
     // Tool bar
+
     setUnifiedTitleAndToolBarOnMac(true);
     settings = new QDialog(this);
     toolBar = addToolBar("controls");
@@ -117,7 +118,7 @@ MainWindow::MainWindow(QWidget *parent):
     fullScreenAction = addToolBarAction(this, SLOT(showBig()),
                                         "view-fullscreen");
 
-    // Buttons for paging
+    // Buttons on top of the book view
     previousButton = new TranslucentButton("back", this);
     nextButton = new TranslucentButton("forward", this);
 
@@ -167,9 +168,9 @@ MainWindow::MainWindow(QWidget *parent):
     settings->setValue("lightson", settings->value("lightson"));
     settings->setValue("usevolumekeys", settings->value("usevolumekeys"));
 
-    // Handle next/previous buttons
-    connect(nextButton, SIGNAL(triggered()), view, SLOT(goNextPage()));
-    connect(previousButton, SIGNAL(triggered()), view, SLOT(goPreviousPage()));
+    // Handle book view buttons
+    connect(nextButton, SIGNAL(triggered()), this, SLOT(goToNextPage()));
+    connect(previousButton, SIGNAL(triggered()), this, SLOT(goToPreviousPage()));
 
 #ifdef DORIAN_TEST_MODEL
     (void)new ModelTest(Library::instance(), this);
@@ -190,24 +191,31 @@ void MainWindow::showRegular()
     Trace t("MainWindow::showRegular");
     fullScreenWindow->hide();
     fullScreenWindow->leaveChildren();
+
+    QList<QWidget *> otherChildren;
+    otherChildren << progress << previousButton << nextButton;
+    takeChildren(view, otherChildren);
     QRect geo = geometry();
-    qDebug() << "Geometry:" << geo;
+    qDebug() << "Geometry" << geo << "toolbar" << toolBar->height();
     progress->setGeometry(0, 0, geo.width(), PROGRESS_HEIGHT);
 #ifdef Q_WS_MAEMO_5
-    previousButton->setGeometry(0,geo.height() - toolBar->height() - 95,
-                                95, 95);
-    nextButton->setGeometry(geo.width() - 95, 0, 95, 95);
+    previousButton->setGeometry(0,
+        geo.height() - toolBar->height() - TranslucentButton::pixels,
+        TranslucentButton::pixels, TranslucentButton::pixels);
+    nextButton->setGeometry(geo.width() - TranslucentButton::pixels, 0,
+        TranslucentButton::pixels, TranslucentButton::pixels);
 #else
-    previousButton->setGeometry(0, geo.height() - 95, 95, 95);
-    nextButton->setGeometry(geo.width() - 95, toolBar->height(), 95, 95);
+    previousButton->setGeometry(0, geo.height() - TranslucentButton::pixels,
+        TranslucentButton::pixels, TranslucentButton::pixels);
+    nextButton->setGeometry(geo.width() - TranslucentButton::pixels,
+        toolBar->height(), TranslucentButton::pixels, TranslucentButton::pixels);
 #endif // Q_WS_MAEMO_5
-
-    QList<QWidget *> otherChildren;
-    otherChildren << progress << previousButton << nextButton;
-    takeChildren(view, otherChildren);
+    qDebug() << "previousButton geometry" << previousButton->geometry();
     progress->flash();
-    nextButton->flash();
-    previousButton->flash();
+    nextButton->show();
+    previousButton->show();
+    nextButton->flash(1500);
+    previousButton->flash(1500);
 }
 
 void MainWindow::showBig()
@@ -218,14 +226,16 @@ void MainWindow::showBig()
     otherChildren << progress << nextButton << previousButton;
     QRect screen = QApplication::desktop()->screenGeometry();
     progress->setGeometry(0, 0, screen.width(), PROGRESS_HEIGHT);
-    nextButton->setGeometry(screen.width() - 95, 0, 95, 95);
-    previousButton->setGeometry(0, screen.height() - 95, 95, 95);
+    nextButton->setGeometry(screen.width() - TranslucentButton::pixels, 0,
+        TranslucentButton::pixels, TranslucentButton::pixels);
+    previousButton->setGeometry(0, screen.height() - TranslucentButton::pixels,
+        TranslucentButton::pixels, TranslucentButton::pixels);
 
     fullScreenWindow->takeChildren(view, otherChildren);
     fullScreenWindow->showFullScreen();
     progress->flash();
-    nextButton->flash();
-    previousButton->flash();
+    nextButton->flash(1500);
+    previousButton->flash(1500);
 }
 
 void MainWindow::setCurrentBook(const QModelIndex &current)
@@ -407,15 +417,20 @@ void MainWindow::resizeEvent(QResizeEvent *e)
     progress->setGeometry(QRect(0, 0, e->size().width(), PROGRESS_HEIGHT));
     qDebug() << "Toolbar height" << toolBar->height();
 #ifdef Q_WS_MAEMO_5
-    previousButton->setGeometry(0, e->size().height() - toolBar->height() - 95,
-                                95, 95);
-    nextButton->setGeometry(e->size().width() - 95, 0, 95, 95);
+    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);
 #else
-    previousButton->setGeometry(0, e->size().height() - 95, 95, 95);
-    nextButton->setGeometry(e->size().width() - 95, toolBar->height(), 95, 95);
+    previousButton->setGeometry(0, e->size().height() - TranslucentButton::pixels,
+        TranslucentButton::pixels, TranslucentButton::pixels);
+    nextButton->setGeometry(e->size().width() - TranslucentButton::pixels,
+        toolBar->height(), TranslucentButton::pixels, TranslucentButton::pixels);
 #endif // Q_WS_MAEMO_5
-    previousButton->flash();
-    nextButton->flash();
+    qDebug() << "previousButton geometry" << previousButton->geometry();
+    previousButton->flash(1500);
+    nextButton->flash(1500);
     QMainWindow::resizeEvent(e);
 }
 
@@ -434,3 +449,18 @@ void MainWindow::about()
     aboutDialog->addWidget(label);
     aboutDialog->show();
 }
+
+
+void MainWindow::goToNextPage()
+{
+    nextButton->flash(1500);
+    previousButton->flash(1500);
+    view->goNextPage();
+}
+
+void MainWindow::goToPreviousPage()
+{
+    nextButton->flash(1500);
+    previousButton->flash(1500);
+    view->goPreviousPage();
+}
index c380a26..4ac7f3f 100755 (executable)
@@ -3,7 +3,7 @@
 
 #include <QtGui>
 
-#include "bookwindow.h"
+#include "adopterwindow.h"
 
 class QString;
 class QModelIndex;
@@ -14,7 +14,7 @@ class FullScreenWindow;
 class Progress;
 class TranslucentButton;
 
-class MainWindow: public BookWindow
+class MainWindow: public AdopterWindow
 {
     Q_OBJECT
 
@@ -39,6 +39,8 @@ public slots:
     void showChapters();
     void onGoToChapter(int index);
     void about();
+    void goToNextPage();
+    void goToPreviousPage();
 
 protected:
     void closeEvent(QCloseEvent *event);
index d5193c2..7a9ced5 100644 (file)
@@ -11,6 +11,7 @@ class QFontComboBox;
 class QLabel;
 class ToolButtonBox;
 
+/** Display settings. */
 class SettingsWindow: public QMainWindow
 {
     Q_OBJECT
diff --git a/trace.h b/trace.h
index 3fe1458..232e2f3 100644 (file)
--- a/trace.h
+++ b/trace.h
@@ -6,6 +6,7 @@
 #include <QTime>
 #include <QEvent>
 
+/** Trace helper. */
 class Trace
 {
 public:
diff --git a/widgets/adopterwindow.cpp b/widgets/adopterwindow.cpp
new file mode 100644 (file)
index 0000000..3aa4827
--- /dev/null
@@ -0,0 +1,94 @@
+#include <QtGui>
+
+#ifdef Q_WS_MAEMO_5
+#   include <QtGui/QX11Info>
+#   include <X11/Xlib.h>
+#   include <X11/Xatom.h>
+#endif // Q_WS_MAEMO_5
+
+#include "adopterwindow.h"
+#include "trace.h"
+
+AdopterWindow::AdopterWindow(QWidget *parent):
+        QMainWindow(parent), grabbingZoomKeys(false), mainChild(0)
+{
+#ifdef Q_WS_MAEMO_5
+    setAttribute(Qt::WA_Maemo5StackedWindow, true);
+#endif // Q_WS_MAEMO_5
+
+    QFrame *frame = new QFrame(this);
+    QVBoxLayout *layout = new QVBoxLayout(frame);
+    layout->setMargin(0);
+    frame->setLayout(layout);
+    setCentralWidget(frame);
+}
+
+void AdopterWindow::takeChildren(QWidget *main, const QList<QWidget *> &others)
+{
+    Trace t("AdopterWindow::takeChildren");
+    leaveChildren();
+    if (main) {
+        mainChild = main;
+        mainChild->setParent(centralWidget());
+        centralWidget()->layout()->addWidget(mainChild);
+        mainChild->show();
+    }
+    foreach (QWidget *child, others) {
+        if (child) {
+            child->setParent(this);
+        }
+    }
+}
+
+void AdopterWindow::leaveChildren()
+{
+    Trace t("AdopterWindow::leaveChildren");
+    if (mainChild) {
+        centralWidget()->layout()->removeWidget(mainChild);
+        mainChild = 0;
+    }
+}
+
+void AdopterWindow::grabZoomKeys(bool grab)
+{
+    Trace t("AdopterWindow::grabZoomKeys");
+    grabbingZoomKeys = grab;
+    doGrabZoomKeys(grab);
+}
+
+void AdopterWindow::showEvent(QShowEvent *e)
+{
+    Trace t("AdopterWindow::showEvent");
+    doGrabZoomKeys(grabbingZoomKeys);
+    QMainWindow::showEvent(e);
+}
+
+void AdopterWindow::doGrabZoomKeys(bool grab)
+{
+    Trace t("AdopterWindow::doGrabZoomKeys");
+#ifdef Q_WS_MAEMO_5
+    if (!isVisible()) {
+        qDebug() << "Not visible - skipping";
+    }
+    if (!winId()) {
+        qDebug() << "Could not get window ID - skipping";
+        return;
+    }
+    unsigned long val = grab? 1: 0;
+    Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
+    if (!atom) {
+        qCritical() << "Unable to obtain _HILDON_ZOOM_KEY_ATOM";
+        return;
+    }
+    XChangeProperty(QX11Info::display(),
+        winId(),
+        atom,
+        XA_INTEGER,
+        32,
+        PropModeReplace,
+        reinterpret_cast<unsigned char *>(&val),
+        1);
+#else
+    Q_UNUSED(grab);
+#endif // Q_WS_MAEMO_5
+}
diff --git a/widgets/adopterwindow.h b/widgets/adopterwindow.h
new file mode 100644 (file)
index 0000000..9818acf
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef ADOPTERWINDOW_H
+#define ADOPTERWINDOW_H
+
+#include <QMainWindow>
+#include <QList>
+
+class QWidget;
+
+/**
+  * A main window that can adopt other windows' children, and grabs the
+  * zoom (volume) keys on Maemo.
+  */
+class AdopterWindow: public QMainWindow
+{
+    Q_OBJECT
+public:
+    explicit AdopterWindow(QWidget *parent = 0);
+    void grabZoomKeys(bool grab);
+    void takeChildren(QWidget *main, const QList<QWidget *> &others);
+    void leaveChildren();
+
+signals:
+
+public slots:
+
+protected:
+    void showEvent(QShowEvent *e);
+    void doGrabZoomKeys(bool grab);
+    bool grabbingZoomKeys;
+    QWidget *mainChild;
+};
+
+#endif // ADOPTERWINDOW_H
diff --git a/widgets/bookwindow.cpp b/widgets/bookwindow.cpp
deleted file mode 100644 (file)
index f87b54b..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-#include <QtGui>
-
-#ifdef Q_WS_MAEMO_5
-#   include <QtGui/QX11Info>
-#   include <X11/Xlib.h>
-#   include <X11/Xatom.h>
-#endif // Q_WS_MAEMO_5
-
-#include "bookwindow.h"
-#include "trace.h"
-
-BookWindow::BookWindow(QWidget *parent):
-        QMainWindow(parent), grabbingZoomKeys(false), mainChild(0)
-{
-#ifdef Q_WS_MAEMO_5
-    setAttribute(Qt::WA_Maemo5StackedWindow, true);
-#endif // Q_WS_MAEMO_5
-
-    QFrame *frame = new QFrame(this);
-    QVBoxLayout *layout = new QVBoxLayout(frame);
-    layout->setMargin(0);
-    frame->setLayout(layout);
-    setCentralWidget(frame);
-}
-
-void BookWindow::takeChildren(QWidget *main, const QList<QWidget *> &others)
-{
-    Trace t("BookWindow::takeChildren");
-    leaveChildren();
-    if (main) {
-        mainChild = main;
-        mainChild->setParent(centralWidget());
-        centralWidget()->layout()->addWidget(mainChild);
-        mainChild->show();
-    }
-    foreach (QWidget *child, others) {
-        if (child) {
-            child->setParent(this);
-        }
-    }
-}
-
-void BookWindow::leaveChildren()
-{
-    Trace t("BookWindow::leaveChildren");
-    if (mainChild) {
-        centralWidget()->layout()->removeWidget(mainChild);
-        mainChild = 0;
-    }
-}
-
-void BookWindow::grabZoomKeys(bool grab)
-{
-    Trace t("BookWindow::grabZoomKeys");
-    grabbingZoomKeys = grab;
-    doGrabZoomKeys(grab);
-}
-
-void BookWindow::showEvent(QShowEvent *e)
-{
-    Trace t("BookWindow::showEvent");
-    doGrabZoomKeys(grabbingZoomKeys);
-    QMainWindow::showEvent(e);
-}
-
-void BookWindow::doGrabZoomKeys(bool grab)
-{
-    Trace t("BookWindow::doGrabZoomKeys");
-#ifdef Q_WS_MAEMO_5
-    if (!isVisible()) {
-        qDebug() << "Not visible - skipping";
-    }
-    if (!winId()) {
-        qDebug() << "Could not get window ID - skipping";
-        return;
-    }
-    unsigned long val = grab? 1: 0;
-    Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
-    if (!atom) {
-        qCritical() << "Unable to obtain _HILDON_ZOOM_KEY_ATOM";
-        return;
-    }
-    XChangeProperty(QX11Info::display(),
-        winId(),
-        atom,
-        XA_INTEGER,
-        32,
-        PropModeReplace,
-        reinterpret_cast<unsigned char *>(&val),
-        1);
-#else
-    Q_UNUSED(grab);
-#endif // Q_WS_MAEMO_5
-}
diff --git a/widgets/bookwindow.h b/widgets/bookwindow.h
deleted file mode 100644 (file)
index e941d4f..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef BOOKWINDOW_H
-#define BOOKWINDOW_H
-
-#include <QMainWindow>
-#include <QList>
-
-class QWidget;
-
-class BookWindow: public QMainWindow
-{
-    Q_OBJECT
-public:
-    explicit BookWindow(QWidget *parent = 0);
-    void grabZoomKeys(bool grab);
-    void takeChildren(QWidget *main, const QList<QWidget *> &others);
-    void leaveChildren();
-
-signals:
-
-public slots:
-
-protected:
-    void showEvent(QShowEvent *e);
-    void doGrabZoomKeys(bool grab);
-    bool grabbingZoomKeys;
-    QWidget *mainChild;
-};
-
-#endif // BOOKWINDOW_H
index d448f9d..2753d79 100644 (file)
@@ -4,7 +4,7 @@
 #include "translucentbutton.h"
 #include "trace.h"
 
-FullScreenWindow::FullScreenWindow(QWidget *parent): BookWindow(parent)
+FullScreenWindow::FullScreenWindow(QWidget *parent): AdopterWindow(parent)
 {
     Q_ASSERT(parent);
 #ifdef Q_WS_MAEMO_5
@@ -17,6 +17,11 @@ FullScreenWindow::FullScreenWindow(QWidget *parent): BookWindow(parent)
     frame->setLayout(layout);
     setCentralWidget(frame);
     restoreButton = new TranslucentButton("view-normal", this);
+    QRect screen = QApplication::desktop()->screenGeometry();
+    restoreButton->setGeometry((screen.width() - TranslucentButton::pixels) / 2,
+        screen.height() - TranslucentButton::pixels - 9,
+        TranslucentButton::pixels, TranslucentButton::pixels);
+    connect(restoreButton, SIGNAL(triggered()), this, SIGNAL(restore()));
 }
 
 void FullScreenWindow::showFullScreen()
@@ -31,24 +36,11 @@ void FullScreenWindow::showFullScreen()
     restoreButton->flash();
 }
 
-void FullScreenWindow::MOUSE_ACTIVATE_EVENT(QMouseEvent *event)
-{
-    Trace t("FullScreenWindow::MOUSE_ACTIVATE_EVENT");
-    if (fullScreenZone().contains(event->x(), event->y())) {
-        emit restore();
-    } else {
-        restoreButton->flash(700);
-    }
-    QMainWindow::MOUSE_ACTIVATE_EVENT(event);
-}
-
-QRect FullScreenWindow::fullScreenZone() const
-{
-    return QRect(width() / 2 - 45, height() - 104, 95, 95);
-}
-
 void FullScreenWindow::resizeEvent(QResizeEvent *e)
 {
-    restoreButton->setGeometry(fullScreenZone());
-    QMainWindow::resizeEvent(e);
+    Q_UNUSED(e);
+    QRect screen = QApplication::desktop()->screenGeometry();
+    restoreButton->setGeometry(screen.width() - TranslucentButton::pixels - 9,
+        screen.height() - TranslucentButton::pixels - 9,
+        TranslucentButton::pixels, TranslucentButton::pixels);
 }
index 2d65a63..9717c2c 100644 (file)
@@ -4,15 +4,15 @@
 #include <QRect>
 #include <QObject>
 
-#include "bookwindow.h"
+#include "adopterwindow.h"
 
 class QWidget;
 class QMouseEvent;
 class QResizeEvent;
 class TranslucentButton;
 
-/** A full screen window that can adopt a child widget from another window. */
-class FullScreenWindow: public BookWindow
+/** A full screen window with a restore button. */
+class FullScreenWindow: public AdopterWindow
 {
     Q_OBJECT
 
@@ -21,17 +21,11 @@ public:
     void showFullScreen();
 
 signals:
+    /** Emitted when the restore button is pressed. */
     void restore();
 
 protected:
-#ifdef Q_WS_MAEMO_5
-#   define MOUSE_ACTIVATE_EVENT mouseReleaseEvent
-#else
-#   define MOUSE_ACTIVATE_EVENT mousePressEvent
-#endif
-    virtual void MOUSE_ACTIVATE_EVENT(QMouseEvent *event);
-    virtual void resizeEvent(QResizeEvent *event);
-    QRect fullScreenZone() const;
+    void resizeEvent(QResizeEvent *e);
     TranslucentButton *restoreButton;
 };
 
index 4e78a7b..d373320 100644 (file)
@@ -3,9 +3,11 @@
 
 #include <QListView>
 
+/** Same as QListView, except contentsHeight() is public. */
 class ListView: public QListView
 {
     Q_OBJECT
+
 public:
     explicit ListView(QWidget *parent = 0): QListView(parent) {
         setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
index 4cb5bd9..92b60ac 100644 (file)
@@ -4,6 +4,7 @@
 #include <QWidget>
 #include <QLabel>
 
+/** Subtle progress bar. */
 class Progress: public QLabel
 {
     Q_OBJECT
index 02c4e25..73fb2d6 100644 (file)
@@ -1,3 +1,5 @@
+#include <QtGui>
+
 #include "translucentbutton.h"
 #include "trace.h"
 
@@ -7,10 +9,12 @@
 #   define ICON_PREFIX ":/icons/"
 #endif
 
+const int TranslucentButton::pixels = 95;
+
 TranslucentButton::TranslucentButton(const QString &name_, QWidget *parent):
-    QWidget(parent), name(name_), opacity(1)
+    QLabel(parent), name(name_), transparent(true)
 {
-    setGeometry(0, 0, 95, 95);
+    setGeometry(0, 0, pixels, pixels);
     timer = new QTimer(this);
     timer->setSingleShot(true);
     connect(timer, SIGNAL(timeout()), this, SLOT(stopFlash()));
@@ -20,32 +24,33 @@ TranslucentButton::TranslucentButton(const QString &name_, QWidget *parent):
 void TranslucentButton::paintEvent(QPaintEvent *)
 {
     QPainter painter(this);
-    if (opacity < 1) {
+    if (!transparent) {
         painter.setRenderHint(QPainter::Antialiasing, true);
         painter.drawPixmap(0, 0, QPixmap(ICON_PREFIX + name + ".png").scaled(
-                QSize(95, 95), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
+                QSize(pixels, pixels), Qt::IgnoreAspectRatio,
+                Qt::SmoothTransformation));
     } else {
-        painter.fillRect(0, 0, 95, 95, Qt::NoBrush);
+        painter.fillRect(0, 0, pixels, pixels, Qt::NoBrush);
     }
 }
 
 void TranslucentButton::flash(int duration)
 {
-    opacity = 0;
+    raise();
+    transparent = false;
     update();
     timer->start(duration);
 }
 
 void TranslucentButton::stopFlash()
 {
-    opacity = 1;
+    transparent = true;
     update();
 }
 
-void TranslucentButton::mousePressEvent(QMouseEvent *e)
+void TranslucentButton::mouseReleaseEvent(QMouseEvent *e)
 {
     Q_UNUSED(e);
-    Trace t("TranslucentButton::mousePressEvent");
     emit triggered();
     e->accept();
 }
index 00035c1..26488cf 100644 (file)
@@ -1,15 +1,24 @@
 #ifndef TRANSLUCENTBUTTON_H
 #define TRANSLUCENTBUTTON_H
 
-#include <QtGui>
+#include <QLabel>
 #include <QString>
 
-class TranslucentButton: public QWidget
+class QWidget;
+class QPaintEvent;
+class QMouseEvent;
+class QTimer;
+
+/**
+ * A button that is transparent, but can temporarily made opaque by flashing it.
+ */
+class TranslucentButton: public QLabel
 {
     Q_OBJECT
 
 public:
-    explicit TranslucentButton(const QString &name, QWidget *parent);
+    static const int pixels;
+    explicit TranslucentButton(const QString &iconName, QWidget *parent);
 
 public slots:
     void flash(int duration = 3000);
@@ -20,9 +29,9 @@ signals:
 
 protected:
     void paintEvent(QPaintEvent *);
-    void mousePressEvent(QMouseEvent *);
+    void mouseReleaseEvent(QMouseEvent *);
     QString name;
-    int opacity;
+    bool transparent;
     QTimer *timer;
 };