#include <QtGui>
-#include <QtDebug>
-#include <QDir>
-#include <QApplication>
-#include <QFileInfo>
-#include <QStringList>
-#include <QWebView>
-#include <QWebFrame>
#ifdef Q_WS_MAEMO_5
-# include <QtMaemo5/QMaemo5InformationBox>
# include <QtDBus>
# include <QtGui/QX11Info>
# include <X11/Xlib.h>
#include "dyalog.h"
#include "translucentbutton.h"
#include "platform.h"
+#include "progressdialog.h"
#ifdef DORIAN_TEST_MODEL
# include "modeltest.h"
MainWindow::MainWindow(QWidget *parent):
AdopterWindow(parent), view(0), preventBlankingTimer(-1)
{
- Trace t("MainWindow::MainWindow");
+ TRACE;
#ifdef Q_WS_MAEMO_5
setAttribute(Qt::WA_Maemo5StackedWindow, true);
#endif
addToolBarSpace();
fullScreenAction = addToolBarAction(this, SLOT(showBig()),
"view-fullscreen", tr("Full screen"));
+#else
+ (void)addToolBarAction(this, SLOT(close()), "", tr("Exit"));
#endif
// Buttons on top of the book view
this, SLOT(onCurrentBookChanged()));
// Load library, upgrade it if needed
- libraryProgress = new QProgressDialog(tr("Upgrading library"), "", 0, 0, this);
- libraryProgress->reset();
- libraryProgress->setMinimumDuration(0);
- libraryProgress->setWindowModality(Qt::WindowModal);
- libraryProgress->setCancelButton(0);
+ libraryProgress = new ProgressDialog(tr("Upgrading library"), this);
Library *library = Library::instance();
connect(library, SIGNAL(beginUpgrade(int)), this, SLOT(onBeginUpgrade(int)));
connect(library, SIGNAL(upgrading(const QString &)),
void MainWindow::showRegular()
{
- Trace t("MainWindow::showRegular");
- fullScreenWindow->hide();
- fullScreenWindow->leaveChildren();
+ TRACE;
+ // Re-parent children
+ fullScreenWindow->leaveChildren();
QList<QWidget *> otherChildren;
otherChildren << progress << previousButton << nextButton;
takeChildren(view, otherChildren);
+
+ // Adjust geometry of decorations
QRect geo = geometry();
progress->setGeometry(0, 0, geo.width(), DORIAN_PROGRESS_HEIGHT);
#if defined(Q_WS_MAEMO_5)
previousButton->setGeometry(0, geo.height() - TranslucentButton::pixels,
TranslucentButton::pixels, TranslucentButton::pixels);
nextButton->setGeometry(geo.width() - TranslucentButton::pixels - 25,
- toolBar->height(), TranslucentButton::pixels, TranslucentButton::pixels);
+ toolBar->height(), TranslucentButton::pixels,
+ TranslucentButton::pixels);
#endif // Q_WS_MAEMO_5
qDebug() << "previousButton geometry" << previousButton->geometry();
+
+ fullScreenWindow->hide();
+ show();
+#if defined(Q_OS_SYMBIAN)
+ activateWindow();
+#elif defined(Q_WS_MAEMO_5)
+ // FIXME: This is ugly.
+ view->restoreLastBookmark();
+#endif
progress->flash();
- nextButton->show();
- previousButton->show();
- nextButton->flash(1500);
- previousButton->flash(1500);
+ nextButton->flash();
+ previousButton->flash();
}
void MainWindow::showBig()
{
- Trace t("MainWindow::showBig");
+ TRACE;
+
+ // Re-parent children
leaveChildren();
QList<QWidget *> otherChildren;
otherChildren << progress << nextButton << previousButton;
+ fullScreenWindow->takeChildren(view, otherChildren);
+
+ // Adjust geometry of decorations
QRect screen = QApplication::desktop()->screenGeometry();
progress->setGeometry(0, 0, screen.width(), DORIAN_PROGRESS_HEIGHT);
#if defined(Q_WS_MAEMO_5)
TranslucentButton::pixels, TranslucentButton::pixels);
#else
nextButton->setGeometry(screen.width() - TranslucentButton::pixels - 25, 0,
- TranslucentButton::pixels, TranslucentButton::pixels);
+ TranslucentButton::pixels, TranslucentButton::pixels);
#endif // Q_WS_MAEMO_5
previousButton->setGeometry(0, screen.height() - TranslucentButton::pixels,
TranslucentButton::pixels, TranslucentButton::pixels);
- fullScreenWindow->takeChildren(view, otherChildren);
+#ifdef Q_OS_SYMBIAN
+ hide();
+#endif
fullScreenWindow->showFullScreen();
+#ifdef Q_OS_SYMBIAN
+ fullScreenWindow->activateWindow();
+#endif
progress->flash();
- nextButton->flash(1500);
- previousButton->flash(1500);
+ nextButton->flash();
+ previousButton->flash();
}
void MainWindow::setCurrentBook(const QModelIndex ¤t)
void MainWindow::closeEvent(QCloseEvent *event)
{
- Trace t("MainWindow::closeEvent");
+ TRACE;
view->setLastBookmark();
event->accept();
}
void MainWindow::onSettingsChanged(const QString &key)
{
-#ifdef Q_WS_MAEMO_5
+#if defined(Q_WS_MAEMO_5)
if (key == "orientation") {
QString value = Settings::instance()->value(key).toString();
qDebug() << "MainWindow::onSettingsChanged: orientation" << value;
grabZoomKeys(value);
fullScreenWindow->grabZoomKeys(value);
}
+#elif defined Q_OS_SYMBIAN
+ if (key == "usevolumekeys") {
+ bool value = Settings::instance()->value(key).toBool();
+ qDebug() << "MainWindow::onSettingsChanged: usevolumekeys" << value;
+ grabZoomKeys(value);
+ fullScreenWindow->grabZoomKeys(value);
+ }
#else
Q_UNUSED(key);
#endif // Q_WS_MAEMO_5
void MainWindow::onPartLoadStart()
{
- Trace t("MainWindow::onPartLoadStart");
+ TRACE;
#ifdef Q_WS_MAEMO_5
setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
#endif
void MainWindow::onPartLoadEnd(int index)
{
- Trace t("MainWindow::onPartLoadEnd");
+ TRACE;
bool enablePrevious = false;
bool enableNext = false;
Book *book = Library::instance()->book(mCurrent);
void MainWindow::onAddBookmark(const QString ¬e)
{
- Trace t("MainWindow:onAddBookmark");
+ TRACE;
view->addBookmark(note);
+ Platform::information(tr("Bookmarked current position"), this);
}
void MainWindow::onGoToBookmark(int index)
{
- Trace t("MainWindow::onGoToBookmark");
+ TRACE;
Book *book = Library::instance()->book(mCurrent);
view->goToBookmark(book->bookmarks()[index]);
}
void MainWindow::onGoToChapter(int index)
{
- Trace t("MainWindow::onGoToChapter");
+ TRACE;
Book *book = Library::instance()->book(mCurrent);
if (book) {
- int partIndex = book->partFromChapter(index);
+ QString fragment;
+ int partIndex = book->partFromChapter(index, fragment);
if (partIndex != -1) {
- view->goToBookmark(Book::Bookmark(partIndex, 0));
+ view->goToPart(partIndex, fragment);
}
}
}
void MainWindow::resizeEvent(QResizeEvent *e)
{
- Trace t("MainWindow::resizeEvent");
+ TRACE;
progress->setGeometry(QRect(0, 0, e->size().width(), DORIAN_PROGRESS_HEIGHT));
#if defined(Q_WS_MAEMO_5)
previousButton->setGeometry(0,
toolBar->height(), TranslucentButton::pixels, TranslucentButton::pixels);
#endif // Q_WS_MAEMO_5
qDebug() << "previousButton geometry" << previousButton->geometry();
- previousButton->flash(1500);
- nextButton->flash(1500);
+ previousButton->flash();
+ nextButton->flash();
QMainWindow::resizeEvent(e);
}
label->setText(tr("<b>Dorian %1</b><br><br>Copyright © 2010 "
"Akos Polster <akos@pipacs.com><br>"
"Licensed under GNU General Public License, Version 3<br>"
- "Source code: <a href='https://garage.maemo.org/projects/dorian/'>"
+ "Source code:<br><a href='https://garage.maemo.org/projects/dorian/'>"
"garage.maemo.org/projects/dorian</a>").arg(Platform::version()));
aboutDialog->addWidget(label);
aboutDialog->addStretch();
void MainWindow::goToNextPage()
{
- nextButton->flash(1500);
- previousButton->flash(1500);
+ nextButton->flash();
+ previousButton->flash();
view->goNextPage();
}
void MainWindow::goToPreviousPage()
{
- nextButton->flash(1500);
- previousButton->flash(1500);
+ nextButton->flash();
+ previousButton->flash();
view->goPreviousPage();
}