Add download statistics.
[dorian] / platform.cpp
index f96cdda..291a4b5 100644 (file)
@@ -25,6 +25,30 @@ static const char *DORIAN_VERSION =
 #include "pkg/version.txt"
 ;
 
+#define DORIAN_LOG "dorian.txt"
+
+#ifdef Q_WS_MAEMO_5
+#   include <QtMaemo5/QMaemo5InformationBox>
+#else
+#   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));
@@ -73,3 +97,43 @@ 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
+}