2013-11-15 13:41:26 +01:00
|
|
|
/************************************************************************
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:50:05 +01:00
|
|
|
** @file main.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-18 21:16:19 +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
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
2013-09-18 21:16:19 +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-18 21:16:19 +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-18 21:16:19 +02:00
|
|
|
|
2016-07-15 11:00:00 +02:00
|
|
|
#include "../fervor/fvupdater.h"
|
2016-11-04 16:34:15 +01:00
|
|
|
#include "../vpatterndb/vpiecenode.h"
|
2023-07-24 12:41:42 +02:00
|
|
|
#include "core/vapplication.h"
|
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "vabstractapplication.h"
|
2016-07-15 11:00:00 +02:00
|
|
|
|
2015-06-25 12:42:49 +02:00
|
|
|
#include <QMessageBox> // For QT_REQUIRE_VERSION
|
2015-10-18 21:30:51 +02:00
|
|
|
#include <QTimer>
|
2015-06-25 12:42:49 +02:00
|
|
|
|
2023-02-09 16:17:08 +01:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
#include <xercesc/util/PlatformUtils.hpp>
|
|
|
|
#endif
|
|
|
|
|
2023-10-24 10:03:04 +02:00
|
|
|
// Fix bug in Qt. Deprecation warning in QMessageBox::critical.
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
|
|
|
#undef QT_REQUIRE_VERSION
|
|
|
|
#define QT_REQUIRE_VERSION(argc, argv, str) \
|
|
|
|
{ \
|
|
|
|
QString s = QString::fromLatin1(str); \
|
|
|
|
QString sq = QString::fromLatin1(qVersion()); \
|
|
|
|
if ((sq.section(QChar::fromLatin1('.'), 0, 0).toInt() << 16) + \
|
|
|
|
(sq.section(QChar::fromLatin1('.'), 1, 1).toInt() << 8) + \
|
|
|
|
sq.section(QChar::fromLatin1('.'), 2, 2).toInt() < \
|
|
|
|
(s.section(QChar::fromLatin1('.'), 0, 0).toInt() << 16) + \
|
|
|
|
(s.section(QChar::fromLatin1('.'), 1, 1).toInt() << 8) + \
|
|
|
|
s.section(QChar::fromLatin1('.'), 2, 2).toInt()) \
|
|
|
|
{ \
|
|
|
|
if (!qApp) \
|
|
|
|
{ \
|
|
|
|
new QApplication(argc, argv); \
|
|
|
|
} \
|
|
|
|
QString s = QApplication::tr("Executable '%1' requires Qt %2, found Qt %3.") \
|
|
|
|
.arg(qAppName()) \
|
|
|
|
.arg(QString::fromLatin1(str)) \
|
|
|
|
.arg(QString::fromLatin1(qVersion())); \
|
|
|
|
QMessageBox::critical(0, QApplication::tr("Incompatible Qt Library Error"), s, QMessageBox::Abort, \
|
|
|
|
static_cast<QMessageBox::StandardButton>(0)); \
|
|
|
|
qFatal("%s", s.toLatin1().data()); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-08-25 19:53:03 +02:00
|
|
|
|
2022-08-12 17:50:13 +02:00
|
|
|
auto main(int argc, char *argv[]) -> int
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2023-08-05 16:51:23 +02:00
|
|
|
Q_INIT_RESOURCE(cursor); // NOLINT
|
2023-08-28 16:25:22 +02:00
|
|
|
Q_INIT_RESOURCE(toolcursor); // NOLINT
|
2023-08-05 16:51:23 +02:00
|
|
|
Q_INIT_RESOURCE(icon); // NOLINT
|
|
|
|
Q_INIT_RESOURCE(schema); // NOLINT
|
|
|
|
Q_INIT_RESOURCE(flags); // NOLINT
|
|
|
|
Q_INIT_RESOURCE(icons); // NOLINT
|
|
|
|
Q_INIT_RESOURCE(toolicon); // NOLINT
|
|
|
|
Q_INIT_RESOURCE(breeze); // NOLINT
|
|
|
|
Q_INIT_RESOURCE(scenestyle); // NOLINT
|
2023-07-24 12:41:42 +02:00
|
|
|
#if defined(Q_OS_MACX)
|
2023-08-07 08:37:00 +02:00
|
|
|
Q_INIT_RESOURCE(mac_light_theme); // NOLINT
|
|
|
|
Q_INIT_RESOURCE(mac_dark_theme); // NOLINT
|
2023-08-18 12:49:13 +02:00
|
|
|
#endif
|
2023-08-07 08:37:00 +02:00
|
|
|
Q_INIT_RESOURCE(win_light_theme); // NOLINT
|
|
|
|
Q_INIT_RESOURCE(win_dark_theme); // NOLINT
|
2014-02-07 17:12:18 +01:00
|
|
|
|
2017-12-10 12:17:04 +01:00
|
|
|
#if defined(Q_OS_WIN)
|
|
|
|
VAbstractApplication::WinAttachConsole();
|
|
|
|
#endif
|
|
|
|
|
2017-03-28 11:08:33 +02:00
|
|
|
// Need to internally move a node inside a piece main path
|
2023-02-09 15:43:58 +01:00
|
|
|
REGISTER_META_TYPE_STREAM_OPERATORS(VPieceNode);
|
2018-12-21 12:01:32 +01:00
|
|
|
// Need to internally move a node inside a custom seam allowance path
|
2023-02-09 15:43:58 +01:00
|
|
|
REGISTER_META_TYPE_STREAM_OPERATORS(CustomSARecord);
|
2017-03-28 11:08:33 +02:00
|
|
|
|
2017-02-09 14:43:17 +01:00
|
|
|
#ifndef Q_OS_MAC // supports natively
|
2023-05-08 16:50:22 +02:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
2023-07-24 12:41:42 +02:00
|
|
|
VAbstractApplication::InitHighDpiScaling(argc, argv);
|
2023-05-08 16:50:22 +02:00
|
|
|
#endif
|
2023-07-24 12:41:42 +02:00
|
|
|
#endif // Q_OS_MAC
|
2016-11-04 11:47:10 +01:00
|
|
|
|
2023-02-17 10:09:41 +01:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
#if MACOS_LAYER_BACKING_AFFECTED
|
|
|
|
MacosEnableLayerBacking();
|
|
|
|
#endif // MACOS_LAYER_BACKING_AFFECTED
|
|
|
|
#endif // Q_OS_MAC
|
|
|
|
|
2023-02-09 16:17:08 +01:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize();
|
|
|
|
|
2023-07-24 12:41:42 +02:00
|
|
|
auto Terminate = qScopeGuard([]() { XERCES_CPP_NAMESPACE::XMLPlatformUtils::Terminate(); });
|
2023-02-09 16:17:08 +01:00
|
|
|
#endif
|
|
|
|
|
2013-10-01 20:15:59 +02:00
|
|
|
VApplication app(argc, argv);
|
2015-06-11 14:24:38 +02:00
|
|
|
app.InitOptions();
|
2014-02-19 22:34:57 +01:00
|
|
|
|
2024-01-23 14:57:23 +01:00
|
|
|
QT_REQUIRE_VERSION(argc, argv, "5.15.0") // clazy:exclude=qstring-arg,qstring-allocations NOLINT
|
2023-07-25 13:01:41 +02:00
|
|
|
|
2023-01-13 14:57:27 +01:00
|
|
|
VApplication::setDesktopFileName(QStringLiteral("ua.com.smart-pattern.valentina.desktop"));
|
2023-01-11 12:03:32 +01:00
|
|
|
|
2021-11-18 13:55:15 +01:00
|
|
|
if (VApplication::IsGUIMode() && VAbstractApplication::VApp()->Settings()->IsAutomaticallyCheckUpdates())
|
2016-07-15 12:14:48 +02:00
|
|
|
{
|
|
|
|
// Set feed URL before doing anything else
|
2018-02-06 12:38:05 +01:00
|
|
|
FvUpdater::sharedUpdater()->SetFeedURL(FvUpdater::CurrentFeedURL());
|
2016-07-15 11:00:00 +02:00
|
|
|
|
2016-07-15 12:14:48 +02:00
|
|
|
// Check for updates automatically
|
|
|
|
FvUpdater::sharedUpdater()->CheckForUpdatesSilent();
|
|
|
|
}
|
2016-07-15 11:00:00 +02:00
|
|
|
|
2013-06-20 16:09:50 +02:00
|
|
|
MainWindow w;
|
2015-12-05 15:16:29 +01:00
|
|
|
#if !defined(Q_OS_MAC)
|
2021-11-18 13:55:15 +01:00
|
|
|
VApplication::setWindowIcon(QIcon(":/icon/64x64/icon64x64.png"));
|
2015-12-05 15:16:29 +01:00
|
|
|
#endif // !defined(Q_OS_MAC)
|
2014-07-08 12:59:50 +02:00
|
|
|
app.setMainWindow(&w);
|
2015-08-27 18:03:43 +02:00
|
|
|
|
2016-01-08 12:08:54 +01:00
|
|
|
int msec = 0;
|
2023-07-24 12:41:42 +02:00
|
|
|
// Before we load pattern show window.
|
2016-01-08 12:08:54 +01:00
|
|
|
if (VApplication::IsGUIMode())
|
|
|
|
{
|
|
|
|
w.show();
|
|
|
|
msec = 15; // set delay for correct the first fitbest zoom
|
|
|
|
}
|
|
|
|
|
2018-04-18 10:15:53 +02:00
|
|
|
QTimer::singleShot(msec, &w, &MainWindow::ProcessCMD);
|
2014-07-13 14:49:00 +02:00
|
|
|
|
2022-08-12 17:50:13 +02:00
|
|
|
return VApplication::exec();
|
2013-06-20 16:09:50 +02:00
|
|
|
}
|