X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=platform.cpp;h=4fc6deedc1c5359f0ef24657d304cb9c6e5eef76;hb=166f29f9d4d6e2ed8080e78d38f45edd68315be4;hp=1c4172b2a4f336a9aa0b56c638b2d6429084a5cb;hpb=b3ae7bb69d48c288fbc49320521a0666b8a1f7dd;p=dorian diff --git a/platform.cpp b/platform.cpp index 1c4172b..4fc6dee 100644 --- a/platform.cpp +++ b/platform.cpp @@ -1,10 +1,11 @@ -#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) -#include -#endif - +#include #include #include +#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) +# include +#endif + #include "platform.h" #if defined(Q_OS_WIN32) || defined(Q_OS_SYMBIAN) @@ -13,8 +14,10 @@ # define DORIAN_BASE ".dorian" #endif -#ifdef Q_WS_MAC +#if defined(Q_WS_MAC) # define DORIAN_ICON_PREFIX ":/icons/mac/" +#elif defined(Q_OS_SYMBIAN) +# define DORIAN_ICON_PREFIX ":/icons/symbian/" #else # define DORIAN_ICON_PREFIX ":/icons/" #endif @@ -23,6 +26,30 @@ static const char *DORIAN_VERSION = #include "pkg/version.txt" ; +#define DORIAN_LOG "dorian.txt" + +#ifdef Q_WS_MAEMO_5 +# include +#else +# include +#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)); @@ -31,7 +58,12 @@ QString Platform::dbPath() QString Platform::icon(const QString &name) { - return QString(DORIAN_ICON_PREFIX) + name + ".png"; + QString iconName = QString(DORIAN_ICON_PREFIX) + name + ".png"; + if (QFile(iconName).exists()) { + return iconName; + } else { + return QString(":/icons/") + name + ".png"; + } } void Platform::restart(char *argv[]) @@ -53,3 +85,56 @@ QString Platform::downloadDir() { return QDir::home().absoluteFilePath("Books"); } + +QString Platform::defaultFont() +{ +#if defined(Q_WS_MAEMO_5) || defined(Q_WS_X11) + return QString("Serif"); +#elif defined(Q_WS_MAC) + return QString("Hoefler Text"); +#elif defined Q_WS_S60 + return QString("Nokia Sans S60"); +#else + return QString("Times New Roman"); +#endif +} + +void Platform::information(const QString &label, QWidget *parent) +{ +#ifdef Q_WS_MAEMO_5 + QMaemo5InformationBox::information(parent, label, + QMaemo5InformationBox::DefaultTimeout); +#else + (void)QMessageBox::information(parent, QObject::tr("Dorian"), label, + QMessageBox::Ok); +#endif +} + +void Platform::showBusy(QWidget *w, bool isBusy) +{ +#ifdef Q_WS_MAEMO_5 + w->setAttribute(Qt::WA_Maemo5ShowProgressIndicator, isBusy); +#else + Q_UNUSED(w); + Q_UNUSED(isBusy); +#endif +} + +QString Platform::traceFileName() +{ + return QDir::home().absoluteFilePath(DORIAN_LOG); +} + +int Platform::defaultZoom() +{ + return 150; +} + +QString Platform::defaultOrientation() +{ +#ifdef Q_OS_SYMBIAN + return QString("portrait"); +#else + return QString("landscape"); +#endif +}