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,16 +573,18 @@ auto VPApplication::event(QEvent *e) -> bool
break;
}
#if defined(Q_OS_MAC)
case QEvent::ApplicationActivate:
{
Clean();
VPMainWindow *mw = MainWindow();
if (mw && not mw->isMinimized())
case QEvent::ApplicationStateChange:
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
if (static_cast<QApplicationStateChangeEvent *>(e)->applicationState() == Qt::ApplicationActive)
{
mw->show();
Clean();
VPMainWindow *mw = MainWindow();
if (mw && not mw->isMinimized())
{
mw->show();
}
}
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,28 +569,30 @@ auto MApplication::event(QEvent *e) -> bool
break;
}
#if defined(Q_OS_MAC)
case QEvent::ApplicationActivate:
{
if (m_knownMeasurementsMode)
case QEvent::ApplicationStateChange:
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
if (static_cast<QApplicationStateChangeEvent *>(e)->applicationState() == Qt::ApplicationActive)
{
CleanKMWindows();
TKMMainWindow *mw = MainKMWindow();
if (mw && not mw->isMinimized())
if (m_knownMeasurementsMode)
{
mw->show();
CleanKMWindows();
TKMMainWindow *mw = MainKMWindow();
if (mw && not mw->isMinimized())
{
mw->show();
}
}
}
else
{
CleanTapeWindows();
TMainWindow *mw = MainTapeWindow();
if (mw && not mw->isMinimized())
else
{
mw->show();
CleanTapeWindows();
TMainWindow *mw = MainTapeWindow();
if (mw && not mw->isMinimized())
{
mw->show();
}
}
return true;
}
return true;
}
#endif // defined(Q_OS_MAC)
default:
return VAbstractApplication::event(e);

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,14 +861,16 @@ auto VApplication::event(QEvent *e) -> bool
break;
}
#if defined(Q_OS_MAC)
case QEvent::ApplicationActivate:
{
if (mainWindow && not mainWindow->isMinimized())
case QEvent::ApplicationStateChange:
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
if (static_cast<QApplicationStateChangeEvent *>(e)->applicationState() == Qt::ApplicationActive)
{
mainWindow->show();
if (mainWindow && not mainWindow->isMinimized())
{
mainWindow->show();
}
return true;
}
return true;
}
#endif // defined(Q_OS_MAC)
default:
return VAbstractApplication::event(e);