diff --git a/OpenRGB.pro b/OpenRGB.pro index acd23a62..6ca28e49 100644 --- a/OpenRGB.pro +++ b/OpenRGB.pro @@ -166,6 +166,8 @@ HEADERS += qt/DeviceView.h \ qt/OpenRGBDialog2.h \ qt/OpenRGBPluginContainer.h \ + qt/OpenRGBPluginsPage/OpenRGBPluginsEntry.h \ + qt/OpenRGBPluginsPage/OpenRGBPluginsPage.h \ qt/OpenRGBProfileSaveDialog.h \ qt/OpenRGBServerInfoPage.h \ qt/OpenRGBSettingsPage.h \ @@ -485,6 +487,8 @@ SOURCES += qt/DeviceView.cpp \ qt/OpenRGBDialog2.cpp \ qt/OpenRGBPluginContainer.cpp \ + qt/OpenRGBPluginsPage/OpenRGBPluginsEntry.cpp \ + qt/OpenRGBPluginsPage/OpenRGBPluginsPage.cpp \ qt/OpenRGBProfileSaveDialog.cpp \ qt/OpenRGBServerInfoPage.cpp \ qt/OpenRGBSettingsPage.cpp \ @@ -826,6 +830,8 @@ FORMS += qt/OpenRGBDialog.ui \ qt/OpenRGBDialog2.ui \ qt/OpenRGBPluginContainer.ui \ + qt/OpenRGBPluginsPage/OpenRGBPluginsEntry.ui \ + qt/OpenRGBPluginsPage/OpenRGBPluginsPage.ui \ qt/OpenRGBProfileSaveDialog.ui \ qt/OpenRGBServerInfoPage.ui \ qt/OpenRGBSettingsPage.ui \ diff --git a/PluginManager.cpp b/PluginManager.cpp index 46e41163..b8150fc0 100644 --- a/PluginManager.cpp +++ b/PluginManager.cpp @@ -1,57 +1,134 @@ #include "LogManager.h" #include "PluginManager.h" -void PluginManager::ScanAndLoadPlugins(bool dark_theme) +PluginManager::PluginManager(bool dark_theme_val) +{ + dark_theme = dark_theme_val; +} + +void PluginManager::RegisterAddPluginTabCallback(AddPluginTabCallback new_callback, void * new_callback_arg) +{ + AddPluginTabCallbacks.push_back(new_callback); + AddPluginTabCallbackArgs.push_back(new_callback_arg); +} + +void PluginManager::ScanAndLoadPlugins() { LOG_INFO("Loading plugins"); - std::string OpenRGBConfigDir = ResourceManager::get()->GetConfigurationDirectory(); - - std::string PluginPath = OpenRGBConfigDir + "/Plugins"; - - /*--------------------------------------------------------------------------------------*\ - | I used https://github.com/krf/cmake-qtqml-plugin-example to figure out how to do this | - | So BIG credit to krf | - \*--------------------------------------------------------------------------------------*/ - OpenRGBPluginInterface *OpenRGBPlugin = nullptr; - - const QDir pluginsDir = QString().fromStdString(ResourceManager::get()->GetConfigurationDirectory()) + "plugins/"; + const QDir plugins_dir = QString().fromStdString(ResourceManager::get()->GetConfigurationDirectory()) + "plugins/"; std::vector FileList; - for(int i = 0; i < QDir(pluginsDir).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(pluginsDir).entryList(QDir::Files)[i].toStdString()); + FileList.push_back(QDir(plugins_dir).entryList(QDir::Files)[i].toStdString()); } - for(const std::string &fileName : FileList) + for(const std::string &plugin_name : FileList) { - const std::string filePath = pluginsDir.absoluteFilePath(QString().fromStdString(fileName)).toStdString(); + const std::string plugin_path = plugins_dir.absoluteFilePath(QString().fromStdString(plugin_name)).toStdString(); - LOG_VERBOSE("Attempting to load: %s", filePath.c_str()); - - QPluginLoader loader(pluginsDir.absoluteFilePath(QString().fromStdString(fileName))); - - if (QObject *instance = loader.instance()) - { - if ((OpenRGBPlugin = qobject_cast(instance))) - { - /*-----------------------------------------------------*\ - | Initialize the plugin | - \*-----------------------------------------------------*/ - OpenRGBPlugin->info = OpenRGBPlugin->Initialize(dark_theme, ResourceManager::get()); - - LOG_VERBOSE("Loaded plugin %s", OpenRGBPlugin->info.PluginName.c_str()); - - PluginManager::ActivePlugins.push_back(OpenRGBPlugin); - } - } - else - { - std::cout << loader.errorString().toStdString() << std::endl; - } + LoadPlugin(plugin_path); + } +} + +void PluginManager::LoadPlugin(std::string path) +{ + OpenRGBPluginInterface *OpenRGBPlugin = nullptr; + + LOG_VERBOSE("Attempting to load: %s", path.c_str()); + + QPluginLoader loader(QString().fromStdString(path)); + + if (QObject *instance = loader.instance()) + { + if ((OpenRGBPlugin = qobject_cast(instance))) + { + /*-----------------------------------------------------*\ + | 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(); + + for(unsigned int plugin_idx = 0; plugin_idx < plugin_settings["plugins"].size(); plugin_idx++) + { + if(plugin_settings["plugins"][plugin_idx].contains("name")) + { + name = plugin_settings["plugins"][plugin_idx]["name"]; + } + + if(plugin_settings["plugins"][plugin_idx].contains("description")) + { + description = plugin_settings["plugins"][plugin_idx]["description"]; + } + + if(plugin_settings["plugins"][plugin_idx].contains("enabled")) + { + enabled = plugin_settings["plugins"][plugin_idx]["enabled"]; + } + + if((OpenRGBPlugin->info.PluginName == name) + &&(OpenRGBPlugin->info.PluginDescription == description)) + { + found = true; + break; + } + } + } + + if(!found) + { + plugin_settings["plugins"][plugin_ct]["name"] = OpenRGBPlugin->info.PluginName; + plugin_settings["plugins"][plugin_ct]["description"] = OpenRGBPlugin->info.PluginDescription; + plugin_settings["plugins"][plugin_ct]["enabled"] = enabled; + + ResourceManager::get()->GetSettingsManager()->SetSettings("Plugins", plugin_settings); + ResourceManager::get()->GetSettingsManager()->SaveSettings(); + } + + LOG_VERBOSE("Loaded plugin %s", OpenRGBPlugin->info.PluginName.c_str()); + + OpenRGBPluginEntry entry; + + entry.plugin = OpenRGBPlugin; + entry.path = path; + entry.enabled = enabled; + + PluginManager::ActivePlugins.push_back(entry); + + /*-------------------------------------------------*\ + | Call the callbacks | + \*-------------------------------------------------*/ + for(unsigned int callback_idx = 0; callback_idx < AddPluginTabCallbacks.size(); callback_idx++) + { + AddPluginTabCallbacks[callback_idx](AddPluginTabCallbackArgs[callback_idx], OpenRGBPlugin); + } + } + } + else + { + std::cout << loader.errorString().toStdString() << std::endl; } } diff --git a/PluginManager.h b/PluginManager.h index 8c0e3cdd..27d64a6b 100644 --- a/PluginManager.h +++ b/PluginManager.h @@ -11,10 +11,29 @@ #include #include +typedef struct +{ + OpenRGBPluginInterface* plugin; + std::string path; + bool enabled; +} OpenRGBPluginEntry; + +typedef void (*AddPluginTabCallback)(void *, OpenRGBPluginInterface* plugin); + class PluginManager { public: - std::vector ActivePlugins; + PluginManager(bool dark_theme); - void ScanAndLoadPlugins(bool dark_theme); + void RegisterAddPluginTabCallback(AddPluginTabCallback new_callback, void * new_callback_arg); + void ScanAndLoadPlugins(); + void LoadPlugin(std::string path); + + std::vector ActivePlugins; + +private: + bool dark_theme; + + std::vector AddPluginTabCallbacks; + std::vector AddPluginTabCallbackArgs; }; diff --git a/qt/OpenRGBDialog2.cpp b/qt/OpenRGBDialog2.cpp index 7d00fff2..02dd7200 100644 --- a/qt/OpenRGBDialog2.cpp +++ b/qt/OpenRGBDialog2.cpp @@ -96,6 +96,13 @@ static void UpdateDetectionProgressCallback(void * this_ptr) QMetaObject::invokeMethod(this_obj, "onDetectionProgressUpdated", Qt::QueuedConnection); } +static void CreatePluginTabCallback(void * this_ptr, OpenRGBPluginInterface * plugin) +{ + OpenRGBDialog2 * this_obj = (OpenRGBDialog2 *)this_ptr; + + this_obj->AddPluginTab(plugin); +} + bool OpenRGBDialog2::IsDarkTheme() { #ifdef _WIN32 @@ -402,6 +409,18 @@ OpenRGBDialog2::OpenRGBDialog2(QWidget *parent) : QMainWindow(parent), ui(new Op \*-----------------------------------------------------*/ AddSettingsPage(); + /*-----------------------------------------------------*\ + | Initialize the plugin manager | + \*-----------------------------------------------------*/ + plugin_manager = new PluginManager(IsDarkTheme()); + plugin_manager->RegisterAddPluginTabCallback(&CreatePluginTabCallback, this); + plugin_manager->ScanAndLoadPlugins(); + + /*-----------------------------------------------------*\ + | Add the Plugins page | + \*-----------------------------------------------------*/ + AddPluginsPage(plugin_manager); + /*-----------------------------------------------------*\ | Add the E1.31 settings page | \*-----------------------------------------------------*/ @@ -424,24 +443,6 @@ OpenRGBDialog2::OpenRGBDialog2(QWidget *parent) : QMainWindow(parent), ui(new Op { AddI2CToolsPage(); } - - /*-----------------------------------------------------*\ - | Add the various plugins tabs | - \*-----------------------------------------------------*/ - plugin_manager = new PluginManager; - - plugin_manager->ScanAndLoadPlugins(IsDarkTheme()); - - if(plugin_manager->ActivePlugins.size() > 0) - { - for(int i = 0; i < int(plugin_manager->ActivePlugins.size()); i++) - { - /*---------------------------------------------------------------------------*\ - | Start by getting location and then placing the widget where it needs to go | - \*---------------------------------------------------------------------------*/ - AddPluginTab(plugin_manager, i); - } - } } OpenRGBDialog2::~OpenRGBDialog2() @@ -492,6 +493,34 @@ void OpenRGBDialog2::closeEvent(QCloseEvent *event) } } +void OpenRGBDialog2::AddPluginsPage(PluginManager* plugin_manager) +{ + /*-----------------------------------------------------*\ + | Create the Plugins page | + \*-----------------------------------------------------*/ + PluginsPage = new OpenRGBPluginsPage(plugin_manager); + + ui->SettingsTabBar->addTab(PluginsPage, ""); + + QString PluginsLabelString; + + if(IsDarkTheme()) + { + PluginsLabelString = "plugin_dark.png"; + } + else + { + PluginsLabelString = "plugin.png"; + } + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* PluginTabLabel = new TabLabel(PluginsLabelString, "Plugins"); + + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, PluginTabLabel); +} + void OpenRGBDialog2::AddSoftwareInfoPage() { /*-----------------------------------------------------*\ @@ -661,7 +690,7 @@ void OpenRGBDialog2::AddSerialSettingsPage() ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); } -void OpenRGBDialog2::AddPluginTab(PluginManager* plugin_manager, int plugin_index) +void OpenRGBDialog2::AddPluginTab(OpenRGBPluginInterface* plugin) { /*-----------------------------------------------------*\ | Create Label for the Tab | @@ -672,13 +701,13 @@ void OpenRGBDialog2::AddPluginTab(PluginManager* plugin_manager, int plugin_inde | If the plugin has custom information, use it, | | otherwise generate it | \*-----------------------------------------------------*/ - if(plugin_manager->ActivePlugins[plugin_index]->info.HasCustom) + if(plugin->info.HasCustom) { - PluginTabLabel = plugin_manager->ActivePlugins[plugin_index]->info.PluginLabel; + PluginTabLabel = plugin->info.PluginLabel; } else { - QLabel *TabLabelText = plugin_manager->ActivePlugins[plugin_index]->info.PluginLabel; + QLabel *TabLabelText = plugin->info.PluginLabel; QString PluginLabelString; if(IsDarkTheme()) @@ -699,14 +728,14 @@ void OpenRGBDialog2::AddPluginTab(PluginManager* plugin_manager, int plugin_inde /*-----------------------------------------------------*\ | Determine plugin location | \*-----------------------------------------------------*/ - std::string Location = plugin_manager->ActivePlugins[plugin_index]->info.PluginLocation; + std::string Location = plugin->info.PluginLocation; /*-----------------------------------------------------*\ | InformationTab - Place plugin in the Information tab | \*-----------------------------------------------------*/ if(Location == "InformationTab") { - QWidget* NewPluginTab = plugin_manager->ActivePlugins[plugin_index]->CreateGUI(this); + QWidget* NewPluginTab = plugin->CreateGUI(this); OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab); @@ -719,7 +748,7 @@ void OpenRGBDialog2::AddPluginTab(PluginManager* plugin_manager, int plugin_inde \*-----------------------------------------------------*/ else if(Location == "DevicesTab") { - QWidget* NewPluginTab = plugin_manager->ActivePlugins[plugin_index]->CreateGUI(this); + QWidget* NewPluginTab = plugin->CreateGUI(this); OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab); @@ -732,18 +761,18 @@ void OpenRGBDialog2::AddPluginTab(PluginManager* plugin_manager, int plugin_inde \*-----------------------------------------------------*/ else if(Location == "TopTabBar") { - QWidget* NewPluginTab = plugin_manager->ActivePlugins[plugin_index]->CreateGUI(this); + QWidget* NewPluginTab = plugin->CreateGUI(this); OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab); - ui->MainTabBar->addTab(NewPluginContainer,QString().fromStdString(plugin_manager->ActivePlugins[plugin_index]->info.PluginName)); + ui->MainTabBar->addTab(NewPluginContainer,QString().fromStdString(plugin->info.PluginName)); } /*-----------------------------------------------------*\ | SettingsTabBar - Place plugin in the Settings tab | \*-----------------------------------------------------*/ else if(Location == "SettingsTabBar") { - QWidget* NewPluginTab = plugin_manager->ActivePlugins[plugin_index]->CreateGUI(this); + QWidget* NewPluginTab = plugin->CreateGUI(this); OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab); @@ -757,7 +786,7 @@ void OpenRGBDialog2::AddPluginTab(PluginManager* plugin_manager, int plugin_inde \*-----------------------------------------------------*/ else { - std::cout << ("Cannot load plugin '" + plugin_manager->ActivePlugins[plugin_index]->info.PluginName + "' as it does not specify a valid location: " + Location + "\n"); + std::cout << ("Cannot load plugin '" + plugin->info.PluginName + "' as it does not specify a valid location: " + Location + "\n"); } } diff --git a/qt/OpenRGBDialog2.h b/qt/OpenRGBDialog2.h index df517fd7..f434bf42 100644 --- a/qt/OpenRGBDialog2.h +++ b/qt/OpenRGBDialog2.h @@ -4,6 +4,7 @@ #include "ui_OpenRGBDialog2.h" #include "OpenRGBClientInfoPage.h" +#include "OpenRGBPluginsPage/OpenRGBPluginsPage.h" #include "OpenRGBSoftwareInfoPage.h" #include "OpenRGBSystemInfoPage.h" #include "OpenRGBSupportedDevicesPage.h" @@ -44,6 +45,8 @@ public: void AddI2CToolsPage(); void AddServerTab(); + void AddPluginTab(OpenRGBPluginInterface* plugin); + void setMode(unsigned char mode_val); static bool IsDarkTheme(); @@ -54,6 +57,7 @@ private: | Page pointers | \*-------------------------------------*/ OpenRGBClientInfoPage *ClientInfoPage; + OpenRGBPluginsPage *PluginsPage; OpenRGBSystemInfoPage *SMBusToolsPage; OpenRGBSoftwareInfoPage *SoftInfoPage; OpenRGBSupportedDevicesPage *SupportedPage; @@ -81,7 +85,7 @@ private: void AddE131SettingsPage(); void AddQMKORGBSettingsPage(); void AddSerialSettingsPage(); - void AddPluginTab(PluginManager* plugin_manager,int plugin_index); + void AddPluginsPage(PluginManager* plugin_manager); void ClearDevicesList(); void UpdateDevicesList(); diff --git a/qt/OpenRGBPluginsPage/OpenRGBPluginsEntry.cpp b/qt/OpenRGBPluginsPage/OpenRGBPluginsEntry.cpp new file mode 100644 index 00000000..ab7f4f67 --- /dev/null +++ b/qt/OpenRGBPluginsPage/OpenRGBPluginsEntry.cpp @@ -0,0 +1,16 @@ +#include "OpenRGBPluginsEntry.h" +#include "ui_OpenRGBPluginsEntry.h" + +using namespace Ui; + +OpenRGBPluginsEntry::OpenRGBPluginsEntry(QWidget *parent) : + QWidget(parent), + ui(new Ui::OpenRGBPluginsEntryUi) +{ + ui->setupUi(this); +} + +OpenRGBPluginsEntry::~OpenRGBPluginsEntry() +{ + delete ui; +} diff --git a/qt/OpenRGBPluginsPage/OpenRGBPluginsEntry.h b/qt/OpenRGBPluginsPage/OpenRGBPluginsEntry.h new file mode 100644 index 00000000..e6cb6319 --- /dev/null +++ b/qt/OpenRGBPluginsPage/OpenRGBPluginsEntry.h @@ -0,0 +1,21 @@ +#ifndef OPENRGBPLUGINSENTRY_H +#define OPENRGBPLUGINSENTRY_H + +#include "ui_OpenRGBPluginsEntry.h" +#include + +namespace Ui { +class OpenRGBPluginsEntry; +} + +class Ui::OpenRGBPluginsEntry : public QWidget +{ + Q_OBJECT + +public: + explicit OpenRGBPluginsEntry(QWidget *parent = nullptr); + ~OpenRGBPluginsEntry(); + Ui::OpenRGBPluginsEntryUi *ui; +}; + +#endif // OPENRGBPLUGINSENTRY_H diff --git a/qt/OpenRGBPluginsPage/OpenRGBPluginsEntry.ui b/qt/OpenRGBPluginsPage/OpenRGBPluginsEntry.ui new file mode 100644 index 00000000..4cce4923 --- /dev/null +++ b/qt/OpenRGBPluginsPage/OpenRGBPluginsEntry.ui @@ -0,0 +1,110 @@ + + + OpenRGBPluginsEntryUi + + + + 0 + 0 + 195 + 109 + + + + Form + + + + + + + + + + + + + 0 + 0 + + + + Description Value + + + + + + + Enabled + + + + + + + + 0 + 0 + + + + Name Value + + + + + + + + 0 + 0 + + + + Description + + + + + + + + 0 + 0 + + + + Name: + + + + + + + + + + + + + + Path + + + + + + + Path Value + + + + + + + + + + + diff --git a/qt/OpenRGBPluginsPage/OpenRGBPluginsPage.cpp b/qt/OpenRGBPluginsPage/OpenRGBPluginsPage.cpp new file mode 100644 index 00000000..e6e3657b --- /dev/null +++ b/qt/OpenRGBPluginsPage/OpenRGBPluginsPage.cpp @@ -0,0 +1,132 @@ +#include +#include + +#include "filesystem.h" +#include "OpenRGBPluginsPage.h" +#include "ui_OpenRGBPluginsPage.h" + +Ui::OpenRGBPluginsPage::OpenRGBPluginsPage(PluginManager* plugin_manager_ptr, QWidget *parent) : + QWidget(parent), + ui(new Ui::OpenRGBPluginsPageUi) +{ + plugin_manager = plugin_manager_ptr; + ui->setupUi(this); + + RefreshList(); +} + +Ui::OpenRGBPluginsPage::~OpenRGBPluginsPage() +{ + delete ui; +} + +void Ui::OpenRGBPluginsPage::RefreshList() +{ + ui->PluginsList->clear(); + entries.clear(); + + for(unsigned int plugin_idx = 0; plugin_idx < plugin_manager->ActivePlugins.size(); plugin_idx++) + { + 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)); + entry->ui->PathValue->setText(QString::fromStdString(plugin_manager->ActivePlugins[plugin_idx].path)); + entry->ui->EnabledCheckBox->setChecked((plugin_manager->ActivePlugins[plugin_idx].enabled)); + + //TODO: Get plugin enable/disable working + // Until then, hide the enable checkbox + entry->ui->EnabledLabel->setVisible(false); + entry->ui->EnabledCheckBox->setVisible(false); + + QListWidgetItem* item = new QListWidgetItem; + + item->setSizeHint(entry->sizeHint()); + + ui->PluginsList->addItem(item); + ui->PluginsList->setItemWidget(item, entry); + entries.push_back(entry); + } +} + +void Ui::OpenRGBPluginsPage::on_InstallPluginButton_clicked() +{ + QString install_file = QFileDialog::getOpenFileName(this, "Install OpenRGB Plugin", "", "DLL Files (*.dll; *.dylib; *.so; *.so.*)"); + + std::string from_path = install_file.toStdString(); + std::string to_path = ResourceManager::get()->GetConfigurationDirectory() + "plugins/"; + std::string to_file = to_path + filesystem::path(from_path).filename().string(); + bool match = false; + + for(unsigned int plugin_idx = 0; plugin_idx < plugin_manager->ActivePlugins.size(); plugin_idx++) + { + if(to_file == plugin_manager->ActivePlugins[plugin_idx].path) + { + match = true; + break; + } + } + + if(match == true) + { + QMessageBox::StandardButton reply; + + reply = QMessageBox::question(this, "Replace Plugin", "A plugin with this filename is already installed. Are you sure you want to replace this plugin?", QMessageBox::Yes | QMessageBox::No); + + if(reply != QMessageBox::Yes) + { + return; + } + } + + try + { + filesystem::copy(from_path, to_path, filesystem::copy_options::update_existing); + + //TODO: Unregister the old plugin and load the new one if matched + // For now, don't load the new plugin + + if(match == false) + { + plugin_manager->LoadPlugin(to_path + "/" + filesystem::path(from_path).filename().string()); + + RefreshList(); + } + } + catch(std::exception& e) + { + + } +} + +void Ui::OpenRGBPluginsPage::on_RemovePluginButton_clicked() +{ + QMessageBox::StandardButton reply; + + reply = QMessageBox::question(this, "Remove Plugin", "Are you sure you want to remove this plugin?", QMessageBox::Yes | QMessageBox::No); + + if(reply != QMessageBox::Yes) + { + return; + } + + int cur_row = ui->PluginsList->currentRow(); + + if(cur_row < 0) + { + return; + } + + QListWidgetItem* item = ui->PluginsList->takeItem(cur_row); + + ui->PluginsList->removeItemWidget(item); + delete item; + + //TODO: Unregister the plugin from the plugin manager + + filesystem::remove(entries[cur_row]->ui->PathValue->text().toStdString()); + + delete entries[cur_row]; + entries.erase(entries.begin() + cur_row); +} + diff --git a/qt/OpenRGBPluginsPage/OpenRGBPluginsPage.h b/qt/OpenRGBPluginsPage/OpenRGBPluginsPage.h new file mode 100644 index 00000000..2b317053 --- /dev/null +++ b/qt/OpenRGBPluginsPage/OpenRGBPluginsPage.h @@ -0,0 +1,35 @@ +#ifndef OPENRGBPLUGINSPAGE_H +#define OPENRGBPLUGINSPAGE_H + +#include +#include "OpenRGBPluginsEntry.h" +#include "ui_OpenRGBPluginsPage.h" +#include "PluginManager.h" + +namespace Ui +{ +class OpenRGBPluginsPage; +} + +class Ui::OpenRGBPluginsPage : public QWidget +{ + Q_OBJECT + +public: + explicit OpenRGBPluginsPage(PluginManager* plugin_manager_ptr, QWidget *parent = nullptr); + ~OpenRGBPluginsPage(); + +private slots: + void on_InstallPluginButton_clicked(); + + void on_RemovePluginButton_clicked(); + +private: + Ui::OpenRGBPluginsPageUi* ui; + PluginManager* plugin_manager; + std::vector entries; + + void RefreshList(); +}; + +#endif // OPENRGBPLUGINSPAGE_H diff --git a/qt/OpenRGBPluginsPage/OpenRGBPluginsPage.ui b/qt/OpenRGBPluginsPage/OpenRGBPluginsPage.ui new file mode 100644 index 00000000..be7e50c1 --- /dev/null +++ b/qt/OpenRGBPluginsPage/OpenRGBPluginsPage.ui @@ -0,0 +1,38 @@ + + + OpenRGBPluginsPageUi + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + Install Plugin + + + + + + + Remove Plugin + + + + + + + + + + +