feat(flatpak): let the user choose which installation to act on

The same application can be present twice — in the user installation
and system-wide, or from two remotes or two branches — and flatpak then
refuses to act on the application id alone: "Multiple installed refs
match 'com.hoptodesk.HopToDesk'". Removing either copy was impossible
from the app.

A row now stands for the application and carries the copies it is made
of, so the details panel lists them and Remove opens one checkbox per
copy; the provider gets back the exact target it listed, and naming a
ref plus its installation is what makes the call unambiguous. Update
gains the same resolution, since it hit the very same refusal, and
removing one copy of two no longer takes the other one's launcher entry
away with it.

The listing that feeds it now asks flatpak for the ref, the branch and
the installation, and reads those columns by position: a branch
installed from a subdirectory has no version, and dropping that empty
column shifted every field after it.
This commit is contained in:
BlackAngelTV committed 2026-09-27 21:33:41 +02:00
1 parent f1fbd3cd8a
commit eb39905bf5
14 files changed
+559 -20

No files matched your search

+34 -2
View File
@@ -460,6 +460,29 @@ AppCore::StartResult AppCore::remove(const PackageInfo& package) {
return startRequest(request);
}
AppCore::StartResult AppCore::removeInstances(const PackageInfo& package,
const std::vector<std::string>& targets) {
if (targets.empty()) return remove(package);
if (targets.size() == 1) {
// One installation picked: the plain removal of that copy. The label
// stays the application name, so the status bar, the journal header and
// the history keep naming the application rather than its ref.
Request request;
request.action = QStringLiteral("remove");
request.package = package;
request.target = QString::fromStdString(targets.front());
return startRequest(request);
}
// Several picked: one operation, one command per installation, the provider
// removing each copy in turn.
Request request;
request.action = QStringLiteral("remove");
request.package = package;
request.targets = targets;
return startRequest(request);
}
AppCore::StartResult AppCore::update(const PackageInfo& package) {
Request request;
request.action = QStringLiteral("update");
@@ -501,8 +524,7 @@ bool AppCore::canInstallFile(const QString& path) const {
}
AppCore::StartResult AppCore::removePackages(const std::vector<PackageInfo>& packages,
const QString& description) {
Request request;
const QString& description) { Request request;
request.action = QStringLiteral("cleanup");
request.packages = packages;
request.description = description;
@@ -713,10 +735,20 @@ AppCore::StartResult AppCore::startRequest(Request request) {
if (action == QLatin1String("update-all") || action == QLatin1String("refresh")
|| action == QLatin1String("clean-caches")) {
worker = new InstallWorker(providers, op);
} else if (!request.targets.empty()) {
// Several installations of one application were picked in the chooser:
// the provider removes one copy per target, and the row they share is
// what the journal and the history name.
worker = new InstallWorker(providers.front(), InstallWorker::Op::RemovePackages,
request.targets);
} else if (action == QLatin1String("install-file")) {
// A file install needs the path, not the display label the other
// single-provider operations pass.
worker = new InstallWorker(providers.front(), op, request.path.toStdString());
} else if (!request.target.isEmpty()) {
// A single installation was picked: the target names it, the label does
// not.
worker = new InstallWorker(providers.front(), op, request.target.toStdString());
} else {
worker = new InstallWorker(providers.front(), op, label.toStdString());
}