2007-12-01 10:47:15 +00:00
|
|
|
/*
|
2019-01-13 16:56:12 +00:00
|
|
|
Copyright 2006-2019 The QElectroTech Team
|
2007-12-01 10:47:15 +00:00
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2007-09-21 13:22:18 +00:00
|
|
|
#include "qetapp.h"
|
2018-08-15 12:45:55 +00:00
|
|
|
#include "singleapplication.h"
|
|
|
|
#include "qet.h"
|
2019-04-10 18:11:24 +00:00
|
|
|
#include "macosxopenevent.h"
|
2019-08-29 13:12:00 +02:00
|
|
|
#include <QStyleFactory>
|
2015-09-16 15:11:13 +00:00
|
|
|
|
2006-10-27 15:47:22 +00:00
|
|
|
/**
|
2015-09-16 15:11:13 +00:00
|
|
|
* @brief main
|
|
|
|
* Main function of QElectroTech
|
|
|
|
* @param argc : number of paramètres
|
|
|
|
* @param argv : paramètres
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
//Some setup, notably to use with QSetting.
|
|
|
|
QCoreApplication::setOrganizationName("QElectroTech");
|
|
|
|
QCoreApplication::setOrganizationDomain("qelectrotech.org");
|
|
|
|
QCoreApplication::setApplicationName("QElectroTech");
|
|
|
|
//Creation and execution of the application
|
2019-12-14 12:10:11 +01:00
|
|
|
|
2019-01-20 13:01:44 +00:00
|
|
|
SingleApplication app(argc, argv, true);
|
2019-04-04 19:27:24 +00:00
|
|
|
#ifdef Q_OS_MACOS
|
|
|
|
//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
|
|
|
|
MacOSXOpenEvent open_event;
|
2019-04-10 18:11:24 +00:00
|
|
|
app.installEventFilter(&open_event);
|
2019-08-29 13:12:00 +02:00
|
|
|
app.setStyle(QStyleFactory::create("Fusion"));
|
2019-04-04 19:27:24 +00:00
|
|
|
#endif
|
2018-08-15 12:45:55 +00:00
|
|
|
|
|
|
|
if (app.isSecondary())
|
|
|
|
{
|
2019-01-21 17:23:00 +00:00
|
|
|
QStringList arg_list = app.arguments();
|
2018-08-15 12:45:55 +00:00
|
|
|
//Remove the first argument, it's the binary file
|
2019-01-21 17:23:00 +00:00
|
|
|
arg_list.takeFirst();
|
|
|
|
QETArguments qetarg(arg_list);
|
|
|
|
QString message = "launched-with-args: " + QET::joinWithSpaces(QStringList(qetarg.arguments()));
|
2018-08-15 12:45:55 +00:00
|
|
|
app.sendMessage(message.toUtf8());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
QETApp qetapp;
|
2018-08-16 22:49:08 +00:00
|
|
|
QETApp::instance()->installEventFilter(&qetapp);
|
2018-08-15 12:45:55 +00:00
|
|
|
QObject::connect(&app, &SingleApplication::receivedMessage, &qetapp, &QETApp::receiveMessage);
|
|
|
|
|
|
|
|
return app.exec();
|
2006-10-27 15:47:22 +00:00
|
|
|
}
|
2019-04-04 19:27:24 +00:00
|
|
|
|