Just Intonation  Version 1.3.1 (19)
Explore key-independent dynamically adapting tuning in just intonation
main.cpp
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2016-2017 Karolin Stange, Christoph Wick, and Haye Hinrichsen
3  *
4  * This file is part of JustIntonation.
5  *
6  * JustIntonation is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * JustIntonation is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with JustIntonation. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
19 
20 //=============================================================================
21 // JustIntonation
22 // Main application file
23 //=============================================================================
24 
25 #include <QApplication>
26 #include <QQmlApplicationEngine>
27 #include <QLoggingCategory>
28 
29 #include "config.h"
30 #include "system/runguard.h"
31 #include "system/downloader.h"
32 #include "system/systemtools.h"
33 #include "system/filehandler.h"
34 #include "application.h"
35 
36 
37 int main(int argc, char *argv[])
38 {
39  // Assign Main thread name for debugging
40  SystemTools::setThreadName("MainThread");
41 
42  // Suppress warning "qt.network.ssl: Error receiving trust for a CA certificate"
43  // This warning is caused by the assumption that the download page is https,
44  // but actually it is non-encrypted
45  QLoggingCategory::setFilterRules(QStringLiteral("qt.network.ssl=false"));
46 
47  while (true)
48  {
49  // Create the application
50  QApplication app(argc, argv);
51 
52  // If another instance is already running show a message box and quit:
53  #if defined(INT_INCLUDE_RUNGUARD)
54  RunGuard runguard (INT_APPLICATIONNAME);
55  if (runguard.anotherInstanceIsRunning()) return 0;
56  #endif
57 
58  // Register map key->cents for tuning corrections
59  qRegisterMetaType<QMap<int,double>>();
60 
61  // Specify unique identifiers, needed for QSettings
62  app.setOrganizationName(INT_ORGANIZATIONNAME);
63  app.setOrganizationDomain(INT_ORGANIZATIONDOMAIN);
64  app.setApplicationName(INT_APPLICATIONNAME);
65 
66  // Create an instance of the Application class
67  Application justintonation(app);
68  justintonation.installTranslations();
69 
70  // Create, load and init the Qml application engine
71  QQmlApplicationEngine engine;
72  engine.load(QUrl(QStringLiteral("qrc:/Main.qml")));
73  if (engine.rootObjects().empty())
74  {
75  qDebug() << "ERROR: main.cpp: Could not load Qml objects, exiting.\n";
76  return 0;
77  }
78 
79  // execute the application
80  justintonation.init(engine);
81  justintonation.start();
82  int result = app.exec();
83 
84  // shut down and exit
85  justintonation.stop();
86  justintonation.exit();
87  if (not justintonation.restartRequested()) return result;
88  }
89 }
void stop()
Stop the application and its components.
void setThreadName(QString threadname)
Helper function for debugging: set the current thread name.
Definition: systemtools.cpp:64
void init(QQmlApplicationEngine &engine)
Initialization of the application.
void start()
Start the application and its components.
#define INT_APPLICATIONNAME
Definition: config.h:31
void exit()
Exit from the application and all its components.
bool restartRequested()
Definition: application.h:74
Class for checking whether the application is already running.
Definition: runguard.h:52
#define INT_ORGANIZATIONNAME
Definition: config.h:32
bool anotherInstanceIsRunning(bool showMessage=true)
Check whether another instance of the application is running.
Definition: runguard.cpp:148
void installTranslations()
Install existing translations.
Main application.
Definition: application.h:60
#define INT_ORGANIZATIONDOMAIN
Definition: config.h:33
int main(int argc, char *argv[])
Definition: main.cpp:37