[PublicDecks] Re-show a displayed failure message on language changes

The status label carries both the loading and the failure message, and
retranslateUi hid it whenever the model was not loading, so a language
change while a server-error or timeout message was on screen swapped it
for the (empty) grid. The tab now keeps the last failure text and
re-shows it when not loading, clearing it once a new refresh starts.
This commit is contained in:
Lukas Brübach 2026-09-20 20:17:12 +02:00 committed by GitHub
parent 2d15529d48
commit dd2400d245
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 3 deletions

View file

@ -90,6 +90,7 @@ TabPublicDecks::TabPublicDecks(TabSupervisor *_tabSupervisor, AbstractClient *_c
connect(model, &QAbstractItemModel::modelReset, this, &TabPublicDecks::rebuildGrid);
connect(model, &RemotePublicDecksModel::loadingChanged, this, &TabPublicDecks::updateLoadingState);
connect(model, &RemotePublicDecksModel::loadFailed, this, [this](const QString &message) {
lastFailureMessage = message;
statusLabel->setText(message);
statusLabel->setVisible(true);
flowWidget->setVisible(false);
@ -127,9 +128,18 @@ void TabPublicDecks::retranslateUi()
refreshButton->setToolTip(tr("Refresh"));
refreshButton->setAccessibleName(tr("Refresh"));
quickSettingsWidget->setToolTip(tr("Public Decks Settings"));
// Re-show the status so a visible loading message picks up the new language
// instead of staying stale; if nothing is shown it just stays hidden.
updateLoadingState(model->isLoading());
// Re-show whatever the status label is showing so a language change picks up
// the new language or, for a failure message, at least does not hide it.
if (model->isLoading()) {
updateLoadingState(true);
} else if (!lastFailureMessage.isEmpty()) {
statusLabel->setText(lastFailureMessage);
statusLabel->setVisible(true);
flowWidget->setVisible(false);
emptyLabel->setVisible(false);
} else {
updateLoadingState(false);
}
emit tabTextChanged(this, getTabText());
}
@ -182,6 +192,9 @@ void TabPublicDecks::updateTagsVisibility(bool visible)
void TabPublicDecks::updateLoadingState(bool loading)
{
if (loading) {
// A new attempt is under way, so the previously shown failure, if any,
// no longer describes the current state.
lastFailureMessage.clear();
statusLabel->setText(tr("Loading public decks…"));
statusLabel->setVisible(true);
flowWidget->setVisible(false);

View file

@ -73,6 +73,7 @@ private:
QLabel *titleLabel;
QLabel *statusLabel;
QLabel *emptyLabel;
QString lastFailureMessage; ///< Last load-failure text, re-shown on retranslate.
int cardSize = 100;
};