UpdateInfo: Show details about available updates

Task-number: QTCREATORBUG-22817
Change-Id: I6b4d54bd89d6343e9f8ae13304ef013db9a786b6
Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
Eike Ziller
2019-08-08 14:40:42 +02:00
parent 6c40fec9b0
commit 7ffc1f5349

View File

@@ -159,6 +159,23 @@ void UpdateInfoPlugin::collectCheckForUpdatesOutput(const QString &contents)
d->m_collectedOutput += contents;
}
static QStringList availableUpdates(const QDomDocument &document)
{
if (document.isNull() || !document.firstChildElement().hasChildNodes())
return {};
QStringList 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"));
}
}
return result;
}
void UpdateInfoPlugin::checkForUpdatesFinished()
{
setLastCheckDate(QDate::currentDate());
@@ -181,6 +198,15 @@ void UpdateInfoPlugin::checkForUpdatesFinished()
Core::ICore::infoBar()->removeInfo(InstallUpdates);
startUpdater();
});
const QStringList updates = availableUpdates(document);
info.setDetailsWidgetCreator([updates]() -> QWidget * {
const QString updateText = updates.join("</li><li>");
auto label = new QLabel;
label->setText("<qt><p>" + tr("Available Updates:") + "<ul><li>" + updateText
+ "</li></ul></p></qt>");
label->setContentsMargins(0, 0, 0, 8);
return label;
});
Core::ICore::infoBar()->unsuppressInfo(InstallUpdates);
Core::ICore::infoBar()->addInfo(info);
} else {