Commit 06e38576 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Use bullet points to confirm packages to remove

BUG: 387935
parent 309703c8
......@@ -25,6 +25,8 @@
#include <QDebug>
#include <KRandom>
// #define TEST_PROCEED
DummyTransaction::DummyTransaction(DummyResource* app, Role role)
: DummyTransaction(app, {}, role)
{
......@@ -48,7 +50,16 @@ void DummyTransaction::iterateTransaction()
setProgress(qBound(0, progress()+(KRandom::random()%30), 100));
QTimer::singleShot(/*KRandom::random()%*/100, this, &DummyTransaction::iterateTransaction);
} else
#ifdef TEST_PROCEED
Q_EMIT proceedRequest(QStringLiteral("yadda yadda"), QStringLiteral("Biii BOooo<ul><li>A</li><li>A</li><li>A</li><li>A</li></ul>"));
#else
finishTransaction();
#endif
}
void DummyTransaction::proceed()
{
finishTransaction();
}
void DummyTransaction::cancel()
......
......@@ -32,6 +32,7 @@ class DummyTransaction : public Transaction
DummyTransaction(DummyResource* app, const AddonList& list, Role role);
void cancel() override;
void proceed() override;
private Q_SLOTS:
void iterateTransaction();
......
......@@ -155,12 +155,13 @@ void PKTransaction::cleanup(PackageKit::Transaction::Exit exit, uint runtime)
}
removedResources.subtract(m_apps.toList().toSet());
QString msg = PackageKitResource::joinPackages(packagesToRemove);
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');
msg += removedResourcesStr.join(QStringLiteral(", "));
msg += removedResourcesStr.join(QStringLiteral("</li><li>"));
}
msg += QStringLiteral("</li></ul>");
if (!msg.isEmpty()) {
Q_EMIT proceedRequest(i18n("Confirm..."), i18np("To proceed with this action, the following package needs removal:\n%2", "To proceed with this action, the following packages need removal:\n%2", packagesToRemove.count(), msg));
......
......@@ -216,13 +216,14 @@ 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)
QString PackageKitResource::joinPackages(const QStringList& pkgids, const QString &_sep)
{
QStringList ret;
foreach(const QString& pkgid, pkgids) {
ret += i18nc("package-name (version)", "%1 (%2)", PackageKit::Daemon::packageName(pkgid), PackageKit::Daemon::packageVersion(pkgid));
}
return ret.join(i18nc("comma separating package names", ", "));
const QString sep = _sep.isEmpty() ? i18nc("comma separating package names", ", ") : _sep;
return ret.join(sep);
}
static QStringList urlToLinks(const QStringList& urls)
......
......@@ -61,7 +61,7 @@ class PackageKitResource : public AbstractResource
PackageKitBackend* backend() const;
static QString joinPackages(const QStringList& pkgids);
static QString joinPackages(const QStringList& pkgids, const QString &_sep = {});
void invokeApplication() const override {}
bool canExecute() const override { return false; }
......
......@@ -168,7 +168,7 @@ void PackageKitUpdater::finished(PackageKit::Transaction::Exit exit, uint /*time
if (!cancel && simulate) {
if (!m_packagesRemoved.isEmpty())
Q_EMIT proceedRequest(i18n("Packages to remove"), i18n("The following packages will be removed by the update:\n%1", PackageKitResource::joinPackages(m_packagesRemoved)));
Q_EMIT proceedRequest(i18n("Packages to remove"), i18n("The following packages will be removed by the update:\n<ul><li>%1</li></ul>", PackageKitResource::joinPackages(m_packagesRemoved, QStringLiteral("</li><li>"))));
else {
proceed();
}
......
Markdown is supported
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