-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkapp.cpp
More file actions
82 lines (64 loc) · 1.94 KB
/
kapp.cpp
File metadata and controls
82 lines (64 loc) · 1.94 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "kapp.h"
#include "kclient.h"
#include "kserver.h"
#include "khotkey.h"
#include "kdocument.h"
#include "config.h"
#include "klog.h"
#include "version.h"
#include <QDesktopServices>
#include <QDir>
KApp::KApp(int argc, char *argv[]) :
QApplication(argc, argv)
{
setOrganizationName(APP_ORG);
setApplicationName(APP_NAME);
setQuitOnLastWindowClosed(false);
qDebug(qPrintable(QDesktopServices::storageLocation(QDesktopServices::DataLocation)));
QDir(QDesktopServices::storageLocation(QDesktopServices::DataLocation)).mkdir("widgets");
QDir(QDesktopServices::storageLocation(QDesktopServices::DataLocation)).mkdir("temp");
addLibraryPath(applicationDirPath() + "/plugins");
}
bool KApp::startClient(const QString &path)
{
return KClient::instance()->initialize(path);
}
bool KApp::startServer()
{
return KServer::instance()->initialize();
}
#if !defined(WIN32)
bool KApp::startHotKeyListener()
{
HotKey hotKey;
QString enginePreferencesFile(QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/" + ENGINE_CONFIG_FILE);
KDocument *doc = new KDocument;
if (doc->openDocument(enginePreferencesFile))
{
hotKey.registerHotKey(doc->getValue("general/hotKey", ""));
}
delete doc;
KLog::log("HotKeyListener::started");
hotKey.run();
return true;
}
#endif
QString KApp::userAgent()
{
QString platform = "(Windows)";
#if !defined(WIN32)
platform = "(Linux)";
#endif
return QString(KLUDGET_MOZ_VERSION) + " "
+ platform + " "
+ KLUDGET_QT_VERSION + " "
+ KLUDGET_NAME + "/" + version();
}
QString KApp::version()
{
return QString(KLUDGET_MAJOR_VERSION) + "." + KLUDGET_MINOR_VERSION;
}
QString KApp::temporaryDirPath()
{
return QDir(QDesktopServices::storageLocation(QDesktopServices::DataLocation)).absolutePath() + "/temp";
}