mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 09:05:10 -07:00
[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:
parent
2d15529d48
commit
dd2400d245
2 changed files with 17 additions and 3 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ private:
|
|||
QLabel *titleLabel;
|
||||
QLabel *statusLabel;
|
||||
QLabel *emptyLabel;
|
||||
QString lastFailureMessage; ///< Last load-failure text, re-shown on retranslate.
|
||||
int cardSize = 100;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue