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

View file

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

View file

@ -80,6 +80,7 @@
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
#include "../vmisc/backport/qscopeguard.h" #include "../vmisc/backport/qscopeguard.h"
#else #else
#include <QEvent>
#include <QScopeGuard> #include <QScopeGuard>
#endif #endif
@ -860,14 +861,16 @@ auto VApplication::event(QEvent *e) -> bool
break; break;
} }
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
case QEvent::ApplicationActivate: case QEvent::ApplicationStateChange:
{ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
if (mainWindow && not mainWindow->isMinimized()) 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) #endif // defined(Q_OS_MAC)
default: default:
return VAbstractApplication::event(e); return VAbstractApplication::event(e);