From b5779ca3e8f4718b8edcec67501212488e65e4cb Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 8 Jun 2023 13:20:20 +0300 Subject: [PATCH] Refactoring. Code style. --- .../configpages/puzzlepreferencespathpage.cpp | 21 +- .../configpages/puzzlepreferencespathpage.h | 6 +- src/app/puzzle/vpapplication.cpp | 146 ++++++------ src/app/puzzle/vpsettings.h | 3 +- src/app/puzzle/xml/vplayoutfilereader.h | 1 - .../configpages/tapepreferencespathpage.cpp | 21 +- .../configpages/tapepreferencespathpage.h | 8 +- src/app/tape/mapplication.cpp | 214 +++++++++--------- .../configpages/preferencespathpage.cpp | 23 +- .../dialogs/configpages/preferencespathpage.h | 6 +- src/libs/vmisc/testvapplication.h | 27 +-- src/libs/vmisc/vabstractapplication.cpp | 32 +-- src/libs/vmisc/vabstractapplication.h | 23 +- 13 files changed, 268 insertions(+), 263 deletions(-) diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.cpp b/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.cpp index 66d4a54f2..9bce9d038 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.cpp +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.cpp @@ -26,26 +26,27 @@ ** *************************************************************************/ #include "puzzlepreferencespathpage.h" -#include "ui_puzzlepreferencespathpage.h" #include "../../vpapplication.h" +#include "ui_puzzlepreferencespathpage.h" //--------------------------------------------------------------------------------------------------------------------- -PuzzlePreferencesPathPage::PuzzlePreferencesPathPage(QWidget *parent) : - QWidget(parent), +PuzzlePreferencesPathPage::PuzzlePreferencesPathPage(QWidget *parent) + : QWidget(parent), ui(new Ui::PuzzlePreferencesPathPage) { ui->setupUi(this); InitTable(); - connect(ui->pathTable, &QTableWidget::itemSelectionChanged, this, [this]() - { - ui->defaultButton->setEnabled(not ui->pathTable->selectedItems().isEmpty()); - ui->defaultButton->setDefault(false); + connect(ui->pathTable, &QTableWidget::itemSelectionChanged, this, + [this]() + { + ui->defaultButton->setEnabled(not ui->pathTable->selectedItems().isEmpty()); + ui->defaultButton->setDefault(false); - ui->editButton->setEnabled(not ui->pathTable->selectedItems().isEmpty()); - ui->editButton->setDefault(true); - }); + ui->editButton->setEnabled(not ui->pathTable->selectedItems().isEmpty()); + ui->editButton->setDefault(true); + }); connect(ui->defaultButton, &QPushButton::clicked, this, &PuzzlePreferencesPathPage::DefaultPath); connect(ui->editButton, &QPushButton::clicked, this, &PuzzlePreferencesPathPage::EditPath); diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.h b/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.h index 09254588f..84be56a5b 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.h +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.h @@ -30,11 +30,9 @@ #include -#include "../vmisc/defglobal.h" - namespace Ui { - class PuzzlePreferencesPathPage; +class PuzzlePreferencesPathPage; } class PuzzlePreferencesPathPage : public QWidget @@ -48,7 +46,7 @@ public: void Apply(); protected: - void changeEvent(QEvent* event) override; + void changeEvent(QEvent *event) override; private slots: void DefaultPath(); diff --git a/src/app/puzzle/vpapplication.cpp b/src/app/puzzle/vpapplication.cpp index 2231b4fa0..aad7c7d2d 100644 --- a/src/app/puzzle/vpapplication.cpp +++ b/src/app/puzzle/vpapplication.cpp @@ -27,24 +27,24 @@ *************************************************************************/ #include "vpapplication.h" -#include "version.h" -#include "vpmainwindow.h" -#include "../ifc/exception/vexceptionobjecterror.h" #include "../ifc/exception/vexceptionbadid.h" #include "../ifc/exception/vexceptionconversionerror.h" #include "../ifc/exception/vexceptionemptyparameter.h" +#include "../ifc/exception/vexceptionobjecterror.h" #include "../ifc/exception/vexceptionwrongid.h" #include "../vmisc/vsysexits.h" +#include "version.h" +#include "vpmainwindow.h" #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) #include "../vmisc/diagnostic.h" #endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0) -#include "../vmisc/qt_dispatch/qt_dispatch.h" #include "../fervor/fvupdater.h" +#include "../vmisc/qt_dispatch/qt_dispatch.h" -#include #include +#include QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") @@ -55,9 +55,9 @@ Q_LOGGING_CATEGORY(pApp, "p.application") // NOLINT QT_WARNING_POP #include -#include -#include #include +#include +#include #include #if !defined(BUILD_REVISION) && defined(QBS_BUILD) @@ -66,7 +66,8 @@ QT_WARNING_POP #endif //--------------------------------------------------------------------------------------------------------------------- -inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) // NOLINT(readability-function-cognitive-complexity) +inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &context, + const QString &msg) // NOLINT(readability-function-cognitive-complexity) { // only the GUI thread should display message boxes. If you are // writing a multithreaded application and the error happens on @@ -77,9 +78,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con if (not isGuiThread) { auto Handler = [](QtMsgType type, const QMessageLogContext &context, const QString &msg) - { - noisyFailureMsgHandler(type, context, msg); - }; + { noisyFailureMsgHandler(type, context, msg); }; q_dispatch_async_main(Handler, type, context, msg); return; @@ -102,20 +101,20 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con { type = QtDebugMsg; } -#endif //defined(V_NO_ASSERT) +#endif // defined(V_NO_ASSERT) #if defined(Q_OS_MAC) -# 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 - if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QNSView"))) - { - type = QtDebugMsg; - } -# endif +#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 + if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QNSView"))) + { + type = QtDebugMsg; + } +#endif -# if QT_VERSION < QT_VERSION_CHECK(5, 9, 0) +#if QT_VERSION < QT_VERSION_CHECK(5, 9, 0) // Hide Qt bug 'Assertion when reading an icns file' // https://bugreports.qt.io/browse/QTBUG-45537 // Remove after Qt fix will be released @@ -123,7 +122,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con { type = QtDebugMsg; } -# endif +#endif // Hide anything that starts with QMacCGContext if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QMacCGContext::"))) @@ -141,8 +140,8 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con // 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) - if ((type == QtDebugMsg) && msg.contains(QStringLiteral("QPainter::begin")) - && msg.contains(QStringLiteral("Paint device returned engine"))) + if ((type == QtDebugMsg) && msg.contains(QStringLiteral("QPainter::begin")) && + msg.contains(QStringLiteral("Paint device returned engine"))) { type = QtWarningMsg; } @@ -150,8 +149,8 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con // 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. - if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QClipboard::event")) - && msg.contains(QStringLiteral("Cowardly refusing"))) + if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QClipboard::event")) && + msg.contains(QStringLiteral("Cowardly refusing"))) { type = QtDebugMsg; } @@ -170,11 +169,11 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con case QtFatalMsg: vStdErr() << QApplication::translate("mNoisyHandler", "FATAL:") << msg << "\n"; break; - #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) +#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) case QtInfoMsg: vStdOut() << QApplication::translate("mNoisyHandler", "INFO:") << msg << "\n"; break; - #endif +#endif default: break; } @@ -184,10 +183,10 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con if (isGuiThread) { - //fixme: trying to make sure there are no save/load dialogs are opened, because error message during them will - //lead to crash + // fixme: trying to make sure there are no save/load dialogs are opened, because error message during them will + // lead to crash const bool topWinAllowsPop = (QApplication::activeModalWidget() == nullptr) || - !QApplication::activeModalWidget()->inherits("QFileDialog"); + !QApplication::activeModalWidget()->inherits("QFileDialog"); QMessageBox messageBox; switch (type) { @@ -203,12 +202,12 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con messageBox.setWindowTitle(QApplication::translate("mNoisyHandler", "Fatal error")); messageBox.setIcon(QMessageBox::Critical); break; - #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) +#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) case QtInfoMsg: messageBox.setWindowTitle(QApplication::translate("mNoisyHandler", "Information")); messageBox.setIcon(QMessageBox::Information); break; - #endif +#endif case QtDebugMsg: Q_UNREACHABLE(); //-V501 break; @@ -226,13 +225,13 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con messageBox.setStandardButtons(QMessageBox::Ok); messageBox.setWindowModality(Qt::ApplicationModal); messageBox.setModal(true); - #ifndef QT_NO_CURSOR +#ifndef QT_NO_CURSOR QGuiApplication::setOverrideCursor(Qt::ArrowCursor); - #endif +#endif messageBox.exec(); - #ifndef QT_NO_CURSOR +#ifndef QT_NO_CURSOR QGuiApplication::restoreOverrideCursor(); - #endif +#endif } } } @@ -253,7 +252,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con //--------------------------------------------------------------------------------------------------------------------- VPApplication::VPApplication(int &argc, char **argv) - :VAbstractApplication(argc, argv) + : VAbstractApplication(argc, argv) { setApplicationDisplayName(QStringLiteral(VER_PRODUCTNAME_STR)); setApplicationName(QStringLiteral(VER_INTERNALNAME_STR)); @@ -289,7 +288,8 @@ auto VPApplication::notify(QObject *receiver, QEvent *event) -> bool } catch (const VExceptionObjectError &e) { - qCCritical(pApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file. Program will be terminated.")), //-V807 + qCCritical(pApp, "%s\n\n%s\n\n%s", + qUtf8Printable(tr("Error parsing file. Program will be terminated.")), //-V807 qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); exit(V_EX_DATAERR); } @@ -326,8 +326,8 @@ auto VPApplication::notify(QObject *receiver, QEvent *event) -> bool } catch (const VException &e) { - qCCritical(pApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Something's wrong!!")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + qCCritical(pApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Something's wrong!!")), qUtf8Printable(e.ErrorMessage()), + qUtf8Printable(e.DetailedInformation())); return true; } catch (std::exception &e) @@ -348,7 +348,7 @@ auto VPApplication::IsAppInGUIMode() const -> bool } //--------------------------------------------------------------------------------------------------------------------- -auto VPApplication::MainWindow()-> VPMainWindow * +auto VPApplication::MainWindow() -> VPMainWindow * { Clean(); if (m_mainWindows.isEmpty()) @@ -362,7 +362,7 @@ auto VPApplication::MainWindow()-> VPMainWindow * auto VPApplication::MainWindows() -> QList { Clean(); - QList list; + QList list; list.reserve(m_mainWindows.size()); for (auto &w : m_mainWindows) { @@ -406,19 +406,19 @@ void VPApplication::InitOptions() QPixmapCache::setCacheLimit(50 * 1024 /* 50 MB */); - LoadTranslation(QString());// By default the console version uses system locale + LoadTranslation(QString()); // By default the console version uses system locale VPCommandLine::Instance(); CheckSystemLocale(); - static const char * GENERIC_ICON_TO_CHECK = "document-open"; + static const char *GENERIC_ICON_TO_CHECK = "document-open"; if (not QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK)) { - //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 + // 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(QStringLiteral("win.icon.theme")); } ActivateDarkMode(); @@ -450,17 +450,17 @@ void VPApplication::ActivateDarkMode() VPSettings *settings = PuzzleSettings(); if (settings->GetDarkMode()) { - QFile f(QStringLiteral(":qdarkstyle/style.qss")); - if (!f.exists()) - { - qDebug()<<"Unable to set stylesheet, file not found\n"; - } - else - { - f.open(QFile::ReadOnly | QFile::Text); - QTextStream ts(&f); - VPApplication::VApp()->setStyleSheet(ts.readAll()); - } + QFile f(QStringLiteral(":qdarkstyle/style.qss")); + if (!f.exists()) + { + qDebug() << "Unable to set stylesheet, file not found\n"; + } + else + { + f.open(QFile::ReadOnly | QFile::Text); + QTextStream ts(&f); + VPApplication::VApp()->setStyleSheet(ts.readAll()); + } } } @@ -530,20 +530,21 @@ void VPApplication::ProcessCMD() //--------------------------------------------------------------------------------------------------------------------- auto VPApplication::event(QEvent *e) -> bool { - switch(e->type()) + 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: { - auto *fileOpenEvent = static_cast(e); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) + auto *fileOpenEvent = + static_cast(e); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) const QString macFileOpen = fileOpenEvent->file(); - if(not macFileOpen.isEmpty()) + if (not macFileOpen.isEmpty()) { VPMainWindow *mw = MainWindow(); if (mw != nullptr) { - mw->LoadFile(macFileOpen); // open file in existing window + mw->LoadFile(macFileOpen); // open file in existing window } return true; } @@ -560,7 +561,7 @@ auto VPApplication::event(QEvent *e) -> bool } return true; } -#endif //defined(Q_OS_MAC) +#endif // defined(Q_OS_MAC) default: return VAbstractApplication::event(e); } @@ -585,7 +586,7 @@ void VPApplication::AboutToQuit() //--------------------------------------------------------------------------------------------------------------------- void VPApplication::NewLocalSocketConnection() { - QScopedPointersocket(m_localServer->nextPendingConnection()); + QScopedPointer socket(m_localServer->nextPendingConnection()); if (socket.isNull()) { return; @@ -633,16 +634,15 @@ void VPApplication::StartLocalServer(const QString &serverName) connect(m_localServer, &QLocalServer::newConnection, this, &VPApplication::NewLocalSocketConnection); if (not m_localServer->listen(serverName)) { - qCDebug(pApp, "Can't begin to listen for incoming connections on name '%s'", - qUtf8Printable(serverName)); + qCDebug(pApp, "Can't begin to listen for incoming connections on name '%s'", qUtf8Printable(serverName)); if (m_localServer->serverError() == QAbstractSocket::AddressInUseError) { QLocalServer::removeServer(serverName); if (not m_localServer->listen(serverName)) { - qCWarning(pApp, "%s", - qUtf8Printable(tr("Can't begin to listen for incoming connections on name '%1'") - .arg(serverName))); + qCWarning( + pApp, "%s", + qUtf8Printable(tr("Can't begin to listen for incoming connections on name '%1'").arg(serverName))); } } } @@ -715,5 +715,5 @@ auto VPApplication::CommandLine() -> VPCommandLinePtr //--------------------------------------------------------------------------------------------------------------------- auto VPApplication::VApp() -> VPApplication * { - return qobject_cast(QCoreApplication::instance()); + return qobject_cast(QCoreApplication::instance()); } diff --git a/src/app/puzzle/vpsettings.h b/src/app/puzzle/vpsettings.h index dc5c04f64..f8691faa5 100644 --- a/src/app/puzzle/vpsettings.h +++ b/src/app/puzzle/vpsettings.h @@ -35,9 +35,10 @@ class VPSettings : public VCommonSettings { Q_OBJECT // NOLINT + public: VPSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), - QObject *parent = nullptr); + QObject *parent = nullptr); VPSettings(const QString &fileName, Format format, QObject *parent = nullptr); ~VPSettings() override = default; diff --git a/src/app/puzzle/xml/vplayoutfilereader.h b/src/app/puzzle/xml/vplayoutfilereader.h index bbb7146ca..e3502f7da 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.h +++ b/src/app/puzzle/xml/vplayoutfilereader.h @@ -32,7 +32,6 @@ #include #include "../ifc/xml/vabstractconverter.h" #include "../layout/layoutdef.h" -#include "../vmisc/defglobal.h" #include diff --git a/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp b/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp index dafa9975f..3fceb670d 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp +++ b/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp @@ -27,30 +27,31 @@ *************************************************************************/ #include "tapepreferencespathpage.h" -#include "ui_tapepreferencespathpage.h" #include "../../mapplication.h" #include "../../vtapesettings.h" +#include "ui_tapepreferencespathpage.h" #include #include //--------------------------------------------------------------------------------------------------------------------- TapePreferencesPathPage::TapePreferencesPathPage(QWidget *parent) - : QWidget(parent), - ui(new Ui::TapePreferencesPathPage) + : QWidget(parent), + ui(new Ui::TapePreferencesPathPage) { ui->setupUi(this); InitTable(); - connect(ui->pathTable, &QTableWidget::itemSelectionChanged, this, [this]() - { - ui->defaultButton->setEnabled(not ui->pathTable->selectedItems().isEmpty()); - ui->defaultButton->setDefault(false); + connect(ui->pathTable, &QTableWidget::itemSelectionChanged, this, + [this]() + { + ui->defaultButton->setEnabled(not ui->pathTable->selectedItems().isEmpty()); + ui->defaultButton->setDefault(false); - ui->editButton->setEnabled(not ui->pathTable->selectedItems().isEmpty()); - ui->editButton->setDefault(true); - }); + ui->editButton->setEnabled(not ui->pathTable->selectedItems().isEmpty()); + ui->editButton->setDefault(true); + }); connect(ui->defaultButton, &QPushButton::clicked, this, &TapePreferencesPathPage::DefaultPath); connect(ui->editButton, &QPushButton::clicked, this, &TapePreferencesPathPage::EditPath); diff --git a/src/app/tape/dialogs/configpages/tapepreferencespathpage.h b/src/app/tape/dialogs/configpages/tapepreferencespathpage.h index 8b8a8d389..6e47c8fce 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencespathpage.h +++ b/src/app/tape/dialogs/configpages/tapepreferencespathpage.h @@ -31,11 +31,9 @@ #include -#include "../vmisc/defglobal.h" - namespace Ui { - class TapePreferencesPathPage; +class TapePreferencesPathPage; } class TapePreferencesPathPage : public QWidget @@ -47,11 +45,13 @@ public: ~TapePreferencesPathPage() override; void Apply(); + protected: - void changeEvent(QEvent* event) override; + void changeEvent(QEvent *event) override; private slots: void DefaultPath(); void EditPath(); + private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(TapePreferencesPathPage) // NOLINT diff --git a/src/app/tape/mapplication.cpp b/src/app/tape/mapplication.cpp index 9c8d46821..17a841bb4 100644 --- a/src/app/tape/mapplication.cpp +++ b/src/app/tape/mapplication.cpp @@ -27,37 +27,37 @@ *************************************************************************/ #include "mapplication.h" -#include "version.h" -#include "tmainwindow.h" -#include "../ifc/exception/vexceptionobjecterror.h" #include "../ifc/exception/vexceptionbadid.h" #include "../ifc/exception/vexceptionconversionerror.h" #include "../ifc/exception/vexceptionemptyparameter.h" +#include "../ifc/exception/vexceptionobjecterror.h" #include "../ifc/exception/vexceptionwrongid.h" -#include "../vmisc/vsysexits.h" #include "../vmisc/projectversion.h" +#include "../vmisc/vsysexits.h" +#include "tmainwindow.h" +#include "version.h" #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) #include "../vmisc/diagnostic.h" #endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0) -#include "../vmisc/qt_dispatch/qt_dispatch.h" -#include "../qmuparser/qmuparsererror.h" #include "../fervor/fvupdater.h" +#include "../qmuparser/qmuparsererror.h" +#include "../vmisc/qt_dispatch/qt_dispatch.h" #include #include -#include -#include -#include -#include -#include -#include -#include +#include #include +#include +#include +#include +#include +#include #include #include -#include +#include +#include #if !defined(BUILD_REVISION) && defined(QBS_BUILD) #include @@ -65,7 +65,7 @@ #endif #if defined(APPIMAGE) && defined(Q_OS_LINUX) -# include "../vmisc/appimage.h" +#include "../vmisc/appimage.h" #endif // defined(APPIMAGE) && defined(Q_OS_LINUX) QT_WARNING_PUSH @@ -81,19 +81,19 @@ QT_WARNING_POP namespace { Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_DIMENSION_A, (QLatin1String("dimensionA"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_DIMENSION_A, (QChar('a'))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_DIMENSION_A, (QChar('a'))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_DIMENSION_B, (QLatin1String("dimensionB"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_DIMENSION_B, (QChar('b'))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_DIMENSION_B, (QChar('b'))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_DIMENSION_C, (QLatin1String("dimensionC"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_DIMENSION_C, (QChar('c'))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_DIMENSION_C, (QChar('c'))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_UNITS, (QLatin1String("units"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_UNITS, (QChar('u'))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_UNITS, (QChar('u'))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_TEST, (QLatin1String("test"))) // NOLINT -} // namespace +} // namespace //--------------------------------------------------------------------------------------------------------------------- inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) @@ -107,9 +107,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con if (not isGuiThread) { auto Handler = [](QtMsgType type, const QMessageLogContext &context, const QString &msg) - { - noisyFailureMsgHandler(type, context, msg); - }; + { noisyFailureMsgHandler(type, context, msg); }; q_dispatch_async_main(Handler, type, context, msg); return; @@ -132,20 +130,20 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con { type = QtDebugMsg; } -#endif //defined(V_NO_ASSERT) +#endif // defined(V_NO_ASSERT) #if defined(Q_OS_MAC) -# 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 - if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QNSView"))) - { - type = QtDebugMsg; - } -# endif +#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 + if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QNSView"))) + { + type = QtDebugMsg; + } +#endif -# if QT_VERSION < QT_VERSION_CHECK(5, 9, 0) +#if QT_VERSION < QT_VERSION_CHECK(5, 9, 0) // Hide Qt bug 'Assertion when reading an icns file' // https://bugreports.qt.io/browse/QTBUG-45537 // Remove after Qt fix will be released @@ -153,7 +151,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con { type = QtDebugMsg; } -# endif +#endif // Hide anything that starts with QMacCGContext if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QMacCGContext::"))) @@ -171,8 +169,8 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con // 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) - if ((type == QtDebugMsg) && msg.contains(QStringLiteral("QPainter::begin")) - && msg.contains(QStringLiteral("Paint device returned engine"))) + if ((type == QtDebugMsg) && msg.contains(QStringLiteral("QPainter::begin")) && + msg.contains(QStringLiteral("Paint device returned engine"))) { type = QtWarningMsg; } @@ -180,8 +178,8 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con // 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. - if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QClipboard::event")) - && msg.contains(QStringLiteral("Cowardly refusing"))) + if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QClipboard::event")) && + msg.contains(QStringLiteral("Cowardly refusing"))) { type = QtDebugMsg; } @@ -207,11 +205,11 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con case QtFatalMsg: vStdErr() << QApplication::translate("mNoisyHandler", "FATAL:") << logMsg << "\n"; break; - #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) +#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) case QtInfoMsg: vStdOut() << QApplication::translate("mNoisyHandler", "INFO:") << logMsg << "\n"; break; - #endif +#endif default: break; } @@ -221,10 +219,10 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con if (isGuiThread) { - //fixme: trying to make sure there are no save/load dialogs are opened, because error message during them will - //lead to crash + // fixme: trying to make sure there are no save/load dialogs are opened, because error message during them will + // lead to crash const bool topWinAllowsPop = (QApplication::activeModalWidget() == nullptr) || - !QApplication::activeModalWidget()->inherits("QFileDialog"); + !QApplication::activeModalWidget()->inherits("QFileDialog"); QMessageBox messageBox; switch (type) { @@ -240,12 +238,12 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con messageBox.setWindowTitle(QApplication::translate("mNoisyHandler", "Fatal error")); messageBox.setIcon(QMessageBox::Critical); break; - #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) +#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) case QtInfoMsg: messageBox.setWindowTitle(QApplication::translate("mNoisyHandler", "Information")); messageBox.setIcon(QMessageBox::Information); break; - #endif +#endif case QtDebugMsg: Q_UNREACHABLE(); //-V501 break; @@ -263,13 +261,13 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con messageBox.setStandardButtons(QMessageBox::Ok); messageBox.setWindowModality(Qt::ApplicationModal); messageBox.setModal(true); - #ifndef QT_NO_CURSOR +#ifndef QT_NO_CURSOR QGuiApplication::setOverrideCursor(Qt::ArrowCursor); - #endif +#endif messageBox.exec(); - #ifndef QT_NO_CURSOR +#ifndef QT_NO_CURSOR QGuiApplication::restoreOverrideCursor(); - #endif +#endif } } } @@ -290,7 +288,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con //--------------------------------------------------------------------------------------------------------------------- MApplication::MApplication(int &argc, char **argv) - :VAbstractApplication(argc, argv) + : VAbstractApplication(argc, argv) { setApplicationDisplayName(QStringLiteral(VER_PRODUCTNAME_STR)); setApplicationName(QStringLiteral(VER_INTERNALNAME_STR)); @@ -332,7 +330,8 @@ auto MApplication::notify(QObject *receiver, QEvent *event) -> bool } catch (const VExceptionObjectError &e) { - qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file. Program will be terminated.")), //-V807 + qCCritical(mApp, "%s\n\n%s\n\n%s", + qUtf8Printable(tr("Error parsing file. Program will be terminated.")), //-V807 qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); exit(V_EX_DATAERR); } @@ -369,8 +368,8 @@ auto MApplication::notify(QObject *receiver, QEvent *event) -> bool } catch (const VException &e) { - qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Something's wrong!!")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Something's wrong!!")), qUtf8Printable(e.ErrorMessage()), + qUtf8Printable(e.DetailedInformation())); return true; } catch (const qmu::QmuParserWarning &e) @@ -423,7 +422,7 @@ auto MApplication::MainWindow() -> TMainWindow * auto MApplication::MainWindows() -> QList { Clean(); - QList list; + QList list; list.reserve(m_mainWindows.size()); for (auto &w : m_mainWindows) { @@ -446,18 +445,18 @@ void MApplication::InitOptions() qCDebug(mApp, "Command-line arguments: %s", qUtf8Printable(arguments().join(QStringLiteral(", ")))); qCDebug(mApp, "Process ID: %s", qUtf8Printable(QString().setNum(applicationPid()))); - LoadTranslation(QString());// By default the console version uses system locale + LoadTranslation(QString()); // By default the console version uses system locale CheckSystemLocale(); - static const char * GENERIC_ICON_TO_CHECK = "document-open"; + static const char *GENERIC_ICON_TO_CHECK = "document-open"; if (not QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK)) { - //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(QStringLiteral("win.icon.theme")); + // 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(QStringLiteral("win.icon.theme")); } ActivateDarkMode(); QResource::registerResource(diagramsPath()); @@ -468,21 +467,20 @@ void MApplication::InitOptions() void MApplication::ActivateDarkMode() { VTapeSettings *settings = TapeSettings(); - if (settings->GetDarkMode()) - { - QFile f(QStringLiteral(":qdarkstyle/style.qss")); - if (!f.exists()) - { - qDebug()<<"Unable to set stylesheet, file not found\n"; - } - else - { - f.open(QFile::ReadOnly | QFile::Text); - QTextStream ts(&f); - qApp->setStyleSheet(ts.readAll()); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) - } - - } + if (settings->GetDarkMode()) + { + QFile f(QStringLiteral(":qdarkstyle/style.qss")); + if (!f.exists()) + { + qDebug() << "Unable to set stylesheet, file not found\n"; + } + else + { + f.open(QFile::ReadOnly | QFile::Text); + QTextStream ts(&f); + qApp->setStyleSheet(ts.readAll()); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) + } + } } //--------------------------------------------------------------------------------------------------------------------- @@ -501,20 +499,21 @@ void MApplication::InitTrVars() //--------------------------------------------------------------------------------------------------------------------- auto MApplication::event(QEvent *e) -> bool { - switch(e->type()) + 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: { - auto *fileOpenEvent = static_cast(e); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) + auto *fileOpenEvent = + static_cast(e); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) const QString macFileOpen = fileOpenEvent->file(); - if(not macFileOpen.isEmpty()) + if (not macFileOpen.isEmpty()) { TMainWindow *mw = MainWindow(); if (mw) { - mw->LoadFile(macFileOpen); // open file in existing window + mw->LoadFile(macFileOpen); // open file in existing window } return true; } @@ -531,7 +530,7 @@ auto MApplication::event(QEvent *e) -> bool } return true; } -#endif //defined(Q_OS_MAC) +#endif // defined(Q_OS_MAC) default: return VAbstractApplication::event(e); } @@ -629,7 +628,7 @@ void MApplication::RetranslateGroups() //--------------------------------------------------------------------------------------------------------------------- void MApplication::RetranslateTables() { - const QList list = MainWindows(); + const QList list = MainWindows(); for (auto *w : list) { w->RetranslateTable(); @@ -688,7 +687,7 @@ void MApplication::ParseCommandLine(const SocketConnection &connection, const QS //--------------------------------------------------------------------------------------------------------------------- auto MApplication::VApp() -> MApplication * { - return qobject_cast(QCoreApplication::instance()); + return qobject_cast(QCoreApplication::instance()); } //--------------------------------------------------------------------------------------------------------------------- @@ -757,27 +756,31 @@ void MApplication::InitParserOptions(QCommandLineParser &parser) { parser.addPositionalArgument(QStringLiteral("filename"), tr("The measurement file.")); - parser.addOptions( - { - {{*SINGLE_OPTION_DIMENSION_A, *LONG_OPTION_DIMENSION_A}, tr("Set base for dimension A in the table units."), - tr("The dimension A base")}, + parser.addOptions({ + {{*SINGLE_OPTION_DIMENSION_A, *LONG_OPTION_DIMENSION_A}, + tr("Set base for dimension A in the table units."), + tr("The dimension A base")}, - {{*SINGLE_OPTION_DIMENSION_B, *LONG_OPTION_DIMENSION_B}, tr("Set base for dimension B in the table units."), - tr("The dimension B base")}, + {{*SINGLE_OPTION_DIMENSION_B, *LONG_OPTION_DIMENSION_B}, + tr("Set base for dimension B in the table units."), + tr("The dimension B base")}, - {{*SINGLE_OPTION_DIMENSION_C, *LONG_OPTION_DIMENSION_C}, tr("Set base for dimension C in the table units."), - tr("The dimension C base")}, + {{*SINGLE_OPTION_DIMENSION_C, *LONG_OPTION_DIMENSION_C}, + tr("Set base for dimension C in the table units."), + tr("The dimension C base")}, - {{*SINGLE_OPTION_UNITS, *LONG_OPTION_UNITS}, tr("Set pattern file units: cm, mm, inch."), - tr("The pattern units")}, + {{*SINGLE_OPTION_UNITS, *LONG_OPTION_UNITS}, + tr("Set pattern file units: cm, mm, inch."), + tr("The pattern units")}, {*LONG_OPTION_TEST, - tr("Use for unit testing. Run the program and open a file without showing the main window.")}, + tr("Use for unit testing. Run the program and open a file without showing the main window.")}, {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 %1 environment variable.").arg("QT_AUTO_SCREEN_SCALE_FACTOR=0")}, - }); + tr("Disable high dpi scaling. Call this option if has problem with scaling (by default scaling enabled). " + "Alternatively you can use the %1 environment variable.") + .arg("QT_AUTO_SCREEN_SCALE_FACTOR=0")}, + }); } //--------------------------------------------------------------------------------------------------------------------- @@ -787,16 +790,15 @@ void MApplication::StartLocalServer(const QString &serverName) connect(m_localServer, &QLocalServer::newConnection, this, &MApplication::NewLocalSocketConnection); if (not m_localServer->listen(serverName)) { - qCDebug(mApp, "Can't begin to listen for incoming connections on name '%s'", - qUtf8Printable(serverName)); + qCDebug(mApp, "Can't begin to listen for incoming connections on name '%s'", qUtf8Printable(serverName)); if (m_localServer->serverError() == QAbstractSocket::AddressInUseError) { QLocalServer::removeServer(serverName); if (not m_localServer->listen(serverName)) { - qCWarning(mApp, "%s", - qUtf8Printable(tr("Can't begin to listen for incoming connections on name '%1'") - .arg(serverName))); + qCWarning( + mApp, "%s", + qUtf8Printable(tr("Can't begin to listen for incoming connections on name '%1'").arg(serverName))); } } } @@ -896,7 +898,7 @@ void MApplication::ParseDimensionAOption(QCommandLineParser &parser, int &dimens bool ok = false; dimensionAValue = value.toInt(&ok); - if(ok && dimensionAValue > 0) + if (ok && dimensionAValue > 0) { flagDimensionA = true; } @@ -917,7 +919,7 @@ void MApplication::ParseDimensionBOption(QCommandLineParser &parser, int &dimens bool ok = false; dimensionBValue = value.toInt(&ok); - if(ok && dimensionBValue > 0) + if (ok && dimensionBValue > 0) { flagDimensionB = true; } @@ -938,7 +940,7 @@ void MApplication::ParseDimensionCOption(QCommandLineParser &parser, int &dimens bool ok = false; dimensionCValue = value.toInt(&ok); - if(ok && dimensionCValue > 0) + if (ok && dimensionCValue > 0) { flagDimensionC = true; } diff --git a/src/app/valentina/dialogs/configpages/preferencespathpage.cpp b/src/app/valentina/dialogs/configpages/preferencespathpage.cpp index 8181ad81a..8e6f003dd 100644 --- a/src/app/valentina/dialogs/configpages/preferencespathpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespathpage.cpp @@ -27,30 +27,31 @@ *************************************************************************/ #include "preferencespathpage.h" -#include "ui_preferencespathpage.h" -#include "../vmisc/vvalentinasettings.h" #include "../vmisc/vabstractvalapplication.h" +#include "../vmisc/vvalentinasettings.h" +#include "ui_preferencespathpage.h" #include #include //--------------------------------------------------------------------------------------------------------------------- PreferencesPathPage::PreferencesPathPage(QWidget *parent) - : QWidget(parent), - ui(new Ui::PreferencesPathPage) + : QWidget(parent), + ui(new Ui::PreferencesPathPage) { ui->setupUi(this); InitTable(); - connect(ui->pathTable, &QTableWidget::itemSelectionChanged, this, [this]() - { - ui->defaultButton->setEnabled(not ui->pathTable->selectedItems().isEmpty()); - ui->defaultButton->setDefault(false); + connect(ui->pathTable, &QTableWidget::itemSelectionChanged, this, + [this]() + { + ui->defaultButton->setEnabled(not ui->pathTable->selectedItems().isEmpty()); + ui->defaultButton->setDefault(false); - ui->editButton->setEnabled(not ui->pathTable->selectedItems().isEmpty()); - ui->editButton->setDefault(true); - }); + ui->editButton->setEnabled(not ui->pathTable->selectedItems().isEmpty()); + ui->editButton->setDefault(true); + }); connect(ui->defaultButton, &QPushButton::clicked, this, &PreferencesPathPage::DefaultPath); connect(ui->editButton, &QPushButton::clicked, this, &PreferencesPathPage::EditPath); diff --git a/src/app/valentina/dialogs/configpages/preferencespathpage.h b/src/app/valentina/dialogs/configpages/preferencespathpage.h index 7bceac358..0c2dede52 100644 --- a/src/app/valentina/dialogs/configpages/preferencespathpage.h +++ b/src/app/valentina/dialogs/configpages/preferencespathpage.h @@ -31,11 +31,9 @@ #include -#include "../vmisc/defglobal.h" - namespace Ui { - class PreferencesPathPage; +class PreferencesPathPage; } class PreferencesPathPage : public QWidget @@ -49,7 +47,7 @@ public: auto Apply() -> QStringList; protected: - void changeEvent(QEvent* event) override; + void changeEvent(QEvent *event) override; private slots: void DefaultPath(); diff --git a/src/libs/vmisc/testvapplication.h b/src/libs/vmisc/testvapplication.h index 4f1069158..9e12a7279 100644 --- a/src/libs/vmisc/testvapplication.h +++ b/src/libs/vmisc/testvapplication.h @@ -29,18 +29,19 @@ #ifndef TESTVAPPLICATION_H #define TESTVAPPLICATION_H -#include "vabstractvalapplication.h" -#include "projectversion.h" -#include "../vmisc/vcommonsettings.h" #include "../vmisc/compatibility.h" +#include "../vmisc/vcommonsettings.h" +#include "projectversion.h" +#include "vabstractvalapplication.h" class VTestSettings : public VCommonSettings { Q_OBJECT // NOLINT + public: VTestSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), QObject *parent = nullptr) - : VCommonSettings(format, scope, organization, application, parent) + : VCommonSettings(format, scope, organization, application, parent) { REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF); } @@ -49,10 +50,11 @@ public: class TestVApplication final : public VAbstractValApplication { Q_OBJECT // NOLINT + public: - TestVApplication(int &argc, char ** argv) - : VAbstractValApplication(argc, argv), - m_trVars(nullptr) + TestVApplication(int &argc, char **argv) + : VAbstractValApplication(argc, argv), + m_trVars(nullptr) { setApplicationName("ValentinaTest"); setOrganizationName(VER_COMPANYNAME_STR); @@ -72,19 +74,14 @@ public: virtual auto IsAppInGUIMode() const -> bool override { return false; } - virtual void InitTrVars() override - {} + virtual void InitTrVars() override {} - void SetTrVars(VTranslateVars *trVars) - { - m_trVars = trVars; - } + void SetTrVars(VTranslateVars *trVars) { m_trVars = trVars; } static auto VApp() -> TestVApplication * { return static_cast(QCoreApplication::instance()); } protected slots: - virtual void AboutToQuit() override - {} + virtual void AboutToQuit() override {} private: Q_DISABLE_COPY_MOVE(TestVApplication) // NOLINT diff --git a/src/libs/vmisc/vabstractapplication.cpp b/src/libs/vmisc/vabstractapplication.cpp index ce783e8b4..40d9855f0 100644 --- a/src/libs/vmisc/vabstractapplication.cpp +++ b/src/libs/vmisc/vabstractapplication.cpp @@ -29,17 +29,21 @@ #include "vabstractapplication.h" #include +#include +#include #include #include #include +#include #include #include +#include #include #include -#include -#include +#include "QtConcurrent/qtconcurrentrun.h" #include "compatibility.h" +#include "svgfont/vsvgfontdatabase.h" #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #include "../vmisc/vtextcodec.h" @@ -48,11 +52,11 @@ #endif #ifdef Q_OS_UNIX -# include +#include #endif #if defined(APPIMAGE) && defined(Q_OS_LINUX) -# include "appimage.h" +#include "appimage.h" #endif // defined(APPIMAGE) && defined(Q_OS_LINUX) namespace @@ -97,14 +101,14 @@ auto LoadQM(QTranslator *translator, const QString &filename, const QString &loc return false; } -} // namespace +} // namespace const QString VAbstractApplication::warningMessageSignature = QStringLiteral("[PATTERN MESSAGE]"); //--------------------------------------------------------------------------------------------------------------------- VAbstractApplication::VAbstractApplication(int &argc, char **argv) - :QApplication(argc, argv), - undoStack(new QUndoStack(this)) + : QApplication(argc, argv), + undoStack(new QUndoStack(this)) { QString rules; @@ -116,7 +120,7 @@ VAbstractApplication::VAbstractApplication(int &argc, char **argv) // See issue #568: Certificate checking on Mac OS X. rules += QLatin1String("qt.network.ssl.critical=false\n" "qt.network.ssl.fatal=false\n"); -#endif //defined(V_NO_ASSERT) +#endif // defined(V_NO_ASSERT) #endif // QT_VERSION >= QT_VERSION_CHECK(5, 4, 1) #if defined(V_NO_ASSERT) @@ -185,8 +189,8 @@ auto VAbstractApplication::translationsPath(const QString &locale) -> QString } else { - mainPath = QCoreApplication::applicationDirPath() + QLatin1String("/../Resources") + trPath + QLatin1String("/") - + locale + QLatin1String(".lproj"); + mainPath = QCoreApplication::applicationDirPath() + QLatin1String("/../Resources") + trPath + + QLatin1String("/") + locale + QLatin1String(".lproj"); } QDir dirBundle(mainPath); if (dirBundle.exists()) @@ -284,11 +288,11 @@ void VAbstractApplication::LoadTranslation(QString locale) if (locale.isEmpty()) { - qDebug()<<"Default locale"; + qDebug() << "Default locale"; } else { - qDebug()<<"Checked locale:"<GetPMSystemCode() + '_', locale, appQmDir); installTranslator(pmsTranslator); - InitTrVars();//Very important do it after load QM files. + InitTrVars(); // Very important do it after load QM files. } //--------------------------------------------------------------------------------------------------------------------- @@ -428,7 +432,7 @@ void VAbstractApplication::CheckSystemLocale() qFatal("Incompatible locale \"%s\"", qPrintable(defLocale)); } - auto CheckLanguage =[](QStandardPaths::StandardLocation type, const QStringList &test) + auto CheckLanguage = [](QStandardPaths::StandardLocation type, const QStringList &test) { const QString path = QStandardPaths::locate(type, QString(), QStandardPaths::LocateDirectory); return std::any_of(test.begin(), test.end(), [path](const QString &t) { return path.contains(t); }); diff --git a/src/libs/vmisc/vabstractapplication.h b/src/libs/vmisc/vabstractapplication.h index e608efab9..5b8fdac73 100644 --- a/src/libs/vmisc/vabstractapplication.h +++ b/src/libs/vmisc/vabstractapplication.h @@ -29,25 +29,27 @@ #ifndef VABSTRACTAPPLICATION_H #define VABSTRACTAPPLICATION_H -#include #include #include +#include #include #include #include #include #include -#include #include -#include +#include +#include #include "../vmisc/def.h" #include "../vpatterndb/vtranslatevars.h" #include "vcommonsettings.h" class QUndoStack; -class VAbstractApplication;// use in define +class VAbstractApplication; // use in define class VCommonSettings; +class VSvgFontDatabase; +class QFileSystemWatcher; #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) class VTextCodec; @@ -60,9 +62,10 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods") class VAbstractApplication : public QApplication { Q_OBJECT // NOLINT + public: - VAbstractApplication(int &argc, char ** argv); - virtual ~VAbstractApplication(); + VAbstractApplication(int &argc, char **argv); + ~VAbstractApplication() override; virtual auto TrVars() -> const VTranslateVars * = 0; @@ -70,7 +73,7 @@ public: void LoadTranslation(QString locale); - virtual void OpenSettings()=0; + virtual void OpenSettings() = 0; auto Settings() -> VCommonSettings *; template auto LocaleToString(const T &value) -> QString; @@ -114,12 +117,12 @@ protected: QPointer appTranslator{nullptr}; QPointer pmsTranslator{nullptr}; - virtual void InitTrVars()=0; + virtual void InitTrVars() = 0; static void CheckSystemLocale(); protected slots: - virtual void AboutToQuit()=0; + virtual void AboutToQuit() = 0; private: Q_DISABLE_COPY_MOVE(VAbstractApplication) // NOLINT @@ -144,7 +147,7 @@ template inline auto VAbstractApplication::LocaleToString(const T & //--------------------------------------------------------------------------------------------------------------------- inline auto VAbstractApplication::VApp() -> VAbstractApplication * { - return qobject_cast(QCoreApplication::instance()); + return qobject_cast(QCoreApplication::instance()); } //---------------------------------------------------------------------------------------------------------------------