diff --git a/src/executableslist.cpp b/src/executableslist.cpp index c4563f90c..b94765fc0 100644 --- a/src/executableslist.cpp +++ b/src/executableslist.cpp @@ -364,6 +364,10 @@ void ExecutablesList::dump() const flags.push_back("hide"); } + if (e.flags() & Executable::MinimizeToSystemTray) { + flags.push_back("minimizeToSystemTray"); + } + log::debug(" . executable '{}'\n" " binary: {}\n" " arguments: {}\n" diff --git a/src/executableslist.h b/src/executableslist.h index d3d31f920..d90320b97 100644 --- a/src/executableslist.h +++ b/src/executableslist.h @@ -28,6 +28,8 @@ along with Mod Organizer. If not, see . #include #include +#include + namespace MOBase { class IPluginGame; @@ -38,7 +40,7 @@ class Settings; /*! * @brief Information about an executable **/ -class Executable +class Executable : public MOBase::IExecutable { public: enum Flag @@ -58,11 +60,11 @@ class Executable */ Executable(const MOBase::ExecutableInfo& info, Flags flags); - const QString& title() const; - const QFileInfo& binaryInfo() const; - const QString& arguments() const; - const QString& steamAppID() const; - const QString& workingDirectory() const; + const QString& title() const override; + const QFileInfo& binaryInfo() const override; + const QString& arguments() const override; + const QString& steamAppID() const override; + const QString& workingDirectory() const override; Flags flags() const; Executable& title(const QString& s); diff --git a/src/executableslistproxy.cpp b/src/executableslistproxy.cpp new file mode 100644 index 000000000..034c377db --- /dev/null +++ b/src/executableslistproxy.cpp @@ -0,0 +1,63 @@ +/* +Copyright (C) 2012 Sebastian Herbord. All rights reserved. + +This file is part of Mod Organizer. + +Mod Organizer is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Mod Organizer is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Mod Organizer. If not, see . +*/ + +#include "executableslistproxy.h" + +#include "executableslist.h" + +#include +#include + +#include +#include + +ExecutablesListProxy::ExecutablesListProxy(ExecutablesList* executablesList) + : m_Proxied(executablesList) +{} + +std::generator ExecutablesListProxy::executables() const +{ + for (const auto& exe : *m_Proxied) { + co_yield exe; + } +} + +const MOBase::IExecutable* ExecutablesListProxy::getByTitle(const QString& title) const +{ + try { + return &m_Proxied->get(title); + } catch (const std::runtime_error&) { + return nullptr; + } +} + +const MOBase::IExecutable* +ExecutablesListProxy::getByBinary(const QFileInfo& info) const +{ + try { + return &m_Proxied->getByBinary(info); + } catch (const std::runtime_error&) { + return nullptr; + } +} + +bool ExecutablesListProxy::contains(const QString& title) const +{ + return m_Proxied->titleExists(title); +} diff --git a/src/executableslistproxy.h b/src/executableslistproxy.h new file mode 100644 index 000000000..9bc4cf0f5 --- /dev/null +++ b/src/executableslistproxy.h @@ -0,0 +1,46 @@ +/* +Copyright (C) 2012 Sebastian Herbord. All rights reserved. + +This file is part of Mod Organizer. + +Mod Organizer is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Mod Organizer is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Mod Organizer. If not, see . +*/ + +#ifndef EXECUTABLESLISTPROXY_H +#define EXECUTABLESLISTPROXY_H + +#include "executableslist.h" + +#include + +#include +#include + +#include +#include + +class ExecutablesListProxy : public MOBase::IExecutablesList +{ +public: + ExecutablesListProxy(ExecutablesList* executablesList); + std::generator executables() const override; + const MOBase::IExecutable* getByTitle(const QString& title) const override; + const MOBase::IExecutable* getByBinary(const QFileInfo& info) const override; + bool contains(const QString& title) const override; + +private: + ExecutablesList* m_Proxied; +}; + +#endif // EXECUTABLESLISTPROXY_H diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index 776f842c7..973af3d1e 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -1,6 +1,7 @@ #include "organizerproxy.h" #include "downloadmanagerproxy.h" +#include "executableslistproxy.h" #include "gamefeaturesproxy.h" #include "glob_matching.h" #include "instancemanager.h" @@ -28,6 +29,8 @@ OrganizerProxy::OrganizerProxy(OrganizerCore* organizer, m_DownloadManagerProxy( std::make_unique(this, organizer->downloadManager())), m_ModListProxy(std::make_unique(this, organizer->modList())), + m_ExecutablesListProxy( + std::make_unique(organizer->executablesList())), m_PluginListProxy( std::make_unique(this, organizer->pluginList())), m_GameFeaturesProxy( @@ -365,6 +368,11 @@ MOBase::IModList* OrganizerProxy::modList() const return m_ModListProxy.get(); } +MOBase::IExecutablesList* OrganizerProxy::executablesList() const +{ + return m_ExecutablesListProxy.get(); +} + MOBase::IGameFeatures* OrganizerProxy::gameFeatures() const { return m_GameFeaturesProxy.get(); diff --git a/src/organizerproxy.h b/src/organizerproxy.h index f5e87046d..8382bd24d 100644 --- a/src/organizerproxy.h +++ b/src/organizerproxy.h @@ -11,6 +11,7 @@ class GameFeaturesProxy; class PluginContainer; class DownloadManagerProxy; +class ExecutablesListProxy; class ModListProxy; class PluginListProxy; @@ -65,6 +66,7 @@ class OrganizerProxy : public MOBase::IOrganizer MOBase::IDownloadManager* downloadManager() const override; MOBase::IPluginList* pluginList() const override; MOBase::IModList* modList() const override; + MOBase::IExecutablesList* executablesList() const override; std::shared_ptr profile() const override; QStringList profileNames() const override; std::shared_ptr @@ -157,6 +159,7 @@ class OrganizerProxy : public MOBase::IOrganizer std::unique_ptr m_DownloadManagerProxy; std::unique_ptr m_ModListProxy; std::unique_ptr m_PluginListProxy; + std::unique_ptr m_ExecutablesListProxy; std::unique_ptr m_GameFeaturesProxy; };