Skip to content

Commit 41b7dc3

Browse files
Show incompatible plugins in the Plugins settings page with a note that it is incompatible, allow it to be removed
1 parent c6408eb commit 41b7dc3

File tree

4 files changed

+138
-72
lines changed

4 files changed

+138
-72
lines changed

PluginManager.cpp

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,15 @@ void PluginManager::AddPlugin(const filesystem::path& path)
197197
\*-----------------------------------------------------*/
198198
OpenRGBPluginEntry entry;
199199

200-
entry.info = info;
201-
entry.plugin = plugin;
202-
entry.loader = loader;
203-
entry.loaded = false;
204-
entry.path = path_string;
205-
entry.enabled = enabled;
206-
entry.widget = nullptr;
200+
entry.info = info;
201+
entry.plugin = plugin;
202+
entry.loader = loader;
203+
entry.loaded = false;
204+
entry.path = path_string;
205+
entry.enabled = enabled;
206+
entry.widget = nullptr;
207+
entry.incompatible = false;
208+
entry.api_version = plugin->GetPluginAPIVersion();
207209

208210
loader->unload();
209211

@@ -216,6 +218,35 @@ void PluginManager::AddPlugin(const filesystem::path& path)
216218
}
217219
else
218220
{
221+
/*-----------------------------------------------------*\
222+
| Fill in a plugin information object with text showing |
223+
| the plugin is incompatible |
224+
\*-----------------------------------------------------*/
225+
OpenRGBPluginInfo info;
226+
227+
info.Name = "Incompatible Plugin";
228+
info.Description = "This plugin is not compatible with this version of OpenRGB.";
229+
230+
/*-----------------------------------------------------*\
231+
| Add the plugin to the PluginManager active plugins |
232+
| but mark it as incompatible |
233+
\*-----------------------------------------------------*/
234+
OpenRGBPluginEntry entry;
235+
236+
entry.info = info;
237+
entry.plugin = plugin;
238+
entry.loader = loader;
239+
entry.loaded = false;
240+
entry.path = path_string;
241+
entry.enabled = false;
242+
entry.widget = nullptr;
243+
entry.incompatible = true;
244+
entry.api_version = plugin->GetPluginAPIVersion();
245+
246+
loader->unload();
247+
248+
PluginManager::ActivePlugins.push_back(entry);
249+
219250
loader->unload();
220251
LOG_WARNING("[PluginManager] Plugin %s has an incompatible API version", path.c_str());
221252
}
@@ -288,6 +319,14 @@ void PluginManager::LoadPlugin(const filesystem::path& path)
288319
return;
289320
}
290321

322+
/*---------------------------------------------------------------------*\
323+
| If the plugin is in the list but is incompatible, return |
324+
\*---------------------------------------------------------------------*/
325+
if(ActivePlugins[plugin_idx].incompatible)
326+
{
327+
return;
328+
}
329+
291330
/*---------------------------------------------------------------------*\
292331
| If the selected plugin is in the list but not loaded, load it |
293332
\*---------------------------------------------------------------------*/

PluginManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ typedef struct
2121
QMenu* traymenu;
2222
std::string path;
2323
bool enabled;
24+
bool incompatible;
25+
int api_version;
2426
} OpenRGBPluginEntry;
2527

2628
typedef void (*AddPluginCallback)(void *, OpenRGBPluginEntry* plugin);

qt/OpenRGBPluginsPage/OpenRGBPluginsEntry.ui

