feat(plugin): support generic addon plugins and build Flatpak by default

The Plugins page replaces the Providers tab and lists every plugin alike:
package-manager providers and generic C++ addons, which can be any extension
(UI tweak, helper, ...) via IPlugin (onLoad/onUnload/onUiReady) exported with
the new FWS_ADDON_PLUGIN macro. Flatpak now ships as a plugin built by
default (FWS_BUILD_FLATPAK_PLUGIN=ON), so a plain build is Flatpak-enabled.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
BlackAngelTV committed 2026-09-10 18:49:46 +02:00
1 parent 3fa306c815
commit 8658855cca
12 files changed
+535 -250

No files matched your search

+28 -19
View File
@@ -6,47 +6,56 @@
#include <string>
#include <vector>
// Registry of package providers. It owns every IPackageManager (built-in and
// external) and can load additional providers at runtime from shared-library
// plugins dropped in the plugin directories (see PluginManager::scanDirectory).
// Registry of every plugin known to the application. It owns each plugin
// (built-in and external), loads shared-library plugins dropped in the plugin
// directories at runtime (see PluginManager::scanDirectory) and tracks which
// are enabled in the settings. A plugin is either a package-manager provider
// (implements IPackageManager) or a generic addon (implements IPlugin) — both
// kinds share the same loading, lifecycle and enable/disable flow.
class PluginManager {
public:
struct ProviderEntry {
ProviderInfo info;
IPackageManager* manager = nullptr; // owned by the PluginManager
struct PluginEntry {
PluginInfo info;
IPlugin* plugin = nullptr; // non-null for addon plugins
IPackageManager* manager = nullptr; // non-null for provider plugins
QLibrary* library = nullptr; // owned by the PluginManager; null for built-ins
};
PluginManager();
~PluginManager();
// Register a provider compiled into the application (e.g. pacman, flatpak).
// Register a provider compiled into the application (e.g. pacman).
// Takes ownership of the manager.
void registerBuiltin(ProviderInfo info, IPackageManager* manager);
void registerBuiltin(PluginInfo info, IPackageManager* manager);
// Scan the plugin directories for external provider plugins and load them.
// Scan the plugin directories for external plugins and load them.
void discoverExternal();
// Drop external plugins and rescan their directories; built-in providers
// Drop external plugins and rescan their directories; built-in plugins
// are kept (their instances stay valid).
void reload();
// Re-run isAvailable() on every known provider (e.g. after the app
// installed a missing tool) so the Providers page reflects reality.
// Re-run isAvailable() on every plugin (e.g. after the app installed a
// missing tool) so the Plugins page reflects reality.
void refreshAvailability();
// All known providers, in registration order.
const std::vector<ProviderEntry>& providers() const;
// All known plugins, in registration order.
const std::vector<PluginEntry>& plugins() const;
// Providers that are enabled (in settings) and whose tool is on the system.
std::vector<const ProviderEntry*> availableProviders() const;
// Provider plugins that are enabled (in settings) and whose tool is on the
// system.
std::vector<const PluginEntry*> availableProviders() const;
// Same as availableProviders() but as plain manager pointers, convenient
// for running aggregated operations across every provider.
std::vector<IPackageManager*> availableManagers() const;
// A single available+enabled provider matching id, or nullptr.
const ProviderEntry* findAvailable(const std::string& id) const;
const PluginEntry* findAvailable(const std::string& id) const;
// Addon plugins that are enabled and available (e.g. to hand the main
// window to via IPlugin::onUiReady).
std::vector<IPlugin*> availableAddons() const;
bool isEnabled(const std::string& id) const;
void setEnabled(const std::string& id, bool enabled);
@@ -59,6 +68,6 @@ private:
void scanDirectory(const QString& dir);
void unloadExternal();
std::vector<ProviderEntry> m_providers;
std::vector<PluginEntry> m_plugins;
QSettings m_settings;
};
};