2015-07-10 13:14:55 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file mapplication.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 8 7, 2015
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2015 Valentina project
|
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
|
|
**
|
|
|
|
** Valentina 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 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina 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 Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#include "mapplication.h"
|
|
|
|
#include "version.h"
|
|
|
|
#include "tmainwindow.h"
|
2015-09-19 22:08:03 +02:00
|
|
|
#include "../ifc/exception/vexceptionobjecterror.h"
|
|
|
|
#include "../ifc/exception/vexceptionbadid.h"
|
|
|
|
#include "../ifc/exception/vexceptionconversionerror.h"
|
|
|
|
#include "../ifc/exception/vexceptionemptyparameter.h"
|
|
|
|
#include "../ifc/exception/vexceptionwrongid.h"
|
|
|
|
#include "../vmisc/logging.h"
|
2015-09-28 20:54:41 +02:00
|
|
|
#include "../vmisc/vsysexits.h"
|
2016-08-06 20:42:40 +02:00
|
|
|
#include "../vmisc/diagnostic.h"
|
2015-09-19 22:08:03 +02:00
|
|
|
#include "../qmuparser/qmuparsererror.h"
|
2015-07-10 13:14:55 +02:00
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
#include <QDir>
|
2015-07-10 13:14:55 +02:00
|
|
|
#include <QFileOpenEvent>
|
|
|
|
#include <QLocalSocket>
|
2015-08-01 11:39:32 +02:00
|
|
|
#include <QResource>
|
2015-07-15 09:16:59 +02:00
|
|
|
#include <QTranslator>
|
2015-08-01 15:56:37 +02:00
|
|
|
#include <QPointer>
|
2015-08-29 11:48:03 +02:00
|
|
|
#include <QLocalServer>
|
2015-09-15 20:21:51 +02:00
|
|
|
#include <QMessageBox>
|
|
|
|
#include <iostream>
|
2015-10-01 16:59:01 +02:00
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QSpacerItem>
|
2015-10-18 21:30:51 +02:00
|
|
|
#include <QThread>
|
2015-07-10 13:14:55 +02:00
|
|
|
|
2016-08-06 20:42:40 +02:00
|
|
|
QT_WARNING_PUSH
|
|
|
|
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
|
|
|
|
QT_WARNING_DISABLE_INTEL(1418)
|
2015-10-19 15:21:06 +02:00
|
|
|
|
2015-09-19 22:08:03 +02:00
|
|
|
Q_LOGGING_CATEGORY(mApp, "m.application")
|
|
|
|
|
2016-08-06 20:42:40 +02:00
|
|
|
QT_WARNING_POP
|
2015-10-19 15:21:06 +02:00
|
|
|
|
2015-08-20 12:56:55 +02:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
2015-10-08 20:11:50 +02:00
|
|
|
# include "../vmisc/backport/qcommandlineparser.h"
|
2015-08-20 12:56:55 +02:00
|
|
|
#else
|
|
|
|
# include <QCommandLineParser>
|
|
|
|
#endif
|
|
|
|
|
2015-09-15 20:21:51 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
|
|
|
{
|
|
|
|
Q_UNUSED(context)
|
|
|
|
|
|
|
|
// Why on earth didn't Qt want to make failed signal/slot connections qWarning?
|
2016-07-20 10:25:53 +02:00
|
|
|
if ((type == QtDebugMsg) && msg.contains(QStringLiteral("::connect")))
|
2015-09-15 20:21:51 +02:00
|
|
|
{
|
|
|
|
type = QtWarningMsg;
|
|
|
|
}
|
|
|
|
|
2016-08-03 13:54:18 +02:00
|
|
|
#if defined(V_NO_ASSERT)
|
2016-05-24 12:06:51 +02:00
|
|
|
// I have decided to hide this annoing message for release builds.
|
2016-08-03 13:54:18 +02:00
|
|
|
if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QSslSocket: cannot resolve")))
|
|
|
|
{
|
|
|
|
type = QtDebugMsg;
|
|
|
|
}
|
|
|
|
|
2016-07-20 10:25:53 +02:00
|
|
|
if ((type == QtWarningMsg) && msg.contains(QStringLiteral("setGeometry: Unable to set geometry")))
|
2016-05-24 12:06:51 +02:00
|
|
|
{
|
|
|
|
type = QtDebugMsg;
|
|
|
|
}
|
2016-08-03 13:54:18 +02:00
|
|
|
#endif //defined(V_NO_ASSERT)
|
2016-05-24 12:06:51 +02:00
|
|
|
|
2015-11-18 13:54:53 +01:00
|
|
|
#if defined(Q_OS_MAC)
|
2016-05-04 15:40:15 +02:00
|
|
|
# if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) && QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
|
|
|
|
// Try hide very annoying, Qt related, warnings in Mac OS X
|
|
|
|
// QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
|
|
|
|
// https://bugreports.qt.io/browse/QTBUG-42846
|
2016-07-20 10:25:53 +02:00
|
|
|
if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QNSView")))
|
2016-05-04 15:40:15 +02:00
|
|
|
{
|
|
|
|
type = QtDebugMsg;
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
|
|
|
|
// Hide Qt bug 'Assertion when reading an icns file'
|
|
|
|
// https://bugreports.qt.io/browse/QTBUG-45537
|
2015-11-18 13:54:53 +01:00
|
|
|
// Remove after Qt fix will be released
|
2016-07-20 10:25:53 +02:00
|
|
|
if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QICNSHandler::read()")))
|
2015-11-18 13:54:53 +01:00
|
|
|
{
|
|
|
|
type = QtDebugMsg;
|
2016-09-20 20:12:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// See issue #568
|
2016-09-20 20:33:33 +02:00
|
|
|
if (msg.contains(QStringLiteral("Error receiving trust for a CA certificate")))
|
2016-09-20 20:12:19 +02:00
|
|
|
{
|
|
|
|
type = QtDebugMsg;
|
2015-11-18 13:54:53 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-09-15 20:21:51 +02:00
|
|
|
// this is another one that doesn't make sense as just a debug message. pretty serious
|
|
|
|
// sign of a problem
|
|
|
|
// http://www.developer.nokia.com/Community/Wiki/QPainter::begin:Paint_device_returned_engine_%3D%3D_0_(Known_Issue)
|
2016-07-20 10:25:53 +02:00
|
|
|
if ((type == QtDebugMsg) && msg.contains(QStringLiteral("QPainter::begin"))
|
|
|
|
&& msg.contains(QStringLiteral("Paint device returned engine")))
|
2015-09-15 20:21:51 +02:00
|
|
|
{
|
|
|
|
type = QtWarningMsg;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This qWarning about "Cowardly refusing to send clipboard message to hung application..."
|
|
|
|
// is something that can easily happen if you are debugging and the application is paused.
|
|
|
|
// As it is so common, not worth popping up a dialog.
|
2016-07-20 10:25:53 +02:00
|
|
|
if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QClipboard::event"))
|
|
|
|
&& msg.contains(QStringLiteral("Cowardly refusing")))
|
2015-09-15 20:21:51 +02:00
|
|
|
{
|
|
|
|
type = QtDebugMsg;
|
|
|
|
}
|
|
|
|
|
|
|
|
// only the GUI thread should display message boxes. If you are
|
|
|
|
// writing a multithreaded application and the error happens on
|
|
|
|
// a non-GUI thread, you'll have to queue the message to the GUI
|
|
|
|
QCoreApplication *instance = QCoreApplication::instance();
|
|
|
|
const bool isGuiThread = instance && (QThread::currentThread() == instance->thread());
|
|
|
|
|
2015-09-28 20:54:41 +02:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case QtDebugMsg:
|
2015-10-01 16:59:01 +02:00
|
|
|
vStdOut() << QApplication::translate("mNoisyHandler", "DEBUG:") << msg << "\n";
|
2015-09-28 20:54:41 +02:00
|
|
|
return;
|
|
|
|
case QtWarningMsg:
|
2015-10-01 16:59:01 +02:00
|
|
|
vStdErr() << QApplication::translate("mNoisyHandler", "WARNING:") << msg << "\n";
|
|
|
|
break;
|
2015-09-28 20:54:41 +02:00
|
|
|
case QtCriticalMsg:
|
2015-10-01 16:59:01 +02:00
|
|
|
vStdErr() << QApplication::translate("mNoisyHandler", "CRITICAL:") << msg << "\n";
|
|
|
|
break;
|
2015-09-28 20:54:41 +02:00
|
|
|
case QtFatalMsg:
|
2015-10-01 16:59:01 +02:00
|
|
|
vStdErr() << QApplication::translate("mNoisyHandler", "FATAL:") << msg << "\n";
|
2015-09-28 20:54:41 +02:00
|
|
|
break;
|
2015-10-01 16:59:01 +02:00
|
|
|
#if QT_VERSION > QT_VERSION_CHECK(5, 4, 2)
|
|
|
|
case QtInfoMsg:
|
|
|
|
vStdOut() << QApplication::translate("mNoisyHandler", "INFO:") << msg << "\n";
|
|
|
|
break;
|
|
|
|
#endif
|
2015-09-28 20:54:41 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-09-15 20:21:51 +02:00
|
|
|
if (isGuiThread)
|
|
|
|
{
|
|
|
|
//fixme: trying to make sure there are no save/load dialogs are opened, because error message during them will
|
|
|
|
//lead to crash
|
2017-03-23 09:25:46 +01:00
|
|
|
const bool topWinAllowsPop = (QApplication::activeModalWidget() == nullptr) ||
|
|
|
|
!QApplication::activeModalWidget()->inherits("QFileDialog");
|
2015-09-15 20:21:51 +02:00
|
|
|
QMessageBox messageBox;
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case QtWarningMsg:
|
2016-08-03 13:54:18 +02:00
|
|
|
messageBox.setWindowTitle(QApplication::translate("mNoisyHandler", "Warning"));
|
2015-09-15 20:21:51 +02:00
|
|
|
messageBox.setIcon(QMessageBox::Warning);
|
|
|
|
break;
|
|
|
|
case QtCriticalMsg:
|
2016-08-03 13:54:18 +02:00
|
|
|
messageBox.setWindowTitle(QApplication::translate("mNoisyHandler", "Critical error"));
|
2015-09-15 20:21:51 +02:00
|
|
|
messageBox.setIcon(QMessageBox::Critical);
|
|
|
|
break;
|
|
|
|
case QtFatalMsg:
|
2016-08-03 13:54:18 +02:00
|
|
|
messageBox.setWindowTitle(QApplication::translate("mNoisyHandler", "Fatal error"));
|
2015-09-15 20:21:51 +02:00
|
|
|
messageBox.setIcon(QMessageBox::Critical);
|
|
|
|
break;
|
2015-10-01 16:59:01 +02:00
|
|
|
#if QT_VERSION > QT_VERSION_CHECK(5, 4, 2)
|
|
|
|
case QtInfoMsg:
|
2016-08-03 13:54:18 +02:00
|
|
|
messageBox.setWindowTitle(QApplication::translate("mNoisyHandler", "Information"));
|
2015-10-01 16:59:01 +02:00
|
|
|
messageBox.setIcon(QMessageBox::Information);
|
|
|
|
break;
|
|
|
|
#endif
|
2015-09-28 20:54:41 +02:00
|
|
|
case QtDebugMsg:
|
2015-10-28 15:22:36 +01:00
|
|
|
Q_UNREACHABLE(); //-V501
|
2017-02-22 18:34:29 +01:00
|
|
|
break;
|
2015-09-15 20:21:51 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg)
|
|
|
|
{
|
2015-09-28 12:42:26 +02:00
|
|
|
if (not qApp->IsTestMode())
|
|
|
|
{
|
|
|
|
if (topWinAllowsPop)
|
|
|
|
{
|
2015-10-01 16:59:01 +02:00
|
|
|
messageBox.setText(msg);
|
2015-09-28 12:42:26 +02:00
|
|
|
messageBox.setStandardButtons(QMessageBox::Ok);
|
|
|
|
messageBox.setWindowModality(Qt::ApplicationModal);
|
|
|
|
messageBox.setModal(true);
|
2015-10-01 16:59:01 +02:00
|
|
|
#ifndef QT_NO_CURSOR
|
|
|
|
QApplication::setOverrideCursor(Qt::ArrowCursor);
|
|
|
|
#endif
|
2015-09-28 12:42:26 +02:00
|
|
|
messageBox.exec();
|
2015-10-01 16:59:01 +02:00
|
|
|
#ifndef QT_NO_CURSOR
|
|
|
|
QApplication::restoreOverrideCursor();
|
|
|
|
#endif
|
2015-09-28 12:42:26 +02:00
|
|
|
}
|
|
|
|
}
|
2015-09-15 20:21:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (QtFatalMsg == type)
|
|
|
|
{
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (type != QtDebugMsg)
|
|
|
|
{
|
|
|
|
abort(); // be NOISY unless overridden!
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-10 13:14:55 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
MApplication::MApplication(int &argc, char **argv)
|
2015-07-24 14:06:53 +02:00
|
|
|
:VAbstractApplication(argc, argv),
|
2015-07-10 13:14:55 +02:00
|
|
|
mainWindows(),
|
2015-07-15 09:16:59 +02:00
|
|
|
localServer(nullptr),
|
2015-08-01 15:56:37 +02:00
|
|
|
trVars(nullptr),
|
2015-09-28 12:42:26 +02:00
|
|
|
dataBase(QPointer<DialogMDataBase>()),
|
|
|
|
testMode(false)
|
2015-07-10 13:14:55 +02:00
|
|
|
{
|
|
|
|
setApplicationDisplayName(VER_PRODUCTNAME_STR);
|
|
|
|
setApplicationName(VER_INTERNALNAME_STR);
|
|
|
|
setOrganizationName(VER_COMPANYNAME_STR);
|
|
|
|
setOrganizationDomain(VER_COMPANYDOMAIN_STR);
|
|
|
|
// Setting the Application version
|
|
|
|
setApplicationVersion(APP_VERSION_STR);
|
2016-01-15 17:02:14 +01:00
|
|
|
// We have been running Tape in two different cases.
|
|
|
|
// The first inside own bundle where info.plist is works fine, but the second,
|
|
|
|
// when we run inside Valentina's bundle, require direct setting the icon.
|
2015-07-12 16:19:53 +02:00
|
|
|
setWindowIcon(QIcon(":/tapeicon/64x64/logo.png"));
|
2015-07-10 13:14:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
MApplication::~MApplication()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < mainWindows.size(); ++i)
|
|
|
|
{
|
|
|
|
TMainWindow *window = mainWindows.at(i);
|
|
|
|
delete window;
|
|
|
|
}
|
2015-08-02 17:27:18 +02:00
|
|
|
|
|
|
|
delete trVars;
|
|
|
|
if (not dataBase.isNull())
|
|
|
|
{
|
|
|
|
delete dataBase;
|
|
|
|
}
|
2015-07-10 13:14:55 +02:00
|
|
|
}
|
|
|
|
|
2015-09-19 22:08:03 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief notify Reimplemented from QApplication::notify().
|
|
|
|
* @param receiver receiver.
|
|
|
|
* @param event event.
|
|
|
|
* @return value that is returned from the receiver's event handler.
|
|
|
|
*/
|
|
|
|
// reimplemented from QApplication so we can throw exceptions in slots
|
|
|
|
bool MApplication::notify(QObject *receiver, QEvent *event)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return QApplication::notify(receiver, event);
|
|
|
|
}
|
|
|
|
catch (const VExceptionObjectError &e)
|
|
|
|
{
|
2015-10-28 15:22:36 +01:00
|
|
|
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file. Program will be terminated.")), //-V807
|
2015-10-01 16:59:01 +02:00
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
2015-10-11 11:06:14 +02:00
|
|
|
exit(V_EX_DATAERR);
|
2015-09-19 22:08:03 +02:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2015-10-01 16:59:01 +02:00
|
|
|
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error bad id. Program will be terminated.")),
|
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
2015-10-11 11:06:14 +02:00
|
|
|
exit(V_EX_DATAERR);
|
2015-09-19 22:08:03 +02:00
|
|
|
}
|
|
|
|
catch (const VExceptionConversionError &e)
|
|
|
|
{
|
2015-10-01 16:59:01 +02:00
|
|
|
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error can't convert value. Program will be terminated.")),
|
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
2015-10-11 11:06:14 +02:00
|
|
|
exit(V_EX_DATAERR);
|
2015-09-19 22:08:03 +02:00
|
|
|
}
|
|
|
|
catch (const VExceptionEmptyParameter &e)
|
|
|
|
{
|
2015-10-01 16:59:01 +02:00
|
|
|
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter. Program will be terminated.")),
|
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
2015-10-11 11:06:14 +02:00
|
|
|
exit(V_EX_DATAERR);
|
2015-09-19 22:08:03 +02:00
|
|
|
}
|
|
|
|
catch (const VExceptionWrongId &e)
|
|
|
|
{
|
2015-10-01 16:59:01 +02:00
|
|
|
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id. Program will be terminated.")),
|
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
2015-10-11 11:06:14 +02:00
|
|
|
exit(V_EX_DATAERR);
|
2015-09-19 22:08:03 +02:00
|
|
|
}
|
2015-11-02 17:25:29 +01:00
|
|
|
catch (const VExceptionToolWasDeleted &e)
|
|
|
|
{
|
|
|
|
qCCritical(mApp, "%s\n\n%s\n\n%s",
|
|
|
|
qUtf8Printable("Unhadled deleting tool. Continue use object after deleting!"),
|
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
|
|
|
exit(V_EX_DATAERR);
|
|
|
|
}
|
2015-09-19 22:08:03 +02:00
|
|
|
catch (const VException &e)
|
|
|
|
{
|
2015-10-01 16:59:01 +02:00
|
|
|
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Something's wrong!!")),
|
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
2015-09-19 22:08:03 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// These last two cases special. I found that we can't show here modal dialog with error message.
|
|
|
|
// Somehow program doesn't waite untile an error dialog will be closed. But if ignore this program will hang.
|
|
|
|
catch (const qmu::QmuParserError &e)
|
|
|
|
{
|
2015-10-01 16:59:01 +02:00
|
|
|
qCCritical(mApp, "%s", qUtf8Printable(tr("Parser error: %1. Program will be terminated.").arg(e.GetMsg())));
|
2015-10-11 11:06:14 +02:00
|
|
|
exit(V_EX_DATAERR);
|
2015-09-19 22:08:03 +02:00
|
|
|
}
|
2015-10-01 16:59:01 +02:00
|
|
|
catch (std::exception &e)
|
2015-09-19 22:08:03 +02:00
|
|
|
{
|
2015-10-01 16:59:01 +02:00
|
|
|
qCCritical(mApp, "%s", qUtf8Printable(tr("Exception thrown: %1. Program will be terminated.").arg(e.what())));
|
2015-10-11 11:06:14 +02:00
|
|
|
exit(V_EX_SOFTWARE);
|
2015-09-19 22:08:03 +02:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-09-28 12:42:26 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool MApplication::IsTestMode() const
|
|
|
|
{
|
|
|
|
return testMode;
|
|
|
|
}
|
|
|
|
|
2015-07-10 13:14:55 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-12-22 19:12:09 +01:00
|
|
|
/**
|
|
|
|
* @brief IsAppInGUIMode little hack that allow to have access to application state from VAbstractApplication class.
|
|
|
|
*/
|
|
|
|
bool MApplication::IsAppInGUIMode() const
|
|
|
|
{
|
|
|
|
return IsTestMode();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-07-10 13:14:55 +02:00
|
|
|
TMainWindow *MApplication::MainWindow()
|
|
|
|
{
|
|
|
|
Clean();
|
|
|
|
if (mainWindows.isEmpty())
|
|
|
|
{
|
|
|
|
NewMainWindow();
|
|
|
|
}
|
|
|
|
return mainWindows[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QList<TMainWindow *> MApplication::MainWindows()
|
|
|
|
{
|
|
|
|
Clean();
|
|
|
|
QList<TMainWindow*> list;
|
|
|
|
for (int i = 0; i < mainWindows.count(); ++i)
|
|
|
|
{
|
|
|
|
list.append(mainWindows.at(i));
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void MApplication::InitOptions()
|
|
|
|
{
|
2015-09-15 20:21:51 +02:00
|
|
|
qInstallMessageHandler(noisyFailureMsgHandler);
|
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
OpenSettings();
|
|
|
|
|
2015-10-03 16:16:28 +02:00
|
|
|
qCDebug(mApp, "Version: %s", qUtf8Printable(APP_VERSION_STR));
|
|
|
|
qCDebug(mApp, "Build revision: %s", BUILD_REVISION);
|
|
|
|
qCDebug(mApp, "%s", qUtf8Printable(buildCompatibilityString()));
|
|
|
|
qCDebug(mApp, "Built on %s at %s", __DATE__, __TIME__);
|
2017-03-23 09:25:46 +01:00
|
|
|
qCDebug(mApp, "Command-line arguments: %s", qUtf8Printable(arguments().join(", ")));
|
|
|
|
qCDebug(mApp, "Process ID: %s", qUtf8Printable(QString().setNum(applicationPid())));
|
2015-07-15 09:16:59 +02:00
|
|
|
|
2017-01-03 09:46:28 +01:00
|
|
|
LoadTranslation(QLocale().name());// By default the console version uses system locale
|
2015-08-02 17:27:18 +02:00
|
|
|
|
|
|
|
static const char * GENERIC_ICON_TO_CHECK = "document-open";
|
|
|
|
if (QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK) == false)
|
|
|
|
{
|
|
|
|
//If there is no default working icon theme then we should
|
|
|
|
//use an icon theme that we provide via a .qrc file
|
|
|
|
//This case happens under Windows and Mac OS X
|
|
|
|
//This does not happen under GNOME or KDE
|
|
|
|
QIcon::setThemeName("win.icon.theme");
|
|
|
|
}
|
|
|
|
|
|
|
|
QResource::registerResource(diagramsPath());
|
|
|
|
}
|
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
const VTranslateVars *MApplication::TrVars()
|
|
|
|
{
|
|
|
|
return trVars;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void MApplication::InitTrVars()
|
|
|
|
{
|
2015-08-02 17:27:18 +02:00
|
|
|
if (trVars != nullptr)
|
|
|
|
{
|
2015-08-08 16:33:37 +02:00
|
|
|
trVars->Retranslate();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-23 17:23:39 +02:00
|
|
|
trVars = new VTranslateVars();
|
2015-08-02 17:27:18 +02:00
|
|
|
}
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
2015-11-19 16:17:25 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool MApplication::event(QEvent *e)
|
|
|
|
{
|
|
|
|
switch(e->type())
|
|
|
|
{
|
|
|
|
// In Mac OS X the QFileOpenEvent event is generated when user perform "Open With" from Finder (this event is
|
|
|
|
// Mac specific).
|
|
|
|
case QEvent::FileOpen:
|
|
|
|
{
|
|
|
|
QFileOpenEvent *fileOpenEvent = static_cast<QFileOpenEvent *>(e);
|
2016-12-21 17:00:56 +01:00
|
|
|
const QString macFileOpen = fileOpenEvent->file();
|
|
|
|
if(not macFileOpen.isEmpty())
|
2015-11-19 16:17:25 +01:00
|
|
|
{
|
2016-12-21 17:00:56 +01:00
|
|
|
TMainWindow *mw = MainWindow();
|
|
|
|
if (mw)
|
2015-11-19 16:17:25 +01:00
|
|
|
{
|
2016-12-21 17:00:56 +01:00
|
|
|
mw->LoadFile(macFileOpen); // open file in existing window
|
2015-11-19 16:17:25 +01:00
|
|
|
}
|
2016-12-21 17:00:56 +01:00
|
|
|
return true;
|
2015-11-19 16:17:25 +01:00
|
|
|
}
|
2015-11-30 11:55:39 +01:00
|
|
|
break;
|
2015-11-19 16:17:25 +01:00
|
|
|
}
|
|
|
|
#if defined(Q_OS_MAC)
|
|
|
|
case QEvent::ApplicationActivate:
|
|
|
|
{
|
|
|
|
Clean();
|
2015-12-02 20:57:16 +01:00
|
|
|
TMainWindow *mw = MainWindow();
|
|
|
|
if (mw && not mw->isMinimized())
|
2015-11-19 16:17:25 +01:00
|
|
|
{
|
2015-12-02 20:57:16 +01:00
|
|
|
mw->show();
|
2015-11-19 16:17:25 +01:00
|
|
|
}
|
2015-12-02 20:57:16 +01:00
|
|
|
return true;
|
2015-11-19 16:17:25 +01:00
|
|
|
}
|
|
|
|
#endif //defined(Q_OS_MAC)
|
|
|
|
default:
|
|
|
|
return VAbstractApplication::event(e);
|
|
|
|
}
|
|
|
|
return VAbstractApplication::event(e);
|
|
|
|
}
|
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void MApplication::OpenSettings()
|
|
|
|
{
|
2017-04-14 16:43:26 +02:00
|
|
|
settings = new VTapeSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(),
|
|
|
|
QCoreApplication::applicationName(), this);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-07-24 14:06:53 +02:00
|
|
|
VTapeSettings *MApplication::TapeSettings()
|
2015-07-15 09:16:59 +02:00
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(settings != nullptr)
|
2015-07-24 14:06:53 +02:00
|
|
|
return qobject_cast<VTapeSettings *>(settings);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
2015-08-01 11:39:32 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString MApplication::diagramsPath() const
|
|
|
|
{
|
|
|
|
const QString dPath = QStringLiteral("/diagrams.rcc");
|
|
|
|
#ifdef Q_OS_WIN
|
2015-08-08 10:22:51 +02:00
|
|
|
return QApplication::applicationDirPath() + dPath;
|
|
|
|
#elif defined(Q_OS_MAC)
|
|
|
|
QFileInfo fileBundle(QApplication::applicationDirPath() + QStringLiteral("/../Resources") + dPath);
|
|
|
|
if (fileBundle.exists())
|
2015-08-01 11:39:32 +02:00
|
|
|
{
|
2015-08-08 10:22:51 +02:00
|
|
|
return fileBundle.absoluteFilePath();
|
2015-08-01 11:39:32 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QFileInfo file(QApplication::applicationDirPath() + dPath);
|
|
|
|
if (file.exists())
|
|
|
|
{
|
|
|
|
return file.absoluteFilePath();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-08 10:22:51 +02:00
|
|
|
return QStringLiteral("/usr/share/valentina") + dPath;
|
2015-08-01 11:39:32 +02:00
|
|
|
}
|
2015-08-08 10:22:51 +02:00
|
|
|
}
|
|
|
|
#else // Unix
|
|
|
|
QFileInfo file(QApplication::applicationDirPath() + dPath);
|
|
|
|
if (file.exists())
|
|
|
|
{
|
|
|
|
return file.absoluteFilePath();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return QStringLiteral("/usr/share/valentina") + dPath;
|
|
|
|
}
|
2015-08-01 11:39:32 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-08-01 15:56:37 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void MApplication::ShowDataBase()
|
|
|
|
{
|
|
|
|
if (dataBase.isNull())
|
|
|
|
{
|
|
|
|
dataBase = new DialogMDataBase();
|
|
|
|
dataBase->setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
dataBase->setModal(false);
|
|
|
|
dataBase->show();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dataBase->activateWindow();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-08 16:33:37 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void MApplication::RetranslateGroups()
|
|
|
|
{
|
|
|
|
if (not dataBase.isNull())
|
|
|
|
{
|
|
|
|
dataBase->RetranslateGroups();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void MApplication::RetranslateTables()
|
|
|
|
{
|
|
|
|
QList<TMainWindow*> list = MainWindows();
|
|
|
|
for (int i=0; i < list.size(); ++i)
|
|
|
|
{
|
|
|
|
list.at(i)->RetranslateTable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-20 12:56:55 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-10-03 16:16:28 +02:00
|
|
|
void MApplication::ParseCommandLine(const SocketConnection &connection, const QStringList &arguments)
|
2015-08-20 12:56:55 +02:00
|
|
|
{
|
|
|
|
QCommandLineParser parser;
|
2015-10-03 19:27:27 +02:00
|
|
|
parser.setApplicationDescription(tr("Valentina's measurements editor."));
|
2015-08-20 12:56:55 +02:00
|
|
|
parser.addHelpOption();
|
|
|
|
parser.addVersionOption();
|
2015-10-03 19:27:27 +02:00
|
|
|
parser.addPositionalArgument("filename", tr("The measurement file."));
|
2015-08-20 12:56:55 +02:00
|
|
|
//-----
|
2015-09-08 09:22:09 +02:00
|
|
|
QCommandLineOption heightOption(QStringList() << "e" << "height",
|
2015-10-11 20:42:13 +02:00
|
|
|
tr("Open with the base height. Valid values: %1cm.")
|
2015-10-07 18:34:46 +02:00
|
|
|
.arg(VMeasurement::WholeListHeights(Unit::Cm).join(", ")),
|
|
|
|
tr("The base height"));
|
2015-08-20 12:56:55 +02:00
|
|
|
parser.addOption(heightOption);
|
|
|
|
//-----
|
|
|
|
QCommandLineOption sizeOption(QStringList() << "s" << "size",
|
2015-10-07 18:34:46 +02:00
|
|
|
tr("Open with the base size. Valid values: %1cm.").arg(VMeasurement::WholeListSizes(Unit::Cm).join(", ")),
|
2015-10-03 19:27:27 +02:00
|
|
|
tr("The base size"));
|
2015-08-20 12:56:55 +02:00
|
|
|
parser.addOption(sizeOption);
|
|
|
|
//-----
|
|
|
|
QCommandLineOption unitOption(QStringList() << "u" << "unit",
|
2015-10-07 18:34:46 +02:00
|
|
|
tr("Set pattern file unit: cm, mm, inch."),
|
|
|
|
tr("The pattern unit"));
|
2015-08-20 12:56:55 +02:00
|
|
|
parser.addOption(unitOption);
|
|
|
|
//-----
|
2015-09-28 12:42:26 +02:00
|
|
|
QCommandLineOption testOption(QStringList() << "test",
|
2015-11-21 14:51:29 +01:00
|
|
|
tr("Use for unit testing. Run the program and open a file without showing the main window."));
|
2015-09-28 12:42:26 +02:00
|
|
|
parser.addOption(testOption);
|
|
|
|
//-----
|
2017-02-09 14:43:17 +01:00
|
|
|
QCommandLineOption scalingOption(QStringList() << LONG_OPTION_NO_HDPI_SCALING,
|
|
|
|
tr("Disable high dpi scaling. Call this option if has problem with scaling (by default scaling enabled). "
|
|
|
|
"Alternatively you can use the QT_AUTO_SCREEN_SCALE_FACTOR=0 environment variable."));
|
|
|
|
parser.addOption(scalingOption);
|
|
|
|
//-----
|
2015-08-20 12:56:55 +02:00
|
|
|
parser.process(arguments);
|
|
|
|
|
|
|
|
bool flagHeight = false;
|
|
|
|
bool flagSize = false;
|
|
|
|
bool flagUnit = false;
|
|
|
|
|
|
|
|
int size = 0;
|
|
|
|
int height = 0;
|
|
|
|
Unit unit = Unit::Cm;
|
|
|
|
|
2015-10-07 19:59:52 +02:00
|
|
|
if (parser.isSet(heightOption))
|
2015-08-20 12:56:55 +02:00
|
|
|
{
|
2015-10-07 19:59:52 +02:00
|
|
|
const QString heightValue = parser.value(heightOption);
|
|
|
|
if (VMeasurement::IsGradationHeightValid(heightValue))
|
|
|
|
{
|
|
|
|
flagHeight = true;
|
|
|
|
height = heightValue.toInt();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qCCritical(mApp, "%s\n",
|
|
|
|
qPrintable(tr("Invalid base height argument. Must be %1cm.")
|
|
|
|
.arg(VMeasurement::WholeListHeights(Unit::Cm).join(", "))));
|
|
|
|
parser.showHelp(V_EX_USAGE);
|
|
|
|
}
|
2015-08-20 12:56:55 +02:00
|
|
|
}
|
|
|
|
|
2015-10-07 19:59:52 +02:00
|
|
|
if (parser.isSet(sizeOption))
|
2015-08-20 12:56:55 +02:00
|
|
|
{
|
2015-10-07 19:59:52 +02:00
|
|
|
const QString sizeValue = parser.value(sizeOption);
|
|
|
|
if (VMeasurement::IsGradationSizeValid(sizeValue))
|
|
|
|
{
|
|
|
|
flagSize = true;
|
|
|
|
size = sizeValue.toInt();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qCCritical(mApp, "%s\n",
|
|
|
|
qPrintable(tr("Invalid base size argument. Must be %1cm.")
|
|
|
|
.arg(VMeasurement::WholeListSizes(Unit::Cm).join(", "))));
|
|
|
|
parser.showHelp(V_EX_USAGE);
|
|
|
|
}
|
2015-08-20 12:56:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const QString unitValue = parser.value(unitOption);
|
|
|
|
if (not unitValue.isEmpty())
|
|
|
|
{
|
|
|
|
|
|
|
|
const QStringList units = QStringList() << VDomDocument::UnitMM
|
|
|
|
<< VDomDocument::UnitCM
|
|
|
|
<< VDomDocument::UnitINCH;
|
|
|
|
if (units.contains(unitValue))
|
|
|
|
{
|
|
|
|
flagUnit = true;
|
|
|
|
unit = VDomDocument::StrToUnits(unitValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-10-03 19:27:27 +02:00
|
|
|
qCCritical(mApp, "%s\n", qPrintable(tr("Invalid base size argument. Must be cm, mm or inch.")));
|
2015-10-03 13:10:58 +02:00
|
|
|
parser.showHelp(V_EX_USAGE);
|
2015-08-20 12:56:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-28 12:42:26 +02:00
|
|
|
testMode = parser.isSet(testOption);
|
|
|
|
|
2015-10-03 16:16:28 +02:00
|
|
|
if (not testMode && connection == SocketConnection::Client)
|
2015-09-28 17:34:29 +02:00
|
|
|
{
|
2015-10-03 16:16:28 +02:00
|
|
|
const QString serverName = QCoreApplication::applicationName();
|
|
|
|
QLocalSocket socket;
|
|
|
|
socket.connectToServer(serverName);
|
|
|
|
if (socket.waitForConnected(1000))
|
|
|
|
{
|
|
|
|
qCDebug(mApp, "Connected to the server '%s'", qUtf8Printable(serverName));
|
|
|
|
QTextStream stream(&socket);
|
|
|
|
stream << QCoreApplication::arguments().join(";;");
|
|
|
|
stream.flush();
|
|
|
|
socket.waitForBytesWritten();
|
2015-10-11 11:06:14 +02:00
|
|
|
qApp->exit(V_EX_OK);
|
|
|
|
return;
|
2015-10-03 16:16:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
qCDebug(mApp, "Can't establish connection to the server '%s'", qUtf8Printable(serverName));
|
|
|
|
|
|
|
|
localServer = new QLocalServer(this);
|
|
|
|
connect(localServer, &QLocalServer::newConnection, this, &MApplication::NewLocalSocketConnection);
|
|
|
|
if (not localServer->listen(serverName))
|
|
|
|
{
|
|
|
|
qCDebug(mApp, "Can't begin to listen for incoming connections on name '%s'",
|
|
|
|
qUtf8Printable(serverName));
|
|
|
|
if (localServer->serverError() == QAbstractSocket::AddressInUseError)
|
|
|
|
{
|
|
|
|
QLocalServer::removeServer(serverName);
|
|
|
|
if (not localServer->listen(serverName))
|
|
|
|
{
|
2015-10-03 19:27:27 +02:00
|
|
|
qCWarning(mApp, "%s",
|
|
|
|
qUtf8Printable(tr("Can't begin to listen for incoming connections on name '%1'").arg(serverName)));
|
2015-10-03 16:16:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-28 17:34:29 +02:00
|
|
|
LoadTranslation(TapeSettings()->GetLocale());
|
|
|
|
}
|
|
|
|
|
2015-08-20 12:56:55 +02:00
|
|
|
const QStringList args = parser.positionalArguments();
|
|
|
|
if (args.count() > 0)
|
|
|
|
{
|
2015-09-28 12:42:26 +02:00
|
|
|
if (testMode && args.count() > 1)
|
|
|
|
{
|
2015-10-03 19:27:27 +02:00
|
|
|
qCCritical(mApp, "%s\n", qPrintable(tr("Test mode doesn't support openning several files.")));
|
2015-10-03 13:10:58 +02:00
|
|
|
parser.showHelp(V_EX_USAGE);
|
2015-09-28 12:42:26 +02:00
|
|
|
}
|
|
|
|
|
2015-08-20 12:56:55 +02:00
|
|
|
for (int i = 0; i < args.size(); ++i)
|
|
|
|
{
|
|
|
|
NewMainWindow();
|
2015-10-11 11:06:14 +02:00
|
|
|
if (not MainWindow()->LoadFile(args.at(i)))
|
|
|
|
{
|
|
|
|
if (testMode)
|
|
|
|
{
|
|
|
|
return; // process only one input file
|
|
|
|
}
|
|
|
|
delete MainWindow();
|
|
|
|
continue;
|
|
|
|
}
|
2015-08-20 12:56:55 +02:00
|
|
|
|
|
|
|
if (flagSize)
|
|
|
|
{
|
|
|
|
MainWindow()->SetBaseMSize(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flagHeight)
|
|
|
|
{
|
|
|
|
MainWindow()->SetBaseMHeight(height);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flagUnit)
|
|
|
|
{
|
|
|
|
MainWindow()->SetPUnit(unit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-28 12:42:26 +02:00
|
|
|
if (not testMode)
|
|
|
|
{
|
|
|
|
NewMainWindow();
|
|
|
|
}
|
2015-10-03 19:27:27 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
qCCritical(mApp, "%s\n", qPrintable(tr("Please, provide one input file.")));
|
|
|
|
parser.showHelp(V_EX_USAGE);
|
|
|
|
}
|
2015-08-20 12:56:55 +02:00
|
|
|
}
|
2015-10-11 11:06:14 +02:00
|
|
|
|
|
|
|
if (testMode)
|
|
|
|
{
|
|
|
|
qApp->exit(V_EX_OK); // close program after processing in console mode
|
|
|
|
}
|
2015-08-20 12:56:55 +02:00
|
|
|
}
|
|
|
|
|
2015-07-10 13:14:55 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
TMainWindow *MApplication::NewMainWindow()
|
|
|
|
{
|
|
|
|
TMainWindow *tape = new TMainWindow();
|
|
|
|
mainWindows.prepend(tape);
|
2015-09-28 12:42:26 +02:00
|
|
|
if (not qApp->IsTestMode())
|
|
|
|
{
|
|
|
|
tape->show();
|
|
|
|
}
|
2015-07-10 13:14:55 +02:00
|
|
|
return tape;
|
|
|
|
}
|
|
|
|
|
2015-10-11 11:06:14 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void MApplication::ProcessCMD()
|
|
|
|
{
|
|
|
|
ParseCommandLine(SocketConnection::Client, arguments());
|
|
|
|
}
|
|
|
|
|
2015-07-10 13:14:55 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void MApplication::NewLocalSocketConnection()
|
|
|
|
{
|
|
|
|
QLocalSocket *socket = localServer->nextPendingConnection();
|
|
|
|
if (not socket)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
socket->waitForReadyRead(1000);
|
|
|
|
QTextStream stream(socket);
|
2015-08-20 12:56:55 +02:00
|
|
|
const QString arg = stream.readAll();
|
|
|
|
if (not arg.isEmpty())
|
2015-07-10 13:14:55 +02:00
|
|
|
{
|
2015-10-03 16:16:28 +02:00
|
|
|
ParseCommandLine(SocketConnection::Server, arg.split(";;"));
|
2015-07-10 13:14:55 +02:00
|
|
|
}
|
|
|
|
delete socket;
|
|
|
|
MainWindow()->raise();
|
|
|
|
MainWindow()->activateWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void MApplication::Clean()
|
|
|
|
{
|
|
|
|
// cleanup any deleted main windows first
|
|
|
|
for (int i = mainWindows.count() - 1; i >= 0; --i)
|
|
|
|
{
|
|
|
|
if (mainWindows.at(i).isNull())
|
|
|
|
{
|
|
|
|
mainWindows.removeAt(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|