Move ResourceManagerInterface to its own file. Refactor Plugin interface
This commit is contained in:
parent
5e08608c56
commit
b3dfd3b4b0
6 changed files with 61 additions and 50 deletions
|
|
@ -179,6 +179,7 @@ HEADERS +=
|
||||||
PluginManager.h \
|
PluginManager.h \
|
||||||
ProfileManager.h \
|
ProfileManager.h \
|
||||||
ResourceManager.h \
|
ResourceManager.h \
|
||||||
|
ResourceManagerInterface.h \
|
||||||
SettingsManager.h \
|
SettingsManager.h \
|
||||||
Detector.h \
|
Detector.h \
|
||||||
DeviceDetector.h \
|
DeviceDetector.h \
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include "ResourceManager.h"
|
#include "ResourceManagerInterface.h"
|
||||||
|
|
||||||
#define OpenRGBPluginInterface_IID "com.OpenRGBPluginInterface"
|
#define OpenRGBPluginInterface_IID "com.OpenRGBPluginInterface"
|
||||||
|
|
||||||
|
|
@ -77,7 +77,7 @@ public:
|
||||||
/*-------------------------------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------------------------------*\
|
||||||
| Plugin Functionality |
|
| Plugin Functionality |
|
||||||
\*-------------------------------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------------------------------*/
|
||||||
virtual void Load(bool dark_theme, ResourceManager* resource_manager_ptr) = 0;
|
virtual void Load(ResourceManagerInterface* resource_manager_ptr) = 0;
|
||||||
virtual QWidget* GetWidget() = 0;
|
virtual QWidget* GetWidget() = 0;
|
||||||
virtual QMenu* GetTrayMenu() = 0;
|
virtual QMenu* GetTrayMenu() = 0;
|
||||||
virtual void Unload() = 0;
|
virtual void Unload() = 0;
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
#include "PluginManager.h"
|
#include "PluginManager.h"
|
||||||
#include "OpenRGBThemeManager.h"
|
#include "OpenRGBThemeManager.h"
|
||||||
#include "SettingsManager.h"
|
#include "SettingsManager.h"
|
||||||
|
#include "ResourceManager.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
@ -423,8 +424,6 @@ void PluginManager::LoadPlugin(OpenRGBPluginEntry* plugin_entry)
|
||||||
|
|
||||||
QObject* instance = plugin_entry->loader->instance();
|
QObject* instance = plugin_entry->loader->instance();
|
||||||
|
|
||||||
bool dark_theme = OpenRGBThemeManager::IsDarkTheme();
|
|
||||||
|
|
||||||
if(instance)
|
if(instance)
|
||||||
{
|
{
|
||||||
OpenRGBPluginInterface* plugin = qobject_cast<OpenRGBPluginInterface*>(instance);
|
OpenRGBPluginInterface* plugin = qobject_cast<OpenRGBPluginInterface*>(instance);
|
||||||
|
|
@ -435,7 +434,7 @@ void PluginManager::LoadPlugin(OpenRGBPluginEntry* plugin_entry)
|
||||||
{
|
{
|
||||||
plugin_entry->plugin = plugin;
|
plugin_entry->plugin = plugin;
|
||||||
|
|
||||||
plugin->Load(dark_theme, ResourceManager::get());
|
plugin->Load(ResourceManager::get());
|
||||||
|
|
||||||
/*-------------------------------------------------*\
|
/*-------------------------------------------------*\
|
||||||
| Call the Add Plugin callback |
|
| Call the Add Plugin callback |
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
#include "SPDWrapper.h"
|
#include "SPDWrapper.h"
|
||||||
#include "hidapi_wrapper.h"
|
#include "hidapi_wrapper.h"
|
||||||
#include "i2c_smbus.h"
|
#include "i2c_smbus.h"
|
||||||
|
#include "ResourceManagerInterface.h"
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
#include "json.hpp"
|
#include "json.hpp"
|
||||||
|
|
||||||
|
|
@ -94,12 +95,6 @@ typedef struct
|
||||||
uint8_t dimm_type;
|
uint8_t dimm_type;
|
||||||
} I2CDIMMDeviceDetectorBlock;
|
} I2CDIMMDeviceDetectorBlock;
|
||||||
|
|
||||||
typedef void (*DeviceListChangeCallback)(void *);
|
|
||||||
typedef void (*DetectionProgressCallback)(void *);
|
|
||||||
typedef void (*DetectionStartCallback)(void *);
|
|
||||||
typedef void (*DetectionEndCallback)(void *);
|
|
||||||
typedef void (*I2CBusListChangeCallback)(void *);
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
| Define a macro for QT lupdate to parse |
|
| Define a macro for QT lupdate to parse |
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
|
|
@ -110,45 +105,6 @@ extern const char* I2C_ERR_LINUX;
|
||||||
extern const char* UDEV_MISSING;
|
extern const char* UDEV_MISSING;
|
||||||
extern const char* UDEV_MULTI;
|
extern const char* UDEV_MULTI;
|
||||||
|
|
||||||
class ResourceManagerInterface
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual std::vector<i2c_smbus_interface*> & GetI2CBusses() = 0;
|
|
||||||
|
|
||||||
virtual void RegisterRGBController(RGBController *rgb_controller) = 0;
|
|
||||||
virtual void UnregisterRGBController(RGBController *rgb_controller) = 0;
|
|
||||||
|
|
||||||
virtual void RegisterDeviceListChangeCallback(DeviceListChangeCallback new_callback, void * new_callback_arg) = 0;
|
|
||||||
virtual void RegisterDetectionProgressCallback(DetectionProgressCallback new_callback, void * new_callback_arg) = 0;
|
|
||||||
virtual void RegisterDetectionStartCallback(DetectionStartCallback new_callback, void * new_callback_arg) = 0;
|
|
||||||
virtual void RegisterDetectionEndCallback(DetectionEndCallback new_callback, void * new_callback_arg) = 0;
|
|
||||||
virtual void RegisterI2CBusListChangeCallback(I2CBusListChangeCallback new_callback, void * new_callback_arg) = 0;
|
|
||||||
|
|
||||||
virtual void UnregisterDeviceListChangeCallback(DeviceListChangeCallback callback, void * callback_arg) = 0;
|
|
||||||
virtual void UnregisterDetectionProgressCallback(DetectionProgressCallback callback, void *callback_arg) = 0;
|
|
||||||
virtual void UnregisterDetectionStartCallback(DetectionStartCallback callback, void *callback_arg) = 0;
|
|
||||||
virtual void UnregisterDetectionEndCallback(DetectionEndCallback callback, void *callback_arg) = 0;
|
|
||||||
virtual void UnregisterI2CBusListChangeCallback(I2CBusListChangeCallback callback, void * callback_arg) = 0;
|
|
||||||
|
|
||||||
virtual std::vector<RGBController*> & GetRGBControllers() = 0;
|
|
||||||
|
|
||||||
virtual unsigned int GetDetectionPercent() = 0;
|
|
||||||
|
|
||||||
virtual filesystem::path GetConfigurationDirectory() = 0;
|
|
||||||
|
|
||||||
virtual std::vector<NetworkClient*>& GetClients() = 0;
|
|
||||||
virtual NetworkServer* GetServer() = 0;
|
|
||||||
|
|
||||||
virtual ProfileManager* GetProfileManager() = 0;
|
|
||||||
virtual SettingsManager* GetSettingsManager() = 0;
|
|
||||||
|
|
||||||
virtual void UpdateDeviceList() = 0;
|
|
||||||
virtual void WaitForDeviceDetection() = 0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual ~ResourceManagerInterface() {};
|
|
||||||
};
|
|
||||||
|
|
||||||
class ResourceManager: public ResourceManagerInterface
|
class ResourceManager: public ResourceManagerInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
54
ResourceManagerInterface.h
Normal file
54
ResourceManagerInterface.h
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include "RGBController.h"
|
||||||
|
#include "i2c_smbus.h"
|
||||||
|
#include "filesystem.h"
|
||||||
|
#include "NetworkClient.h"
|
||||||
|
#include "NetworkServer.h"
|
||||||
|
#include "SettingsManager.h"
|
||||||
|
|
||||||
|
typedef void (*DeviceListChangeCallback)(void *);
|
||||||
|
typedef void (*DetectionProgressCallback)(void *);
|
||||||
|
typedef void (*DetectionStartCallback)(void *);
|
||||||
|
typedef void (*DetectionEndCallback)(void *);
|
||||||
|
typedef void (*I2CBusListChangeCallback)(void *);
|
||||||
|
|
||||||
|
class ResourceManagerInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual std::vector<i2c_smbus_interface*> & GetI2CBusses() = 0;
|
||||||
|
|
||||||
|
virtual void RegisterRGBController(RGBController *rgb_controller) = 0;
|
||||||
|
virtual void UnregisterRGBController(RGBController *rgb_controller) = 0;
|
||||||
|
|
||||||
|
virtual void RegisterDeviceListChangeCallback(DeviceListChangeCallback new_callback, void * new_callback_arg) = 0;
|
||||||
|
virtual void RegisterDetectionProgressCallback(DetectionProgressCallback new_callback, void * new_callback_arg) = 0;
|
||||||
|
virtual void RegisterDetectionStartCallback(DetectionStartCallback new_callback, void * new_callback_arg) = 0;
|
||||||
|
virtual void RegisterDetectionEndCallback(DetectionEndCallback new_callback, void * new_callback_arg) = 0;
|
||||||
|
virtual void RegisterI2CBusListChangeCallback(I2CBusListChangeCallback new_callback, void * new_callback_arg) = 0;
|
||||||
|
|
||||||
|
virtual void UnregisterDeviceListChangeCallback(DeviceListChangeCallback callback, void * callback_arg) = 0;
|
||||||
|
virtual void UnregisterDetectionProgressCallback(DetectionProgressCallback callback, void *callback_arg) = 0;
|
||||||
|
virtual void UnregisterDetectionStartCallback(DetectionStartCallback callback, void *callback_arg) = 0;
|
||||||
|
virtual void UnregisterDetectionEndCallback(DetectionEndCallback callback, void *callback_arg) = 0;
|
||||||
|
virtual void UnregisterI2CBusListChangeCallback(I2CBusListChangeCallback callback, void * callback_arg) = 0;
|
||||||
|
|
||||||
|
virtual std::vector<RGBController*> & GetRGBControllers() = 0;
|
||||||
|
|
||||||
|
virtual unsigned int GetDetectionPercent() = 0;
|
||||||
|
|
||||||
|
virtual filesystem::path GetConfigurationDirectory() = 0;
|
||||||
|
|
||||||
|
virtual std::vector<NetworkClient*>& GetClients() = 0;
|
||||||
|
virtual NetworkServer* GetServer() = 0;
|
||||||
|
|
||||||
|
virtual ProfileManager* GetProfileManager() = 0;
|
||||||
|
virtual SettingsManager* GetSettingsManager() = 0;
|
||||||
|
|
||||||
|
virtual void UpdateDeviceList() = 0;
|
||||||
|
virtual void WaitForDeviceDetection() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~ResourceManagerInterface() {};
|
||||||
|
};
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
#include "SettingsManager.h"
|
#include "SettingsManager.h"
|
||||||
#include "OpenRGBPluginsPage.h"
|
#include "OpenRGBPluginsPage.h"
|
||||||
#include "ui_OpenRGBPluginsPage.h"
|
#include "ui_OpenRGBPluginsPage.h"
|
||||||
|
#include "ResourceManager.h"
|
||||||
|
|
||||||
void EnableClickCallbackFunction(void* this_ptr, void* entry_ptr)
|
void EnableClickCallbackFunction(void* this_ptr, void* entry_ptr)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue