From a5db7ed864ac58657bf9bfbbc292cdccbeeaa38b Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Thu, 19 Sep 2019 11:23:21 -0400 Subject: added Settings::isExecutableBlacklisted() moved blacklisted confirmation to dialogs --- src/settings.cpp | 11 +++++++++++ src/settings.h | 1 + src/spawn.cpp | 29 ++++++++++++++++------------- 3 files changed, 28 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/settings.cpp b/src/settings.cpp index 7fdda2bf..ae487c18 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -222,6 +222,17 @@ QString Settings::executablesBlacklist() const return get(m_Settings, "Settings", "executable_blacklist", def); } +bool Settings::isExecutableBlacklisted(const QString& s) const +{ + for (auto exec : executablesBlacklist().split(";")) { + if (exec.compare(s, Qt::CaseInsensitive) == 0) { + return true; + } + } + + return false; +} + void Settings::setExecutablesBlacklist(const QString& s) { set(m_Settings, "Settings", "executable_blacklist", s); diff --git a/src/settings.h b/src/settings.h index 815ed160..cd478a5b 100644 --- a/src/settings.h +++ b/src/settings.h @@ -678,6 +678,7 @@ public: // by MO but given to usvfs when starting an executable // QString executablesBlacklist() const; + bool isExecutableBlacklisted(const QString& s) const; void setExecutablesBlacklist(const QString& s); // ? looks obsolete, only used by dead code diff --git a/src/spawn.cpp b/src/spawn.cpp index c9025d98..45324d79 100644 --- a/src/spawn.cpp +++ b/src/spawn.cpp @@ -345,6 +345,20 @@ bool eventLogNotRunning( return (r != QDialogButtonBox::No); } +bool 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); + + return (r != QDialogButtonBox::No); +} + } // namespace @@ -652,18 +666,8 @@ bool checkEnvironment(QWidget* parent, const SpawnParameters& sp) bool checkBlacklist(QWidget* parent, const SpawnParameters& sp, const Settings& settings) { - for (auto exec : settings.executablesBlacklist().split(";")) { - if (exec.compare(sp.binary.fileName(), Qt::CaseInsensitive) == 0) { - if (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) == QDialogButtonBox::No) { - return false; - } - } + if (settings.isExecutableBlacklisted(sp.binary.fileName())) { + return dialogs::confirmBlacklisted(parent, sp); } return true; @@ -779,7 +783,6 @@ bool backdateBSAs(const std::wstring &moPath, const std::wstring &dataPath) return helperExec(moPath, commandLine, FALSE); } - bool adminLaunch(const std::wstring &moPath, const std::wstring &moFile, const std::wstring &workingDir) { const std::wstring commandLine = fmt::format( -- cgit v1.3.1