forked from easymodo/qimgv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
executable file
·86 lines (73 loc) · 2.48 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <QApplication>
#include "appversion.h"
#include "settings.h"
#include "components/actionmanager/actionmanager.h"
#include "utils/inputmap.h"
#include "utils/actions.h"
#include "utils/helprunner.h"
#include "sharedresources.h"
#include "core.h"
void saveSettings() {
delete settings;
}
//------------------------------------------------------------------------------
QDataStream& operator<<(QDataStream& out, const Script& v) {
out << v.command << v.blocking;
return out;
}
//------------------------------------------------------------------------------
QDataStream& operator>>(QDataStream& in, Script& v) {
in >> v.command;
in >> v.blocking;
return in;
}
int main(int argc, char *argv[]) {
// I'm not sure what this does but "1" breaks the UI
// Huge widgets but tiny fonts
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR","0");
// for testing purposes
//qputenv("QT_SCALE_FACTOR","2.0");
//qputenv("QT_SCREEN_SCALE_FACTORS", "1;1.7");
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication a(argc, argv);
QCoreApplication::setOrganizationName("greenpepper software");
QCoreApplication::setOrganizationDomain("github.com/easymodo/qimgv");
QCoreApplication::setApplicationName("qimgv");
QCoreApplication::setApplicationVersion(appVersion.normalized().toString());
// get arguments
QString arg1;
if(a.arguments().length() > 1) {
arg1 = a.arguments().at(1);
}
// output help text & shutdown
if(arg1 == "-h" || arg1 == "--help") {
HelpRunner r;
QTimer::singleShot(0, &r, SLOT(run()));
return a.exec();
}
// init
// needed for mpv
#ifndef _MSC_VER
std::setlocale(LC_NUMERIC, "C");
#endif
qRegisterMetaTypeStreamOperators<Script>("Script");
inputMap = InputMap::getInstance();
appActions = Actions::getInstance();
settings = Settings::getInstance();
scriptManager = ScriptManager::getInstance();
actionManager = ActionManager::getInstance();
shrRes = SharedResources::getInstance();
atexit(saveSettings);
QFile file(":/res/styles/dark.qss");
if(file.open(QFile::ReadOnly)) {
QString StyleSheet = QLatin1String(file.readAll());
qApp->setStyleSheet(StyleSheet);
}
Core core;
core.showGui();
// assume 1st arg is the filename
if(!arg1.isEmpty()) {
core.loadByPathBlocking(arg1);
}
return a.exec();
}