setBook(0);
extractIcons();
-
#ifdef Q_WS_MAEMO_5
scroller = property("kineticScroller").value<QAbstractKineticScroller *>();
- if (scroller) {
- t.trace("Got scroller");
- }
#endif
}
bool BookView::eventFilter(QObject *o, QEvent *e)
{
-#if 0
if (e->type() != QEvent::Paint && e->type() != QEvent::MouseMove) {
if (e->type() == QEvent::Resize) {
Trace::trace(QString("BookView::eventFilter QEvent::Resize to %1").
arg(Trace::event(e->type())));
}
}
-#endif
switch (e->type()) {
case QEvent::MouseButtonPress:
} else {
killTimer(scrollerMonitor);
}
- }
#endif // Q_WS_MAEMO_5
+ }
+}
+
+void BookView::keyPressEvent(QKeyEvent* event)
+{
+ switch (event->key()) {
+ case Qt::Key_F7:
+ goNextPage();
+ event->accept();
+ break;
+ case Qt::Key_F8:
+ goPreviousPage();
+ event->accept();
+ break;
+ default:
+ ;
+ }
+ QWebView::keyPressEvent(event);
+}
+
+void BookView::goPreviousPage()
+{
+ QWebFrame *frame = page()->mainFrame();
+ int pos = frame->scrollPosition().y();
+ frame->scroll(0, -height());
+ if (pos == frame->scrollPosition().y()) {
+ if (contentIndex > 0) {
+ goToBookmark(Book::Bookmark(contentIndex - 1, 1.0));
+ }
+ } else {
+ showProgress();
+ }
+}
+
+void BookView::goNextPage()
+{
+ Trace t("BookView::goNextPage");
+ QWebFrame *frame = page()->mainFrame();
+ int pos = frame->scrollPosition().y();
+ frame->scroll(0, height());
+ if (pos == frame->scrollPosition().y()) {
+ goNext();
+ } else {
+ showProgress();
+ }
}
void leaveEvent(QEvent *e);
void enterEvent(QEvent *e);
void timerEvent(QTimerEvent *e);
+ void keyPressEvent(QKeyEvent *e);
private:
/** Save navigation icons from resource to the file system. */
/** Show progress. */
void showProgress();
+ /** Go to previous page. */
+ void goPreviousPage();
+
+ /** Go to next page. */
+ void goNextPage();
+
int contentIndex; /**< Current part in book. */
Book *mBook; /**< Book to show. */
bool restorePositionAfterLoad;
#ifdef Q_WS_MAEMO_5
# include <QtMaemo5/QMaemo5InformationBox>
# include <QtDBus>
+# include <QtGui/QX11Info>
+# include <X11/Xlib.h>
+# include <X11/Xatom.h>
# include <mce/mode-names.h>
# include <mce/dbus-names.h>
#endif // Q_WS_MAEMO_5
Trace t("MainWindow::MainWindow");
#ifdef Q_WS_MAEMO_5
setAttribute(Qt::WA_Maemo5StackedWindow, true);
+ grabZoomKeys();
#endif
setWindowTitle("Dorian");
progress->setGeometry(QRect(0, 0, e->size().width(), PROGRESS_HEIGHT));
QMainWindow::resizeEvent(e);
}
+
+void MainWindow::grabZoomKeys()
+{
+#ifdef Q_WS_MAEMO_5
+ if (!winId()) {
+ qCritical() << "Can't grab keys unless we have a window id";
+ return;
+ }
+ unsigned long val = 1;
+ 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);
+#endif // Q_WS_MAEMO_5
+}
void setCurrentBook(const QModelIndex ¤t);
QAction *addToolBarAction(const QObject *receiver, const char *member,
const QString &name);
+ void grabZoomKeys();
BookView *view;
QAction *settingsAction;
QAction *libraryAction;
* Improve cover image display
* Fix naming: book parts vs. chapters
* Show reading progress
+ * Navigate with volume keys
- -- Akos Polster <akos@pipacs.com> Sat, 7 Aug 2010 20:00:00 +0200
+ -- Akos Polster <akos@pipacs.com> Sat, 8 Aug 2010 20:00:00 +0200
dorian (0.1.1-1) unstable; urgency=low