#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>
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");
+ TRACE;
// Re-parent children
fullScreenWindow->leaveChildren();
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->flash(1500);
- previousButton->flash(1500);
+ nextButton->flash();
+ previousButton->flash();
}
void MainWindow::showBig()
{
- Trace t("MainWindow::showBig");
+ TRACE;
// Re-parent children
leaveChildren();
previousButton->setGeometry(0, screen.height() - TranslucentButton::pixels,
TranslucentButton::pixels, TranslucentButton::pixels);
+#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;
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();
}