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

master
Adam Honse 3 years ago
parent c6408eb752
commit 41b7dc3102

@ -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());
}
@ -289,6 +320,14 @@ void PluginManager::LoadPlugin(const filesystem::path& path)
}
/*---------------------------------------------------------------------*\
| 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 |
\*---------------------------------------------------------------------*/
if(!ActivePlugins[plugin_idx].loaded)

@ -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);

@ -20,50 +20,55 @@
<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">
<item row="5" column="1">
<widget class="QLabel" name="URLLabel">
<property name="text">
<string notr="true">Path Value</string>
<string>URL:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="DescriptionValue">
<item row="0" column="0" rowspan="8">
<widget class="QLabel" name="IconView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<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 notr="true">Description Value</string>
<string notr="true">Icon</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</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>
<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>Name:</string>
<string>Enabled</string>
</property>
</widget>
</item>
@ -80,13 +85,6 @@
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="URLLabel">
<property name="text">
<string>URL:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="NameValue">
<property name="sizePolicy">
@ -100,6 +98,13 @@
</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">
@ -114,6 +119,19 @@
</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">
@ -121,55 +139,51 @@
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="EnabledLabel">
<item row="7" column="2">
<widget class="QCheckBox" name="EnabledCheckBox">
<property name="text">
<string>Enabled</string>
<string/>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="CommitLabel">
<item row="3" column="1">
<widget class="QLabel" name="VersionLabel">
<property name="text">
<string>Commit:</string>
<string>Version:</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLabel" name="URLValue">
<item row="4" column="1">
<widget class="QLabel" name="CommitLabel">
<property name="text">
<string notr="true">URL Value</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
<string>Commit:</string>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="7">
<widget class="QLabel" name="IconView">
<item row="1" column="2">
<widget class="QLabel" name="DescriptionValue">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<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 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 notr="true">Icon</string>
<string>API Version:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</widget>
</item>
<item row="6" column="2">
<widget class="QLabel" name="APIVersionValue">
<property name="text">
<string>API Version Value</string>
</property>
</widget>
</item>

@ -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 |

Loading…
Cancel
Save