QElectroTech  0.70
main.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech 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 2 of the License, or
8  (at your option) any later version.
9 
10  QElectroTech 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 QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #include "qetapp.h"
19 #include "singleapplication.h"
20 #include "qet.h"
21 #include "macosxopenevent.h"
22 
30 int main(int argc, char **argv)
31 {
32  //Some setup, notably to use with QSetting.
33  QCoreApplication::setOrganizationName("QElectroTech");
34  QCoreApplication::setOrganizationDomain("qelectrotech.org");
35  QCoreApplication::setApplicationName("QElectroTech");
36  //Creation and execution of the application
37  //HighDPI
38 #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
39  QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
40 #else
41  qputenv("QT_DEVICE_PIXEL_RATIO", QByteArray("auto"));
42 #endif
43 
44  SingleApplication app(argc, argv, true);
45 #ifdef Q_OS_MACOS
46  //Handle the opening of QET when user double click on a .qet .elmt .tbt file
47  //or drop these same files to the QET icon of the dock
48  MacOSXOpenEvent open_event;
49  app.installEventFilter(&open_event);
50 #endif
51 
52  if (app.isSecondary())
53  {
54  QStringList arg_list = app.arguments();
55  //Remove the first argument, it's the binary file
56  arg_list.takeFirst();
57  QETArguments qetarg(arg_list);
58  QString message = "launched-with-args: " + QET::joinWithSpaces(QStringList(qetarg.arguments()));
59  app.sendMessage(message.toUtf8());
60  return 0;
61  }
62 
63  QETApp qetapp;
64  QETApp::instance()->installEventFilter(&qetapp);
65  QObject::connect(&app, &SingleApplication::receivedMessage, &qetapp, &QETApp::receiveMessage);
66 
67  return app.exec();
68 }
69 
int main(int argc, char **argv)
main Main function of QElectroTech
Definition: main.cpp:30
QString joinWithSpaces(const QStringList &)
Definition: qet.cpp:417
virtual QList< QString > arguments() const
void receiveMessage(int instanceId, QByteArray message)
Definition: qetapp.cpp:1124
Definition: qetapp.h:53
static QETApp * instance()
Definition: qetapp.cpp:143