Commit 70542199 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

When we are showing a confirmation dialog

The version is not always enough.
Just show it when it's actually the same package we are talking about.
The use-case explained in phabricator should remain the same.

CCMAIL: nate@kde.org
parent 51dade98
......@@ -168,7 +168,7 @@ void PKTransaction::cleanup(PackageKit::Transaction::Exit exit, uint runtime)
removedResources.subtract(kVectorToSet(m_apps));
if (!packagesToRemove.isEmpty() || !removedResources.isEmpty()) {
QString msg = QStringLiteral("<ul><li>") + PackageKitResource::joinPackages(packagesToRemove, QStringLiteral("</li><li>"));
QString msg = QStringLiteral("<ul><li>") + PackageKitResource::joinPackages(packagesToRemove, QStringLiteral("</li><li>"), {});
if (!removedResources.isEmpty()) {
const QStringList removedResourcesStr = kTransform<QStringList>(removedResources, [](AbstractResource* a) { return a->name(); });
msg += QLatin1Char('\n');
......
......@@ -216,11 +216,15 @@ static void addIfNotEmpty(const QString& title, const QString& content, QString&
where += QStringLiteral("<p><b>") + title + QStringLiteral("</b>&nbsp;") + QString(content).replace(QStringLiteral("\n"), QStringLiteral("<br />")) + QStringLiteral("</p>");
}
QString PackageKitResource::joinPackages(const QStringList& pkgids, const QString &_sep)
QString PackageKitResource::joinPackages(const QStringList& pkgids, const QString &_sep, const QString &shadowPackage)
{
QStringList ret;
foreach(const QString& pkgid, pkgids) {
ret += PackageKit::Daemon::packageVersion(pkgid);
const auto pkgname = PackageKit::Daemon::packageName(pkgid);
if (pkgname == shadowPackage)
ret += PackageKit::Daemon::packageVersion(pkgid);
else
ret += i18nc("package-name (version)", "%1 (%2)", pkgname, PackageKit::Daemon::packageVersion(pkgid));
}
const QString sep = _sep.isEmpty() ? i18nc("comma separating package names", ", ") : _sep;
return ret.join(sep);
......@@ -234,13 +238,15 @@ static QStringList urlToLinks(const QStringList& urls)
return ret;
}
void PackageKitResource::updateDetail(const QString& /*packageID*/, const QStringList& updates, const QStringList& obsoletes, const QStringList& vendorUrls,
void PackageKitResource::updateDetail(const QString& packageID, const QStringList& updates, const QStringList& obsoletes, const QStringList& vendorUrls,
const QStringList& /*bugzillaUrls*/, const QStringList& /*cveUrls*/, PackageKit::Transaction::Restart restart, const QString& updateText,
const QString& /*changelog*/, PackageKit::Transaction::UpdateState state, const QDateTime& /*issued*/, const QDateTime& /*updated*/)
{
const auto name = PackageKit::Daemon::packageName(packageID);
QString info;
addIfNotEmpty(i18n("Current Version:"), joinPackages(updates), info);
addIfNotEmpty(i18n("Obsoletes:"), joinPackages(obsoletes), info);
addIfNotEmpty(i18n("Current Version:"), joinPackages(updates, {}, name), info);
addIfNotEmpty(i18n("Obsoletes:"), joinPackages(obsoletes, {}, name), info);
addIfNotEmpty(i18n("New Version:"), updateText, info);
addIfNotEmpty(i18n("Update State:"), PackageKitMessages::updateStateMessage(state), info);
addIfNotEmpty(i18n("Restart:"), PackageKitMessages::restartMessage(restart), info);
......
......@@ -62,7 +62,7 @@ class PackageKitResource : public AbstractResource
PackageKitBackend* backend() const;
static QString joinPackages(const QStringList& pkgids, const QString &_sep = {});
static QString joinPackages(const QStringList& pkgids, const QString &_sep, const QString &shadowPackageName);
void invokeApplication() const override {}
bool canExecute() const override { return false; }
......
......@@ -182,8 +182,8 @@ void PackageKitUpdater::finished(PackageKit::Transaction::Exit exit, uint /*time
if (!toremove.isEmpty()) {
const auto toinstall = QStringList() << m_packagesModified.value(PackageKit::Transaction::InfoInstalling) << m_packagesModified.value(PackageKit::Transaction::InfoUpdating);
Q_EMIT proceedRequest(i18n("Packages to remove"), i18n("The following packages will be removed by the update:\n<ul><li>%1</li></ul>\nin order to install:\n<ul><li>%2</li></ul>",
PackageKitResource::joinPackages(toremove, QStringLiteral("</li><li>")),
PackageKitResource::joinPackages(toinstall, QStringLiteral("</li><li>"))
PackageKitResource::joinPackages(toremove, QStringLiteral("</li><li>"), {}),
PackageKitResource::joinPackages(toinstall, QStringLiteral("</li><li>"), {})
));
} else {
proceed();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment