summaryrefslogtreecommitdiff
path: root/src/organizerproxy.cpp
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2022-05-17 11:47:01 +0200
committerMikaël Capelle <capelle.mikael@gmail.com>2023-07-09 17:20:40 +0200
commitd13f6bb870cdda71257f665367be8ef9fca86255 (patch)
tree52e214718478f1e52856572f5aa1a2ac58537f9f /src/organizerproxy.cpp
parent86bb01ba9eac879d3685c439ac9da0028bc4bc80 (diff)
Apply clang-format.
Diffstat (limited to 'src/organizerproxy.cpp')
-rw-r--r--src/organizerproxy.cpp204
1 files changed, 116 insertions, 88 deletions
diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp
index d5118421..a47e8798 100644
--- a/src/organizerproxy.cpp
+++ b/src/organizerproxy.cpp
@@ -1,30 +1,32 @@
#include "organizerproxy.h"
-#include "shared/appconfig.h"
-#include "organizercore.h"
-#include "plugincontainer.h"
-#include "settings.h"
-#include "glob_matching.h"
#include "downloadmanagerproxy.h"
+#include "glob_matching.h"
#include "modlistproxy.h"
+#include "organizercore.h"
+#include "plugincontainer.h"
#include "pluginlistproxy.h"
#include "proxyutils.h"
+#include "settings.h"
+#include "shared/appconfig.h"
#include "shared/util.h"
-#include <QObject>
#include <QApplication>
+#include <QObject>
using namespace MOBase;
using namespace MOShared;
-
-OrganizerProxy::OrganizerProxy(OrganizerCore* organizer, PluginContainer* pluginContainer, MOBase::IPlugin* plugin)
- : m_Proxied(organizer)
- , m_PluginContainer(pluginContainer)
- , m_Plugin(plugin)
- , m_DownloadManagerProxy(std::make_unique<DownloadManagerProxy>(this, organizer->downloadManager()))
- , m_ModListProxy(std::make_unique<ModListProxy>(this, organizer->modList()))
- , m_PluginListProxy(std::make_unique<PluginListProxy>(this, organizer->pluginList())) { }
+OrganizerProxy::OrganizerProxy(OrganizerCore* organizer,
+ PluginContainer* pluginContainer,
+ MOBase::IPlugin* plugin)
+ : m_Proxied(organizer), m_PluginContainer(pluginContainer), m_Plugin(plugin),
+ m_DownloadManagerProxy(
+ std::make_unique<DownloadManagerProxy>(this, organizer->downloadManager())),
+ m_ModListProxy(std::make_unique<ModListProxy>(this, organizer->modList())),
+ m_PluginListProxy(
+ std::make_unique<PluginListProxy>(this, organizer->pluginList()))
+{}
OrganizerProxy::~OrganizerProxy()
{
@@ -33,17 +35,27 @@ OrganizerProxy::~OrganizerProxy()
void OrganizerProxy::connectSignals()
{
- m_Connections.push_back(m_Proxied->onAboutToRun(callSignalIfPluginActive(this, m_AboutToRun, true)));
- m_Connections.push_back(m_Proxied->onFinishedRun(callSignalIfPluginActive(this, m_FinishedRun)));
- m_Connections.push_back(m_Proxied->onProfileCreated(callSignalIfPluginActive(this, m_ProfileCreated)));
- m_Connections.push_back(m_Proxied->onProfileRenamed(callSignalIfPluginActive(this, m_ProfileRenamed)));
- m_Connections.push_back(m_Proxied->onProfileRemoved(callSignalIfPluginActive(this, m_ProfileRemoved)));
- m_Connections.push_back(m_Proxied->onProfileChanged(callSignalIfPluginActive(this, m_ProfileChanged)));
+ m_Connections.push_back(
+ m_Proxied->onAboutToRun(callSignalIfPluginActive(this, m_AboutToRun, true)));
+ m_Connections.push_back(
+ m_Proxied->onFinishedRun(callSignalIfPluginActive(this, m_FinishedRun)));
+ m_Connections.push_back(
+ m_Proxied->onProfileCreated(callSignalIfPluginActive(this, m_ProfileCreated)));
+ m_Connections.push_back(
+ m_Proxied->onProfileRenamed(callSignalIfPluginActive(this, m_ProfileRenamed)));
+ m_Connections.push_back(
+ m_Proxied->onProfileRemoved(callSignalIfPluginActive(this, m_ProfileRemoved)));
+ m_Connections.push_back(
+ m_Proxied->onProfileChanged(callSignalIfPluginActive(this, m_ProfileChanged)));
- m_Connections.push_back(m_Proxied->onUserInterfaceInitialized(callSignalAlways(m_UserInterfaceInitialized)));
- m_Connections.push_back(m_Proxied->onPluginSettingChanged(callSignalAlways(m_PluginSettingChanged)));
- m_Connections.push_back(m_Proxied->onPluginEnabled(callSignalAlways(m_PluginEnabled)));
- m_Connections.push_back(m_Proxied->onPluginDisabled(callSignalAlways(m_PluginDisabled)));
+ m_Connections.push_back(m_Proxied->onUserInterfaceInitialized(
+ callSignalAlways(m_UserInterfaceInitialized)));
+ m_Connections.push_back(
+ m_Proxied->onPluginSettingChanged(callSignalAlways(m_PluginSettingChanged)));
+ m_Connections.push_back(
+ m_Proxied->onPluginEnabled(callSignalAlways(m_PluginEnabled)));
+ m_Connections.push_back(
+ m_Proxied->onPluginDisabled(callSignalAlways(m_PluginDisabled)));
// Connect the child proxies.
m_DownloadManagerProxy->connectSignals();
@@ -64,7 +76,7 @@ void OrganizerProxy::disconnectSignals()
m_Connections.clear();
}
-IModRepositoryBridge *OrganizerProxy::createNexusBridge() const
+IModRepositoryBridge* OrganizerProxy::createNexusBridge() const
{
return new NexusBridge(m_PluginContainer, m_Plugin->name());
}
@@ -104,17 +116,17 @@ VersionInfo OrganizerProxy::appVersion() const
return m_Proxied->appVersion();
}
-IPluginGame *OrganizerProxy::getGame(const QString &gameName) const
+IPluginGame* OrganizerProxy::getGame(const QString& gameName) const
{
return m_Proxied->getGame(gameName);
}
-IModInterface *OrganizerProxy::createMod(MOBase::GuessedValue<QString> &name)
+IModInterface* OrganizerProxy::createMod(MOBase::GuessedValue<QString>& name)
{
return m_Proxied->createMod(name);
}
-void OrganizerProxy::modDataChanged(IModInterface *mod)
+void OrganizerProxy::modDataChanged(IModInterface* mod)
{
m_Proxied->modDataChanged(mod);
}
@@ -129,22 +141,26 @@ bool OrganizerProxy::isPluginEnabled(IPlugin* plugin) const
return m_PluginContainer->isEnabled(plugin);
}
-QVariant OrganizerProxy::pluginSetting(const QString &pluginName, const QString &key) const
+QVariant OrganizerProxy::pluginSetting(const QString& pluginName,
+ const QString& key) const
{
return m_Proxied->pluginSetting(pluginName, key);
}
-void OrganizerProxy::setPluginSetting(const QString &pluginName, const QString &key, const QVariant &value)
+void OrganizerProxy::setPluginSetting(const QString& pluginName, const QString& key,
+ const QVariant& value)
{
m_Proxied->setPluginSetting(pluginName, key, value);
}
-QVariant OrganizerProxy::persistent(const QString &pluginName, const QString &key, const QVariant &def) const
+QVariant OrganizerProxy::persistent(const QString& pluginName, const QString& key,
+ const QVariant& def) const
{
return m_Proxied->persistent(pluginName, key, def);
}
-void OrganizerProxy::setPersistent(const QString &pluginName, const QString &key, const QVariant &value, bool sync)
+void OrganizerProxy::setPersistent(const QString& pluginName, const QString& key,
+ const QVariant& value, bool sync)
{
m_Proxied->setPersistent(pluginName, key, value, sync);
}
@@ -154,39 +170,37 @@ QString OrganizerProxy::pluginDataPath() const
return OrganizerCore::pluginDataPath();
}
-HANDLE OrganizerProxy::startApplication(
- const QString& exe, const QStringList& args, const QString &cwd,
- const QString& profile, const QString &overwrite, bool ignoreOverwrite)
+HANDLE OrganizerProxy::startApplication(const QString& exe, const QStringList& args,
+ const QString& cwd, const QString& profile,
+ const QString& overwrite, bool ignoreOverwrite)
{
- log::debug(
- "a plugin has requested to start an application:\n"
- " . executable: '{}'\n"
- " . args: '{}'\n"
- " . cwd: '{}'\n"
- " . profile: '{}'\n"
- " . overwrite: '{}'\n"
- " . ignore overwrite: {}",
- exe, args.join(" "), cwd, profile, overwrite, ignoreOverwrite);
+ log::debug("a plugin has requested to start an application:\n"
+ " . executable: '{}'\n"
+ " . args: '{}'\n"
+ " . cwd: '{}'\n"
+ " . profile: '{}'\n"
+ " . overwrite: '{}'\n"
+ " . ignore overwrite: {}",
+ exe, args.join(" "), cwd, profile, overwrite, ignoreOverwrite);
auto runner = m_Proxied->processRunner();
// don't wait for completion
- runner
- .setFromFileOrExecutable(exe, args, cwd, profile, overwrite, ignoreOverwrite)
- .run();
+ runner.setFromFileOrExecutable(exe, args, cwd, profile, overwrite, ignoreOverwrite)
+ .run();
// the plugin is in charge of closing the handle, unless waitForApplication()
// is called on it
return runner.stealProcessHandle().release();
}
-bool OrganizerProxy::waitForApplication(HANDLE handle, bool refresh, LPDWORD exitCode) const
+bool OrganizerProxy::waitForApplication(HANDLE handle, bool refresh,
+ LPDWORD exitCode) const
{
const auto pid = ::GetProcessId(handle);
- log::debug(
- "a plugin wants to wait for an application to complete, pid {}{}",
- pid, (pid == 0 ? "unknown (probably already completed)" : ""));
+ log::debug("a plugin wants to wait for an application to complete, pid {}{}", pid,
+ (pid == 0 ? "unknown (probably already completed)" : ""));
auto runner = m_Proxied->processRunner();
@@ -196,28 +210,26 @@ bool OrganizerProxy::waitForApplication(HANDLE handle, bool refresh, LPDWORD exi
waitFlags |= ProcessRunner::TriggerRefresh | ProcessRunner::WaitForRefresh;
}
- const auto r = runner
- .setWaitForCompletion(waitFlags, UILocker::OutputRequired)
- .attachToProcess(handle);
+ const auto r = runner.setWaitForCompletion(waitFlags, UILocker::OutputRequired)
+ .attachToProcess(handle);
if (exitCode) {
*exitCode = runner.exitCode();
}
- switch (r)
- {
- case ProcessRunner::Completed:
- return true;
+ switch (r) {
+ case ProcessRunner::Completed:
+ return true;
- case ProcessRunner::Cancelled: // fall-through
- case ProcessRunner::ForceUnlocked:
- // this is always an error because the application should have run to
- // completion
- return false;
+ case ProcessRunner::Cancelled: // fall-through
+ case ProcessRunner::ForceUnlocked:
+ // this is always an error because the application should have run to
+ // completion
+ return false;
- case ProcessRunner::Error: // fall-through
- default:
- return false;
+ case ProcessRunner::Error: // fall-through
+ default:
+ return false;
}
}
@@ -226,27 +238,31 @@ void OrganizerProxy::refresh(bool saveChanges)
m_Proxied->refresh(saveChanges);
}
-IModInterface *OrganizerProxy::installMod(const QString &fileName, const QString &nameSuggestion)
+IModInterface* OrganizerProxy::installMod(const QString& fileName,
+ const QString& nameSuggestion)
{
return m_Proxied->installMod(fileName, -1, false, nullptr, nameSuggestion);
}
-QString OrganizerProxy::resolvePath(const QString &fileName) const
+QString OrganizerProxy::resolvePath(const QString& fileName) const
{
return m_Proxied->resolvePath(fileName);
}
-QStringList OrganizerProxy::listDirectories(const QString &directoryName) const
+QStringList OrganizerProxy::listDirectories(const QString& directoryName) const
{
return m_Proxied->listDirectories(directoryName);
}
-QStringList OrganizerProxy::findFiles(const QString &path, const std::function<bool(const QString&)> &filter) const
+QStringList
+OrganizerProxy::findFiles(const QString& path,
+ const std::function<bool(const QString&)>& filter) const
{
return m_Proxied->findFiles(path, filter);
}
-QStringList OrganizerProxy::findFiles(const QString& path, const QStringList& globFilters) const
+QStringList OrganizerProxy::findFiles(const QString& path,
+ const QStringList& globFilters) const
{
QList<GlobPattern<QChar>> patterns;
for (auto& gfilter : globFilters) {
@@ -262,12 +278,14 @@ QStringList OrganizerProxy::findFiles(const QString& path, const QStringList& gl
});
}
-QStringList OrganizerProxy::getFileOrigins(const QString &fileName) const
+QStringList OrganizerProxy::getFileOrigins(const QString& fileName) const
{
return m_Proxied->getFileOrigins(fileName);
}
-QList<MOBase::IOrganizer::FileInfo> OrganizerProxy::findFileInfos(const QString &path, const std::function<bool (const MOBase::IOrganizer::FileInfo &)> &filter) const
+QList<MOBase::IOrganizer::FileInfo> OrganizerProxy::findFileInfos(
+ const QString& path,
+ const std::function<bool(const MOBase::IOrganizer::FileInfo&)>& filter) const
{
return m_Proxied->findFileInfos(path, filter);
}
@@ -277,27 +295,27 @@ std::shared_ptr<const MOBase::IFileTree> OrganizerProxy::virtualFileTree() const
return m_Proxied->m_VirtualFileTree.value();
}
-MOBase::IDownloadManager *OrganizerProxy::downloadManager() const
+MOBase::IDownloadManager* OrganizerProxy::downloadManager() const
{
return m_DownloadManagerProxy.get();
}
-MOBase::IPluginList *OrganizerProxy::pluginList() const
+MOBase::IPluginList* OrganizerProxy::pluginList() const
{
return m_PluginListProxy.get();
}
-MOBase::IModList *OrganizerProxy::modList() const
+MOBase::IModList* OrganizerProxy::modList() const
{
return m_ModListProxy.get();
}
-MOBase::IProfile *OrganizerProxy::profile() const
+MOBase::IProfile* OrganizerProxy::profile() const
{
return m_Proxied->currentProfile();
}
-MOBase::IPluginGame const *OrganizerProxy::managedGame() const
+MOBase::IPluginGame const* OrganizerProxy::managedGame() const
{
return m_Proxied->managedGame();
}
@@ -306,10 +324,12 @@ MOBase::IPluginGame const *OrganizerProxy::managedGame() const
bool OrganizerProxy::onAboutToRun(const std::function<bool(const QString&)>& func)
{
- return m_Proxied->onAboutToRun(MOShared::callIfPluginActive(this, func, true)).connected();
+ return m_Proxied->onAboutToRun(MOShared::callIfPluginActive(this, func, true))
+ .connected();
}
-bool OrganizerProxy::onFinishedRun(const std::function<void(const QString&, unsigned int)>& func)
+bool OrganizerProxy::onFinishedRun(
+ const std::function<void(const QString&, unsigned int)>& func)
{
return m_Proxied->onFinishedRun(MOShared::callIfPluginActive(this, func)).connected();
}
@@ -319,7 +339,8 @@ bool OrganizerProxy::onProfileCreated(std::function<void(IProfile*)> const& func
return m_ProfileCreated.connect(func).connected();
}
-bool OrganizerProxy::onProfileRenamed(std::function<void(IProfile*, QString const&, QString const&)> const& func)
+bool OrganizerProxy::onProfileRenamed(
+ std::function<void(IProfile*, QString const&, QString const&)> const& func)
{
return m_ProfileRenamed.connect(func).connected();
}
@@ -329,19 +350,24 @@ bool OrganizerProxy::onProfileRemoved(std::function<void(QString const&)> const&
return m_ProfileRemoved.connect(func).connected();
}
-bool OrganizerProxy::onProfileChanged(std::function<void(MOBase::IProfile*, MOBase::IProfile*)> const& func)
+bool OrganizerProxy::onProfileChanged(
+ std::function<void(MOBase::IProfile*, MOBase::IProfile*)> const& func)
{
return m_ProfileChanged.connect(func).connected();
}
-bool OrganizerProxy::onUserInterfaceInitialized(std::function<void(QMainWindow*)> const& func)
+bool OrganizerProxy::onUserInterfaceInitialized(
+ std::function<void(QMainWindow*)> const& func)
{
// Always call this one to allow plugin to initialize themselves even when not active:
return m_UserInterfaceInitialized.connect(func).connected();
}
-// Always call these one, otherwise plugin cannot detect they are being enabled / disabled:
-bool OrganizerProxy::onPluginSettingChanged(std::function<void(QString const&, const QString& key, const QVariant&, const QVariant&)> const& func)
+// Always call these one, otherwise plugin cannot detect they are being enabled /
+// disabled:
+bool OrganizerProxy::onPluginSettingChanged(
+ std::function<void(QString const&, const QString& key, const QVariant&,
+ const QVariant&)> const& func)
{
return m_PluginSettingChanged.connect(func).connected();
}
@@ -351,13 +377,14 @@ bool OrganizerProxy::onPluginEnabled(std::function<void(const IPlugin*)> const&
return m_PluginEnabled.connect(func).connected();
}
-bool OrganizerProxy::onPluginEnabled(const QString& pluginName, std::function<void()> const& func)
+bool OrganizerProxy::onPluginEnabled(const QString& pluginName,
+ std::function<void()> const& func)
{
return onPluginEnabled([=](const IPlugin* plugin) {
if (plugin->name().compare(pluginName, Qt::CaseInsensitive) == 0) {
func();
}
- });
+ });
}
bool OrganizerProxy::onPluginDisabled(std::function<void(const IPlugin*)> const& func)
@@ -365,7 +392,8 @@ bool OrganizerProxy::onPluginDisabled(std::function<void(const IPlugin*)> const&
return m_PluginDisabled.connect(func).connected();
}
-bool OrganizerProxy::onPluginDisabled(const QString& pluginName, std::function<void()> const& func)
+bool OrganizerProxy::onPluginDisabled(const QString& pluginName,
+ std::function<void()> const& func)
{
return onPluginDisabled([=](const IPlugin* plugin) {
if (plugin->name().compare(pluginName, Qt::CaseInsensitive) == 0) {