forked from qt-creator/qt-creator
UpdateInfo: Include package versions in update notification
Fixes: QTCREATORBUG-24692 Change-Id: I5e3327b92b533dd21eabbd14402b81c1c5ad8d92 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/settingsdatabase.h>
|
||||
#include <coreplugin/shellcommand.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/infobar.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
@@ -159,18 +160,24 @@ void UpdateInfoPlugin::collectCheckForUpdatesOutput(const QString &contents)
|
||||
d->m_collectedOutput += contents;
|
||||
}
|
||||
|
||||
static QStringList availableUpdates(const QDomDocument &document)
|
||||
struct Update
|
||||
{
|
||||
QString name;
|
||||
QString version;
|
||||
};
|
||||
|
||||
static QList<Update> availableUpdates(const QDomDocument &document)
|
||||
{
|
||||
if (document.isNull() || !document.firstChildElement().hasChildNodes())
|
||||
return {};
|
||||
QStringList result;
|
||||
QList<Update> result;
|
||||
const QDomNodeList updates = document.firstChildElement().elementsByTagName("update");
|
||||
for (int i = 0; i < updates.size(); ++i) {
|
||||
const QDomNode node = updates.item(i);
|
||||
if (node.isElement()) {
|
||||
const QDomElement element = node.toElement();
|
||||
if (element.hasAttribute("name"))
|
||||
result.append(element.attribute("name"));
|
||||
result.append({element.attribute("name"), element.attribute("version")});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -197,9 +204,14 @@ void UpdateInfoPlugin::checkForUpdatesFinished()
|
||||
Core::ICore::infoBar()->removeInfo(InstallUpdates);
|
||||
startUpdater();
|
||||
});
|
||||
const QStringList updates = availableUpdates(document);
|
||||
const QList<Update> updates = availableUpdates(document);
|
||||
info.setDetailsWidgetCreator([updates]() -> QWidget * {
|
||||
const QString updateText = updates.join("</li><li>");
|
||||
const QString updateText = Utils::transform(updates, [](const Update &u) {
|
||||
return u.version.isEmpty()
|
||||
? u.name
|
||||
: tr("%1 (%2)", "Package name and version")
|
||||
.arg(u.name, u.version);
|
||||
}).join("</li><li>");
|
||||
auto label = new QLabel;
|
||||
label->setText("<qt><p>" + tr("Available updates:") + "<ul><li>" + updateText
|
||||
+ "</li></ul></p></qt>");
|
||||
|
Reference in New Issue
Block a user