Beautify QGuiApplication::event()

Replace if/elseif with a switch.

Task-number: QTBUG-112479
Task-number: QTBUG-119032
Pick-to: 6.5
Change-Id: Iff29fde6a9b9a16357b26cf90009fec7c9826349
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
(cherry picked from commit b3958d26caffaa90193e649024ff2c0bf953fc2d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Axel Spoerl 2023-11-10 19:04:34 +01:00 committed by Qt Cherry-pick Bot
parent 99cda97844
commit 5363ac342d

View File

@ -1997,7 +1997,8 @@ bool QGuiApplication::notify(QObject *object, QEvent *event)
*/
bool QGuiApplication::event(QEvent *e)
{
if (e->type() == QEvent::LanguageChange) {
switch (e->type()) {
case QEvent::LanguageChange:
// if the layout direction was set explicitly, then don't override it here
if (layout_direction == Qt::LayoutDirectionAuto)
setLayoutDirection(layout_direction);
@ -2005,13 +2006,15 @@ bool QGuiApplication::event(QEvent *e)
if (topLevelWindow->flags() != Qt::Desktop)
postEvent(topLevelWindow, new QEvent(QEvent::LanguageChange));
}
} else if (e->type() == QEvent::ApplicationFontChange ||
e->type() == QEvent::ApplicationPaletteChange) {
break;
case QEvent::ApplicationFontChange:
case QEvent::ApplicationPaletteChange:
for (auto *topLevelWindow : QGuiApplication::topLevelWindows()) {
if (topLevelWindow->flags() != Qt::Desktop)
postEvent(topLevelWindow, new QEvent(e->type()));
}
} else if (e->type() == QEvent::Quit) {
break;
case QEvent::Quit:
// Close open windows. This is done in order to deliver de-expose
// events while the event loop is still running.
for (QWindow *topLevelWindow : QGuiApplication::topLevelWindows()) {
@ -2023,8 +2026,9 @@ bool QGuiApplication::event(QEvent *e)
return true;
}
}
default:
break;
}
return QCoreApplication::event(e);
}