TRACE;
qDebug() << "icon" << iconName << "text" << text;
#ifndef Q_OS_SYMBIAN
- return toolBar->addAction(QIcon(Platform::icon(iconName)),
+ return toolBar->addAction(QIcon(Platform::instance()->icon(iconName)),
text, receiver, member);
#else
Q_UNUSED(iconName);
connect(s, SIGNAL(valueChanged(const QString &)),
this, SLOT(onSettingsChanged(const QString &)));
s->setValue("zoom", s->value("zoom", 160));
- s->setValue("font", s->value("font", Platform::defaultFont()));
+ s->setValue("font", s->value("font", Platform::instance()->defaultFont()));
s->setValue("scheme", s->value("scheme", "default"));
s->setValue("usevolumekeys", s->value("usevolumekeys", false));
setBook(0);
{
TRACE;
if (mBook) {
- if (part != contentIndex) {
- qDebug() << "Loading new part" << part;
- restoreFragmentAfterLoad = true;
- fragmentAfterLoad = fragment;
- loadContent(part);
+ if (fragment.isEmpty()) {
+ goToBookmark(Book::Bookmark(part, 0));
} else {
- goToFragment(fragment);
- showProgress();
+ if (part != contentIndex) {
+ qDebug() << "Loading new part" << part;
+ restoreFragmentAfterLoad = true;
+ fragmentAfterLoad = fragment;
+ loadContent(part);
+ } else {
+ goToFragment(fragment);
+ showProgress();
+ }
}
}
}
QVariant ret = page()->mainFrame()->evaluateJavaScript(
QString("window.location='") + fragment + "'");
qDebug() << ret;
- setLastBookmark();
+ // FIXME: setLastBookmark();
}
}
QWebView::leaveEvent(e);
}
-void BookView::enterEvent(QEvent *e)
+void BookView::resizeEvent(QEvent *e)
{
TRACE;
// Restore position saved at Leave event. This seems to be required,
void timerEvent(QTimerEvent *e);
#ifdef Q_WS_MAEMO_5
void leaveEvent(QEvent *e);
- void enterEvent(QEvent *e);
+ void resizeEvent(QEvent *e);
#endif // Q_WS_MAEMO_5
/** Load given part. */
void DevTools::onTraceToFileToggled(bool enable)
{
- QString name = enable? Platform::traceFileName(): QString();
+ QString name = enable? Platform::instance()->traceFileName(): QString();
Trace::setFileName(name);
Settings::instance()->setValue("tracefilename", name);
}
FullScreenWindow::FullScreenWindow(QWidget *parent): AdopterWindow(parent)
{
+ TRACE;
Q_ASSERT(parent);
#ifdef Q_WS_MAEMO_5
setAttribute(Qt::WA_Maemo5StackedWindow, true);
void FullScreenWindow::showFullScreen()
{
+ TRACE;
#ifdef Q_WS_MAEMO_5
setAttribute(Qt::WA_Maemo5PortraitOrientation, parentWidget()->
testAttribute(Qt::WA_Maemo5PortraitOrientation));
void FullScreenWindow::resizeEvent(QResizeEvent *e)
{
+ TRACE;
Q_UNUSED(e);
QRect screen = QApplication::desktop()->screenGeometry();
restoreButton->setGeometry(screen.width() - TranslucentButton::pixels - 9,
// Add book to library
QModelIndex index = library->find(path);
if (index.isValid()) {
- Platform::information(tr("This book is already in the library"), this);
+ Platform::instance()->information(
+ tr("This book is already in the library"), this);
setSelected(index);
}
else {
progress->reset();
qDebug() << "LibraryDialog::onRefreshDone:" << msg;
- Platform::information(msg, this);
+ Platform::instance()->information(msg, this);
}
void LibraryDialog::onAddFromFolder(const QString &path)
ret = a.exec();
}
+ // Re-start application if event loop exit code was 1000
+ if (ret == 1000) {
+ Platform::instance()->restart(argv);
+ }
+
// Release singletons
Library::close();
BookDb::close();
Settings::close();
Search::close();
+ Platform::close();
#ifdef Q_OS_SYMBIAN
MediaKeysObserver::close();
#endif
- // Re-start application if event loop exit code was 1000
- if (ret == 1000) {
- Platform::restart(argv);
- }
return ret;
}
void MainWindow::onCurrentBookChanged()
{
+ TRACE;
setCurrentBook(Library::instance()->nowReading());
}
activateWindow();
#elif defined(Q_WS_MAEMO_5)
// FIXME: This is ugly.
- view->restoreLastBookmark();
+ // view->restoreLastBookmark();
#endif
progress->flash();
nextButton->flash();
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();
{
TRACE;
bool shouldCreate = false;
- QFileInfo info(Platform::dbPath());
+ QFileInfo info(Platform::instance()->dbPath());
if (!info.exists()) {
QDir dbDir;
if (!dbDir.mkpath(info.absolutePath())) {
shouldCreate = true;
}
db = QSqlDatabase::addDatabase("QSQLITE");
- db.setDatabaseName(QDir::toNativeSeparators(Platform::dbPath()));
+ db.setDatabaseName(QDir::toNativeSeparators(Platform::instance()->dbPath()));
if (!db.open()) {
- qCritical() << "Could not open" << Platform::dbPath() << ": Error"
- << db.lastError().text();
+ qCritical() << "Could not open" << Platform::instance()->dbPath()
+ << ": Error" << db.lastError().text();
}
if (shouldCreate) {
create();
#include "pkg/version.txt"
;
-Library *Library::mInstance = 0;
+static Library *theInstance = 0;
Library::Library(QObject *parent): QAbstractListModel(parent)
{
Library *Library::instance()
{
- if (!mInstance) {
- mInstance = new Library();
+ if (!theInstance) {
+ theInstance = new Library();
}
- return mInstance;
+ return theInstance;
}
int Library::rowCount(const QModelIndex &parent) const
void Library::close()
{
- delete mInstance;
- mInstance = 0;
+ delete theInstance;
+ theInstance = 0;
}
void Library::load()
explicit Library(QObject *parent = 0);
~Library();
void clear();
- static Library *mInstance;
QList<Book *> mBooks;
QModelIndex mNowReading;
};
#include "settings.h"
-static Settings *inst;
+static Settings *theInstance;
Settings::Settings(QObject *parent) :
QObject(parent)
Settings *Settings::instance()
{
- if (!inst) {
- inst = new Settings();
+ if (!theInstance) {
+ theInstance = new Settings();
}
- return inst;
+ return theInstance;
}
void Settings::close()
{
- delete inst;
- inst = 0;
+ delete theInstance;
+ theInstance = 0;
}
void Settings::setValue(const QString &key, const QVariant &value)
+dorian (0.3.5-1) unstable; urgency=low
+
+ *
+
+ -- Akos Polster <akos@pipacs.com> Sun, 7 Nov 2010 02:00:00 +0100
+
dorian (0.3.4-1) unstable; urgency=low
* On Symbian, display confirmation after downloading a book
# include <QMessageBox>
#endif
+static Platform *theInstance;
+
+Platform *Platform::instance()
+{
+ if (!theInstance) {
+ theInstance = new Platform();
+ }
+ return theInstance;
+}
+
+void Platform::close()
+{
+ delete theInstance;
+ theInstance = 0;
+}
+
QString Platform::dbPath()
{
QString base(QDir::home().absoluteFilePath(DORIAN_BASE));
class Platform
{
public:
- static QString dbPath();
- static QString icon(const QString &name);
- static void restart(char *argv[]);
- static QString version();
- static QString downloadDir();
- static QString defaultFont();
- static void information(const QString &label, QWidget *parent = 0);
- static void showBusy(QWidget *w, bool isBusy);
- static QString traceFileName();
+ static Platform *instance();
+ static void close();
+
+ QString dbPath();
+ QString icon(const QString &name);
+ void restart(char *argv[]);
+ QString version();
+ QString downloadDir();
+ QString defaultFont();
+ void information(const QString &label, QWidget *parent = 0);
+ void showBusy(QWidget *w, bool isBusy);
+ QString traceFileName();
};
#endif // PLATFORM_H
QString SearchResultsDialog::downloadName() const
{
TRACE;
- QString dir = Platform::downloadDir();
+ QString dir = Platform::instance()->downloadDir();
QDir().mkpath(dir); // Not sure if this works. QDir API is quiet lame.
unsigned i = 0;
QString fileName;
if (-1 != row) {
list->model()->removeRow(row);
}
- Platform::information(tr("Downloaded \"%1\"\nand added to the library").
- arg(result.title), this);
+ Platform::instance()->information(tr("Downloaded \"%1\"\nand added to the "
+ "library").arg(result.title), this);
}
}
ToolButtonBox *box = new ToolButtonBox(this);
layout->addWidget(box);
box->addButton(SchemeDefault, tr("Default"),
- Platform::icon("style-default"));
- box->addButton(SchemeNight, tr("Night"), Platform::icon("style-night"));
- box->addButton(SchemeDay, tr("Day"), Platform::icon("style-day"));
- box->addButton(SchemeSand, tr("Sand"), Platform::icon("style-sand"));
+ Platform::instance()->icon("style-default"));
+ box->addButton(SchemeNight, tr("Night"),
+ Platform::instance()->icon("style-night"));
+ box->addButton(SchemeDay, tr("Day"), Platform::instance()->icon("style-day"));
+ box->addButton(SchemeSand, tr("Sand"),
+ Platform::instance()->icon("style-sand"));
box->addStretch();
QString scheme = settings->value("scheme", "default").toString();
if (scheme == "night") {
TRACE;
#ifdef Q_WS_MAEMO_5
Q_UNUSED(role);
- QPushButton *button =
- new QPushButton(QIcon(Platform::icon(iconName)), title, this);
+ QPushButton *button = new QPushButton(QIcon(Platform::instance()->
+ icon(iconName)), title, this);
contentLayout->addWidget(button);
connect(button, SIGNAL(clicked()), receiver, slot);
#elif defined(Q_OS_SYMBIAN)
QPainter painter(this);
if (!transparent) {
painter.setRenderHint(QPainter::Antialiasing, true);
- painter.drawPixmap(0, 0, QPixmap(Platform::icon(name)).scaled(
+ painter.drawPixmap(0, 0, QPixmap(Platform::instance()->icon(name)).scaled(
QSize(pixels, pixels), Qt::IgnoreAspectRatio,
Qt::SmoothTransformation));
} else {