mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-26 18:47:07 -05:00
Fix some of the broken native dialogs
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user