-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
53 lines (47 loc) · 1.29 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
// SPDX-License-Identifier: GPL-2.0
#include "globals.hpp"
#include "mainwindow.hpp"
#include <QApplication>
#include <QDate>
#include <QSettings>
#include <iostream>
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(xfft);
QApplication app(argc, argv);
QCoreApplication::setApplicationName("xfft");
QCoreApplication::setOrganizationName("TU Wien");
QCoreApplication::setOrganizationDomain("crystallography.at");
QCoreApplication::setApplicationVersion(QT_VERSION_STR);
// Parse options until we reach the first "--", which means that only filenames follow.
QStringList args = QCoreApplication::arguments();
args.removeFirst();
std::vector<QString> filenames;
bool no_options = false;
for (const QString &arg: qAsConst(args)) {
if (arg.isEmpty())
continue;
if (!no_options && arg[0] == '-') {
if (arg == "-debug")
Globals::debug_mode = true;
else if (arg == "--")
no_options = true;
else
std::cerr << "Unknown option: " << arg.toStdString();
} else {
filenames.push_back(arg);
}
}
if (filenames.empty()) {
// Open a window with default settings
MainWindow *w = new MainWindow(nullptr);
w->show();
} else {
for (const QString &filename: filenames) {
MainWindow *w = new MainWindow(nullptr);
w->open(filename);
w->show();
}
}
return app.exec();
}