MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / AddPlugin

Method AddPlugin

PluginManager.cpp:82–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82void PluginManager::AddPlugin(const filesystem::path& path)
83{
84 OpenRGBPluginInterface* plugin = nullptr;
85
86 unsigned int plugin_idx;
87
88 /*---------------------------------------------------------------------*\
89 | Search active plugins to see if this path already exists |
90 \*---------------------------------------------------------------------*/
91 for(plugin_idx = 0; plugin_idx < ActivePlugins.size(); plugin_idx++)
92 {
93 if(path == ActivePlugins[plugin_idx].path)
94 {
95 break;
96 }
97 }
98
99 /*---------------------------------------------------------------------*\
100 | If the path does not match an existing entry, create a new entry |
101 \*---------------------------------------------------------------------*/
102 if(plugin_idx == ActivePlugins.size())
103 {
104 /*-----------------------------------------------------------------*\
105 | Create a QPluginLoader and load the plugin |
106 \*-----------------------------------------------------------------*/
107 std::string path_string = path.generic_u8string();
108 QPluginLoader* loader = new QPluginLoader(QString::fromStdString(path_string));
109 QObject* instance = loader->instance();
110
111 /*-----------------------------------------------------------------*\
112 | Check that the plugin is valid, then check the API version |
113 \*-----------------------------------------------------------------*/
114 if(instance)
115 {
116 plugin = qobject_cast<OpenRGBPluginInterface*>(instance);
117
118 if(plugin)
119 {
120 if(plugin->GetPluginAPIVersion() == OPENRGB_PLUGIN_API_VERSION)
121 {
122 LOG_TRACE("[PluginManager] Plugin %s has a compatible API version", path.c_str());
123
124 /*-----------------------------------------------------*\
125 | Get the plugin information |
126 \*-----------------------------------------------------*/
127 OpenRGBPluginInfo info = plugin->GetPluginInfo();
128
129 /*-----------------------------------------------------*\
130 | Search the settings to see if it is enabled |
131 \*-----------------------------------------------------*/
132 std::string name = "";
133 std::string description = "";
134 bool enabled = true;
135 bool found = false;
136 unsigned int plugin_ct = 0;
137
138 /*-----------------------------------------------------*\
139 | Open plugin list and check if plugin is in the list |

Callers

nothing calls this directly

Calls 8

GetSettingsMethod · 0.80
GetSettingsManagerMethod · 0.80
containsMethod · 0.80
SetSettingsMethod · 0.80
getFunction · 0.50
sizeMethod · 0.45
SaveSettingsMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected