Show incompatible plugins in the Plugins settings page with a note that it is incompatible, allow it to be removed

This commit is contained in:
Adam Honse 2023-09-26 23:41:33 -05:00
parent c6408eb752
commit 41b7dc3102
4 changed files with 192 additions and 126 deletions

View file

@ -197,13 +197,15 @@ void PluginManager::AddPlugin(const filesystem::path& path)
\*-----------------------------------------------------*/
OpenRGBPluginEntry entry;
entry.info = info;
entry.plugin = plugin;
entry.loader = loader;
entry.loaded = false;
entry.path = path_string;
entry.enabled = enabled;
entry.widget = nullptr;
entry.info = info;
entry.plugin = plugin;
entry.loader = loader;
entry.loaded = false;
entry.path = path_string;
entry.enabled = enabled;
entry.widget = nullptr;
entry.incompatible = false;
entry.api_version = plugin->GetPluginAPIVersion();
loader->unload();
@ -216,6 +218,35 @@ void PluginManager::AddPlugin(const filesystem::path& path)
}
else
{
/*-----------------------------------------------------*\
| Fill in a plugin information object with text showing |
| the plugin is incompatible |
\*-----------------------------------------------------*/
OpenRGBPluginInfo info;
info.Name = "Incompatible Plugin";
info.Description = "This plugin is not compatible with this version of OpenRGB.";
/*-----------------------------------------------------*\
| Add the plugin to the PluginManager active plugins |
| but mark it as incompatible |
\*-----------------------------------------------------*/
OpenRGBPluginEntry entry;
entry.info = info;
entry.plugin = plugin;
entry.loader = loader;
entry.loaded = false;
entry.path = path_string;
entry.enabled = false;
entry.widget = nullptr;
entry.incompatible = true;
entry.api_version = plugin->GetPluginAPIVersion();
loader->unload();
PluginManager::ActivePlugins.push_back(entry);
loader->unload();
LOG_WARNING("[PluginManager] Plugin %s has an incompatible API version", path.c_str());
}
@ -288,6 +319,14 @@ void PluginManager::LoadPlugin(const filesystem::path& path)
return;
}
/*---------------------------------------------------------------------*\
| If the plugin is in the list but is incompatible, return |
\*---------------------------------------------------------------------*/
if(ActivePlugins[plugin_idx].incompatible)
{
return;
}
/*---------------------------------------------------------------------*\
| If the selected plugin is in the list but not loaded, load it |
\*---------------------------------------------------------------------*/

View file

@ -21,6 +21,8 @@ typedef struct
QMenu* traymenu;
std::string path;
bool enabled;
bool incompatible;
int api_version;
} OpenRGBPluginEntry;
typedef void (*AddPluginCallback)(void *, OpenRGBPluginEntry* plugin);

View file

@ -20,66 +20,6 @@
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<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 notr="true">Path Value</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="DescriptionValue">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">Description Value</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="NameLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<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="5" column="1">
<widget class="QLabel" name="URLLabel">
<property name="text">
@ -87,65 +27,7 @@
</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 notr="true">Name Value</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="VersionValue">
<property name="text">
<string notr="true">Version Value</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLabel" name="CommitValue">
<property name="text">
<string notr="true">Commit Value</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="PathLabel">
<property name="text">
<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 notr="true">URL Value</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="7">
<item row="0" column="0" rowspan="8">
<widget class="QLabel" name="IconView">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -173,6 +55,138 @@
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLabel" name="URLValue">
<property name="text">
<string notr="true">URL Value</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="EnabledLabel">
<property name="text">
<string>Enabled</string>
</property>
</widget>
</item>
<item row="1" column="1">
<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="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 notr="true">Name Value</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="PathValue">
<property name="text">
<string notr="true">Path Value</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="VersionValue">
<property name="text">
<string notr="true">Version Value</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLabel" name="CommitValue">
<property name="text">
<string notr="true">Commit Value</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="NameLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="PathLabel">
<property name="text">
<string>Path:</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QCheckBox" name="EnabledCheckBox">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="VersionLabel">
<property name="text">
<string>Version:</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="1" column="2">
<widget class="QLabel" name="DescriptionValue">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">Description Value</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="APIVersionLabel">
<property name="text">
<string>API Version:</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLabel" name="APIVersionValue">
<property name="text">
<string>API Version Value</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View file

@ -56,6 +56,17 @@ void Ui::OpenRGBPluginsPage::RefreshList()
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));
entry->ui->APIVersionValue->setText(QString::number(plugin_manager->ActivePlugins[plugin_idx].api_version));
/*---------------------------------------------------------*\
| If the plugin is incompatible, highlight the API version |
| in red and disable the enable checkbox |
\*---------------------------------------------------------*/
if(plugin_manager->ActivePlugins[plugin_idx].incompatible)
{
entry->ui->APIVersionValue->setStyleSheet("QLabel { color : red; }");
entry->ui->EnabledCheckBox->setEnabled(false);
}
/*---------------------------------------------------------*\
| Fill in plugin icon |