QEvent::ApplicationActivate has been deprecated. Use ApplicationStateChange instead.

This commit is contained in:
Roman Telezhynskyi 2023-11-09 17:59:21 +02:00
parent 9d652aa3b5
commit 4778102fc9
3 changed files with 41 additions and 31 deletions

View File

@ -43,6 +43,7 @@
#include "vpuzzleshortcutmanager.h"
#include <QCommandLineParser>
#include <QEvent>
#include <QFileOpenEvent>
#include <QLocalServer>
#include <QLocalSocket>
@ -557,8 +558,8 @@ auto VPApplication::event(QEvent *e) -> bool
// Mac specific).
case QEvent::FileOpen:
{
auto *fileOpenEvent =
static_cast<QFileOpenEvent *>(e); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
auto *fileOpenEvent = static_cast<QFileOpenEvent *>(e);
const QString macFileOpen = fileOpenEvent->file();
if (not macFileOpen.isEmpty())
{
@ -572,7 +573,9 @@ auto VPApplication::event(QEvent *e) -> bool
break;
}
#if defined(Q_OS_MAC)
case QEvent::ApplicationActivate:
case QEvent::ApplicationStateChange:
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
if (static_cast<QApplicationStateChangeEvent *>(e)->applicationState() == Qt::ApplicationActive)
{
Clean();
VPMainWindow *mw = MainWindow();
@ -580,8 +583,8 @@ auto VPApplication::event(QEvent *e) -> bool
{
mw->show();
}
return true;
}
return true;
#endif // defined(Q_OS_MAC)
default:
return VAbstractApplication::event(e);

View File

@ -69,6 +69,7 @@
#include <iostream>
#if !defined(BUILD_REVISION) && defined(QBS_BUILD)
#include <QEvent>
#include <vcsRepoState.h>
#define BUILD_REVISION VCS_REPO_STATE_REVISION
#endif
@ -551,6 +552,7 @@ auto MApplication::event(QEvent *e) -> bool
TKMMainWindow *mw = MainKMWindow();
if (mw)
{
m_knownMeasurementsMode = true;
mw->LoadFile(macFileOpen); // open file in existing window
}
}
@ -567,7 +569,9 @@ auto MApplication::event(QEvent *e) -> bool
break;
}
#if defined(Q_OS_MAC)
case QEvent::ApplicationActivate:
case QEvent::ApplicationStateChange:
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
if (static_cast<QApplicationStateChangeEvent *>(e)->applicationState() == Qt::ApplicationActive)
{
if (m_knownMeasurementsMode)
{

View File

@ -80,6 +80,7 @@
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
#include "../vmisc/backport/qscopeguard.h"
#else
#include <QEvent>
#include <QScopeGuard>
#endif
@ -860,7 +861,9 @@ auto VApplication::event(QEvent *e) -> bool
break;
}
#if defined(Q_OS_MAC)
case QEvent::ApplicationActivate:
case QEvent::ApplicationStateChange:
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
if (static_cast<QApplicationStateChangeEvent *>(e)->applicationState() == Qt::ApplicationActive)
{
if (mainWindow && not mainWindow->isMinimized())
{