From 54252184ab3d42c92ecb4bbdb9cf449d7f181848 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 20 Jan 2022 00:35:12 +0800 Subject: [PATCH] Make use of std algorithms Since the result code is shorter. --- src/gui/mainwindow.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 0d7b7ebbf..ab8f34c2d 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -28,6 +28,7 @@ #include "mainwindow.h" +#include #include #include @@ -1279,15 +1280,9 @@ bool MainWindow::event(QEvent *e) { qDebug() << "Has active window:" << (qApp->activeWindow() != nullptr); // Check if there is a modal window - bool hasModalWindow = false; - for (QWidget *widget : asConst(QApplication::allWidgets())) - { - if (widget->isModal()) - { - hasModalWindow = true; - break; - } - } + const QWidgetList allWidgets = QApplication::allWidgets(); + const bool hasModalWindow = std::any_of(allWidgets.cbegin(), allWidgets.cend() + , [](const QWidget *widget) { return widget->isModal(); }); // Iconify if there is no modal window if (!hasModalWindow) {