mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
[Client] Improve card database update visibility (#7458)
* [Client] Improve card database update visibility Addresses Cockatrice/Cockatrice#7431. Cockatrice previously offered no in-client feedback while the card database updater ran: the only progress UI lived in the first-run wizard, stderr/stdout were not parsed in interactive runs, and starting a second update with Oracle already open or with a hidden background run active just showed a confusing 'already running' guard - even though Oracle is launched as a separate process with no lifecycle tracking. - Add a status-bar widget (CardDatabaseUpdateStatusBar) that appears while an update runs and shows the Downloading/Parsing/Importing stages with percent progress; it is also used in the quit-confirm prompt so users see an unfinished update before cancelling it. - Parse the updater's PROGRESS lines (new CardUpdateProgressParser, unit-tested) in both foreground and background runs and log stage changes to the new card_database.update category, throttled to at most one line per second; forward Oracle stderr to the logs. - Show a tray balloon when a background update starts and on finish or failure instead of staying silent. - Request a running Oracle instance to raise itself (QLocalServer CockatriceOracleRaise-<user>) when the user starts another update, and demote the 'already running' guard to an informative message only when no running instance can be found. - Emit download/scan/import progress unconditionally from Oracle so interactive and background runs behave the same. - Document the new log category in the troubleshooting guide. * [Client] Address card database update review feedback * [Client] Add setting to control card database update tray notifications * [Client] Address remaining card database update review nits - Rename card_update_progress_parser.{h,cpp} to card_update_progress.{h,cpp} - Store the CardUpdateProgress struct in the status bar widget * Lint. --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
6bed5d6f67
commit
a44757bd11
26 changed files with 702 additions and 67 deletions
|
|
@ -185,10 +185,10 @@ void FirstRunWizard::onCardDatabaseUpdateFinished(bool success)
|
|||
}
|
||||
}
|
||||
|
||||
void FirstRunWizard::onCardDatabaseUpdateProgress(const QString &stage, qint64 done, qint64 total)
|
||||
void FirstRunWizard::onCardDatabaseUpdateProgress(const CardUpdateProgress &progress)
|
||||
{
|
||||
if (cardDatabasePage) {
|
||||
cardDatabasePage->onUpdateProgress(stage, done, total);
|
||||
cardDatabasePage->onUpdateProgress(progress);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef FIRST_RUN_WIZARD_H
|
||||
#define FIRST_RUN_WIZARD_H
|
||||
|
||||
#include "../../card_database_update/card_update_progress.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
|
@ -42,7 +44,7 @@ public slots:
|
|||
void onCardDatabaseUpdateFinished(bool success);
|
||||
|
||||
/** @brief Forwarded from MainWindow while the background card database update process runs. */
|
||||
void onCardDatabaseUpdateProgress(const QString &stage, qint64 done, qint64 total);
|
||||
void onCardDatabaseUpdateProgress(const CardUpdateProgress &progress);
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
|
|
|||
|
|
@ -188,21 +188,29 @@ void CardDatabaseSetupPage::onUpdateFinished(bool success)
|
|||
}
|
||||
}
|
||||
|
||||
void CardDatabaseSetupPage::onUpdateProgress(const QString &stage, qint64 done, qint64 total)
|
||||
void CardDatabaseSetupPage::onUpdateProgress(const CardUpdateProgress &progress)
|
||||
{
|
||||
if (state != State::Running) {
|
||||
return;
|
||||
}
|
||||
const qint64 total = progress.total;
|
||||
const qint64 done = progress.done;
|
||||
progressBar->setRange(0, total > 0 ? static_cast<int>(qMin<qint64>(total, INT_MAX)) : 0);
|
||||
progressBar->setValue(static_cast<int>(qMin<qint64>(done, INT_MAX)));
|
||||
if (total > 0) {
|
||||
const int percent = static_cast<int>((100.0 * done) / total);
|
||||
if (stage == QLatin1String("download")) {
|
||||
statusLabel->setText(tr("Downloading the card database (%1%)…").arg(percent));
|
||||
} else if (stage == QLatin1String("scan")) {
|
||||
statusLabel->setText(tr("Parsing the card database (%1%)…").arg(percent));
|
||||
} else if (stage == QLatin1String("import")) {
|
||||
statusLabel->setText(tr("Importing cards (%1%)…").arg(percent));
|
||||
switch (progress.stage) {
|
||||
case CardUpdateStage::Download:
|
||||
statusLabel->setText(tr("Downloading the card database (%1%)…").arg(percent));
|
||||
break;
|
||||
case CardUpdateStage::Scan:
|
||||
statusLabel->setText(tr("Parsing the card database (%1%)…").arg(percent));
|
||||
break;
|
||||
case CardUpdateStage::Import:
|
||||
statusLabel->setText(tr("Importing cards (%1%)…").arg(percent));
|
||||
break;
|
||||
case CardUpdateStage::Unknown:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef CARD_DATABASE_SETUP_PAGE_H
|
||||
#define CARD_DATABASE_SETUP_PAGE_H
|
||||
|
||||
#include "../../../card_database_update/card_update_progress.h"
|
||||
#include "../first_run_wizard_page.h"
|
||||
|
||||
#include <QSize>
|
||||
|
|
@ -33,7 +34,7 @@ public:
|
|||
void retranslateUi() override;
|
||||
|
||||
void onUpdateFinished(bool success);
|
||||
void onUpdateProgress(const QString &stage, qint64 done, qint64 total);
|
||||
void onUpdateProgress(const CardUpdateProgress &progress);
|
||||
|
||||
signals:
|
||||
void updateRequested();
|
||||
|
|
|
|||
|
|
@ -161,12 +161,18 @@ GeneralSettingsPage::GeneralSettingsPage()
|
|||
|
||||
newVersionOracleCheckBox.setChecked(settings.updates().getNotifyAboutNewVersion());
|
||||
|
||||
cardDatabaseUpdateTrayNotificationCheckBox.setChecked(settings.updates().getCardDatabaseUpdateTrayNotification());
|
||||
|
||||
connect(&cardDatabaseUpdateTrayNotificationCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings.updates(),
|
||||
&UpdatesSettings::setCardDatabaseUpdateTrayNotification);
|
||||
|
||||
auto *cardDatabaseGrid = new QGridLayout;
|
||||
cardDatabaseGrid->addWidget(&startupCardUpdateCheckBehaviorLabel, 0, 0);
|
||||
cardDatabaseGrid->addWidget(&startupCardUpdateCheckBehaviorSelector, 0, 1);
|
||||
cardDatabaseGrid->addWidget(&cardUpdateCheckIntervalLabel, 1, 0);
|
||||
cardDatabaseGrid->addWidget(&cardUpdateCheckIntervalSpinBox, 1, 1);
|
||||
cardDatabaseGrid->addWidget(&lastCardUpdateCheckDateLabel, 2, 1);
|
||||
cardDatabaseGrid->addWidget(&cardDatabaseUpdateTrayNotificationCheckBox, 3, 0, 1, 2);
|
||||
|
||||
cardDatabaseGroupBox = new QGroupBox;
|
||||
cardDatabaseGroupBox->setLayout(cardDatabaseGrid);
|
||||
|
|
@ -565,6 +571,7 @@ void GeneralSettingsPage::retranslateUi()
|
|||
tr("Always update in the background"));
|
||||
cardUpdateCheckIntervalLabel.setText(tr("Check for card database updates every"));
|
||||
cardUpdateCheckIntervalSpinBox.setSuffix(tr(" days"));
|
||||
cardDatabaseUpdateTrayNotificationCheckBox.setText(tr("Notify in the system tray while the card database updates"));
|
||||
|
||||
QDate lastCheckDate = settings.updates().getLastCardUpdateCheck();
|
||||
int daysAgo = lastCheckDate.daysTo(QDate::currentDate());
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ private:
|
|||
QLabel cardUpdateCheckIntervalLabel;
|
||||
QSpinBox cardUpdateCheckIntervalSpinBox;
|
||||
QLabel lastCardUpdateCheckDateLabel;
|
||||
QCheckBox cardDatabaseUpdateTrayNotificationCheckBox;
|
||||
|
||||
QCheckBox showTipsOnStartup;
|
||||
QLabel startupTabLabel;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue