File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,18 @@ bool ApiHelper::loadPlugin(const QString& fileName)
158
158
return false ;
159
159
}
160
160
161
+ bool ApiHelper::loadPlugin (QCloudMusicApiPlugin *plugin)
162
+ {
163
+ ApiPluginImpl* pluginImpl = new ApiPluginImpl ();
164
+ if (plugin) {
165
+ pluginImpl->loader = new QPluginLoader (this );
166
+ pluginImpl->plugin = plugin;
167
+ m_pluginImpls.push_back (pluginImpl);
168
+ return true ;
169
+ }
170
+ return false ;
171
+ }
172
+
161
173
bool ApiHelper::unloadPlugin (const QString& fileName)
162
174
{
163
175
auto result = false ;
@@ -175,3 +187,21 @@ bool ApiHelper::unloadPlugin(const QString& fileName)
175
187
}
176
188
return result;
177
189
}
190
+
191
+ bool ApiHelper::unloadPlugin (QCloudMusicApiPlugin *plugin)
192
+ {
193
+ auto result = false ;
194
+ for (auto i = 0 ; i < m_pluginImpls.size (); i++) {
195
+ auto pluginImpl = m_pluginImpls[i];
196
+ if (pluginImpl->plugin == plugin) {
197
+ m_pluginImpls.removeAt (i);
198
+ pluginImpl->loader ->deleteLater ();
199
+ result = pluginImpl->loader ->unload ();
200
+ if (!result) {
201
+ DEBUG << pluginImpl->loader ->errorString ();
202
+ }
203
+ break ;
204
+ }
205
+ }
206
+ return result;
207
+ }
Original file line number Diff line number Diff line change 6
6
#include < QObject>
7
7
8
8
class ApiPluginImpl ;
9
+ class QCloudMusicApiPlugin ;
9
10
10
11
/* *
11
12
* @class ApiHelper
@@ -64,13 +65,27 @@ class QCLOUDMUSICAPI_EXPORT ApiHelper : public NeteaseCloudMusicApi
64
65
*/
65
66
Q_INVOKABLE bool loadPlugin (const QString& fileName);
66
67
68
+ /* *
69
+ * @brief 加载插件
70
+ * @param plugin 插件指针
71
+ * @return 加载结果
72
+ */
73
+ Q_INVOKABLE bool loadPlugin (QCloudMusicApiPlugin* plugin);
74
+
67
75
/* *
68
76
* @brief 卸载插件
69
77
* @param fileName 插件路径
70
78
* @return 卸载结果
71
79
*/
72
80
Q_INVOKABLE bool unloadPlugin (const QString& fileName);
73
81
82
+ /* *
83
+ * @brief 卸载插件
84
+ * @param plugin 插件指针
85
+ * @return 卸载结果
86
+ */
87
+ Q_INVOKABLE bool unloadPlugin (QCloudMusicApiPlugin* plugin);
88
+
74
89
public:
75
90
DEFINE_VALUE (QString, proxy, " " )
76
91
DEFINE_VALUE (QString, realIP, " " )
You can’t perform that action at this time.
0 commit comments