Mod documentation + wrap code for better readability

This commit is contained in:
Simon De Backer
2020-07-16 22:09:59 +02:00
parent 26fd1a497c
commit d3b237d06c

View File

@@ -22,29 +22,31 @@
#include <QStyleFactory> #include <QStyleFactory>
/** /**
* @brief main @brief main
* Main function of QElectroTech Main function of QElectroTech
* @param argc : number of paramètres @param argc : number of parameters
* @param argv : paramètres \~French number of paramètres
* @return \~ @param argv : parameters
*/ \~French paramètres
\~ @return exit code
*/
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
//Some setup, notably to use with QSetting. //Some setup, notably to use with QSetting.
QCoreApplication::setOrganizationName("QElectroTech"); QCoreApplication::setOrganizationName("QElectroTech");
QCoreApplication::setOrganizationDomain("qelectrotech.org"); QCoreApplication::setOrganizationDomain("qelectrotech.org");
QCoreApplication::setApplicationName("QElectroTech"); QCoreApplication::setApplicationName("QElectroTech");
//Creation and execution of the application //Creation and execution of the application
//HighDPI //HighDPI
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#else #else
qputenv("QT_DEVICE_PIXEL_RATIO", QByteArray("auto")); qputenv("QT_DEVICE_PIXEL_RATIO", QByteArray("auto"));
#endif #endif
SingleApplication app(argc, argv, true); SingleApplication app(argc, argv, true);
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
//Handle the opening of QET when user double click on a .qet .elmt .tbt file //Handle the opening of QET when user double click on a .qet .elmt .tbt file
//or drop these same files to the QET icon of the dock //or drop these same files to the QET icon of the dock
MacOSXOpenEvent open_event; MacOSXOpenEvent open_event;
app.installEventFilter(&open_event); app.installEventFilter(&open_event);
app.setStyle(QStyleFactory::create("Fusion")); app.setStyle(QStyleFactory::create("Fusion"));
@@ -53,17 +55,19 @@ int main(int argc, char **argv)
if (app.isSecondary()) if (app.isSecondary())
{ {
QStringList arg_list = app.arguments(); QStringList arg_list = app.arguments();
//Remove the first argument, it's the binary file //Remove the first argument, it's the binary file
arg_list.takeFirst(); arg_list.takeFirst();
QETArguments qetarg(arg_list); QETArguments qetarg(arg_list);
QString message = "launched-with-args: " + QET::joinWithSpaces(QStringList(qetarg.arguments())); QString message = "launched-with-args: " + QET::joinWithSpaces(
QStringList(qetarg.arguments()));
app.sendMessage(message.toUtf8()); app.sendMessage(message.toUtf8());
return 0; return 0;
} }
QETApp qetapp; QETApp qetapp;
QETApp::instance()->installEventFilter(&qetapp); QETApp::instance()->installEventFilter(&qetapp);
QObject::connect(&app, &SingleApplication::receivedMessage, &qetapp, &QETApp::receiveMessage); QObject::connect(&app, &SingleApplication::receivedMessage,
&qetapp, &QETApp::receiveMessage);
return app.exec(); return app.exec();
} }