X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=platform.cpp;h=ee7f5d9bc56ec8358c31de6e5dcb81afcd2e94ab;hb=c88b9707625d40c905e88c8099499981c77ec807;hp=f090489101008d86d877ec1de01d415147a3e99b;hpb=9c05884a77fb00596e9579fd4eacdff848383710;p=dorian diff --git a/platform.cpp b/platform.cpp index f090489..ee7f5d9 100644 --- a/platform.cpp +++ b/platform.cpp @@ -1,8 +1,9 @@ #include #include +#include #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) -#include +# include #endif #include "platform.h" @@ -25,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)); @@ -58,5 +83,65 @@ QString Platform::version() QString Platform::downloadDir() { +#ifdef Q_OS_SYMBIAN + if (QDir("E:/").exists()) { + return "E:/Books"; + } + return "C:/Books"; +#else return QDir::home().absoluteFilePath("Books"); +#endif +} + +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 }