feat(ui): load the updates list as soon as the tab opens
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 <noreply@codebuff.com>
This commit is contained in:
3 files changed
+59
No files matched your search
@@ -154,6 +154,10 @@ BrowsePage::BrowsePage(AppCore* core, QWidget* parent) : Page(core, parent) {
|
|||||||
m_table,
|
m_table,
|
||||||
"Aucun paquet à afficher.\nLancez une recherche ou ouvrez la liste des "
|
"Aucun paquet à afficher.\nLancez une recherche ou ouvrez la liste des "
|
||||||
"paquets installés.");
|
"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);
|
listLayout->addWidget(m_tableStack);
|
||||||
splitter->addWidget(listCard);
|
splitter->addWidget(listCard);
|
||||||
|
|
||||||
@@ -222,9 +226,24 @@ BrowsePage::BrowsePage(AppCore* core, QWidget* parent) : Page(core, parent) {
|
|||||||
m_installed = results;
|
m_installed = results;
|
||||||
if (m_mode == Mode::Installed) onFilterChanged(m_filterBar->text());
|
if (m_mode == Mode::Installed) onFilterChanged(m_filterBar->text());
|
||||||
} else if (mode == AppCore::ListMode::Updates) {
|
} 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);
|
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) {
|
connect(core, &AppCore::busyChanged, this, [this](bool busy) {
|
||||||
m_progressBar->setVisible(busy);
|
m_progressBar->setVisible(busy);
|
||||||
if (!busy) {
|
if (!busy) {
|
||||||
@@ -298,6 +317,19 @@ void BrowsePage::showInstalled(const QString& select) {
|
|||||||
|
|
||||||
void BrowsePage::showUpdates() {
|
void BrowsePage::showUpdates() {
|
||||||
setMode(Mode::Updates);
|
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"));
|
start(core()->loadUpdates(), tr("Mises à jour"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,6 +339,23 @@ void BrowsePage::setMode(Mode mode) {
|
|||||||
m_filterRow->setVisible(mode == Mode::Installed);
|
m_filterRow->setVisible(mode == Mode::Installed);
|
||||||
m_installButton->setVisible(mode == Mode::Search);
|
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
|
// Clear any stale selection and reset the details panel
|
||||||
m_table->clearSelection();
|
m_table->clearSelection();
|
||||||
resetDetails();
|
resetDetails();
|
||||||
|
|||||||
@@ -103,6 +103,13 @@ void showEmptyState(QStackedWidget* stack, bool empty) {
|
|||||||
if (stack) stack->setCurrentIndex(empty ? 1 : 0);
|
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<QLabel*>()) label->setText(hint);
|
||||||
|
}
|
||||||
|
|
||||||
QLabel* countLabel() {
|
QLabel* countLabel() {
|
||||||
QLabel* label = new QLabel();
|
QLabel* label = new QLabel();
|
||||||
label->setStyleSheet("font-size: 12px; color: #64748b; font-weight: 600;");
|
label->setStyleSheet("font-size: 12px; color: #64748b; font-weight: 600;");
|
||||||
|
|||||||
@@ -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.
|
// so a screen with no result explains itself instead of showing a bare header.
|
||||||
QStackedWidget* withEmptyState(QTableWidget* table, const QString& hint);
|
QStackedWidget* withEmptyState(QTableWidget* table, const QString& hint);
|
||||||
void showEmptyState(QStackedWidget* stack, bool empty);
|
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)").
|
// Small grey counter ("12 paquet(s)").
|
||||||
QLabel* countLabel();
|
QLabel* countLabel();
|
||||||
|
|||||||
Reference in new issue
Block a user