More plugin updates, enum for location
This commit is contained in:
parent
702be2401b
commit
2f25c4af7f
3 changed files with 73 additions and 62 deletions
|
|
@ -18,11 +18,22 @@
|
|||
|
||||
#define OPENRGB_PLUGIN_API_VERSION 1
|
||||
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Plugin Tab Location Values |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
OPENRGB_PLUGIN_LOCATION_TOP = 0, /* Top-level tab (no icon) */
|
||||
OPENRGB_PLUGIN_LOCATION_DEVICES = 1, /* Devices tab */
|
||||
OPENRGB_PLUGIN_LOCATION_INFORMATION = 2, /* Information tab */
|
||||
OPENRGB_PLUGIN_LOCATION_SETTINGS = 3, /* Settings tab */
|
||||
};
|
||||
|
||||
struct OpenRGBPluginInfo
|
||||
{
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Plugin Details |
|
||||
\*------------------------------------------------------------------------------------------------ */
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
std::string Name; /* Plugin name string */
|
||||
std::string Description; /* Plugin description string */
|
||||
std::string Version; /* Plugin version string */
|
||||
|
|
@ -33,9 +44,9 @@ struct OpenRGBPluginInfo
|
|||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Plugin Tab Configuration |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
std::string Location; /* Plugin tab location. This field is mandatory */
|
||||
/* Options are "TopTabBar", "DevicesTab", */
|
||||
/* "InformationTab", or "SettingsTab" */
|
||||
unsigned int Location; /* Plugin tab location from Plugin Tab Location enum */
|
||||
/* This field is mandatory, an invalid value will */
|
||||
/* prevent plugin tab from being displayed */
|
||||
std::string Label; /* Plugin tab label string */
|
||||
std::string TabIconString; /* Plugin tab icon string, leave empty to use custom */
|
||||
QImage TabIcon; /* Custom tab icon image (displayed 16x16) */
|
||||
|
|
@ -55,8 +66,8 @@ public:
|
|||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Plugin Functionality |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
virtual void Initialize(bool dark_theme, ResourceManager* resource_manager_ptr) = 0;
|
||||
virtual QWidget *CreateGUI(QWidget* parent) = 0;
|
||||
virtual void Load(bool dark_theme, ResourceManager* resource_manager_ptr) = 0;
|
||||
virtual QWidget* GetWidget() = 0;
|
||||
virtual void Unload() = 0;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ void PluginManager::LoadPlugin(std::string path)
|
|||
{
|
||||
ActivePlugins[plugin_idx].plugin = plugin;
|
||||
|
||||
plugin->Initialize(dark_theme, ResourceManager::get());
|
||||
plugin->Load(dark_theme, ResourceManager::get());
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Call the Add Plugin Tab callback |
|
||||
|
|
|
|||
|
|
@ -726,26 +726,24 @@ void OpenRGBDialog2::AddPluginTab(OpenRGBPluginEntry* plugin)
|
|||
PluginTabLabel = (QLabel*)new TabLabel(PluginLabelString, QString::fromStdString(plugin->info.Label));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| InformationTab - Place plugin in the Information tab |
|
||||
| Place plugin as its own top level tab |
|
||||
\*-----------------------------------------------------*/
|
||||
if(plugin->info.Location == "InformationTab")
|
||||
if(plugin->info.Location == OPENRGB_PLUGIN_LOCATION_TOP)
|
||||
{
|
||||
QWidget* NewPluginTab = plugin->plugin->CreateGUI(this);
|
||||
QWidget* NewPluginTab = plugin->plugin->GetWidget();
|
||||
|
||||
plugin->widget = NewPluginTab;
|
||||
|
||||
OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab);
|
||||
|
||||
ui->InformationTabBar->addTab(NewPluginContainer," ");
|
||||
|
||||
ui->InformationTabBar->tabBar()->setTabButton((ui->InformationTabBar->count() - 1),QTabBar::LeftSide , PluginTabLabel);
|
||||
ui->MainTabBar->addTab(NewPluginContainer,QString().fromStdString(plugin->info.Label));
|
||||
}
|
||||
/*-----------------------------------------------------*\
|
||||
| DevicesTab - Place plugin in the Devices tab |
|
||||
| Place plugin in the Devices tab |
|
||||
\*-----------------------------------------------------*/
|
||||
else if(plugin->info.Location == "DevicesTab")
|
||||
else if(plugin->info.Location == OPENRGB_PLUGIN_LOCATION_DEVICES)
|
||||
{
|
||||
QWidget* NewPluginTab = plugin->plugin->CreateGUI(this);
|
||||
QWidget* NewPluginTab = plugin->plugin->GetWidget();
|
||||
|
||||
plugin->widget = NewPluginTab;
|
||||
|
||||
|
|
@ -756,24 +754,26 @@ void OpenRGBDialog2::AddPluginTab(OpenRGBPluginEntry* plugin)
|
|||
ui->DevicesTabBar->tabBar()->setTabButton((ui->DevicesTabBar->count() - 1),QTabBar::LeftSide , PluginTabLabel);
|
||||
}
|
||||
/*-----------------------------------------------------*\
|
||||
| TopTabBar - Place plugin as its own top level tab |
|
||||
| Place plugin in the Information tab |
|
||||
\*-----------------------------------------------------*/
|
||||
else if(plugin->info.Location == "TopTabBar")
|
||||
else if(plugin->info.Location == OPENRGB_PLUGIN_LOCATION_INFORMATION)
|
||||
{
|
||||
QWidget* NewPluginTab = plugin->plugin->CreateGUI(this);
|
||||
QWidget* NewPluginTab = plugin->plugin->GetWidget();
|
||||
|
||||
plugin->widget = NewPluginTab;
|
||||
|
||||
OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab);
|
||||
|
||||
ui->MainTabBar->addTab(NewPluginContainer,QString().fromStdString(plugin->info.Label));
|
||||
ui->InformationTabBar->addTab(NewPluginContainer," ");
|
||||
|
||||
ui->InformationTabBar->tabBar()->setTabButton((ui->InformationTabBar->count() - 1),QTabBar::LeftSide , PluginTabLabel);
|
||||
}
|
||||
/*-----------------------------------------------------*\
|
||||
| SettingsTab - Place plugin in the Settings tab |
|
||||
| Place plugin in the Settings tab |
|
||||
\*-----------------------------------------------------*/
|
||||
else if(plugin->info.Location == "SettingsTab")
|
||||
else if(plugin->info.Location == OPENRGB_PLUGIN_LOCATION_SETTINGS)
|
||||
{
|
||||
QWidget* NewPluginTab = plugin->plugin->CreateGUI(this);
|
||||
QWidget* NewPluginTab = plugin->plugin->GetWidget();
|
||||
|
||||
plugin->widget = NewPluginTab;
|
||||
|
||||
|
|
@ -789,50 +789,16 @@ void OpenRGBDialog2::AddPluginTab(OpenRGBPluginEntry* plugin)
|
|||
\*-----------------------------------------------------*/
|
||||
else
|
||||
{
|
||||
std::cout << ("Cannot load plugin '" + plugin->info.Name + "' as it does not specify a valid location: " + plugin->info.Location + "\n");
|
||||
std::cout << ("Cannot load plugin '" + plugin->info.Name + "' as it does not specify a valid location.\n");
|
||||
}
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::RemovePluginTab(OpenRGBPluginEntry* plugin)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| InformationTab - Place plugin in the Information tab |
|
||||
| Place plugin as its own top level tab |
|
||||
\*-----------------------------------------------------*/
|
||||
if(plugin->info.Location == "InformationTab")
|
||||
{
|
||||
for(int tab_idx = 0; tab_idx < ui->InformationTabBar->count(); tab_idx++)
|
||||
{
|
||||
if(dynamic_cast<OpenRGBPluginContainer*>(ui->InformationTabBar->widget(tab_idx)) != nullptr)
|
||||
{
|
||||
if(dynamic_cast<OpenRGBPluginContainer*>(ui->InformationTabBar->widget(tab_idx))->plugin_widget == plugin->widget)
|
||||
{
|
||||
ui->InformationTabBar->removeTab(tab_idx);
|
||||
delete plugin->widget;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------*\
|
||||
| DevicesTab - Place plugin in the Devices tab |
|
||||
\*-----------------------------------------------------*/
|
||||
else if(plugin->info.Location == "DevicesTab")
|
||||
{
|
||||
for(int tab_idx = 0; tab_idx < ui->DevicesTabBar->count(); tab_idx++)
|
||||
{
|
||||
if(dynamic_cast<OpenRGBPluginContainer*>(ui->DeviceTabBar->widget(tab_idx)) != nullptr)
|
||||
{
|
||||
if(dynamic_cast<OpenRGBPluginContainer*>(ui->DeviceTabBar->widget(tab_idx))->plugin_widget == plugin->widget)
|
||||
{
|
||||
ui->DeviceTabBar->removeTab(tab_idx);
|
||||
delete plugin->widget;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------*\
|
||||
| TopTabBar - Place plugin as its own top level tab |
|
||||
\*-----------------------------------------------------*/
|
||||
else if(plugin->info.Location == "TopTabBar")
|
||||
if(plugin->info.Location == OPENRGB_PLUGIN_LOCATION_TOP)
|
||||
{
|
||||
for(int tab_idx = 0; tab_idx < ui->MainTabBar->count(); tab_idx++)
|
||||
{
|
||||
|
|
@ -847,9 +813,43 @@ void OpenRGBDialog2::RemovePluginTab(OpenRGBPluginEntry* plugin)
|
|||
}
|
||||
}
|
||||
/*-----------------------------------------------------*\
|
||||
| SettingsTab - Place plugin in the Settings tab |
|
||||
| Place plugin in the Devices tab |
|
||||
\*-----------------------------------------------------*/
|
||||
else if(plugin->info.Location == "SettingsTab")
|
||||
else if(plugin->info.Location == OPENRGB_PLUGIN_LOCATION_DEVICES)
|
||||
{
|
||||
for(int tab_idx = 0; tab_idx < ui->DevicesTabBar->count(); tab_idx++)
|
||||
{
|
||||
if(dynamic_cast<OpenRGBPluginContainer*>(ui->DevicesTabBar->widget(tab_idx)) != nullptr)
|
||||
{
|
||||
if(dynamic_cast<OpenRGBPluginContainer*>(ui->DevicesTabBar->widget(tab_idx))->plugin_widget == plugin->widget)
|
||||
{
|
||||
ui->DevicesTabBar->removeTab(tab_idx);
|
||||
delete plugin->widget;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------*\
|
||||
| Place plugin in the Information tab |
|
||||
\*-----------------------------------------------------*/
|
||||
else if(plugin->info.Location == OPENRGB_PLUGIN_LOCATION_INFORMATION)
|
||||
{
|
||||
for(int tab_idx = 0; tab_idx < ui->InformationTabBar->count(); tab_idx++)
|
||||
{
|
||||
if(dynamic_cast<OpenRGBPluginContainer*>(ui->InformationTabBar->widget(tab_idx)) != nullptr)
|
||||
{
|
||||
if(dynamic_cast<OpenRGBPluginContainer*>(ui->InformationTabBar->widget(tab_idx))->plugin_widget == plugin->widget)
|
||||
{
|
||||
ui->InformationTabBar->removeTab(tab_idx);
|
||||
delete plugin->widget;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------*\
|
||||
| Place plugin in the Settings tab |
|
||||
\*-----------------------------------------------------*/
|
||||
else if(plugin->info.Location == OPENRGB_PLUGIN_LOCATION_SETTINGS)
|
||||
{
|
||||
for(int tab_idx = 0; tab_idx < ui->SettingsTabBar->count(); tab_idx++)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue