New version 0.3.3. Fix font scaling on Symbian.
[dorian] / platform.cpp
1 #include <QtGlobal>
2 #include <QDir>
3
4 #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
5 #   include <unistd.h>
6 #endif
7
8 #include "platform.h"
9
10 #if defined(Q_OS_WIN32) || defined(Q_OS_SYMBIAN)
11 #   define DORIAN_BASE "dorian"
12 #else
13 #   define DORIAN_BASE ".dorian"
14 #endif
15
16 #if defined(Q_WS_MAC)
17 #   define DORIAN_ICON_PREFIX ":/icons/mac/"
18 #elif defined(Q_OS_SYMBIAN)
19 #   define DORIAN_ICON_PREFIX ":/icons/symbian/"
20 #else
21 #   define DORIAN_ICON_PREFIX ":/icons/"
22 #endif
23
24 static const char *DORIAN_VERSION =
25 #include "pkg/version.txt"
26 ;
27
28 QString Platform::dbPath()
29 {
30     QString base(QDir::home().absoluteFilePath(DORIAN_BASE));
31     return QDir(base).absoluteFilePath("books.db");
32 }
33
34 QString Platform::icon(const QString &name)
35 {
36     QString iconName = QString(DORIAN_ICON_PREFIX) + name + ".png";
37     if (QFile(iconName).exists()) {
38         return iconName;
39     } else {
40         return QString(":/icons/") + name + ".png";
41     }
42 }
43
44 void Platform::restart(char *argv[])
45 {
46 #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
47     extern char **environ;
48     execve(argv[0], argv, environ);
49 #else
50     Q_UNUSED(argv);
51 #endif
52 }
53
54 QString Platform::version()
55 {
56     return QString(DORIAN_VERSION);
57 }
58
59 QString Platform::downloadDir()
60 {
61     return QDir::home().absoluteFilePath("Books");
62 }
63
64 QString Platform::defaultFont()
65 {
66 #if defined(Q_WS_MAEMO_5) || defined(Q_WS_X11)
67     return QString("Serif");
68 #elif defined(Q_WS_MAC)
69     return QString("Hoefler Text");
70 #elif defined Q_WS_S60
71     return QString("Nokia Sans S60");
72 #else
73     return QString("Times New Roman");
74 #endif
75 }