diff --git a/src/OMODFrameworkWrapper.cpp b/src/OMODFrameworkWrapper.cpp index da789e9..fcf6127 100644 --- a/src/OMODFrameworkWrapper.cpp +++ b/src/OMODFrameworkWrapper.cpp @@ -411,11 +411,11 @@ void OMODFrameworkWrapper::displayReadmeSlot(const QString& modName, const QStri { // TODO: ideally this wouldn't be part of the same window heirarchy so that modal popups in the installer don't prevent it being moved/resized etc. // DarNified UI's popups are modal for the whole process, so any fancy trick needs to be *here*. - RtfPopup* readmePopup = new RtfPopup(toDotNetString(readme), mParentWidget); + RtfPopup* readmePopup = new RtfPopup(toDotNetString(readme), nullptr); //: %1 is the mod name readmePopup->setWindowTitle(tr("%1 Readme").arg(modName)); - readmePopup->show(); readmePopup->setAttribute(Qt::WA_DeleteOnClose); + readmePopup->show(); } } diff --git a/src/implementations/ScriptFunctions.cpp b/src/implementations/ScriptFunctions.cpp index 6418785..2d81a5e 100644 --- a/src/implementations/ScriptFunctions.cpp +++ b/src/implementations/ScriptFunctions.cpp @@ -90,7 +90,11 @@ void ScriptFunctionsHelper::DisplayTextSlot(QWidget* parentWidget, const QString popup.setWindowTitle(title); // the size readmes are becoming automatically popup.resize(492, 366); - popup.exec(); + popup.setWindowModality(Qt::ApplicationModal); + popup.show(); + QEventLoop loop; + connect(&popup, SIGNAL(closed()), &loop, SLOT(quit()), Qt::DirectConnection); + loop.exec(); } void ScriptFunctionsHelper::DialogSelectSlot(std::optional>& resultOut, QWidget* parent, const QString& title, const QVector& items, diff --git a/src/newstuff/rtfPopup.cpp b/src/newstuff/rtfPopup.cpp index 476f078..73d3073 100644 --- a/src/newstuff/rtfPopup.cpp +++ b/src/newstuff/rtfPopup.cpp @@ -8,18 +8,16 @@ #include "../interop/QtDotNetConverters.h" -RtfPopup::RtfPopup(System::String^ rtfText, QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f) +RtfPopup::RtfPopup(System::String^ rtfText, QWidget* parent, Qt::WindowFlags f) : QMainWindow(parent, f) { QString text = rtfText->StartsWith("{\\rtf") ? toQString(RtfPipe::Rtf::ToHtml(rtfText)) : Qt::convertFromPlainText(toQString(rtfText), Qt::WhiteSpaceNormal); QRegularExpression urlFinder(R"REGEX((?\1)"); - QLayout* layout = new QGridLayout(this); - setLayout(layout); QScrollArea* scrollArea = new QScrollArea(this); scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - layout->addWidget(scrollArea); + setCentralWidget(scrollArea); QLabel* label = new QLabel(text, scrollArea); label->setWordWrap(true); @@ -28,6 +26,10 @@ RtfPopup::RtfPopup(System::String^ rtfText, QWidget* parent, Qt::WindowFlags f) label->setTextInteractionFlags(Qt::TextBrowserInteraction); scrollArea->setWidget(label); scrollArea->setWidgetResizable(true); +} - setSizeGripEnabled(true); +void RtfPopup::closeEvent(QCloseEvent* event) +{ + emit closed(); + event->accept(); } diff --git a/src/newstuff/rtfPopup.h b/src/newstuff/rtfPopup.h index 17ca10c..235c1e7 100644 --- a/src/newstuff/rtfPopup.h +++ b/src/newstuff/rtfPopup.h @@ -1,11 +1,18 @@ using namespace cli; -#include +#include +#include -class RtfPopup : public QDialog +class RtfPopup : public QMainWindow { Q_OBJECT public: RtfPopup(System::String^ rtfText, QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); + +signals: + void closed(); + +protected: + void closeEvent(QCloseEvent* event) override; };