Add some platform helpers.
authorAkos Polster <akos@pipacs.com>
Fri, 8 Oct 2010 22:45:44 +0000 (00:45 +0200)
committerAkos Polster <akos@pipacs.com>
Fri, 8 Oct 2010 22:45:44 +0000 (00:45 +0200)
platform.cpp [new file with mode: 0644]
platform.h [new file with mode: 0644]

diff --git a/platform.cpp b/platform.cpp
new file mode 100644 (file)
index 0000000..d93c63d
--- /dev/null
@@ -0,0 +1,26 @@
+#include <QDir>
+
+#include "platform.h"
+
+#if defined(Q_OS_WIN32) || defined(Q_OS_SYMBIAN)
+#   define DORIAN_BASE "dorian"
+#else
+#   define DORIAN_BASE ".dorian"
+#endif
+
+#ifdef Q_WS_MAC
+#   define DORIAN_ICON_PREFIX ":/icons/mac/"
+#else
+#   define DORIAN_ICON_PREFIX ":/icons/"
+#endif
+
+QString Platform::dbPath()
+{
+    QString base(QDir::home().absoluteFilePath(DORIAN_BASE));
+    return QDir(base).absoluteFilePath("books.db");
+}
+
+QString Platform::icon(const QString &name)
+{
+    return QString(DORIAN_ICON_PREFIX) + name + ".png";
+}
diff --git a/platform.h b/platform.h
new file mode 100644 (file)
index 0000000..b10d17e
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef PLATFORM_H
+#define PLATFORM_H
+
+#include <QString>
+
+class Platform
+{
+public:
+    static QString dbPath();
+    static QString icon(const QString &name);
+};
+
+#endif // PLATFORM_H