Refactoring.
Code style.
This commit is contained in:
parent
3a7803b78f
commit
b5779ca3e8
|
@ -26,19 +26,20 @@
|
|||
**
|
||||
*************************************************************************/
|
||||
#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]()
|
||||
connect(ui->pathTable, &QTableWidget::itemSelectionChanged, this,
|
||||
[this]()
|
||||
{
|
||||
ui->defaultButton->setEnabled(not ui->pathTable->selectedItems().isEmpty());
|
||||
ui->defaultButton->setDefault(false);
|
||||
|
|
|
@ -30,11 +30,9 @@
|
|||
|
||||
#include <QWidget>
|
||||
|
||||
#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();
|
||||
|
|
|
@ -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 <QMessageBox>
|
||||
#include <QLoggingCategory>
|
||||
#include <QMessageBox>
|
||||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
|
||||
|
@ -55,9 +55,9 @@ Q_LOGGING_CATEGORY(pApp, "p.application") // NOLINT
|
|||
QT_WARNING_POP
|
||||
|
||||
#include <QCommandLineParser>
|
||||
#include <QLocalSocket>
|
||||
#include <QLocalServer>
|
||||
#include <QFileOpenEvent>
|
||||
#include <QLocalServer>
|
||||
#include <QLocalSocket>
|
||||
#include <QPixmapCache>
|
||||
|
||||
#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,10 +101,10 @@ 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)
|
||||
#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
|
||||
|
@ -113,9 +112,9 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
|
|||
{
|
||||
type = QtDebugMsg;
|
||||
}
|
||||
# endif
|
||||
#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,8 +183,8 @@ 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");
|
||||
QMessageBox messageBox;
|
||||
|
@ -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<VPMainWindow *>
|
||||
{
|
||||
Clean();
|
||||
QList<VPMainWindow*> list;
|
||||
QList<VPMainWindow *> 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();
|
||||
|
@ -453,7 +453,7 @@ void VPApplication::ActivateDarkMode()
|
|||
QFile f(QStringLiteral(":qdarkstyle/style.qss"));
|
||||
if (!f.exists())
|
||||
{
|
||||
qDebug()<<"Unable to set stylesheet, file not found\n";
|
||||
qDebug() << "Unable to set stylesheet, file not found\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -530,15 +530,16 @@ 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<QFileOpenEvent *>(e); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
|
||||
auto *fileOpenEvent =
|
||||
static_cast<QFileOpenEvent *>(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)
|
||||
|
@ -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()
|
||||
{
|
||||
QScopedPointer<QLocalSocket>socket(m_localServer->nextPendingConnection());
|
||||
QScopedPointer<QLocalSocket> 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<VPApplication*>(QCoreApplication::instance());
|
||||
return qobject_cast<VPApplication *>(QCoreApplication::instance());
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
class VPSettings : public VCommonSettings
|
||||
{
|
||||
Q_OBJECT // NOLINT
|
||||
|
||||
public:
|
||||
VPSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
|
||||
QObject *parent = nullptr);
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include <QXmlStreamReader>
|
||||
#include "../ifc/xml/vabstractconverter.h"
|
||||
#include "../layout/layoutdef.h"
|
||||
#include "../vmisc/defglobal.h"
|
||||
|
||||
#include <QLoggingCategory>
|
||||
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "tapepreferencespathpage.h"
|
||||
#include "ui_tapepreferencespathpage.h"
|
||||
#include "../../mapplication.h"
|
||||
#include "../../vtapesettings.h"
|
||||
#include "ui_tapepreferencespathpage.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
|
@ -43,7 +43,8 @@ TapePreferencesPathPage::TapePreferencesPathPage(QWidget *parent)
|
|||
|
||||
InitTable();
|
||||
|
||||
connect(ui->pathTable, &QTableWidget::itemSelectionChanged, this, [this]()
|
||||
connect(ui->pathTable, &QTableWidget::itemSelectionChanged, this,
|
||||
[this]()
|
||||
{
|
||||
ui->defaultButton->setEnabled(not ui->pathTable->selectedItems().isEmpty());
|
||||
ui->defaultButton->setDefault(false);
|
||||
|
|
|
@ -31,11 +31,9 @@
|
|||
|
||||
#include <QWidget>
|
||||
|
||||
#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
|
||||
|
|
|
@ -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 <QDir>
|
||||
#include <QFileOpenEvent>
|
||||
#include <QLocalSocket>
|
||||
#include <QResource>
|
||||
#include <QTranslator>
|
||||
#include <QPointer>
|
||||
#include <QLocalServer>
|
||||
#include <QMessageBox>
|
||||
#include <iostream>
|
||||
#include <QGlobalStatic>
|
||||
#include <QGridLayout>
|
||||
#include <QLocalServer>
|
||||
#include <QLocalSocket>
|
||||
#include <QMessageBox>
|
||||
#include <QPointer>
|
||||
#include <QResource>
|
||||
#include <QSpacerItem>
|
||||
#include <QThread>
|
||||
#include <QGlobalStatic>
|
||||
#include <QTranslator>
|
||||
#include <iostream>
|
||||
|
||||
#if !defined(BUILD_REVISION) && defined(QBS_BUILD)
|
||||
#include <vcsRepoState.h>
|
||||
|
@ -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
|
||||
|
@ -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,10 +130,10 @@ 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)
|
||||
#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
|
||||
|
@ -143,9 +141,9 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
|
|||
{
|
||||
type = QtDebugMsg;
|
||||
}
|
||||
# endif
|
||||
#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,8 +219,8 @@ 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");
|
||||
QMessageBox messageBox;
|
||||
|
@ -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<TMainWindow *>
|
||||
{
|
||||
Clean();
|
||||
QList<TMainWindow*> list;
|
||||
QList<TMainWindow *> list;
|
||||
list.reserve(m_mainWindows.size());
|
||||
for (auto &w : m_mainWindows)
|
||||
{
|
||||
|
@ -446,17 +445,17 @@ 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
|
||||
// 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();
|
||||
|
@ -473,7 +472,7 @@ void MApplication::ActivateDarkMode()
|
|||
QFile f(QStringLiteral(":qdarkstyle/style.qss"));
|
||||
if (!f.exists())
|
||||
{
|
||||
qDebug()<<"Unable to set stylesheet, file not found\n";
|
||||
qDebug() << "Unable to set stylesheet, file not found\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -481,7 +480,6 @@ void MApplication::ActivateDarkMode()
|
|||
QTextStream ts(&f);
|
||||
qApp->setStyleSheet(ts.readAll()); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -501,15 +499,16 @@ 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<QFileOpenEvent *>(e); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
|
||||
auto *fileOpenEvent =
|
||||
static_cast<QFileOpenEvent *>(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)
|
||||
|
@ -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<TMainWindow*> list = MainWindows();
|
||||
const QList<TMainWindow *> 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<MApplication*>(QCoreApplication::instance());
|
||||
return qobject_cast<MApplication *>(QCoreApplication::instance());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -757,18 +756,21 @@ 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."),
|
||||
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."),
|
||||
{{*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."),
|
||||
{{*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."),
|
||||
{{*SINGLE_OPTION_UNITS, *LONG_OPTION_UNITS},
|
||||
tr("Set pattern file units: cm, mm, inch."),
|
||||
tr("The pattern units")},
|
||||
|
||||
{*LONG_OPTION_TEST,
|
||||
|
@ -776,7 +778,8 @@ void MApplication::InitParserOptions(QCommandLineParser &parser)
|
|||
|
||||
{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")},
|
||||
"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;
|
||||
}
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "preferencespathpage.h"
|
||||
#include "ui_preferencespathpage.h"
|
||||
#include "../vmisc/vvalentinasettings.h"
|
||||
#include "../vmisc/vabstractvalapplication.h"
|
||||
#include "../vmisc/vvalentinasettings.h"
|
||||
#include "ui_preferencespathpage.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
|
@ -43,7 +43,8 @@ PreferencesPathPage::PreferencesPathPage(QWidget *parent)
|
|||
|
||||
InitTable();
|
||||
|
||||
connect(ui->pathTable, &QTableWidget::itemSelectionChanged, this, [this]()
|
||||
connect(ui->pathTable, &QTableWidget::itemSelectionChanged, this,
|
||||
[this]()
|
||||
{
|
||||
ui->defaultButton->setEnabled(not ui->pathTable->selectedItems().isEmpty());
|
||||
ui->defaultButton->setDefault(false);
|
||||
|
|
|
@ -31,11 +31,9 @@
|
|||
|
||||
#include <QWidget>
|
||||
|
||||
#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();
|
||||
|
|
|
@ -29,14 +29,15 @@
|
|||
#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)
|
||||
|
@ -49,8 +50,9 @@ public:
|
|||
class TestVApplication final : public VAbstractValApplication
|
||||
{
|
||||
Q_OBJECT // NOLINT
|
||||
|
||||
public:
|
||||
TestVApplication(int &argc, char ** argv)
|
||||
TestVApplication(int &argc, char **argv)
|
||||
: VAbstractValApplication(argc, argv),
|
||||
m_trVars(nullptr)
|
||||
{
|
||||
|
@ -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<TestVApplication *>(QCoreApplication::instance()); }
|
||||
|
||||
protected slots:
|
||||
virtual void AboutToQuit() override
|
||||
{}
|
||||
virtual void AboutToQuit() override {}
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY_MOVE(TestVApplication) // NOLINT
|
||||
|
|
|
@ -29,17 +29,21 @@
|
|||
#include "vabstractapplication.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QFuture>
|
||||
#include <QLibraryInfo>
|
||||
#include <QLoggingCategory>
|
||||
#include <QMessageLogger>
|
||||
#include <QStandardPaths>
|
||||
#include <QTranslator>
|
||||
#include <QUndoStack>
|
||||
#include <QWidget>
|
||||
#include <Qt>
|
||||
#include <QtDebug>
|
||||
#include <QWidget>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#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 <unistd.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(APPIMAGE) && defined(Q_OS_LINUX)
|
||||
# include "appimage.h"
|
||||
#include "appimage.h"
|
||||
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
|
||||
|
||||
namespace
|
||||
|
@ -103,7 +107,7 @@ const QString VAbstractApplication::warningMessageSignature = QStringLiteral("[P
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VAbstractApplication::VAbstractApplication(int &argc, char **argv)
|
||||
:QApplication(argc, argv),
|
||||
: 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:"<<locale;
|
||||
qDebug() << "Checked locale:" << locale;
|
||||
}
|
||||
|
||||
ClearTranslation();
|
||||
|
@ -322,7 +326,7 @@ void VAbstractApplication::LoadTranslation(QString locale)
|
|||
LoadQM(pmsTranslator, QStringLiteral("measurements_") + Settings()->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); });
|
||||
|
|
|
@ -29,25 +29,27 @@
|
|||
#ifndef VABSTRACTAPPLICATION_H
|
||||
#define VABSTRACTAPPLICATION_H
|
||||
|
||||
#include <qcompilerdetection.h>
|
||||
#include <QApplication>
|
||||
#include <QCoreApplication>
|
||||
#include <QFileDialog>
|
||||
#include <QLocale>
|
||||
#include <QMetaObject>
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
#include <QString>
|
||||
#include <QtGlobal>
|
||||
#include <QTranslator>
|
||||
#include <QFileDialog>
|
||||
#include <QtGlobal>
|
||||
#include <qcompilerdetection.h>
|
||||
|
||||
#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 <typename T> auto LocaleToString(const T &value) -> QString;
|
||||
|
@ -114,12 +117,12 @@ protected:
|
|||
QPointer<QTranslator> appTranslator{nullptr};
|
||||
QPointer<QTranslator> 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 <typename T> inline auto VAbstractApplication::LocaleToString(const T &
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline auto VAbstractApplication::VApp() -> VAbstractApplication *
|
||||
{
|
||||
return qobject_cast<VAbstractApplication*>(QCoreApplication::instance());
|
||||
return qobject_cast<VAbstractApplication *>(QCoreApplication::instance());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user