From cf5242cde0ade17a4a308074ad6034d98ca69c8a Mon Sep 17 00:00:00 2001 From: Akos Polster Date: Fri, 5 Nov 2010 00:07:26 +0100 Subject: [PATCH] Small dialog improvements. --- bookview.cpp | 16 +++++++++++++--- bookview.h | 7 ++++++- infodialog.cpp | 3 +++ widgets/adopterwindow.h | 4 ---- widgets/dyalog.cpp | 29 ++++++++++++++++++++++++----- widgets/dyalog.h | 5 ++++- 6 files changed, 50 insertions(+), 14 deletions(-) diff --git a/bookview.cpp b/bookview.cpp index e11f56e..05c5be9 100644 --- a/bookview.cpp +++ b/bookview.cpp @@ -70,7 +70,8 @@ BookView::BookView(QWidget *parent): scrollerMonitor = 0; scroller = property("kineticScroller").value(); #elif defined(Q_OS_SYMBIAN) - FlickCharm *charm = new FlickCharm(this); + scrollerMonitor = 0; + charm = new FlickCharm(this); charm->activateOn(this); #endif } @@ -226,6 +227,8 @@ void BookView::onLoadFinished(bool ok) } loaded = true; onSettingsChanged("scheme"); + onSettingsChanged("zoom"); + onSettingsChanged("font"); emit partLoadEnd(contentIndex); showProgress(); } @@ -281,7 +284,7 @@ void BookView::paintEvent(QPaintEvent *e) void BookView::mousePressEvent(QMouseEvent *e) { QWebView::mousePressEvent(e); -#ifdef Q_WS_MAEMO_5 +#if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN) // Start monitoring kinetic scroll if (scrollerMonitor) { killTimer(scrollerMonitor); @@ -327,6 +330,7 @@ QString BookView::tmpPath() bool BookView::eventFilter(QObject *o, QEvent *e) { +#if 0 if (e->type() != QEvent::Paint && e->type() != QEvent::MouseMove) { if (e->type() == QEvent::Resize) { qDebug() << "BookView::eventFilter QEvent::Resize to" @@ -338,6 +342,7 @@ bool BookView::eventFilter(QObject *o, QEvent *e) qDebug() << "BookView::eventFilter" << Trace::event(e->type()); } } +#endif // Work around Qt bug that sometimes selects web view contents during swipe switch (e->type()) { @@ -424,7 +429,7 @@ void BookView::showProgress() void BookView::timerEvent(QTimerEvent *e) { -#ifdef Q_WS_MAEMO_5 +#if defined(Q_WS_MAEMO_5) if (e->timerId() == scrollerMonitor) { if (scroller && ((scroller->state() == QAbstractKineticScroller::AutoScrolling) || @@ -432,8 +437,13 @@ void BookView::timerEvent(QTimerEvent *e) showProgress(); } else { killTimer(scrollerMonitor); + scrollerMonitor = -1; } } +#elif defined(Q_OS_SYMBIAN) + if (e->timerId() == scrollerMonitor) { + if (charm && charm->) + } #endif QWebView::timerEvent(e); } diff --git a/bookview.h b/bookview.h index 30af1f9..b79e8bf 100644 --- a/bookview.h +++ b/bookview.h @@ -14,6 +14,7 @@ class QModelIndex; class Progress; class QAbstractKineticScroller; class ProgressDialog; +class FlickCharm; /** Visual representation of a book. */ class BookView: public QWebView @@ -105,9 +106,13 @@ private: bool mousePressed; int contentsHeight; /**< Last know height of the frame. */ -#if defined(Q_WS_MAEMO_5) +#if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN) int scrollerMonitor; +#endif +#if defined(Q_WS_MAEMO_5) QAbstractKineticScroller *scroller; +#elif defined(Q_OS_SYMBIAN) + FlickCharm *charm; #endif }; diff --git a/infodialog.cpp b/infodialog.cpp index eadc647..d6dee93 100644 --- a/infodialog.cpp +++ b/infodialog.cpp @@ -3,10 +3,13 @@ #include "infodialog.h" #include "book.h" #include "library.h" +#include "trace.h" InfoDialog::InfoDialog(Book *b, QWidget *parent, bool showButtons): Dyalog(parent, showButtons), book(b) { + TRACE; + setWindowTitle(tr("Book Details")); if (book) { diff --git a/widgets/adopterwindow.h b/widgets/adopterwindow.h index 0c8d210..ba486b1 100644 --- a/widgets/adopterwindow.h +++ b/widgets/adopterwindow.h @@ -31,10 +31,6 @@ public: /** Add space. */ void addToolBarSpace(); - /** Add action that is visible on the menu. */ - QAction *addAction(QObject *receiver, const char *slot, - const QString &text); - /** Show window. */ void show(); diff --git a/widgets/dyalog.cpp b/widgets/dyalog.cpp index 3ffdfbc..db75c88 100644 --- a/widgets/dyalog.cpp +++ b/widgets/dyalog.cpp @@ -1,6 +1,7 @@ #include #include "dyalog.h" +#include "trace.h" #ifdef Q_OS_SYMBIAN #include "flickcharm.h" @@ -64,6 +65,7 @@ Dyalog::Dyalog(QWidget *parent, bool showButtons_): closeAction->setSoftKeyRole(QAction::NegativeSoftKey); connect(closeAction, SIGNAL(triggered()), this, SLOT(reject())); addAction(closeAction); + leftSoftKey = 0; menuBar = 0; #endif // Q_OS_SYMBIAN } @@ -81,17 +83,34 @@ void Dyalog::addStretch(int stretch) void Dyalog::addButton(const QString &label, QObject *receiver, const char *slot, QDialogButtonBox::ButtonRole role) { + TRACE; if (!showButtons) { + qDebug() << "Ignored: showButtons is false"; return; } #ifdef Q_OS_SYMBIAN Q_UNUSED(role); - if (!menuBar) { - menuBar = new QMenuBar(this); +#if 0 + if (!leftSoftKey) { + qDebug() << "Adding left soft key"; + leftSoftKey = new QAction(label, this); + leftSoftKey->setSoftKeyRole(QAction::PositiveSoftKey); + connect(leftSoftKey, SIGNAL(triggered()), receiver, slot); + addAction(leftSoftKey); + } else { +#endif + if (!menuBar) { + qDebug() << "Creating menu bar"; + menuBar = new QMenuBar(this); + menuBar->addAction(leftSoftKey); + } + qDebug() << "Adding to menu bar"; + QAction *action = new QAction(label, this); + connect(action, SIGNAL(triggered()), receiver, slot); + menuBar->addAction(action); +#if 0 } - QAction *action = new QAction(label, this); - connect(action, SIGNAL(triggered()), receiver, slot); - menuBar->addAction(action); +#endif #else QPushButton *button = new QPushButton(label, this); connect(button, SIGNAL(clicked()), receiver, slot); diff --git a/widgets/dyalog.h b/widgets/dyalog.h index 2150efb..ffbb231 100644 --- a/widgets/dyalog.h +++ b/widgets/dyalog.h @@ -9,9 +9,11 @@ class QPushButton; class QScrollArea; class QVBoxLayout; class QMenuBar; +class QAction; /** Maemo- and Mac-friendly dialog box. */ -class Dyalog: public QDialog +class Dyalog: + public QDialog { Q_OBJECT @@ -41,6 +43,7 @@ private: QDialogButtonBox *buttonBox; bool showButtons; #ifdef Q_OS_SYMBIAN + QAction *leftSoftKey; QMenuBar *menuBar; #endif }; -- 1.7.9.5