Lines changed: 79 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -20,50 +20,55 @@
2020
<string/>
2121
</property>
2222
<layout class="QGridLayout" name="gridLayout_2">
23-
<item row="3" column="1">
24-
<widget class="QLabel" name="VersionLabel">
25-
<property name="text">
26-
<string>Version:</string>
27-
</property>
28-
</widget>
29-
</item>
30-
<item row="6" column="2">
31-
<widget class="QCheckBox" name="EnabledCheckBox">
32-
<property name="text">
33-
<string/>
34-
</property>
35-
</widget>
36-
</item>
37-
<item row="2" column="2">
38-
<widget class="QLabel" name="PathValue">
23+
<item row="5" column="1">
24+
<widget class="QLabel" name="URLLabel">
3925
<property name="text">
40-
<string notr="true">Path Value</string>
26+
<string>URL:</string>
4127
</property>
4228
</widget>
4329
</item>
44-
<item row="1" column="2">
45-
<widget class="QLabel" name="DescriptionValue">
30+
<item row="0" column="0" rowspan="8">
31+
<widget class="QLabel" name="IconView">
4632
<property name="sizePolicy">
47-
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
33+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
4834
<horstretch>0</horstretch>
4935
<verstretch>0</verstretch>
5036
</sizepolicy>
5137
</property>
38+
<property name="minimumSize">
39+
<size>
40+
<width>64</width>
41+
<height>64</height>
42+
</size>
43+
</property>
44+
<property name="maximumSize">
45+
<size>
46+
<width>64</width>
47+
<height>64</height>
48+
</size>
49+
</property>
5250
<property name="text">
53-
<string notr="true">Description Value</string>
51+
<string notr="true">Icon</string>
52+
</property>
53+
<property name="alignment">
54+
<set>Qt::AlignCenter</set>
5455
</property>
5556
</widget>
5657
</item>
57-
<item row="0" column="1">
58-
<widget class="QLabel" name="NameLabel">
59-
<property name="sizePolicy">
60-
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
61-
<horstretch>0</horstretch>
62-
<verstretch>0</verstretch>
63-
</sizepolicy>
58+
<item row="5" column="2">
59+
<widget class="QLabel" name="URLValue">
60+
<property name="text">
61+
<string notr="true">URL Value</string>
62+
</property>
63+
<property name="openExternalLinks">
64+
<bool>true</bool>
6465
</property>
66+
</widget>
67+
</item>
68+
<item row="7" column="1">
69+
<widget class="QLabel" name="EnabledLabel">
6570
<property name="text">
66-
<string>Name:</string>
71+
<string>Enabled</string>
6772
</property>
6873
</widget>
6974
</item>
@@ -80,13 +85,6 @@
8085
</property>
8186
</widget>
8287
</item>
83-
<item row="5" column="1">
84-
<widget class="QLabel" name="URLLabel">
85-
<property name="text">
86-
<string>URL:</string>
87-
</property>
88-
</widget>
89-
</item>
9088
<item row="0" column="2">
9189
<widget class="QLabel" name="NameValue">
9290
<property name="sizePolicy">
@@ -100,6 +98,13 @@
10098
</property>
10199
</widget>
102100
</item>
101+
<item row="2" column="2">
102+
<widget class="QLabel" name="PathValue">
103+
<property name="text">
104+
<string notr="true">Path Value</string>
105+
</property>
106+
</widget>
107+
</item>
103108
<item row="3" column="2">
104109
<widget class="QLabel" name="VersionValue">
105110
<property name="text">
@@ -114,62 +119,71 @@
114119
</property>
115120
</widget>
116121
</item>
122+
<item row="0" column="1">
123+
<widget class="QLabel" name="NameLabel">
124+
<property name="sizePolicy">
125+
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
126+
<horstretch>0</horstretch>
127+
<verstretch>0</verstretch>
128+
</sizepolicy>
129+
</property>
130+
<property name="text">
131+
<string>Name:</string>
132+
</property>
133+
</widget>
134+
</item>
117135
<item row="2" column="1">
118136
<widget class="QLabel" name="PathLabel">
119137
<property name="text">
120138
<string>Path:</string>
121139
</property>
122140
</widget>
123141
</item>
124-
<item row="6" column="1">
125-
<widget class="QLabel" name="EnabledLabel">
142+
<item row="7" column="2">
143+
<widget class="QCheckBox" name="EnabledCheckBox">
126144
<property name="text">
127-
<string>Enabled</string>
145+
<string/>
128146
</property>
129147
</widget>
130148
</item>
131-
<item row="4" column="1">
132-
<widget class="QLabel" name="CommitLabel">
149+
<item row="3" column="1">
150+
<widget class="QLabel" name="VersionLabel">
133151
<property name="text">
134-
<string>Commit:</string>
152+
<string>Version:</string>
135153
</property>
136154
</widget>
137155
</item>
138-
<item row="5" column="2">
139-
<widget class="QLabel" name="URLValue">
156+
<item row="4" column="1">
157+
<widget class="QLabel" name="CommitLabel">
140158
<property name="text">
141-
<string notr="true">URL Value</string>
142-
</property>
143-
<property name="openExternalLinks">
144-
<bool>true</bool>
159+
<string>Commit:</string>
145160
</property>
146161
</widget>
147162
</item>
148-
<item row="0" column="0" rowspan="7">
149-
<widget class="QLabel" name="IconView">
163+
<item row="1" column="2">
164+
<widget class="QLabel" name="DescriptionValue">
150165
<property name="sizePolicy">
151-
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
166+
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
152167
<horstretch>0</horstretch>
153168
<verstretch>0</verstretch>
154169
</sizepolicy>
155170
</property>
156-
<property name="minimumSize">
157-
<size>
158-
<width>64</width>
159-
<height>64</height>
160-
</size>
161-
</property>
162-
<property name="maximumSize">
163-
<size>
164-
<width>64</width>
165-
<height>64</height>
166-
</size>
171+
<property name="text">
172+
<string notr="true">Description Value</string>
167173
</property>
174+
</widget>
175+
</item>
176+
<item row="6" column="1">
177+
<widget class="QLabel" name="APIVersionLabel">
168178
<property name="text">
169-
<string notr="true">Icon</string>
179+
<string>API Version:</string>
170180
</property>
171-
<property name="alignment">
172-
<set>Qt::AlignCenter</set>
181+
</widget>
182+
</item>
183+
<item row="6" column="2">
184+
<widget class="QLabel" name="APIVersionValue">
185+
<property name="text">
186+
<string>API Version Value</string>
173187
</property>
174188
</widget>
175189
</item>

qt/OpenRGBPluginsPage/OpenRGBPluginsPage.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ void Ui::OpenRGBPluginsPage::RefreshList()
5656
entry->ui->VersionValue->setText(QString::fromStdString(plugin_manager->ActivePlugins[plugin_idx].info.Version));
5757
entry->ui->CommitValue->setText(QString::fromStdString(plugin_manager->ActivePlugins[plugin_idx].info.Commit));
5858
entry->ui->URLValue->setText(QString::fromStdString(plugin_manager->ActivePlugins[plugin_idx].info.URL));
59+
entry->ui->APIVersionValue->setText(QString::number(plugin_manager->ActivePlugins[plugin_idx].api_version));
60+
61+
/*---------------------------------------------------------*\
62+
| If the plugin is incompatible, highlight the API version |
63+
| in red and disable the enable checkbox |
64+
\*---------------------------------------------------------*/
65+
if(plugin_manager->ActivePlugins[plugin_idx].incompatible)
66+
{
67+
entry->ui->APIVersionValue->setStyleSheet("QLabel { color : red; }");
68+
entry->ui->EnabledCheckBox->setEnabled(false);
69+
}
5970

6071
/*---------------------------------------------------------*\
6172
| Fill in plugin icon |

0 commit comments

Comments
 (0)