diff --git a/pages/browse-page.cpp b/pages/browse-page.cpp index 655408a..158a570 100644 --- a/pages/browse-page.cpp +++ b/pages/browse-page.cpp @@ -104,12 +104,21 @@ BrowsePage::BrowsePage(AppCore* core, QWidget* parent) : Page(core, parent) { connect(m_removeButton, &QPushButton::clicked, this, [this, core] { if (m_selected.name.empty()) return; m_pendingSelect = QString::fromStdString(m_selected.name); + + // One row stands for one installation, or for a provider that only ever + // has one: there is nothing to choose, so the row is what gets removed. + if (m_selected.instances.size() < 2) { + start(core->remove(m_selected), tr("Suppression")); + return; + } + // Several copies of the same application: the user says which ones go. - // A cancelled chooser aborts, an empty choice tells why in the status bar. + // A cancelled chooser aborts, an empty choice says so in the status bar. const auto targets = chooseInstancesToRemove(); if (!targets.has_value()) return; if (targets->empty()) { - emit message(tr("Aucune installation sélectionnée.")); + emit message(tr("Aucune installation sélectionnée : cochez les copies " + "à supprimer, ou annulez.")); return; } start(core->removeInstances(m_selected, *targets), tr("Suppression")); @@ -575,14 +584,10 @@ void BrowsePage::updateDetails(const PackageInfo& pkg) { // holds it more than once (flatpak: a user and a system-wide installation, or // two remotes or branches of the same id). One line per copy, each with the // provider's own target kept aside, so the core is handed exactly what it must -// act on. Returns nothing when the user cancels. +// act on. Returns nothing when the user cancels, and an empty list when they +// ticked nothing — which is why the caller only asks when there are at least +// two copies: with one, the row is the thing to remove. std::optional> BrowsePage::chooseInstancesToRemove() { - if (m_selected.instances.size() < 2) { - // A single installation, or a provider that only ever has one: the row - // is the thing to remove, no question to ask. - return std::vector{}; - } - QDialog dialog(this); dialog.setWindowTitle(tr("Supprimer %1").arg(QString::fromStdString(m_selected.name))); diff --git a/pages/browse-page.h b/pages/browse-page.h index 9121283..325323d 100644 --- a/pages/browse-page.h +++ b/pages/browse-page.h @@ -51,9 +51,9 @@ private: void populateTable(const std::vector& packages); void appendRows(const std::vector& packages); void addRow(int row, const PackageInfo& pkg); - // Which installations of the selected package to remove, when the provider - // holds it more than once. Empty when there is only one to remove, nothing - // (std::nullopt) when the user cancels the chooser. + // Which installations of the selected package to remove, asked only when + // the provider holds it more than once. Nothing (std::nullopt) when the + // user cancels, an empty list when they tick nothing. std::optional> chooseInstancesToRemove(); void updateDetails(const PackageInfo& pkg); void resetDetails();