Observe volume keys on Symbian. Add minimal documentation to headers.
[dorian] / platform.cpp
index c65bae8..dff134c 100644 (file)
@@ -1,10 +1,10 @@
+#include <QtGlobal>
+#include <QDir>
+
 #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
-#include <unistd.h>
+#   include <unistd.h>
 #endif
 
-#include <QDir>
-#include <QtGui>
-
 #include "platform.h"
 
 #if defined(Q_OS_WIN32) || defined(Q_OS_SYMBIAN)
 #   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
 
+static const char *DORIAN_VERSION =
+#include "pkg/version.txt"
+;
+
+#ifdef Q_WS_MAEMO_5
+#   include <QtMaemo5/QMaemo5InformationBox>
+#else
+#   include <QMessageBox>
+#endif
+
 QString Platform::dbPath()
 {
     QString base(QDir::home().absoluteFilePath(DORIAN_BASE));
@@ -27,7 +39,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[])
@@ -39,3 +56,37 @@ void Platform::restart(char *argv[])
     Q_UNUSED(argv);
 #endif
 }
+
+QString Platform::version()
+{
+    return QString(DORIAN_VERSION);
+}
+
+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
+}