mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-04 23:05:48 +02:00
PluginId: add handler for the plugin id
Change-Id: I377d5856491d38f127fe422e84a6c93839295447
This commit is contained in:
parent
80fe376e3c
commit
9947021394
8 changed files with 29 additions and 16 deletions
2
daemon
2
daemon
|
@ -1 +1 @@
|
|||
Subproject commit 56dc3ca07c79f4dbe536c1cab184eba8194deccd
|
||||
Subproject commit e1edf0adfac853e47d60e87623f755e83f94fbb6
|
|
@ -97,7 +97,11 @@ PluginAdapter::getPluginsFromStore()
|
|||
QList<QVariantMap> plugins;
|
||||
for (const auto& plugin : result) {
|
||||
auto qPlugin = plugin.toVariant().toMap();
|
||||
if (!pluginsInstalled.contains(qPlugin["name"].toString())) {
|
||||
if (!qPlugin.contains("id")) {
|
||||
qPlugin["id"] = qPlugin["name"];
|
||||
}
|
||||
qWarning() << qPlugin["id"];
|
||||
if (!pluginsInstalled.contains(qPlugin["id"].toString())) {
|
||||
plugins.append(qPlugin);
|
||||
}
|
||||
}
|
||||
|
@ -115,8 +119,11 @@ PluginAdapter::getPluginDetails(const QString& pluginId)
|
|||
auto result = QJsonDocument::fromJson(data).object();
|
||||
// my response is a json object and I want to convert
|
||||
// it to a QVariantMap
|
||||
pluginStoreListModel_->addPlugin(
|
||||
result.toVariantMap());
|
||||
auto plugin = result.toVariantMap();
|
||||
if (!plugin.contains("id")) {
|
||||
plugin["id"] = plugin["name"];
|
||||
}
|
||||
pluginStoreListModel_->addPlugin(plugin);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,8 @@ PluginStoreListModel::data(const QModelIndex& index, int role) const
|
|||
switch (role) {
|
||||
case Role::Name:
|
||||
return QVariant(plugin["name"].toString());
|
||||
case Role::Id:
|
||||
return QVariant(plugin["id"].toString());
|
||||
case Role::IconPath:
|
||||
return QVariant(plugin["iconPath"].toString());
|
||||
case Role::Description:
|
||||
|
@ -104,7 +106,7 @@ PluginStoreListModel::removePlugin(const QString& pluginId)
|
|||
{
|
||||
auto index = 0;
|
||||
for (auto& plugin : plugins_) {
|
||||
if (plugin["name"].toString() == pluginId) {
|
||||
if (plugin["id"].toString() == pluginId) {
|
||||
beginRemoveRows(QModelIndex(), index, index);
|
||||
plugins_.removeAt(index);
|
||||
endRemoveRows();
|
||||
|
@ -120,7 +122,7 @@ PluginStoreListModel::updatePlugin(const QVariantMap& plugin)
|
|||
{
|
||||
auto index = 0;
|
||||
for (auto& p : plugins_) {
|
||||
if (p["name"].toString() == plugin["name"].toString()) {
|
||||
if (p["id"].toString() == plugin["id"].toString()) {
|
||||
p = plugin;
|
||||
Q_EMIT dataChanged(createIndex(index, 0), createIndex(index, 0));
|
||||
return;
|
||||
|
@ -169,7 +171,7 @@ void
|
|||
PluginStoreListModel::onVersionStatusChanged(const QString& pluginId, PluginStatus::Role status)
|
||||
{
|
||||
auto it = std::find_if(plugins_.begin(), plugins_.end(), [&pluginId](const QVariantMap& p) {
|
||||
return p["name"].toString() == pluginId;
|
||||
return p["id"].toString() == pluginId;
|
||||
});
|
||||
|
||||
switch (status) {
|
||||
|
@ -237,7 +239,7 @@ PluginStoreListModel::filterPlugins(const QList<QVariantMap>& plugins)
|
|||
installedPlugins.end(),
|
||||
[remotePlugin, &pluginModel, this](const QString& installedPlugin) {
|
||||
const auto& details = pluginModel.getPluginDetails(installedPlugin);
|
||||
return remotePlugin["name"].toString() == details.name;
|
||||
return remotePlugin["id"].toString() == details.id;
|
||||
})
|
||||
== installedPlugins.end()) {
|
||||
filterPluginsNotInstalled.append(remotePlugin);
|
||||
|
|
|
@ -24,6 +24,7 @@ class QColor;
|
|||
class QString;
|
||||
|
||||
#define PLUGINSTORE_ROLES \
|
||||
X(Id) \
|
||||
X(Name) \
|
||||
X(IconPath) \
|
||||
X(Background) \
|
||||
|
|
|
@ -28,6 +28,7 @@ import "../../mainview/components"
|
|||
ItemDelegate {
|
||||
id: root
|
||||
property string pluginName
|
||||
property string pluginId
|
||||
property string pluginIcon
|
||||
property string pluginBackground: JamiTheme.pluginDefaultBackgroundColor
|
||||
property string pluginDescription
|
||||
|
@ -238,13 +239,13 @@ ItemDelegate {
|
|||
function installPlugin() {
|
||||
switch (pluginStatus) {
|
||||
case PluginStatus.DOWNLOADING:
|
||||
PluginAdapter.cancelDownload(pluginName);
|
||||
PluginAdapter.cancelDownload(pluginId);
|
||||
break;
|
||||
case PluginStatus.INSTALLABLE:
|
||||
PluginAdapter.installRemotePlugin(pluginName);
|
||||
PluginAdapter.installRemotePlugin(pluginId);
|
||||
break;
|
||||
case PluginStatus.FAILED:
|
||||
PluginAdapter.installRemotePlugin(pluginName);
|
||||
PluginAdapter.installRemotePlugin(pluginId);
|
||||
break;
|
||||
case PluginStatus.INSTALLING:
|
||||
break;
|
||||
|
|
|
@ -59,7 +59,7 @@ ColumnLayout {
|
|||
Repeater {
|
||||
model: PluginStoreListModel
|
||||
onCountChanged: {
|
||||
root.visible = count > 0
|
||||
root.visible = count > 0;
|
||||
}
|
||||
delegate: Item {
|
||||
id: wrapper
|
||||
|
@ -87,6 +87,7 @@ ColumnLayout {
|
|||
width: wrapper.widthProvider() * scalingFactor
|
||||
height: wrapper.heightProvider() * scalingFactor
|
||||
pluginName: Name
|
||||
pluginId:
|
||||
pluginIcon: IconPath
|
||||
pluginDescription: Description
|
||||
pluginAuthor: Author
|
||||
|
|
|
@ -38,10 +38,10 @@ namespace plugin {
|
|||
*/
|
||||
struct PluginDetails
|
||||
{
|
||||
QString path = "";
|
||||
QString id = "";
|
||||
QString name = "";
|
||||
QString description = "";
|
||||
QString path = "";
|
||||
QString version = "";
|
||||
QString author = "";
|
||||
QString iconPath = "";
|
||||
|
|
|
@ -88,6 +88,7 @@ PluginModel::getPluginDetails(const QString& path)
|
|||
MapStringString details = PluginManager::instance().getPluginDetails(path);
|
||||
plugin::PluginDetails result;
|
||||
if (!details.empty()) {
|
||||
result.path = details["path"];
|
||||
result.id = details["id"];
|
||||
result.name = details["name"];
|
||||
result.description = details["description"];
|
||||
|
@ -97,8 +98,8 @@ PluginModel::getPluginDetails(const QString& path)
|
|||
result.author = details["author"];
|
||||
result.version = details["version"];
|
||||
}
|
||||
if (!pluginsPath_.contains(result.id)) {
|
||||
pluginsPath_[result.id] = path;
|
||||
if (!pluginsPath_.contains(result.path)) {
|
||||
pluginsPath_[result.path] = path;
|
||||
}
|
||||
VectorString loadedPlugins = getLoadedPlugins();
|
||||
if (std::find(loadedPlugins.begin(), loadedPlugins.end(), result.path) != loadedPlugins.end()) {
|
||||
|
@ -158,7 +159,7 @@ PluginModel::setPluginsPath()
|
|||
{
|
||||
for (auto plugin : getInstalledPlugins()) {
|
||||
auto details = getPluginDetails(plugin);
|
||||
pluginsPath_[details.name] = details.path;
|
||||
pluginsPath_[details.id] = details.path;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue