2013-11-15 13:41:26 +01:00
|
|
|
/************************************************************************
|
2013-09-23 14:08:06 +02:00
|
|
|
**
|
2013-11-15 13:50:05 +01:00
|
|
|
** @file vapplication.cpp
|
2014-04-30 07:38:52 +02:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
2013-11-15 13:50:05 +01:00
|
|
|
** @date November 15, 2013
|
2013-09-23 14:08:06 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2013-11-15 13:41:26 +01:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2013-11-15 13:41:26 +01:00
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
2013-09-23 14:08:06 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
2013-09-23 14:08:06 +02:00
|
|
|
** 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.
|
|
|
|
**
|
2013-10-27 13:36:29 +01:00
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
2013-09-23 14:08:06 +02:00
|
|
|
** 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/>.
|
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
*************************************************************************/
|
2013-09-23 14:08:06 +02:00
|
|
|
|
|
|
|
#include "vapplication.h"
|
2015-08-28 18:38:02 +02:00
|
|
|
#include "../ifc/exception/vexceptionobjecterror.h"
|
2015-07-10 11:24:47 +02:00
|
|
|
#include "../ifc/exception/vexceptionbadid.h"
|
|
|
|
#include "../ifc/exception/vexceptionconversionerror.h"
|
|
|
|
#include "../ifc/exception/vexceptionemptyparameter.h"
|
|
|
|
#include "../ifc/exception/vexceptionwrongid.h"
|
|
|
|
#include "../vwidgets/vmaingraphicsview.h"
|
2014-11-15 16:52:27 +01:00
|
|
|
#include "../version.h"
|
2015-06-15 13:43:41 +02:00
|
|
|
#include "../vmisc/logging.h"
|
2016-08-16 18:57:32 +02:00
|
|
|
#include "../vmisc/vmath.h"
|
2015-08-25 12:35:50 +02:00
|
|
|
#include "../qmuparser/qmuparsererror.h"
|
2015-11-19 16:17:25 +01:00
|
|
|
#include "../mainwindow.h"
|
2013-09-23 14:08:06 +02:00
|
|
|
|
2016-08-16 19:35:21 +02:00
|
|
|
#include <QtDebug>
|
2014-05-12 11:35:33 +02:00
|
|
|
#include <QDir>
|
2014-07-04 16:52:11 +02:00
|
|
|
#include <QProcess>
|
2014-10-23 23:44:50 +02:00
|
|
|
#include <QTemporaryFile>
|
2014-06-08 20:10:57 +02:00
|
|
|
#include <QUndoStack>
|
2014-10-23 21:16:40 +02:00
|
|
|
#include <QTemporaryFile>
|
2014-11-20 13:18:43 +01:00
|
|
|
#include <QFile>
|
|
|
|
#include <QStandardPaths>
|
|
|
|
#include <QMessageBox>
|
2014-11-28 19:33:28 +01:00
|
|
|
#include <QThread>
|
|
|
|
#include <QDateTime>
|
2015-08-27 18:03:43 +02:00
|
|
|
#include <QtXmlPatterns>
|
2015-10-18 21:30:51 +02:00
|
|
|
#include <QIcon>
|
2015-08-27 17:55:17 +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-20 16:32:01 +02:00
|
|
|
|
2014-11-20 18:52:51 +01:00
|
|
|
Q_LOGGING_CATEGORY(vApp, "v.application")
|
2014-11-20 13:18:43 +01:00
|
|
|
|
2016-08-06 20:42:40 +02:00
|
|
|
QT_WARNING_POP
|
2015-10-20 16:32:01 +02:00
|
|
|
|
2015-10-23 19:47:33 +02:00
|
|
|
Q_DECL_CONSTEXPR auto DAYS_TO_KEEP_LOGS = 3;
|
2015-09-14 13:53:49 +02:00
|
|
|
|
2014-11-20 13:18:43 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
|
|
|
{
|
|
|
|
// 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")))
|
2014-11-20 13:18:43 +01: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
|
2016-05-02 18:45:36 +02:00
|
|
|
|
|
|
|
// Hide Qt bug 'Assertion when reading an icns file'
|
|
|
|
// https://bugreports.qt.io/browse/QTBUG-45537
|
|
|
|
// Remove after Qt fix will be released
|
2016-07-20 10:25:53 +02:00
|
|
|
if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QICNSHandler::read()")))
|
2016-05-02 18:45:36 +02: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
|
|
|
|
|
2014-11-20 13:18:43 +01: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")))
|
2014-11-20 13:18:43 +01: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")))
|
2014-11-20 13:18:43 +01: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());
|
|
|
|
|
|
|
|
{
|
2016-07-20 10:25:53 +02:00
|
|
|
QString debugdate = "[" + QDateTime::currentDateTime().toString(QStringLiteral("yyyy.MM.dd hh:mm:ss"));
|
2015-09-28 20:54:41 +02:00
|
|
|
|
2014-11-20 13:18:43 +01:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case QtDebugMsg:
|
2014-11-28 14:49:06 +01:00
|
|
|
debugdate += QString(":DEBUG:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line)
|
2018-03-14 14:39:15 +01:00
|
|
|
.arg(context.function, context.category, msg);
|
2015-10-01 16:59:01 +02:00
|
|
|
vStdOut() << QApplication::translate("vNoisyHandler", "DEBUG:") << msg << "\n";
|
2014-11-20 13:18:43 +01:00
|
|
|
break;
|
|
|
|
case QtWarningMsg:
|
2014-11-28 14:49:06 +01:00
|
|
|
debugdate += QString(":WARNING:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line)
|
2018-03-14 14:39:15 +01:00
|
|
|
.arg(context.function, context.category, msg);
|
2015-10-01 16:59:01 +02:00
|
|
|
vStdErr() << QApplication::translate("vNoisyHandler", "WARNING:") << msg << "\n";
|
2014-11-20 13:18:43 +01:00
|
|
|
break;
|
|
|
|
case QtCriticalMsg:
|
2014-11-28 14:49:06 +01:00
|
|
|
debugdate += QString(":CRITICAL:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line)
|
2018-03-14 14:39:15 +01:00
|
|
|
.arg(context.function, context.category, msg);
|
2015-10-01 16:59:01 +02:00
|
|
|
vStdErr() << QApplication::translate("vNoisyHandler", "CRITICAL:") << msg << "\n";
|
2014-11-20 13:18:43 +01:00
|
|
|
break;
|
|
|
|
case QtFatalMsg:
|
2014-11-28 14:49:06 +01:00
|
|
|
debugdate += QString(":FATAL:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line)
|
2018-03-14 14:39:15 +01:00
|
|
|
.arg(context.function, context.category, msg);
|
2015-10-01 16:59:01 +02:00
|
|
|
vStdErr() << QApplication::translate("vNoisyHandler", "FATAL:") << msg << "\n";
|
2014-11-20 13:18:43 +01:00
|
|
|
break;
|
2015-10-01 16:59:01 +02:00
|
|
|
#if QT_VERSION > QT_VERSION_CHECK(5, 4, 2)
|
|
|
|
case QtInfoMsg:
|
|
|
|
debugdate += QString(":INFO:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line)
|
2018-03-14 14:39:15 +01:00
|
|
|
.arg(context.function, context.category, msg);
|
2015-10-01 16:59:01 +02:00
|
|
|
vStdOut() << QApplication::translate("vNoisyHandler", "INFO:") << msg << "\n";
|
|
|
|
break;
|
|
|
|
#endif
|
2014-11-20 13:18:43 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
(*qApp->LogFile()) << debugdate << endl;
|
2015-09-28 20:54:41 +02:00
|
|
|
}
|
2014-11-20 13:18:43 +01:00
|
|
|
|
2015-09-28 20:54:41 +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-28 20:54:41 +02:00
|
|
|
|
|
|
|
QMessageBox messageBox;
|
|
|
|
switch (type)
|
2014-11-28 18:55:27 +01:00
|
|
|
{
|
2015-09-28 20:54:41 +02:00
|
|
|
case QtWarningMsg:
|
2018-05-25 16:54:21 +02:00
|
|
|
messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Warning"));
|
2015-09-28 20:54:41 +02:00
|
|
|
messageBox.setIcon(QMessageBox::Warning);
|
|
|
|
break;
|
|
|
|
case QtCriticalMsg:
|
2018-05-25 16:54:21 +02:00
|
|
|
messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Critical error"));
|
2015-09-28 20:54:41 +02:00
|
|
|
messageBox.setIcon(QMessageBox::Critical);
|
|
|
|
break;
|
|
|
|
case QtFatalMsg:
|
2018-05-25 16:54:21 +02:00
|
|
|
messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Fatal error"));
|
2015-09-28 20:54:41 +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:
|
2018-05-25 16:54:21 +02:00
|
|
|
messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "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:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2015-08-25 19:53:03 +02:00
|
|
|
|
2015-09-28 20:54:41 +02:00
|
|
|
if (type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg)
|
|
|
|
{
|
2015-12-09 12:31:33 +01:00
|
|
|
if (VApplication::IsGUIMode())
|
2015-08-25 19:53:03 +02:00
|
|
|
{
|
|
|
|
if (topWinAllowsPop)
|
|
|
|
{
|
2018-05-25 16:54:21 +02:00
|
|
|
messageBox.setText(VAbstractApplication::ClearMessage(msg));
|
2015-08-25 19:53:03 +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
|
2017-07-09 08:02:26 +02:00
|
|
|
QGuiApplication::setOverrideCursor(Qt::ArrowCursor);
|
2015-10-01 16:59:01 +02:00
|
|
|
#endif
|
2015-08-25 19:53:03 +02:00
|
|
|
messageBox.exec();
|
2015-10-01 16:59:01 +02:00
|
|
|
#ifndef QT_NO_CURSOR
|
2017-07-09 08:02:26 +02:00
|
|
|
QGuiApplication::restoreOverrideCursor();
|
2015-10-01 16:59:01 +02:00
|
|
|
#endif
|
2015-08-25 19:53:03 +02:00
|
|
|
}
|
|
|
|
}
|
2014-11-28 18:55:27 +01:00
|
|
|
}
|
|
|
|
|
2014-11-20 13:18:43 +01:00
|
|
|
if (QtFatalMsg == type)
|
|
|
|
{
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (type != QtDebugMsg)
|
|
|
|
{
|
|
|
|
abort(); // be NOISY unless overridden!
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-26 05:39:07 +01:00
|
|
|
#define DefWidth 1.2//mm
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief VApplication constructor.
|
|
|
|
* @param argc number arguments.
|
|
|
|
* @param argv command line.
|
|
|
|
*/
|
2014-03-19 19:27:11 +01:00
|
|
|
VApplication::VApplication(int &argc, char **argv)
|
2015-06-18 19:23:24 +02:00
|
|
|
: VAbstractApplication(argc, argv),
|
2015-09-28 17:34:29 +02:00
|
|
|
trVars(nullptr),
|
|
|
|
autoSaveTimer(nullptr),
|
2015-09-14 13:53:49 +02:00
|
|
|
lockLog(),
|
2015-04-05 16:31:28 +02:00
|
|
|
out(nullptr)
|
2014-03-19 19:27:11 +01:00
|
|
|
{
|
2015-09-29 19:12:23 +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);
|
|
|
|
|
|
|
|
OpenSettings();
|
|
|
|
|
2015-09-28 17:34:29 +02:00
|
|
|
// making sure will create new instance...just in case we will ever do 2 objects of VApplication
|
|
|
|
VCommandLine::Reset();
|
2017-01-03 09:46:28 +01:00
|
|
|
LoadTranslation(QLocale().name());// By default the console version uses system locale
|
2015-08-25 19:53:03 +02:00
|
|
|
VCommandLine::Get(*this);
|
2014-06-04 13:30:45 +02:00
|
|
|
undoStack = new QUndoStack(this);
|
2014-03-19 19:27:11 +01:00
|
|
|
}
|
|
|
|
|
2014-11-20 13:18:43 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VApplication::~VApplication()
|
|
|
|
{
|
2015-04-01 19:08:35 +02:00
|
|
|
qCDebug(vApp, "Application closing.");
|
2017-07-05 18:35:34 +02:00
|
|
|
qInstallMessageHandler(nullptr); // Resore the message handler
|
2015-06-11 12:15:57 +02:00
|
|
|
delete trVars;
|
2015-08-25 19:53:03 +02:00
|
|
|
VCommandLine::Reset();
|
2014-11-20 13:18:43 +01:00
|
|
|
}
|
|
|
|
|
2014-07-04 16:52:11 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief NewValentina start Valentina in new process, send path to pattern file in argument.
|
|
|
|
* @param fileName path to pattern file.
|
|
|
|
*/
|
|
|
|
void VApplication::NewValentina(const QString &fileName)
|
|
|
|
{
|
2015-04-01 19:08:35 +02:00
|
|
|
qCDebug(vApp, "Open new detached process.");
|
2014-10-23 11:13:18 +02:00
|
|
|
if (fileName.isEmpty())
|
|
|
|
{
|
2017-03-23 09:25:46 +01:00
|
|
|
qCDebug(vApp, "New process without arguments. program = %s",
|
|
|
|
qUtf8Printable(QCoreApplication::applicationFilePath()));
|
2014-11-26 19:34:43 +01:00
|
|
|
// Path can contain spaces.
|
2017-03-23 09:25:46 +01:00
|
|
|
if (QProcess::startDetached("\""+QCoreApplication::applicationFilePath()+"\""))
|
2014-11-26 19:34:43 +01:00
|
|
|
{
|
2015-04-01 19:08:35 +02:00
|
|
|
qCDebug(vApp, "The process was started successfully.");
|
2014-11-26 19:34:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-04-01 19:08:35 +02:00
|
|
|
qCWarning(vApp, "Could not run process. The operation timed out or an error occurred.");
|
2014-11-26 19:34:43 +01:00
|
|
|
}
|
2014-10-23 11:13:18 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
const QString run = QString("\"%1\" \"%2\"").arg(QCoreApplication::applicationFilePath(), fileName);
|
2015-10-01 17:34:03 +02:00
|
|
|
qCDebug(vApp, "New process with arguments. program = %s", qUtf8Printable(run));
|
2015-03-02 18:11:43 +01:00
|
|
|
if (QProcess::startDetached(run))
|
2014-11-26 19:34:43 +01:00
|
|
|
{
|
2015-04-01 19:08:35 +02:00
|
|
|
qCDebug(vApp, "The process was started successfully.");
|
2014-11-26 19:34:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-04-01 19:08:35 +02:00
|
|
|
qCWarning(vApp, "Could not run process. The operation timed out or an error occurred.");
|
2014-11-26 19:34:43 +01:00
|
|
|
}
|
2014-10-23 11:13:18 +02:00
|
|
|
}
|
2014-07-04 16:52:11 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +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.
|
|
|
|
*/
|
2014-03-26 05:39:07 +01:00
|
|
|
// reimplemented from QApplication so we can throw exceptions in slots
|
2013-11-04 21:35:15 +01:00
|
|
|
bool VApplication::notify(QObject *receiver, QEvent *event)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2014-03-19 19:27:11 +01:00
|
|
|
return QApplication::notify(receiver, event);
|
2013-09-23 14:08:06 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionObjectError &e)
|
|
|
|
{
|
2015-10-28 15:22:36 +01:00
|
|
|
qCCritical(vApp, "%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);
|
2013-09-23 14:08:06 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2015-10-01 16:59:01 +02:00
|
|
|
qCCritical(vApp, "%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);
|
2013-09-23 14:08:06 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionConversionError &e)
|
|
|
|
{
|
2015-10-01 16:59:01 +02:00
|
|
|
qCCritical(vApp, "%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);
|
2013-09-23 14:08:06 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionEmptyParameter &e)
|
|
|
|
{
|
2015-10-01 16:59:01 +02:00
|
|
|
qCCritical(vApp, "%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);
|
2013-09-23 14:08:06 +02:00
|
|
|
}
|
2014-03-03 18:32:38 +01:00
|
|
|
catch (const VExceptionWrongId &e)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2015-10-01 16:59:01 +02:00
|
|
|
qCCritical(vApp, "%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);
|
2013-09-23 14:08:06 +02:00
|
|
|
}
|
2015-11-02 17:25:29 +01:00
|
|
|
catch (const VExceptionToolWasDeleted &e)
|
|
|
|
{
|
|
|
|
qCCritical(vApp, "%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);
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VException &e)
|
|
|
|
{
|
2015-10-01 16:59:01 +02:00
|
|
|
qCCritical(vApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Something's wrong!!")),
|
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
2014-03-03 16:42:14 +01:00
|
|
|
return true;
|
2013-10-10 20:45:58 +02:00
|
|
|
}
|
2016-03-05 16:27:07 +01:00
|
|
|
// These last two cases are special. I found that we can't show here a modal dialog with an error message.
|
|
|
|
// Somehow program doesn't wait until an error dialog will be closed. But if ignore the exception the program will
|
|
|
|
// hang.
|
2015-08-25 12:35:50 +02:00
|
|
|
catch (const qmu::QmuParserError &e)
|
|
|
|
{
|
2015-10-01 16:59:01 +02:00
|
|
|
qCCritical(vApp, "%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-08-25 12:35:50 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
2015-10-01 16:59:01 +02:00
|
|
|
qCCritical(vApp, "%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);
|
2013-09-23 14:08:06 +02:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2014-03-19 19:27:11 +01:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-08-18 12:36:17 +02:00
|
|
|
QString VApplication::TapeFilePath() const
|
2014-03-19 19:27:11 +01:00
|
|
|
{
|
2015-08-18 12:36:17 +02:00
|
|
|
const QString tape = QStringLiteral("tape");
|
2014-03-26 05:39:07 +01:00
|
|
|
#ifdef Q_OS_WIN
|
2017-07-09 08:02:26 +02:00
|
|
|
QFileInfo tapeFile(QCoreApplication::applicationDirPath() + "/" + tape + ".exe");
|
2015-08-18 12:36:17 +02:00
|
|
|
if (tapeFile.exists())
|
|
|
|
{
|
2015-08-28 21:54:17 +02:00
|
|
|
return tapeFile.absoluteFilePath();
|
2015-08-27 17:39:02 +02:00
|
|
|
}
|
2015-08-18 12:36:17 +02:00
|
|
|
else
|
2015-08-25 19:53:03 +02:00
|
|
|
{
|
2017-07-09 08:02:26 +02:00
|
|
|
return QCoreApplication::applicationDirPath() + "/../../tape/bin/" + tape + ".exe";
|
2015-08-18 12:36:17 +02:00
|
|
|
}
|
|
|
|
#elif defined(Q_OS_MAC)
|
2017-07-09 08:02:26 +02:00
|
|
|
QFileInfo tapeFile(QCoreApplication::applicationDirPath() + "/" + tape);
|
2015-08-18 12:36:17 +02:00
|
|
|
if (tapeFile.exists())
|
|
|
|
{
|
|
|
|
return tapeFile.absoluteFilePath();
|
2015-08-25 19:53:03 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-07-09 08:02:26 +02:00
|
|
|
QFileInfo file(QCoreApplication::applicationDirPath() + "/../../tape/bin/" + tape);
|
2015-08-18 12:36:17 +02:00
|
|
|
if (file.exists())
|
|
|
|
{
|
|
|
|
return file.absoluteFilePath();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return tape;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else // Unix
|
2017-07-09 08:02:26 +02:00
|
|
|
QFileInfo file(QCoreApplication::applicationDirPath() + "/../../tape/bin/" + tape);
|
2015-08-18 12:36:17 +02:00
|
|
|
if (file.exists())
|
|
|
|
{
|
|
|
|
return file.absoluteFilePath();
|
2015-08-25 19:53:03 +02:00
|
|
|
}
|
2015-08-27 20:33:38 +02:00
|
|
|
else
|
|
|
|
{
|
2017-07-09 08:02:26 +02:00
|
|
|
QFileInfo tapeFile(QCoreApplication::applicationDirPath() + "/" + tape);
|
2015-11-18 13:42:25 +01:00
|
|
|
if (tapeFile.exists())
|
|
|
|
{
|
|
|
|
return tapeFile.absoluteFilePath();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return tape;
|
|
|
|
}
|
2015-08-27 20:33:38 +02:00
|
|
|
}
|
2014-05-12 11:35:33 +02:00
|
|
|
#endif
|
2014-03-19 19:27:11 +01:00
|
|
|
}
|
2014-03-26 05:39:07 +01:00
|
|
|
|
2014-11-20 13:18:43 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VApplication::LogDirPath() const
|
|
|
|
{
|
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_OSX)
|
|
|
|
const QString logDirPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QString(),
|
|
|
|
QStandardPaths::LocateDirectory) + "Valentina";
|
|
|
|
#else
|
|
|
|
const QString logDirPath = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString(),
|
2017-04-14 16:43:26 +02:00
|
|
|
QStandardPaths::LocateDirectory)
|
|
|
|
+ QCoreApplication::organizationName();
|
2014-11-20 13:18:43 +01:00
|
|
|
#endif
|
|
|
|
return logDirPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VApplication::LogPath() const
|
|
|
|
{
|
2017-03-23 09:25:46 +01:00
|
|
|
return QString("%1/valentina-pid%2.log").arg(LogDirPath()).arg(applicationPid());
|
2014-11-28 14:49:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-04-19 11:48:13 +02:00
|
|
|
bool VApplication::CreateLogDir() const
|
2014-11-28 14:49:06 +01:00
|
|
|
{
|
|
|
|
QDir logDir(LogDirPath());
|
|
|
|
if (logDir.exists() == false)
|
|
|
|
{
|
2018-04-13 08:14:55 +02:00
|
|
|
return logDir.mkpath(QChar('.')); // Create directory for log if need
|
2014-11-28 14:49:06 +01:00
|
|
|
}
|
2017-04-19 11:48:13 +02:00
|
|
|
return true;
|
2014-11-28 14:49:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VApplication::BeginLogging()
|
|
|
|
{
|
2015-10-26 08:57:20 +01:00
|
|
|
VlpCreateLock(lockLog, LogPath(), [this](){return new QFile(LogPath());});
|
2015-08-25 19:53:03 +02:00
|
|
|
|
2015-09-14 13:53:49 +02:00
|
|
|
if (lockLog->IsLocked())
|
|
|
|
{
|
|
|
|
if (lockLog->GetProtected()->open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
|
2014-11-28 14:49:06 +01:00
|
|
|
{
|
2015-09-14 13:53:49 +02:00
|
|
|
out.reset(new QTextStream(lockLog->GetProtected().get()));
|
|
|
|
qInstallMessageHandler(noisyFailureMsgHandler);
|
2015-10-01 17:34:03 +02:00
|
|
|
qCDebug(vApp, "Log file %s was locked.", qUtf8Printable(LogPath()));
|
2014-11-28 14:49:06 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-14 13:53:49 +02:00
|
|
|
qCDebug(vApp, "Error opening log file \'%s\'. All debug output redirected to console.",
|
2015-10-01 17:34:03 +02:00
|
|
|
qUtf8Printable(LogPath()));
|
2014-11-28 14:49:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-10-01 17:34:03 +02:00
|
|
|
qCDebug(vApp, "Failed to lock %s", qUtf8Printable(LogPath()));
|
2014-11-28 14:49:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VApplication::ClearOldLogs() const
|
|
|
|
{
|
2017-09-22 18:16:16 +02:00
|
|
|
const QString workingDirectory = QDir::currentPath();// Save the app working directory
|
2014-11-28 14:49:06 +01:00
|
|
|
QDir logsDir(LogDirPath());
|
2015-10-23 19:47:33 +02:00
|
|
|
logsDir.setNameFilters(QStringList("*.log"));
|
2014-11-28 14:49:06 +01:00
|
|
|
logsDir.setCurrent(LogDirPath());
|
|
|
|
|
|
|
|
const QStringList allFiles = logsDir.entryList(QDir::NoDotAndDotDot | QDir::Files);
|
|
|
|
if (allFiles.isEmpty() == false)
|
|
|
|
{
|
2015-04-01 19:08:35 +02:00
|
|
|
qCDebug(vApp, "Clearing old logs");
|
2018-04-03 13:36:38 +02:00
|
|
|
for (auto &fn : allFiles)
|
2014-11-28 14:49:06 +01:00
|
|
|
{
|
2015-09-14 13:53:49 +02:00
|
|
|
QFileInfo info(fn);
|
2018-03-24 06:31:46 +01:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
|
|
|
const QDateTime created = info.birthTime();
|
|
|
|
#else
|
|
|
|
const QDateTime created = info.created();
|
|
|
|
#endif
|
|
|
|
if (created.daysTo(QDateTime::currentDateTime()) >= DAYS_TO_KEEP_LOGS)
|
2015-04-05 16:31:28 +02:00
|
|
|
{
|
2015-10-26 08:57:20 +01:00
|
|
|
VLockGuard<QFile> tmp(info.absoluteFilePath(), [&fn](){return new QFile(fn);});
|
2015-09-14 13:53:49 +02:00
|
|
|
if (tmp.GetProtected() != nullptr)
|
2015-04-05 16:31:28 +02:00
|
|
|
{
|
2015-09-14 13:53:49 +02:00
|
|
|
if (tmp.GetProtected()->remove())
|
|
|
|
{
|
2015-10-01 17:34:03 +02:00
|
|
|
qCDebug(vApp, "Deleted %s", qUtf8Printable(info.absoluteFilePath()));
|
2015-09-14 13:53:49 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-10-01 17:34:03 +02:00
|
|
|
qCDebug(vApp, "Could not delete %s", qUtf8Printable(info.absoluteFilePath()));
|
2015-09-14 13:53:49 +02:00
|
|
|
}
|
2015-04-05 16:31:28 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-10-01 17:34:03 +02:00
|
|
|
qCDebug(vApp, "Failed to lock %s", qUtf8Printable(info.absoluteFilePath()));
|
2015-04-05 16:31:28 +02:00
|
|
|
}
|
|
|
|
}
|
2014-11-28 14:49:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-04-01 19:08:35 +02:00
|
|
|
qCDebug(vApp, "There are no old logs.");
|
2014-11-28 14:49:06 +01:00
|
|
|
}
|
2017-09-22 18:16:16 +02:00
|
|
|
|
|
|
|
QDir::setCurrent(workingDirectory); // Restore working directory
|
2014-11-20 13:18:43 +01:00
|
|
|
}
|
|
|
|
|
2015-06-11 14:24:38 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VApplication::InitOptions()
|
|
|
|
{
|
|
|
|
// Run creation log after sending crash report
|
|
|
|
StartLogging();
|
|
|
|
|
|
|
|
qDebug()<<"Version:"<<APP_VERSION_STR;
|
|
|
|
qDebug()<<"Build revision:"<<BUILD_REVISION;
|
|
|
|
qDebug()<<buildCompatibilityString();
|
|
|
|
qDebug()<<"Built on"<<__DATE__<<"at"<<__TIME__;
|
2017-03-23 09:25:46 +01:00
|
|
|
qDebug()<<"Command-line arguments:"<<arguments();
|
|
|
|
qDebug()<<"Process ID:"<<applicationPid();
|
2015-06-11 14:24:38 +02:00
|
|
|
|
2015-12-09 12:31:33 +01:00
|
|
|
if (VApplication::IsGUIMode())// By default console version uses system locale
|
2015-09-28 17:34:29 +02:00
|
|
|
{
|
|
|
|
LoadTranslation(ValentinaSettings()->GetLocale());
|
|
|
|
}
|
2015-06-11 14:24:38 +02:00
|
|
|
|
|
|
|
static const char * GENERIC_ICON_TO_CHECK = "document-open";
|
|
|
|
if (QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK) == false)
|
|
|
|
{
|
2015-08-25 19:53:03 +02:00
|
|
|
//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");
|
2015-06-11 14:24:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-09 15:11:50 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QStringList VApplication::LabelLanguages()
|
|
|
|
{
|
2014-10-17 22:26:30 +02:00
|
|
|
QStringList list = QStringList() << "de" // German
|
|
|
|
<< "en" // English
|
|
|
|
<< "fr" // French
|
|
|
|
<< "ru" // Russian
|
|
|
|
<< "uk" // Ukrainian
|
|
|
|
<< "hr" // Croatian
|
|
|
|
<< "sr" // Serbian
|
|
|
|
<< "bs"; // Bosnian
|
2014-09-09 15:11:50 +02:00
|
|
|
return list;
|
|
|
|
}
|
2014-09-18 11:30:33 +02:00
|
|
|
|
2014-11-20 13:18:43 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VApplication::StartLogging()
|
|
|
|
{
|
2017-04-19 11:48:13 +02:00
|
|
|
if (CreateLogDir())
|
|
|
|
{
|
|
|
|
BeginLogging();
|
|
|
|
ClearOldLogs();
|
|
|
|
}
|
2014-11-20 13:18:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QTextStream *VApplication::LogFile()
|
|
|
|
{
|
2015-09-14 13:53:49 +02:00
|
|
|
return out.get();
|
2014-11-20 13:18:43 +01:00
|
|
|
}
|
|
|
|
|
2015-06-11 12:15:57 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
const VTranslateVars *VApplication::TrVars()
|
|
|
|
{
|
|
|
|
return trVars;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VApplication::InitTrVars()
|
|
|
|
{
|
2015-11-25 10:30:02 +01:00
|
|
|
if (trVars == nullptr)
|
|
|
|
{
|
2016-05-23 17:23:39 +02:00
|
|
|
trVars = new VTranslateVars();
|
2015-11-25 10:30:02 +01:00
|
|
|
}
|
2015-07-24 14:06:53 +02:00
|
|
|
}
|
|
|
|
|
2015-11-19 16:17:25 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VApplication::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 16:19:12 +01:00
|
|
|
const QString macFileOpen = fileOpenEvent->file();
|
|
|
|
if(not macFileOpen.isEmpty())
|
2015-11-19 16:17:25 +01:00
|
|
|
{
|
2016-12-21 16:19:12 +01:00
|
|
|
MainWindow *window = qobject_cast<MainWindow*>(mainWindow);
|
|
|
|
if (window)
|
2015-11-19 16:17:25 +01:00
|
|
|
{
|
2016-12-21 16:19:12 +01:00
|
|
|
window->LoadPattern(macFileOpen); // open file in existing window
|
2015-11-19 16:17:25 +01:00
|
|
|
}
|
2016-12-21 16:19:12 +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:
|
|
|
|
{
|
|
|
|
if (mainWindow && not mainWindow->isMinimized())
|
|
|
|
{
|
|
|
|
mainWindow->show();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif //defined(Q_OS_MAC)
|
|
|
|
default:
|
|
|
|
return VAbstractApplication::event(e);
|
|
|
|
}
|
|
|
|
return VAbstractApplication::event(e);
|
|
|
|
}
|
|
|
|
|
2015-07-24 14:06:53 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief OpenSettings get acsses to application settings.
|
|
|
|
*
|
|
|
|
* Because we can create object in constructor we open file separately.
|
|
|
|
*/
|
|
|
|
void VApplication::OpenSettings()
|
|
|
|
{
|
2017-04-14 16:43:26 +02:00
|
|
|
settings = new VSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(),
|
|
|
|
QCoreApplication::applicationName(), this);
|
2015-07-24 14:06:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VSettings *VApplication::ValentinaSettings()
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(settings != nullptr)
|
2015-07-24 14:06:53 +02:00
|
|
|
return qobject_cast<VSettings *>(settings);
|
2015-06-11 12:15:57 +02:00
|
|
|
}
|
2015-08-25 21:27:21 +02:00
|
|
|
|
2015-08-25 19:53:03 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-12-09 12:31:33 +01:00
|
|
|
bool VApplication::IsGUIMode()
|
2015-08-25 19:53:03 +02:00
|
|
|
{
|
|
|
|
return (VCommandLine::instance != nullptr) && VCommandLine::instance->IsGuiEnabled();
|
|
|
|
}
|
2015-08-25 21:27:21 +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 VApplication::IsAppInGUIMode() const
|
|
|
|
{
|
|
|
|
return IsGUIMode();
|
|
|
|
}
|
|
|
|
|
2015-08-25 19:53:03 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
const VCommandLinePtr VApplication::CommandLine() const
|
|
|
|
{
|
|
|
|
return VCommandLine::instance;
|
|
|
|
}
|