diff --git a/cockatrice/src/interface/widgets/tabs/tab_public_decks.cpp b/cockatrice/src/interface/widgets/tabs/tab_public_decks.cpp index 5d5fddaa0..35389d3bf 100644 --- a/cockatrice/src/interface/widgets/tabs/tab_public_decks.cpp +++ b/cockatrice/src/interface/widgets/tabs/tab_public_decks.cpp @@ -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); diff --git a/cockatrice/src/interface/widgets/tabs/tab_public_decks.h b/cockatrice/src/interface/widgets/tabs/tab_public_decks.h index 737d866b5..492fdeafa 100644 --- a/cockatrice/src/interface/widgets/tabs/tab_public_decks.h +++ b/cockatrice/src/interface/widgets/tabs/tab_public_decks.h @@ -73,6 +73,7 @@ private: QLabel *titleLabel; QLabel *statusLabel; QLabel *emptyLabel; + QString lastFailureMessage; ///< Last load-failure text, re-shown on retranslate. int cardSize = 100; };