5 #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
11 # include <eikappui.h>
13 # include <aknappui.h>
19 #if defined(Q_OS_WIN32) || defined(Q_OS_SYMBIAN)
20 # define DORIAN_BASE "dorian"
22 # define DORIAN_BASE ".dorian"
26 # define DORIAN_ICON_PREFIX ":/icons/mac/"
27 #elif defined(Q_OS_SYMBIAN)
28 # define DORIAN_ICON_PREFIX ":/icons/symbian/"
29 #elif defined(Q_WS_MAEMO_5)
30 # define DORIAN_ICON_PREFIX ":/icons/maemo/"
32 # define DORIAN_ICON_PREFIX ":/icons/"
35 static const char *DORIAN_VERSION =
36 #include "pkg/version.txt"
39 #define DORIAN_LOG "dorian.txt"
42 # include <QtMaemo5/QMaemo5InformationBox>
44 # include <QMessageBox>
47 static Platform *theInstance;
49 Platform *Platform::instance()
52 theInstance = new Platform();
57 void Platform::close()
63 QString Platform::dbPath()
65 QString base(QDir::home().absoluteFilePath(DORIAN_BASE));
66 return QDir(base).absoluteFilePath("books.db");
69 QString Platform::icon(const QString &name, const QString &extension)
71 QString iconName = QString(DORIAN_ICON_PREFIX) + name + extension;
72 if (QFile(iconName).exists()) {
75 return QString(":/icons/") + name + extension;
79 void Platform::restart(char *argv[])
81 #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
82 extern char **environ;
83 execve(argv[0], argv, environ);
89 QString Platform::version()
91 return QString(DORIAN_VERSION);
94 QString Platform::downloadDir()
97 if (QDir("E:/").exists()) {
102 return QDir::home().absoluteFilePath("Books");
106 QString Platform::defaultFont()
108 #if defined(Q_WS_MAEMO_5) || defined(Q_WS_X11)
109 return QString("Serif");
110 #elif defined(Q_WS_MAC)
111 return QString("Hoefler Text");
112 #elif defined Q_WS_S60
113 return QString("Nokia Sans S60");
115 return QString("Times New Roman");
119 void Platform::information(const QString &label, QWidget *parent)
122 QMaemo5InformationBox::information(parent, label,
123 QMaemo5InformationBox::DefaultTimeout);
125 (void)QMessageBox::information(parent, QObject::tr("Dorian"), label,
130 void Platform::showBusy(QWidget *w, bool isBusy)
133 w->setAttribute(Qt::WA_Maemo5ShowProgressIndicator, isBusy);
140 QString Platform::traceFileName()
142 return QDir::home().absoluteFilePath(DORIAN_LOG);
145 int Platform::defaultZoom()
150 QString Platform::defaultOrientation()
153 return QString("portrait");
155 return QString("landscape");
159 void Platform::setOrientation(QWidget *widget, const QString &orientation)
162 qDebug() << "To" << orientation;
166 #if defined(Q_OS_SYMBIAN)
167 CAknAppUi *appUi = dynamic_cast<CAknAppUi *>(CEikonEnv::Static()->AppUi());
169 qCritical() << "Platform::setOrientation: Couldn't get AppUi pointer";
174 if (orientation == "portrait") {
175 #if defined(Q_WS_MAEMO_5)
176 widget->setAttribute(Qt::WA_Maemo5LandscapeOrientation, false);
177 widget->setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
178 #elif defined(Q_OS_SYMBIAN)
180 appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait););
183 #if defined(Q_WS_MAEMO_5)
184 widget->setAttribute(Qt::WA_Maemo5PortraitOrientation, false);
185 widget->setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);
186 #elif defined(Q_OS_SYMBIAN)
188 appUi->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape););
193 int Platform::softKeyHeight()
195 #if defined(Q_OS_SYMBIAN)
202 int Platform::toolBarIconHeight()
204 #if defined(Q_OS_SYMBIAN)
206 #elif defined(Q_WS_X11) && !defined(Q_WS_MAEMO_5)
213 QSize Platform::size()
215 return QApplication::desktop()->geometry().size();
218 QSize Platform::availableSize()
220 QSize s = QApplication::desktop()->availableGeometry().size();
221 #if defined(Q_OS_SYMBIAN)
222 // Work around a Qt bug on Symbian which sometimes forgets to reduce the
223 // available height by the soft key area height
224 if (s.height() == 548) {
225 s.setHeight(s.height() - softKeyHeight());