X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=platform.cpp;h=ac2503997cbd40da22b9eb424a928ff58239850a;hb=4f302c4427507fec544f32b9003035e93f32b2e2;hp=f96cddaf75a523592cb5536d12f8b57c0306c63e;hpb=f2642c65286c00bdd7c3b01dcb0bd5d4bfc9e370;p=dorian diff --git a/platform.cpp b/platform.cpp index f96cdda..ac25039 100644 --- a/platform.cpp +++ b/platform.cpp @@ -1,11 +1,20 @@ #include #include +#include #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) # include #endif +#ifdef Q_OS_SYMBIAN +# include +# include +# include +# include +#endif + #include "platform.h" +#include "trace.h" #if defined(Q_OS_WIN32) || defined(Q_OS_SYMBIAN) # define DORIAN_BASE "dorian" @@ -25,6 +34,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,7 +91,14 @@ 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() @@ -73,3 +113,77 @@ QString Platform::defaultFont() 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 +} + +void Platform::setOrientation(QWidget *widget, const QString &orientation) +{ + TRACE; + qDebug() << "To" << orientation; + + Q_UNUSED(widget); + +#if defined(Q_OS_SYMBIAN) + CAknAppUi *appUi = dynamic_cast(CEikonEnv::Static()->AppUi()); + if (!appUi) { + qCritical() << "Platform::setOrientation: Couldn't get AppUi pointer"; + return; + } +#endif + + if (orientation == "portrait") { +#if defined(Q_WS_MAEMO_5) + widget->setAttribute(Qt::WA_Maemo5LandscapeOrientation, false); + widget->setAttribute(Qt::WA_Maemo5PortraitOrientation, true); +#elif defined(Q_OS_SYMBIAN) + TRAPD(error, + appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait);); +#endif + } else { +#if defined(Q_WS_MAEMO_5) + widget->setAttribute(Qt::WA_Maemo5PortraitOrientation, false); + widget->setAttribute(Qt::WA_Maemo5LandscapeOrientation, true); +#elif defined(Q_OS_SYMBIAN) + TRAPD(error, + appUi->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape);); +#endif + } +}