#include <QtGui>
-#include <QtDebug>
-#include <QDir>
-#include <QApplication>
-#include <QFileInfo>
-#include <QStringList>
-#include <QWebView>
-#include <QWebFrame>
#ifdef Q_WS_MAEMO_5
# include <QtMaemo5/QMaemo5InformationBox>
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
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);
}
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);
void MainWindow::closeEvent(QCloseEvent *event)
{
- Trace t("MainWindow::closeEvent");
+ TRACE;
view->setLastBookmark();
event->accept();
}
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);
}
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) {
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,