First draft of plugin API changes
This commit is contained in:
parent
90788131ae
commit
28d590b64d
7 changed files with 302 additions and 161 deletions
|
|
@ -14,16 +14,22 @@
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
#define OpenRGBPluginInterface_IID "com.OpenRGBPluginInterface"
|
#define OpenRGBPluginInterface_IID "com.OpenRGBPluginInterface"
|
||||||
|
|
||||||
|
#define OPENRGB_PLUGIN_API_VERSION 1
|
||||||
|
|
||||||
struct OpenRGBPluginInfo
|
struct OpenRGBPluginInfo
|
||||||
{
|
{
|
||||||
std::string PluginName;
|
std::string Name;
|
||||||
std::string PluginDescription;
|
std::string Description;
|
||||||
std::string PluginLocation;
|
std::string Version;
|
||||||
|
std::string Commit;
|
||||||
|
std::string URL;
|
||||||
|
|
||||||
bool HasCustom;
|
std::string Location;
|
||||||
QLabel *PluginLabel;
|
std::string Label;
|
||||||
|
|
||||||
|
QImage Icon;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpenRGBPluginInterface
|
class OpenRGBPluginInterface
|
||||||
|
|
@ -31,11 +37,18 @@ class OpenRGBPluginInterface
|
||||||
public:
|
public:
|
||||||
virtual ~OpenRGBPluginInterface() {}
|
virtual ~OpenRGBPluginInterface() {}
|
||||||
|
|
||||||
virtual OpenRGBPluginInfo Initialize(bool dark_theme, ResourceManager* resource_manager_ptr) = 0;
|
/*-------------------------------------------------------------------------------------------------*\
|
||||||
|
| Plugin Information |
|
||||||
|
\*-------------------------------------------------------------------------------------------------*/
|
||||||
|
virtual OpenRGBPluginInfo GetPluginInfo() = 0;
|
||||||
|
virtual unsigned int GetPluginAPIVersion() = 0;
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------------------------------*\
|
||||||
|
| Plugin Functionality |
|
||||||
|
\*-------------------------------------------------------------------------------------------------*/
|
||||||
|
virtual void Initialize(bool dark_theme, ResourceManager* resource_manager_ptr) = 0;
|
||||||
virtual QWidget *CreateGUI(QWidget* parent) = 0;
|
virtual QWidget *CreateGUI(QWidget* parent) = 0;
|
||||||
|
virtual void Unload() = 0;
|
||||||
OpenRGBPluginInfo info;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_INTERFACE(OpenRGBPluginInterface, OpenRGBPluginInterface_IID)
|
Q_DECLARE_INTERFACE(OpenRGBPluginInterface, OpenRGBPluginInterface_IID)
|
||||||
|
|
|
||||||
|
|
@ -16,18 +16,27 @@ void PluginManager::ScanAndLoadPlugins()
|
||||||
{
|
{
|
||||||
LOG_INFO("Loading plugins");
|
LOG_INFO("Loading plugins");
|
||||||
|
|
||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| Get the plugins directory |
|
||||||
|
| |
|
||||||
|
| The plugins directory is a directory named "plugins" in |
|
||||||
|
| the configuration directory |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
const QDir plugins_dir = QString().fromStdString(ResourceManager::get()->GetConfigurationDirectory()) + "plugins/";
|
const QDir plugins_dir = QString().fromStdString(ResourceManager::get()->GetConfigurationDirectory()) + "plugins/";
|
||||||
|
|
||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| Get a list of all files in the plugins directory |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
std::vector<std::string> FileList;
|
std::vector<std::string> FileList;
|
||||||
|
|
||||||
for(int i = 0; i < QDir(plugins_dir).entryList(QDir::Files).size(); i++)
|
for(int i = 0; i < QDir(plugins_dir).entryList(QDir::Files).size(); i++)
|
||||||
{
|
{
|
||||||
/*--------------------------------------*\
|
|
||||||
| Add all of the Plugin Files to a list |
|
|
||||||
\*--------------------------------------*/
|
|
||||||
FileList.push_back(QDir(plugins_dir).entryList(QDir::Files)[i].toStdString());
|
FileList.push_back(QDir(plugins_dir).entryList(QDir::Files)[i].toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| Attempt to load each file in the plugins directory |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
for(const std::string &plugin_name : FileList)
|
for(const std::string &plugin_name : FileList)
|
||||||
{
|
{
|
||||||
const std::string plugin_path = plugins_dir.absoluteFilePath(QString().fromStdString(plugin_name)).toStdString();
|
const std::string plugin_path = plugins_dir.absoluteFilePath(QString().fromStdString(plugin_name)).toStdString();
|
||||||
|
|
@ -38,92 +47,127 @@ void PluginManager::ScanAndLoadPlugins()
|
||||||
|
|
||||||
void PluginManager::LoadPlugin(std::string path)
|
void PluginManager::LoadPlugin(std::string path)
|
||||||
{
|
{
|
||||||
OpenRGBPluginInterface *OpenRGBPlugin = nullptr;
|
OpenRGBPluginInterface* plugin = nullptr;
|
||||||
|
|
||||||
LOG_VERBOSE("Attempting to load: %s", path.c_str());
|
LOG_VERBOSE("Attempting to load: %s", path.c_str());
|
||||||
|
|
||||||
QPluginLoader loader(QString().fromStdString(path));
|
/*-----------------------------------------------------------------*\
|
||||||
|
| Create a QPluginLoader and load the plugin |
|
||||||
|
\*-----------------------------------------------------------------*/
|
||||||
|
QPluginLoader loader(QString().fromStdString(path));
|
||||||
|
QObject* instance = loader.instance();
|
||||||
|
|
||||||
if (QObject *instance = loader.instance())
|
/*-----------------------------------------------------------------*\
|
||||||
|
| Check that the plugin is valid, then check the API version |
|
||||||
|
\*-----------------------------------------------------------------*/
|
||||||
|
if(instance)
|
||||||
{
|
{
|
||||||
if ((OpenRGBPlugin = qobject_cast<OpenRGBPluginInterface*>(instance)))
|
plugin = qobject_cast<OpenRGBPluginInterface*>(instance);
|
||||||
|
|
||||||
|
if(plugin)
|
||||||
{
|
{
|
||||||
/*-----------------------------------------------------*\
|
if(plugin->GetPluginAPIVersion() == OPENRGB_PLUGIN_API_VERSION)
|
||||||
| Initialize the plugin |
|
|
||||||
\*-----------------------------------------------------*/
|
|
||||||
OpenRGBPlugin->info = OpenRGBPlugin->Initialize(dark_theme, ResourceManager::get());
|
|
||||||
|
|
||||||
/*-----------------------------------------------------*\
|
|
||||||
| Search the settings to see if it is enabled |
|
|
||||||
\*-----------------------------------------------------*/
|
|
||||||
std::string name = "";
|
|
||||||
std::string description = "";
|
|
||||||
bool enabled = true;
|
|
||||||
bool found = false;
|
|
||||||
unsigned int plugin_ct = 0;
|
|
||||||
|
|
||||||
/*-------------------------------------------------*\
|
|
||||||
| Open device disable list and read in disabled |
|
|
||||||
| device strings |
|
|
||||||
\*-------------------------------------------------*/
|
|
||||||
json plugin_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Plugins");
|
|
||||||
|
|
||||||
if(plugin_settings.contains("plugins"))
|
|
||||||
{
|
{
|
||||||
plugin_ct = plugin_settings["plugins"].size();
|
/*-----------------------------------------------------*\
|
||||||
|
| Get the plugin information |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
OpenRGBPluginInfo info = plugin->GetPluginInfo();
|
||||||
|
|
||||||
for(unsigned int plugin_idx = 0; plugin_idx < plugin_settings["plugins"].size(); plugin_idx++)
|
/*-----------------------------------------------------*\
|
||||||
|
| Search the settings to see if it is enabled |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
std::string name = "";
|
||||||
|
std::string description = "";
|
||||||
|
bool enabled = true;
|
||||||
|
bool found = false;
|
||||||
|
unsigned int plugin_ct = 0;
|
||||||
|
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| Open plugin list and check if plugin is in the list |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
json plugin_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Plugins");
|
||||||
|
|
||||||
|
if(plugin_settings.contains("plugins"))
|
||||||
{
|
{
|
||||||
if(plugin_settings["plugins"][plugin_idx].contains("name"))
|
plugin_ct = plugin_settings["plugins"].size();
|
||||||
{
|
|
||||||
name = plugin_settings["plugins"][plugin_idx]["name"];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(plugin_settings["plugins"][plugin_idx].contains("description"))
|
for(unsigned int plugin_idx = 0; plugin_idx < plugin_settings["plugins"].size(); plugin_idx++)
|
||||||
{
|
{
|
||||||
description = plugin_settings["plugins"][plugin_idx]["description"];
|
if(plugin_settings["plugins"][plugin_idx].contains("name"))
|
||||||
}
|
{
|
||||||
|
name = plugin_settings["plugins"][plugin_idx]["name"];
|
||||||
|
}
|
||||||
|
|
||||||
if(plugin_settings["plugins"][plugin_idx].contains("enabled"))
|
if(plugin_settings["plugins"][plugin_idx].contains("description"))
|
||||||
{
|
{
|
||||||
enabled = plugin_settings["plugins"][plugin_idx]["enabled"];
|
description = plugin_settings["plugins"][plugin_idx]["description"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if((OpenRGBPlugin->info.PluginName == name)
|
if(plugin_settings["plugins"][plugin_idx].contains("enabled"))
|
||||||
&&(OpenRGBPlugin->info.PluginDescription == description))
|
{
|
||||||
{
|
enabled = plugin_settings["plugins"][plugin_idx]["enabled"];
|
||||||
found = true;
|
}
|
||||||
break;
|
|
||||||
|
if((info.Name == name)
|
||||||
|
&&(info.Description == description))
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(!found)
|
/*-----------------------------------------------------*\
|
||||||
{
|
| If the plugin was not in the list, add it to the list |
|
||||||
plugin_settings["plugins"][plugin_ct]["name"] = OpenRGBPlugin->info.PluginName;
|
| and default it to enabled, then save the settings |
|
||||||
plugin_settings["plugins"][plugin_ct]["description"] = OpenRGBPlugin->info.PluginDescription;
|
\*-----------------------------------------------------*/
|
||||||
plugin_settings["plugins"][plugin_ct]["enabled"] = enabled;
|
if(!found)
|
||||||
|
{
|
||||||
|
plugin_settings["plugins"][plugin_ct]["name"] = info.Name;
|
||||||
|
plugin_settings["plugins"][plugin_ct]["description"] = info.Description;
|
||||||
|
plugin_settings["plugins"][plugin_ct]["enabled"] = enabled;
|
||||||
|
|
||||||
ResourceManager::get()->GetSettingsManager()->SetSettings("Plugins", plugin_settings);
|
ResourceManager::get()->GetSettingsManager()->SetSettings("Plugins", plugin_settings);
|
||||||
ResourceManager::get()->GetSettingsManager()->SaveSettings();
|
ResourceManager::get()->GetSettingsManager()->SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_VERBOSE("Loaded plugin %s", OpenRGBPlugin->info.PluginName.c_str());
|
LOG_VERBOSE("Loaded plugin %s", info.Name.c_str());
|
||||||
|
|
||||||
OpenRGBPluginEntry entry;
|
/*-----------------------------------------------------*\
|
||||||
|
| Add the plugin to the PluginManager active plugins |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
OpenRGBPluginEntry entry;
|
||||||
|
|
||||||
entry.plugin = OpenRGBPlugin;
|
entry.info = info;
|
||||||
entry.path = path;
|
entry.plugin = plugin;
|
||||||
entry.enabled = enabled;
|
entry.path = path;
|
||||||
|
entry.enabled = enabled;
|
||||||
|
|
||||||
PluginManager::ActivePlugins.push_back(entry);
|
PluginManager::ActivePlugins.push_back(entry);
|
||||||
|
|
||||||
/*-------------------------------------------------*\
|
/*-----------------------------------------------------*\
|
||||||
| Call the callbacks |
|
| If the plugin is enabled, load it |
|
||||||
\*-------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
for(unsigned int callback_idx = 0; callback_idx < AddPluginTabCallbacks.size(); callback_idx++)
|
if(enabled)
|
||||||
{
|
{
|
||||||
AddPluginTabCallbacks[callback_idx](AddPluginTabCallbackArgs[callback_idx], OpenRGBPlugin);
|
/*-------------------------------------------------*\
|
||||||
|
| Initialize the plugin |
|
||||||
|
\*-------------------------------------------------*/
|
||||||
|
plugin->Initialize(dark_theme, ResourceManager::get());
|
||||||
|
|
||||||
|
/*-------------------------------------------------*\
|
||||||
|
| Call the callbacks |
|
||||||
|
\*-------------------------------------------------*/
|
||||||
|
for(unsigned int callback_idx = 0; callback_idx < AddPluginTabCallbacks.size(); callback_idx++)
|
||||||
|
{
|
||||||
|
AddPluginTabCallbacks[callback_idx](AddPluginTabCallbackArgs[callback_idx], entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete instance;
|
||||||
|
loader.unload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,13 @@
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
OpenRGBPluginInfo info;
|
||||||
OpenRGBPluginInterface* plugin;
|
OpenRGBPluginInterface* plugin;
|
||||||
std::string path;
|
std::string path;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
} OpenRGBPluginEntry;
|
} OpenRGBPluginEntry;
|
||||||
|
|
||||||
typedef void (*AddPluginTabCallback)(void *, OpenRGBPluginInterface* plugin);
|
typedef void (*AddPluginTabCallback)(void *, OpenRGBPluginEntry plugin);
|
||||||
|
|
||||||
class PluginManager
|
class PluginManager
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ static void UpdateDetectionProgressCallback(void * this_ptr)
|
||||||
QMetaObject::invokeMethod(this_obj, "onDetectionProgressUpdated", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this_obj, "onDetectionProgressUpdated", Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CreatePluginTabCallback(void * this_ptr, OpenRGBPluginInterface * plugin)
|
static void CreatePluginTabCallback(void * this_ptr, OpenRGBPluginEntry plugin)
|
||||||
{
|
{
|
||||||
OpenRGBDialog2 * this_obj = (OpenRGBDialog2 *)this_ptr;
|
OpenRGBDialog2 * this_obj = (OpenRGBDialog2 *)this_ptr;
|
||||||
|
|
||||||
|
|
@ -690,7 +690,7 @@ void OpenRGBDialog2::AddSerialSettingsPage()
|
||||||
ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel);
|
ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenRGBDialog2::AddPluginTab(OpenRGBPluginInterface* plugin)
|
void OpenRGBDialog2::AddPluginTab(OpenRGBPluginEntry plugin)
|
||||||
{
|
{
|
||||||
/*-----------------------------------------------------*\
|
/*-----------------------------------------------------*\
|
||||||
| Create Label for the Tab |
|
| Create Label for the Tab |
|
||||||
|
|
@ -701,41 +701,28 @@ void OpenRGBDialog2::AddPluginTab(OpenRGBPluginInterface* plugin)
|
||||||
| If the plugin has custom information, use it, |
|
| If the plugin has custom information, use it, |
|
||||||
| otherwise generate it |
|
| otherwise generate it |
|
||||||
\*-----------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
if(plugin->info.HasCustom)
|
QString PluginLabelString;
|
||||||
|
|
||||||
|
if(IsDarkTheme())
|
||||||
{
|
{
|
||||||
PluginTabLabel = plugin->info.PluginLabel;
|
PluginLabelString = "plugin_dark.png";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QLabel *TabLabelText = plugin->info.PluginLabel;
|
PluginLabelString = "plugin.png";
|
||||||
QString PluginLabelString;
|
|
||||||
|
|
||||||
if(IsDarkTheme())
|
|
||||||
{
|
|
||||||
PluginLabelString = "plugin_dark.png";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PluginLabelString = "plugin.png";
|
|
||||||
}
|
|
||||||
|
|
||||||
/*-----------------------------------------------------*\
|
|
||||||
| Create the tab label |
|
|
||||||
\*-----------------------------------------------------*/
|
|
||||||
PluginTabLabel = (QLabel*)new TabLabel(PluginLabelString, TabLabelText->text());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------*\
|
/*-----------------------------------------------------*\
|
||||||
| Determine plugin location |
|
| Create the tab label |
|
||||||
\*-----------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
std::string Location = plugin->info.PluginLocation;
|
PluginTabLabel = (QLabel*)new TabLabel(PluginLabelString, QString::fromStdString(plugin.info.Label));
|
||||||
|
|
||||||
/*-----------------------------------------------------*\
|
/*-----------------------------------------------------*\
|
||||||
| InformationTab - Place plugin in the Information tab |
|
| InformationTab - Place plugin in the Information tab |
|
||||||
\*-----------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
if(Location == "InformationTab")
|
if(plugin.info.Location == "InformationTab")
|
||||||
{
|
{
|
||||||
QWidget* NewPluginTab = plugin->CreateGUI(this);
|
QWidget* NewPluginTab = plugin.plugin->CreateGUI(this);
|
||||||
|
|
||||||
OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab);
|
OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab);
|
||||||
|
|
||||||
|
|
@ -746,9 +733,9 @@ void OpenRGBDialog2::AddPluginTab(OpenRGBPluginInterface* plugin)
|
||||||
/*-----------------------------------------------------*\
|
/*-----------------------------------------------------*\
|
||||||
| DevicesTab - Place plugin in the Devices tab |
|
| DevicesTab - Place plugin in the Devices tab |
|
||||||
\*-----------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
else if(Location == "DevicesTab")
|
else if(plugin.info.Location == "DevicesTab")
|
||||||
{
|
{
|
||||||
QWidget* NewPluginTab = plugin->CreateGUI(this);
|
QWidget* NewPluginTab = plugin.plugin->CreateGUI(this);
|
||||||
|
|
||||||
OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab);
|
OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab);
|
||||||
|
|
||||||
|
|
@ -759,20 +746,20 @@ void OpenRGBDialog2::AddPluginTab(OpenRGBPluginInterface* plugin)
|
||||||
/*-----------------------------------------------------*\
|
/*-----------------------------------------------------*\
|
||||||
| TopTabBar - Place plugin as its own top level tab |
|
| TopTabBar - Place plugin as its own top level tab |
|
||||||
\*-----------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
else if(Location == "TopTabBar")
|
else if(plugin.info.Location == "TopTabBar")
|
||||||
{
|
{
|
||||||
QWidget* NewPluginTab = plugin->CreateGUI(this);
|
QWidget* NewPluginTab = plugin.plugin->CreateGUI(this);
|
||||||
|
|
||||||
OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab);
|
OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab);
|
||||||
|
|
||||||
ui->MainTabBar->addTab(NewPluginContainer,QString().fromStdString(plugin->info.PluginName));
|
ui->MainTabBar->addTab(NewPluginContainer,QString().fromStdString(plugin.info.Label));
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------*\
|
/*-----------------------------------------------------*\
|
||||||
| SettingsTabBar - Place plugin in the Settings tab |
|
| SettingsTabBar - Place plugin in the Settings tab |
|
||||||
\*-----------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
else if(Location == "SettingsTabBar")
|
else if(plugin.info.Location == "SettingsTabBar")
|
||||||
{
|
{
|
||||||
QWidget* NewPluginTab = plugin->CreateGUI(this);
|
QWidget* NewPluginTab = plugin.plugin->CreateGUI(this);
|
||||||
|
|
||||||
OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab);
|
OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab);
|
||||||
|
|
||||||
|
|
@ -786,7 +773,7 @@ void OpenRGBDialog2::AddPluginTab(OpenRGBPluginInterface* plugin)
|
||||||
\*-----------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << ("Cannot load plugin '" + plugin->info.PluginName + "' as it does not specify a valid location: " + Location + "\n");
|
std::cout << ("Cannot load plugin '" + plugin.info.Name + "' as it does not specify a valid location: " + plugin.info.Location + "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ public:
|
||||||
void AddI2CToolsPage();
|
void AddI2CToolsPage();
|
||||||
void AddServerTab();
|
void AddServerTab();
|
||||||
|
|
||||||
void AddPluginTab(OpenRGBPluginInterface* plugin);
|
void AddPluginTab(OpenRGBPluginEntry plugin);
|
||||||
|
|
||||||
void setMode(unsigned char mode_val);
|
void setMode(unsigned char mode_val);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>195</width>
|
<width>478</width>
|
||||||
<height>109</height>
|
<height>238</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
|
@ -20,7 +20,28 @@
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="1" column="1">
|
<item row="3" column="1">
|
||||||
|
<widget class="QLabel" name="VersionLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Version:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="2">
|
||||||
|
<widget class="QCheckBox" name="EnabledCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QLabel" name="PathValue">
|
||||||
|
<property name="text">
|
||||||
|
<string>Path Value</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
<widget class="QLabel" name="DescriptionValue">
|
<widget class="QLabel" name="DescriptionValue">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
|
|
@ -33,40 +54,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QLabel" name="EnabledLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Enabled</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLabel" name="NameValue">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Name Value</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="DescriptionLabel">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Description</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="NameLabel">
|
<widget class="QLabel" name="NameLabel">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||||
|
|
@ -79,24 +67,109 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QCheckBox" name="EnabledCheckBox">
|
<widget class="QLabel" name="DescriptionLabel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string>Description:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="5" column="1">
|
||||||
<widget class="QLabel" name="PathLabel">
|
<widget class="QLabel" name="URLLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Path</string>
|
<string>URL:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QLabel" name="NameValue">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Name Value</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="2">
|
||||||
|
<widget class="QLabel" name="VersionValue">
|
||||||
|
<property name="text">
|
||||||
|
<string>Version Value</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="2">
|
||||||
|
<widget class="QLabel" name="CommitValue">
|
||||||
|
<property name="text">
|
||||||
|
<string>Commit Value</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QLabel" name="PathValue">
|
<widget class="QLabel" name="PathLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Path Value</string>
|
<string>Path:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="1">
|
||||||
|
<widget class="QLabel" name="EnabledLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enabled</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QLabel" name="CommitLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Commit:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="2">
|
||||||
|
<widget class="QLabel" name="URLValue">
|
||||||
|
<property name="text">
|
||||||
|
<string>URL Value</string>
|
||||||
|
</property>
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" rowspan="7">
|
||||||
|
<widget class="QLabel" name="IconView">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>64</width>
|
||||||
|
<height>64</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>64</width>
|
||||||
|
<height>64</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Icon</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QGraphicsPixmapItem>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
#include "OpenRGBPluginsPage.h"
|
#include "OpenRGBPluginsPage.h"
|
||||||
|
|
@ -29,22 +31,43 @@ void Ui::OpenRGBPluginsPage::RefreshList()
|
||||||
{
|
{
|
||||||
OpenRGBPluginsEntry* entry = new OpenRGBPluginsEntry();
|
OpenRGBPluginsEntry* entry = new OpenRGBPluginsEntry();
|
||||||
|
|
||||||
entry->ui->NameValue->setText(QString::fromStdString(plugin_manager->ActivePlugins[plugin_idx].plugin->info.PluginName));
|
/*---------------------------------------------------------*\
|
||||||
entry->ui->DescriptionValue->setText(QString::fromStdString(plugin_manager->ActivePlugins[plugin_idx].plugin->info.PluginDescription));
|
| Fill in plugin information fields |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
|
entry->ui->NameValue->setText(QString::fromStdString(plugin_manager->ActivePlugins[plugin_idx].info.Name));
|
||||||
|
entry->ui->DescriptionValue->setText(QString::fromStdString(plugin_manager->ActivePlugins[plugin_idx].info.Description));
|
||||||
|
entry->ui->VersionValue->setText(QString::fromStdString(plugin_manager->ActivePlugins[plugin_idx].info.Version));
|
||||||
|
entry->ui->CommitValue->setText(QString::fromStdString(plugin_manager->ActivePlugins[plugin_idx].info.Commit));
|
||||||
|
entry->ui->URLValue->setText(QString::fromStdString(plugin_manager->ActivePlugins[plugin_idx].info.URL));
|
||||||
|
|
||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| Fill in plugin icon |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
|
QPixmap pixmap(QPixmap::fromImage(plugin_manager->ActivePlugins[plugin_idx].info.Icon));
|
||||||
|
|
||||||
|
entry->ui->IconView->setPixmap(pixmap);
|
||||||
|
entry->ui->IconView->setScaledContents(true);
|
||||||
|
|
||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| Fill in plugin path |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
entry->ui->PathValue->setText(QString::fromStdString(plugin_manager->ActivePlugins[plugin_idx].path));
|
entry->ui->PathValue->setText(QString::fromStdString(plugin_manager->ActivePlugins[plugin_idx].path));
|
||||||
|
|
||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| Fill in plugin enabled status |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
entry->ui->EnabledCheckBox->setChecked((plugin_manager->ActivePlugins[plugin_idx].enabled));
|
entry->ui->EnabledCheckBox->setChecked((plugin_manager->ActivePlugins[plugin_idx].enabled));
|
||||||
|
|
||||||
//TODO: Get plugin enable/disable working
|
/*---------------------------------------------------------*\
|
||||||
// Until then, hide the enable checkbox
|
| Add the entry to the plugin list |
|
||||||
entry->ui->EnabledLabel->setVisible(false);
|
\*---------------------------------------------------------*/
|
||||||
entry->ui->EnabledCheckBox->setVisible(false);
|
|
||||||
|
|
||||||
QListWidgetItem* item = new QListWidgetItem;
|
QListWidgetItem* item = new QListWidgetItem;
|
||||||
|
|
||||||
item->setSizeHint(entry->sizeHint());
|
item->setSizeHint(entry->sizeHint());
|
||||||
|
|
||||||
ui->PluginsList->addItem(item);
|
ui->PluginsList->addItem(item);
|
||||||
ui->PluginsList->setItemWidget(item, entry);
|
ui->PluginsList->setItemWidget(item, entry);
|
||||||
|
|
||||||
entries.push_back(entry);
|
entries.push_back(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue