From b1f531924fd852714f9830bb17f96f83db9388fa Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 12 May 2025 22:50:06 -0400 Subject: [PATCH] Fix some of the broken native dialogs --- include/ui/message.h | 3 ++- src/mainwindow.cpp | 3 ++- src/ui/message.cpp | 12 ++++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/ui/message.h b/include/ui/message.h index 1756c48d..9d4770c6 100644 --- a/include/ui/message.h +++ b/include/ui/message.h @@ -38,7 +38,8 @@ public: class InfoMessage : public Message { public: InfoMessage(const QString &message, QWidget *parent); - static void show(const QString &message, QWidget *parent); + static void show(const QString &message, const QString &informativeText, QWidget *parent); + static void show(const QString &message, QWidget *parent) { InfoMessage::show(message, QString(), parent); } }; // Basic question message with a 'Yes' and 'No' button. diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 29d4a509..13d98923 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1895,7 +1895,8 @@ bool MainWindow::save(bool currentOnly) { if (success && !porymapConfig.shownInGameReloadMessage) { // Show a one-time warning that the user may need to reload their map to see their new changes. - InfoMessage::show(QStringLiteral("Reload your map in-game!\n\nIf your game is currently saved on a map you have edited, " + InfoMessage::show(QStringLiteral("Reload your map in-game!"), + QStringLiteral("If your game is currently saved on a map you have edited, " "the changes may not appear until you leave the map and return."), this); porymapConfig.shownInGameReloadMessage = true; diff --git a/src/ui/message.cpp b/src/ui/message.cpp index ce51f7c7..cb301918 100644 --- a/src/ui/message.cpp +++ b/src/ui/message.cpp @@ -7,6 +7,13 @@ Message::Message(QMessageBox::Icon icon, const QString &text, QMessageBox::Stand QMessageBox(icon, QApplication::applicationName(), text, buttons, parent) { setWindowModality(Qt::WindowModal); + + // QMessageBoxes with stylesheets are not allowed to be native (see Qt's QMessageBoxPrivate::canBeNativeDialog). + // We're preferring the native dialog appearance over Porymap's themes here. + // Frustratingly, it doesn't matter what's in the stylesheet. Even a stylesheet with just comments will trigger this, + // and manually setting the Message's stylesheet to an empty string doesn't undo this, so we need to explicitly clear + // the stylesheet attribute in order to use native dialogs. + setAttribute(Qt::WA_StyleSheet, false); } ErrorMessage::ErrorMessage(const QString &message, QWidget *parent) : @@ -75,8 +82,9 @@ int QuestionMessage::show(const QString &message, QWidget *parent) { return msgBox.exec(); }; -void InfoMessage::show(const QString &message, QWidget *parent) { +void InfoMessage::show(const QString &message, const QString &informativeText, QWidget *parent) { auto msgBox = new InfoMessage(message, parent); msgBox->setAttribute(Qt::WA_DeleteOnClose); + msgBox->setInformativeText(informativeText); msgBox->open(); -}; +}