layout->addWidget(view);
// Progress
- progress = new Progress(central);
+ progress = new Progress(this);
// Settings dialog
settings = new QDialog(this);
connect(library, SIGNAL(upgrading(const QString &)),
this, SLOT(onUpgrading(const QString &)));
connect(library, SIGNAL(endUpgrade()), this, SLOT(onEndUpgrade()));
- connect(library, SIGNAL(beginLoad(int)), this, SLOT(onBeginLoad(int)));
- connect(library, SIGNAL(loading(const QString &)),
- this, SLOT(onLoading(const QString &)));
- connect(library, SIGNAL(endLoad()), this, SLOT(onEndLoad()));
- library->upgrade();
- library->load();
-
- // Load book on command line, or load last read book, or load default book
- if (QCoreApplication::arguments().size() == 2) {
- QString path = QCoreApplication::arguments()[1];
- library->add(path);
- QModelIndex index = library->find(path);
- if (index.isValid()) {
- library->setNowReading(index);
- }
- } else {
- QModelIndex index = library->nowReading();
- if (index.isValid()) {
- library->setNowReading(index);
- } else {
- if (!library->rowCount()) {
- library->add(":/books/2BR02B.epub");
- }
- library->setNowReading(library->index(0));
- }
- }
// Handle loading book parts
connect(view, SIGNAL(partLoadStart(int)), this, SLOT(onPartLoadStart()));
connect(fullScreenWindow, SIGNAL(restore()), this, SLOT(showRegular()));
// Handle settings changes
- Settings *settings = Settings::instance();
- connect(settings, SIGNAL(valueChanged(const QString &)),
+ connect(Settings::instance(), SIGNAL(valueChanged(const QString &)),
this, SLOT(onSettingsChanged(const QString &)));
- settings->setValue("orientation", settings->value("orientation"));
- settings->setValue("lightson", settings->value("lightson"));
// Handle book view buttons
connect(nextButton, SIGNAL(triggered()), this, SLOT(goToNextPage()));
#endif
}
+void MainWindow::initialize()
+{
+ TRACE;
+ Library *library = Library::instance();
+
+ // Upgrade library if needed, then load it
+ library->upgrade();
+ library->load();
+
+ // Load book on command line, or load last read book, or load default book
+ if (QCoreApplication::arguments().size() == 2) {
+ QString path = QCoreApplication::arguments()[1];
+ library->add(path);
+ QModelIndex index = library->find(path);
+ if (index.isValid()) {
+ library->setNowReading(index);
+ }
+ } else {
+ QModelIndex index = library->nowReading();
+ if (index.isValid()) {
+ library->setNowReading(index);
+ } else {
+ if (!library->rowCount()) {
+ library->add(":/books/2BR02B.epub");
+ }
+ library->setNowReading(library->index(0));
+ }
+ }
+}
+
void MainWindow::onCurrentBookChanged()
{
+ TRACE;
setCurrentBook(Library::instance()->nowReading());
}
show();
#if defined(Q_OS_SYMBIAN)
activateWindow();
-#elif defined(Q_WS_MAEMO_5)
- // FIXME: This is ugly.
- view->restoreLastBookmark();
#endif
progress->flash();
nextButton->flash();
void MainWindow::onSettingsChanged(const QString &key)
{
- TRACE;
- qDebug() << key;
#if defined(Q_WS_MAEMO_5)
if (key == "orientation") {
- QString value = Settings::instance()->value(key).toString();
+ QString value = Settings::instance()->value(key,
+ Platform::instance()->defaultOrientation()).toString();
+ qDebug() << "MainWindow::onSettingsChanged: orientation" << value;
if (value == "portrait") {
setAttribute(Qt::WA_Maemo5LandscapeOrientation, false);
setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
}
} else if (key == "lightson") {
bool enable = Settings::instance()->value(key, false).toBool();
+ qDebug() << "MainWindow::onSettingsChanged: lightson" << enable;
killTimer(preventBlankingTimer);
if (enable) {
preventBlankingTimer = startTimer(29 * 1000);
void MainWindow::onPartLoadStart()
{
TRACE;
- Platform::showBusy(this, true);
+ Platform::instance()->showBusy(this, true);
}
void MainWindow::onPartLoadEnd(int index)
enableNext = true;
}
}
- Platform::showBusy(this, false);
+ Platform::instance()->showBusy(this, false);
}
void MainWindow::onAddBookmark(const QString ¬e)
{
TRACE;
view->addBookmark(note);
- Platform::information(tr("Bookmarked current position"), this);
+ Platform::instance()->information(tr("Bookmarked current position"), this);
}
void MainWindow::onGoToBookmark(int index)
{
Dyalog *aboutDialog = new Dyalog(this, false);
aboutDialog->setWindowTitle(tr("About Dorian"));
+ QString version = Platform::instance()->version();
QLabel *label = new QLabel(aboutDialog);
label->setTextFormat(Qt::RichText);
label->setOpenExternalLinks(true);
"Akos Polster <akos@pipacs.com><br>"
"Licensed under GNU General Public License, Version 3<br>"
"Source code:<br><a href='https://garage.maemo.org/projects/dorian/'>"
- "garage.maemo.org/projects/dorian</a>").arg(Platform::version()));
+ "garage.maemo.org/projects/dorian</a>").arg(version));
aboutDialog->addWidget(label);
aboutDialog->addStretch();
aboutDialog->show();