Motiv
Marvelous OTF2 Traces Interactive Visualizer
Loading...
Searching...
No Matches
main.cpp
1/*
2 * Marvelous OTF2 Traces Interactive Visualizer (MOTIV)
3 * Copyright (C) 2023 Florian Gallrein, Björn Gehrke
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18#include <QApplication>
19#include <QCommandLineParser>
20#include <QFile>
21#include <QIODeviceBase>
22
23#include "src/ui/windows/MainWindow.hpp"
24#include "src/ui/windows/RecentFilesDialog.hpp"
25
26int main(int argc, char *argv[])
27{
28 QApplication app(argc, argv);
29 QApplication::setApplicationName("Motiv");
30 QApplication::setApplicationVersion(MOTIV_VERSION_STRING);
31 QApplication::setWindowIcon(QIcon(":/res/motiv.png"));
32
33 // Load an application style
34 QFile styleFile( ":/res/style.qss" );
35 styleFile.open( QFile::ReadOnly );
36
37 // Apply the loaded stylesheet
38 QString style( styleFile.readAll() );
39 app.setStyleSheet( style );
40
41 QCommandLineParser parser;
42 parser.setApplicationDescription("Visualizer for OTF2 trace files");
43
44 QCommandLineOption helpOption = parser.addHelpOption();
45 QCommandLineOption versionOption = parser.addVersionOption();
46 parser.addPositionalArgument("file", QCoreApplication::translate("main", "filepath of the .otf2 trace file to open"), "[file]");
47 parser.process(app);
48
49 // Early return if help or version is shown
50 if (parser.isSet(helpOption) || parser.isSet(versionOption)) {
51 return EXIT_SUCCESS;
52 }
53
54 QStringList positionalArguments = parser.positionalArguments();
55 QString filepath;
56 if (!positionalArguments.isEmpty()) {
57 filepath = positionalArguments.first();
58 }
59
60 RecentFilesDialog recentFilesDialog(&filepath);
61 if(!filepath.isEmpty() || recentFilesDialog.exec() == QDialog::Accepted) {
62 auto mainWindow = new MainWindow(filepath);
63 mainWindow->show();
64 } else {
65 app.quit();
66 return EXIT_SUCCESS;
67 }
68
69 return app.exec();
70}
The main window of the application.
Definition: MainWindow.hpp:38
A dialog that displays an open button and previously opened trace files.