Skip to content

Commit

Permalink
Add repo info to plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlie committed Apr 20, 2024
1 parent 4b002c0 commit bd6a62b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 19 deletions.
10 changes: 6 additions & 4 deletions src/plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ Plugins::~Plugins()
//saveRepositories(_availableRepositories);
}

void Plugins::scanForAvailablePlugins(const QString &path,
void Plugins::scanForAvailablePlugins(const RepoSpecs &repo,
const QString &path,
bool append,
bool emitChanges,
bool emitCache)
Expand All @@ -86,6 +87,7 @@ void Plugins::scanForAvailablePlugins(const QString &path,
QString item = it.next();
if (!folderHasPlugin(item) && !folderHasAddon(item)) { continue; }
PluginSpecs plugin = folderHasPlugin(item) ? getPluginSpecs(item) : folderHasAddon(item) ? getAddonSpecs(item) : PluginSpecs();
plugin.repo = repo;
if (!hasAvailablePlugin(plugin.id) &&
!hasInstalledPlugin(plugin.id))
{
Expand Down Expand Up @@ -1013,7 +1015,7 @@ void Plugins::checkRepositories(bool emitChanges,
return;
}
for (unsigned long i = 0; i < _availableRepositories.size(); ++i) {
RepoSpecs repo = _availableRepositories.at(i);
const auto repo = _availableRepositories.at(i);
if (!isValidRepository(repo) || !repo.enabled) { continue; }
QString repoPath = getRepoPath(repo.id);
qDebug() << "repo path?" << repoPath;
Expand All @@ -1022,7 +1024,7 @@ void Plugins::checkRepositories(bool emitChanges,
emit statusMessage(tr("Need to download %1 repository").arg(repo.label));
_downloadQueue.push_back(repo.zip);
} else {
scanForAvailablePlugins(repoPath, true, emitChanges, emitCache);
scanForAvailablePlugins(repo, repoPath, true, emitChanges, emitCache);
}
}
emit statusMessage(tr("Done"));
Expand Down Expand Up @@ -1314,7 +1316,7 @@ void Plugins::handleFileDownloaded(QNetworkReply *reply)
if (res.success) {
emit statusMessage(tr("Done"));
saveRepositories(_availableRepositories);
scanForAvailablePlugins(destFolder, true);
scanForAvailablePlugins(repo, destFolder, true);
} else {
emit statusError(res.message);
}
Expand Down
30 changes: 16 additions & 14 deletions src/plugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ class Plugins : public QObject

public:

struct RepoSpecs {
double version = 1.0;
QString label;
QString id;
QUrl url;
QUrl manifest;
QUrl logo;
QUrl zip;
QString checksum;
QDateTime modified;
bool enabled = false;
};

struct PluginSpecs {
QString id;
QString label;
Expand All @@ -85,19 +98,7 @@ class Plugins : public QObject
QString key; // addons-only
QString modifier; // addons-only
bool isAddon = false;
};

struct RepoSpecs {
double version = 1.0;
QString label;
QString id;
QUrl url;
QUrl manifest;
QUrl logo;
QUrl zip;
QString checksum;
QDateTime modified;
bool enabled = false;
RepoSpecs repo;
};

struct PluginStatus {
Expand All @@ -115,7 +116,8 @@ class Plugins : public QObject
explicit Plugins(QObject *parent = nullptr);
~Plugins();

void scanForAvailablePlugins(const QString &path,
void scanForAvailablePlugins(const RepoSpecs &repo,
const QString &path,
bool append = false,
bool emitChanges = true,
bool emitCache = false);
Expand Down
10 changes: 9 additions & 1 deletion src/pluginviewwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,15 @@ void PluginViewWidget::showPlugin(const QString &id)
_id = id;

_pluginTitleLabel->setText(plugin.label);
_pluginGroupLabel->setText(plugin.group);

if (!plugin.repo.label.isEmpty()) {
_pluginGroupLabel->setText(QString("%1 <span style=\"font-weight: normal; font-size: small;\">(%2)</span>")
.arg(plugin.group,
plugin.repo.label));
} else {
_pluginGroupLabel->setText(plugin.group);
}

_pluginVersionLabel->setText(tr("Version %1").arg(plugin.version));

_pluginIconLabel->setPixmap(QIcon(QString(DEFAULT_ICON)).pixmap(_iconSize).scaled(_iconSize,
Expand Down

0 comments on commit bd6a62b

Please sign in to comment.