From 2c7d99138d38f508cd253e08a72a331366d5cea2 Mon Sep 17 00:00:00 2001 From: BlackAngelTV Date: Wed, 23 Sep 2026 21:58:29 +0200 Subject: [PATCH] feat(ui): load the updates list as soon as the tab opens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clicking the Updates tab already triggered the check but showed a bare empty table until it completed, and an "Update all" button that stayed disabled for ever. The tab now shows a searching hint, reports "system is up to date" on an empty result, reloads by itself when the core frees up, and enables "Update all" without a row selection. 🤖 Generated with Codebuff Co-Authored-By: Codebuff --- pages/browse-page.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++ pages/ui-kit.cpp | 7 +++++++ pages/ui-kit.h | 3 +++ 3 files changed, 59 insertions(+) diff --git a/pages/browse-page.cpp b/pages/browse-page.cpp index 2afdfae..73e9afa 100644 --- a/pages/browse-page.cpp +++ b/pages/browse-page.cpp @@ -154,6 +154,10 @@ BrowsePage::BrowsePage(AppCore* core, QWidget* parent) : Page(core, parent) { m_table, "Aucun paquet à afficher.\nLancez une recherche ou ouvrez la liste des " "paquets installés."); + // The "Tout mettre à jour" button only makes sense on the updates tab, but + // there it must be usable without selecting a row first; the per-package + // buttons stay gated on the selection. + m_updateAllButton->setToolTip("Mettre à jour tous les paquets listés"); listLayout->addWidget(m_tableStack); splitter->addWidget(listCard); @@ -222,9 +226,24 @@ BrowsePage::BrowsePage(AppCore* core, QWidget* parent) : Page(core, parent) { m_installed = results; if (m_mode == Mode::Installed) onFilterChanged(m_filterBar->text()); } else if (mode == AppCore::ListMode::Updates) { + // The "searching" hint is replaced by the outcome: an empty + // result means the system is up to date, not that the check + // is still running. + if (results.empty()) { + ui::setEmptyStateText( + m_tableStack, + "Aucune mise à jour disponible.\nVotre système est à " + "jour."); + } if (m_mode == Mode::Updates) populateTable(results); } }); + connect(core, &AppCore::busyChanged, this, [this](bool busy) { + // A listing started from elsewhere (dashboard) while the user was + // already on the updates tab would leave it without data: reload now + // that the core is free again. + if (!busy && m_mode == Mode::Updates && isVisible()) reloadCurrentView(); + }); connect(core, &AppCore::busyChanged, this, [this](bool busy) { m_progressBar->setVisible(busy); if (!busy) { @@ -298,6 +317,19 @@ void BrowsePage::showInstalled(const QString& select) { void BrowsePage::showUpdates() { setMode(Mode::Updates); + // The update check is what the user came for: run it on every arrival on + // the tab (pacman caches its queries for a few seconds, so a click right + // after the dashboard loaded reuses that answer instead of respawning it). + // The "searching" hint replaces the empty-state text for the duration, so + // the tab never looks stuck on an empty table. + ui::setEmptyStateText(m_tableStack, + "Recherche des mises à jour en cours...\nLes résultats " + "s'afficheront automatiquement."); + if (core()->busy()) { + // Something else is loading (e.g. the dashboard asked for the counts): + // the busyChanged handler below reloads when the core frees up. + return; + } start(core()->loadUpdates(), tr("Mises à jour")); } @@ -307,6 +339,23 @@ void BrowsePage::setMode(Mode mode) { m_filterRow->setVisible(mode == Mode::Installed); m_installButton->setVisible(mode == Mode::Search); + // "Tout mettre à jour" acts on the whole list, so it is only offered on the + // tab that displays pending updates; there it needs no row selection. + if (m_updateAllButton) { + m_updateAllButton->setVisible(mode == Mode::Updates); + m_updateAllButton->setEnabled(mode == Mode::Updates + && core()->hasAvailableProvider()); + } + + // The updates tab rewrote the empty-state hint for its own states; restore + // the generic one so the other tabs never show a stale updates message. + if (mode != Mode::Updates) { + ui::setEmptyStateText( + m_tableStack, + "Aucun paquet à afficher.\nLancez une recherche ou ouvrez la liste des " + "paquets installés."); + } + // Clear any stale selection and reset the details panel m_table->clearSelection(); resetDetails(); diff --git a/pages/ui-kit.cpp b/pages/ui-kit.cpp index f730739..2ccb6d1 100644 --- a/pages/ui-kit.cpp +++ b/pages/ui-kit.cpp @@ -103,6 +103,13 @@ void showEmptyState(QStackedWidget* stack, bool empty) { if (stack) stack->setCurrentIndex(empty ? 1 : 0); } +void setEmptyStateText(QStackedWidget* stack, const QString& hint) { + if (!stack) return; + // withEmptyState() puts the hint label second in the placeholder's layout: + // the only label of the stack, so this stays a safe lookup. + if (QLabel* label = stack->findChild()) label->setText(hint); +} + QLabel* countLabel() { QLabel* label = new QLabel(); label->setStyleSheet("font-size: 12px; color: #64748b; font-weight: 600;"); diff --git a/pages/ui-kit.h b/pages/ui-kit.h index 48083c6..5755529 100644 --- a/pages/ui-kit.h +++ b/pages/ui-kit.h @@ -41,6 +41,9 @@ QTableWidget* table(const QStringList& headers, bool allStretch = false); // so a screen with no result explains itself instead of showing a bare header. QStackedWidget* withEmptyState(QTableWidget* table, const QString& hint); void showEmptyState(QStackedWidget* stack, bool empty); +// Rewrites the hint shown while the listing is empty, so a screen can walk the +// user through its states ("searching..." then "nothing found"). +void setEmptyStateText(QStackedWidget* stack, const QString& hint); // Small grey counter ("12 paquet(s)"). QLabel* countLabel();