fix ports specific bugs

This commit is contained in:
Geoffray Levasseur committed 2026-11-04 17:11:16 +01:00
1 parent c30531e032
commit 80c329a697
3 files changed
+44 -6

No files matched your search

+25
View File
@@ -34,6 +34,7 @@
#include <QGuiApplication>
#include <QKeyEvent>
#include <QScreen>
#include <QWindow>
#include <QtMath>
namespace Dpi {
@@ -50,12 +51,36 @@ ModalResult Form::showModal()
{
setWindowModality(Qt::ApplicationModal);
m_modalResult = ModalResult::None;
// Without a transient parent, the window manager may stack the dialog behind the main window.
QWidget *owner = QApplication::activeWindow();
if (!owner || owner == this || !owner->isVisible()) {
owner = nullptr;
int bestArea = 0;
for (QWidget *candidate : QApplication::topLevelWidgets()) {
const int area = candidate->width() * candidate->height();
if (candidate != this && candidate->isVisible() && area > bestArea) {
owner = candidate;
bestArea = area;
}
}
}
if (owner) {
winId();
owner->winId(); // creates the native windows
if (windowHandle() && owner->windowHandle())
windowHandle()->setTransientParent(owner->windowHandle());
}
show();
raise();
QEventLoop loop;
m_modalLoop = &loop;
loop.exec();
m_modalLoop = nullptr;
setWindowModality(Qt::NonModal); // the same dialog may later be shown as a persistent window
if (windowHandle())
windowHandle()->setTransientParent(nullptr);
return m_modalResult;
}