diff options
| -rw-r--r-- | src/settingsdialogworkarounds.cpp | 51 | ||||
| -rw-r--r-- | src/settingsdialogworkarounds.h | 15 | ||||
| -rw-r--r-- | src/spawn.cpp | 61 |
3 files changed, 97 insertions, 30 deletions
diff --git a/src/settingsdialogworkarounds.cpp b/src/settingsdialogworkarounds.cpp index 5e70e5a6..0e31fc4b 100644 --- a/src/settingsdialogworkarounds.cpp +++ b/src/settingsdialogworkarounds.cpp @@ -1,6 +1,7 @@ #include "settingsdialogworkarounds.h" #include "ui_settingsdialog.h" #include "spawn.h" +#include "settings.h" #include <iplugingame.h> WorkaroundsSettingsTab::WorkaroundsSettingsTab(Settings& s, SettingsDialog& d) @@ -26,7 +27,7 @@ WorkaroundsSettingsTab::WorkaroundsSettingsTab(Settings& s, SettingsDialog& d) ui->lockGUIBox->setChecked(settings().interface().lockGUI()); ui->enableArchiveParsingBox->setChecked(settings().archiveParsing()); - setExecutableBlacklist(settings().executablesBlacklist()); + m_ExecutableBlacklist = settings().executablesBlacklist(); QObject::connect(ui->bsaDateBtn, &QPushButton::clicked, [&]{ on_bsaDateBtn_clicked(); }); QObject::connect(ui->execBlacklistBtn, &QPushButton::clicked, [&]{ on_execBlacklistBtn_clicked(); }); @@ -49,14 +50,29 @@ void WorkaroundsSettingsTab::update() settings().interface().setDisplayForeign(ui->displayForeignBox->isChecked()); settings().interface().setLockGUI(ui->lockGUIBox->isChecked()); settings().setArchiveParsing(ui->enableArchiveParsingBox->isChecked()); - settings().setExecutablesBlacklist(getExecutableBlacklist()); + settings().setExecutablesBlacklist(m_ExecutableBlacklist); } -void WorkaroundsSettingsTab::on_execBlacklistBtn_clicked() +bool WorkaroundsSettingsTab::changeBlacklistNow( + QWidget* parent, Settings& settings) +{ + const auto current = settings.executablesBlacklist(); + + if (auto s=changeBlacklistLater(parent, current)) { + settings.setExecutablesBlacklist(*s); + return true; + } + + return false; +} + +std::optional<QString> WorkaroundsSettingsTab::changeBlacklistLater( + QWidget* parent, const QString& current) { bool ok = false; + QString result = QInputDialog::getMultiLineText( - &dialog(), + parent, QObject::tr("Executables Blacklist"), QObject::tr("Enter one executable per line to be blacklisted from the virtual file system.\n" "Mods and other virtualized files will not be visible to these executables and\n" @@ -64,17 +80,28 @@ void WorkaroundsSettingsTab::on_execBlacklistBtn_clicked() "Example:\n" " Chrome.exe\n" " Firefox.exe"), - m_ExecutableBlacklist.split(";").join("\n"), + current.split(";").join("\n"), &ok ); - if (ok) { - QStringList blacklist; - for (auto exec : result.split("\n")) { - if (exec.trimmed().endsWith(".exe", Qt::CaseInsensitive)) { - blacklist << exec.trimmed(); - } + + if (!ok) { + return {}; + } + + QStringList blacklist; + for (auto exec : result.split("\n")) { + if (exec.trimmed().endsWith(".exe", Qt::CaseInsensitive)) { + blacklist << exec.trimmed(); } - m_ExecutableBlacklist = blacklist.join(";"); + } + + return blacklist.join(";"); +} + +void WorkaroundsSettingsTab::on_execBlacklistBtn_clicked() +{ + if (auto s=changeBlacklistLater(parentWidget(), m_ExecutableBlacklist)) { + m_ExecutableBlacklist = *s; } } diff --git a/src/settingsdialogworkarounds.h b/src/settingsdialogworkarounds.h index d5d6815f..cffc54a0 100644 --- a/src/settingsdialogworkarounds.h +++ b/src/settingsdialogworkarounds.h @@ -8,6 +8,18 @@ class WorkaroundsSettingsTab : public SettingsTab { public: WorkaroundsSettingsTab(Settings& settings, SettingsDialog& dialog); + + // shows the blacklist dialog from the given settings, and changes the + // settings when the user accepts it + // + static bool changeBlacklistNow(QWidget* parent, Settings& settings); + + // shows the blacklist dialog from the given string and returns the new + // blacklist if the user accepted it + // + static std::optional<QString> changeBlacklistLater( + QWidget* parent, const QString& current); + void update(); private: @@ -16,9 +28,6 @@ private: void on_bsaDateBtn_clicked(); void on_execBlacklistBtn_clicked(); void on_resetGeometryBtn_clicked(); - - QString getExecutableBlacklist() { return m_ExecutableBlacklist; } - void setExecutableBlacklist(QString blacklist) { m_ExecutableBlacklist = blacklist; } }; #endif // SETTINGSDIALOGWORKAROUNDS_H diff --git a/src/spawn.cpp b/src/spawn.cpp index b7aa90c0..ab9d90a0 100644 --- a/src/spawn.cpp +++ b/src/spawn.cpp @@ -26,6 +26,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include "envsecurity.h"
#include "envmodule.h"
#include "settings.h"
+#include "settingsdialogworkarounds.h"
#include <errorcodes.h>
#include <report.h>
#include <log.h>
@@ -379,21 +380,45 @@ bool eventLogNotRunning( QMessageBox::Cancel})
.exec();
- return (r == QDialogButtonBox::Yes);
+ return (r == QMessageBox::Yes);
}
-bool confirmBlacklisted(QWidget* parent, const SpawnParameters& sp)
+QMessageBox::StandardButton confirmBlacklisted(
+ QWidget* parent, const SpawnParameters& sp)
{
- const auto r = QuestionBoxMemory::query(
- parent, QString("blacklistedExecutable"), sp.binary.fileName(),
- QObject::tr("Blacklisted Executable"),
- QObject::tr("The executable you are attempted to launch is blacklisted in the virtual file"
- " system. This will likely prevent the executable, and any executables that are"
- " launched by this one, from seeing any mods. This could extend to INI files, save"
- " games and any other virtualized files.\n\nContinue launching %1?").arg(sp.binary.fileName()),
- QDialogButtonBox::Yes | QDialogButtonBox::No);
+ const auto title = QObject::tr("Blacklisted program");
+ const auto mainText = QObject::tr("The program %1 is blacklisted")
+ .arg(sp.binary.fileName());
+ const auto content = QObject::tr(
+ "The program you are attempting to launch is blacklisted in the virtual "
+ "filesystem. This will likely prevent it from seeing any mods, INI files "
+ "or any other virtualized files.");
+
+ auto r = MOBase::TaskDialog(parent, title)
+ .main(mainText)
+ .content(content)
+ .details("")
+ .icon(QMessageBox::Question)
+ .remember("blacklistedExecutable", sp.binary.fileName())
+ .button({
+ QObject::tr("Continue"),
+ QObject::tr("Your mods might not work"),
+ QMessageBox::Yes})
+ .button({
+ QObject::tr("Change the blacklist"),
+ QMessageBox::Retry})
+ .button({
+ QObject::tr("Cancel"),
+ QMessageBox::Cancel})
+ .exec();
- return (r != QDialogButtonBox::No);
+ if (r == QMessageBox::Retry) {
+ if (!WorkaroundsSettingsTab::changeBlacklistNow(parent, Settings::instance())) {
+ r = QMessageBox::Cancel;
+ }
+ }
+
+ return r;
}
} // namespace
@@ -716,11 +741,17 @@ bool checkEnvironment(QWidget* parent, const SpawnParameters& sp) bool checkBlacklist(QWidget* parent, const SpawnParameters& sp, const Settings& settings)
{
- if (settings.isExecutableBlacklisted(sp.binary.fileName())) {
- return dialogs::confirmBlacklisted(parent, sp);
- }
+ for (;;) {
+ if (!settings.isExecutableBlacklisted(sp.binary.fileName())) {
+ return true;
+ }
- return true;
+ const auto r = dialogs::confirmBlacklisted(parent, sp);
+
+ if (r != QMessageBox::Retry) {
+ return (r == QMessageBox::Yes);
+ }
+ }
}
|
