-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
74 lines (63 loc) · 1.97 KB
/
main.cpp
File metadata and controls
74 lines (63 loc) · 1.97 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
#include "mainwindow.h"
#include <QApplication>
#include <QCommandLineParser>
#include <QSettings>
#include <QMessageBox>
#include <QDebug>
#include "toolfactory.h"
#include "nativeeventfilter.h"
#include "deviceselectdialog.h"
#include "batchprocessor.h"
#ifdef Q_OS_MAC
#include "machelpers.h"
#endif
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
a.setAttribute(Qt::AA_UseDesktopOpenGL, true);
#endif
a.setApplicationName("TileShadow");
a.setApplicationDisplayName("TileShadow");
a.setOrganizationName("TileShadow");
a.setOrganizationDomain("danielsabo.bitbucket.org");
#ifdef Q_OS_MAC
QSettings::setDefaultFormat(QSettings::NativeFormat);
PlatformHelpers::macDisableAutoTabBar();
#else
QSettings::setDefaultFormat(QSettings::IniFormat);
#endif
QSettings appSettings;
//FIXME: Remove this old setting
appSettings.remove("EnableGLSharing");
ToolFactory::initializeUserPaths();
QCommandLineParser parser;
QCommandLineOption batchFile("batch", "Command file to execute", "batchfile");
parser.addOption(batchFile);
parser.process(a);
QString batchFilePath = parser.value(batchFile);
std::unique_ptr<MainWindow> w;
if (!batchFilePath.isEmpty())
{
BatchProcessor *batch = new BatchProcessor();
QMetaObject::invokeMethod(batch, "execute", Qt::QueuedConnection, Q_ARG(QString, batchFilePath));
}
else
{
bool deviceValid = false;
appSettings.value("OpenCL/Device").toString().toInt(&deviceValid);
if ((!deviceValid) ||
(a.queryKeyboardModifiers() & Qt::ShiftModifier))
{
DeviceSelectDialog().exec();
}
w.reset(new MainWindow());
w->show();
if (!parser.positionalArguments().empty())
w->openFileRequest(parser.positionalArguments().at(0));
}
#ifdef USE_NATIVE_EVENT_FILTER
NativeEventFilter::install(&a);
#endif
return a.exec();
}