-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
executable file
·62 lines (49 loc) · 1.72 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifdef QT_QML_DEBUG
#include <QtQuick>
#endif
#include <QScopedPointer>
#include <QQuickView>
#include <QQmlEngine>
#include <QGuiApplication>
#include <QQmlContext>
#include <QtQml>
#include <QDebug>
#include <sailfishapp.h>
/**
* Clears the web cache, because Qt 5.2 WebView chokes on caches from older Qt versions.
*/
void clearWebCache() {
const QStringList cachePaths = QStandardPaths::standardLocations(
QStandardPaths::CacheLocation);
if (cachePaths.size()) {
// some very old versions of SailfishOS may not find this cache,
// but that's OK since they don't have the web cache bug anyway
const QString webCache = QDir(cachePaths.at(0)).filePath(".QtWebKit");
QDir cacheDir(webCache);
if (cacheDir.exists()) {
if (cacheDir.removeRecursively()) {
qDebug() << "Cleared web cache:" << webCache;
} else {
qDebug() << "Failed to clear web cache:" << webCache;
}
} else {
qDebug() << "Web cache does not exist:" << webCache;
}
} else {
qDebug() << "No web cache available.";
}
}
int main(int argc, char *argv[])
{
QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));
clearWebCache();
QScopedPointer<QQuickView> view(SailfishApp::createView());
app->setApplicationName("harbour-haikala");
app->setOrganizationName("harbour-haikala");
app->setApplicationVersion(APP_VERSION);
view->rootContext()->setContextProperty("APP_VERSION", APP_VERSION);
view->rootContext()->setContextProperty("APP_RELEASE", APP_RELEASE);
view->setSource(SailfishApp::pathTo("qml/main.qml"));
view->show();
return app->exec();
}