mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 22:42:14 -07:00
Change to a prompt instead.
This commit is contained in:
parent
18c2155714
commit
f10bfa31da
10 changed files with 166 additions and 16 deletions
|
|
@ -172,6 +172,7 @@ set(cockatrice_SOURCES
|
|||
src/dialogs/dlg_roll_dice.cpp
|
||||
src/dialogs/dlg_select_set_for_cards.cpp
|
||||
src/dialogs/dlg_settings.cpp
|
||||
src/dialogs/dlg_startup_card_check.cpp
|
||||
src/dialogs/dlg_tip_of_the_day.cpp
|
||||
src/dialogs/dlg_update.cpp
|
||||
src/dialogs/dlg_view_log.cpp
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include "../../dialogs/dlg_manage_sets.h"
|
||||
#include "../../dialogs/dlg_register.h"
|
||||
#include "../../dialogs/dlg_settings.h"
|
||||
#include "../../dialogs/dlg_startup_card_check.h"
|
||||
#include "../../dialogs/dlg_tip_of_the_day.h"
|
||||
#include "../../dialogs/dlg_update.h"
|
||||
#include "../../dialogs/dlg_view_log.h"
|
||||
|
|
@ -62,6 +63,7 @@
|
|||
#include <QMenuBar>
|
||||
#include <QMessageBox>
|
||||
#include <QPixmapCache>
|
||||
#include <QRadioButton>
|
||||
#include <QStatusBar>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QThread>
|
||||
|
|
@ -69,6 +71,7 @@
|
|||
#include <QWindow>
|
||||
#include <QtConcurrent>
|
||||
#include <QtNetwork>
|
||||
#include <qbuttongroup.h>
|
||||
|
||||
#define GITHUB_PAGES_URL "https://cockatrice.github.io"
|
||||
#define GITHUB_CONTRIBUTORS_URL "https://github.com/Cockatrice/Cockatrice/graphs/contributors?type=c"
|
||||
|
|
@ -949,7 +952,33 @@ void MainWindow::startupConfigCheck()
|
|||
qCInfo(WindowMainStartupVersionLog) << "Startup: found config with current version";
|
||||
|
||||
if (SettingsCache::instance().getCardUpdateCheckRequired()) {
|
||||
actCheckCardUpdatesBackground();
|
||||
if (SettingsCache::instance().getStartupCardUpdateCheckPromptForUpdate()) {
|
||||
auto startupCardCheckDialog = new DlgStartupCardCheck(this);
|
||||
|
||||
if (startupCardCheckDialog->exec() == QDialog::Accepted) {
|
||||
switch (startupCardCheckDialog->group->checkedId()) {
|
||||
case 0: // foreground
|
||||
actCheckCardUpdates();
|
||||
break;
|
||||
case 1: // background
|
||||
actCheckCardUpdatesBackground();
|
||||
break;
|
||||
case 2: // background + always
|
||||
SettingsCache::instance().setStartupCardUpdateCheckPromptForUpdate(false);
|
||||
SettingsCache::instance().setStartupCardUpdateCheckAlwaysUpdate(true);
|
||||
actCheckCardUpdatesBackground();
|
||||
break;
|
||||
case 3: // don't prompt again + don't run
|
||||
SettingsCache::instance().setStartupCardUpdateCheckPromptForUpdate(false);
|
||||
SettingsCache::instance().setStartupCardUpdateCheckAlwaysUpdate(false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (SettingsCache::instance().getStartupCardUpdateCheckAlwaysUpdate()) {
|
||||
actCheckCardUpdatesBackground();
|
||||
}
|
||||
}
|
||||
|
||||
const auto reloadOk1 = QtConcurrent::run([] { CardDatabaseManager::getInstance()->loadCardDatabases(); });
|
||||
|
|
|
|||
|
|
@ -52,6 +52,13 @@
|
|||
#define WIKI_CUSTOM_SHORTCUTS "https://github.com/Cockatrice/Cockatrice/wiki/Custom-Keyboard-Shortcuts"
|
||||
#define WIKI_TRANSLATION_FAQ "https://github.com/Cockatrice/Cockatrice/wiki/Translation-FAQ"
|
||||
|
||||
enum startupCardUpdateCheckBehaviorIndex
|
||||
{
|
||||
startupCardUpdateCheckBehaviorIndexNone,
|
||||
startupCardUpdateCheckBehaviorIndexPrompt,
|
||||
startupCardUpdateCheckBehaviorIndexAlways
|
||||
};
|
||||
|
||||
GeneralSettingsPage::GeneralSettingsPage()
|
||||
{
|
||||
QStringList languageCodes = findQmFiles();
|
||||
|
|
@ -71,7 +78,17 @@ GeneralSettingsPage::GeneralSettingsPage()
|
|||
// updates
|
||||
SettingsCache &settings = SettingsCache::instance();
|
||||
startupUpdateCheckCheckBox.setChecked(settings.getCheckUpdatesOnStartup());
|
||||
startupCardUpdateCheckCheckBox.setChecked(settings.getCheckCardUpdatesOnStartup());
|
||||
startupCardUpdateCheckBehaviorSelector.addItem(""); // these will be set in retranslateUI
|
||||
startupCardUpdateCheckBehaviorSelector.addItem("");
|
||||
startupCardUpdateCheckBehaviorSelector.addItem("");
|
||||
if (SettingsCache::instance().getStartupCardUpdateCheckPromptForUpdate()) {
|
||||
startupCardUpdateCheckBehaviorSelector.setCurrentIndex(startupCardUpdateCheckBehaviorIndexPrompt);
|
||||
} else if (SettingsCache::instance().getStartupCardUpdateCheckAlwaysUpdate()) {
|
||||
startupCardUpdateCheckBehaviorSelector.setCurrentIndex(startupCardUpdateCheckBehaviorIndexAlways);
|
||||
} else {
|
||||
startupCardUpdateCheckBehaviorSelector.setCurrentIndex(startupCardUpdateCheckBehaviorIndexNone);
|
||||
}
|
||||
|
||||
cardUpdateCheckIntervalSpinBox.setMinimum(1);
|
||||
cardUpdateCheckIntervalSpinBox.setMaximum(30);
|
||||
cardUpdateCheckIntervalSpinBox.setValue(settings.getCardUpdateCheckInterval());
|
||||
|
|
@ -87,8 +104,13 @@ GeneralSettingsPage::GeneralSettingsPage()
|
|||
&GeneralSettingsPage::languageBoxChanged);
|
||||
connect(&startupUpdateCheckCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings,
|
||||
&SettingsCache::setCheckUpdatesOnStartup);
|
||||
connect(&startupCardUpdateCheckCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings,
|
||||
&SettingsCache::setCheckCardUpdatesOnStartup);
|
||||
connect(&startupCardUpdateCheckBehaviorSelector, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||
[](int index) {
|
||||
SettingsCache::instance().setStartupCardUpdateCheckPromptForUpdate(
|
||||
index == startupCardUpdateCheckBehaviorIndexPrompt);
|
||||
SettingsCache::instance().setStartupCardUpdateCheckAlwaysUpdate(
|
||||
index == startupCardUpdateCheckBehaviorIndexAlways);
|
||||
});
|
||||
connect(&cardUpdateCheckIntervalSpinBox, qOverload<int>(&QSpinBox::valueChanged), &settings,
|
||||
&SettingsCache::setCardUpdateCheckInterval);
|
||||
connect(&updateNotificationCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings, &SettingsCache::setNotifyAboutUpdate);
|
||||
|
|
@ -103,7 +125,7 @@ GeneralSettingsPage::GeneralSettingsPage()
|
|||
personalGrid->addWidget(&updateReleaseChannelLabel, 2, 0);
|
||||
personalGrid->addWidget(&updateReleaseChannelBox, 2, 1);
|
||||
personalGrid->addWidget(&startupUpdateCheckCheckBox, 4, 0, 1, 2);
|
||||
personalGrid->addWidget(&startupCardUpdateCheckCheckBox, 5, 0, 1, 2);
|
||||
personalGrid->addWidget(&startupCardUpdateCheckBehaviorSelector, 5, 0, 1, 2);
|
||||
personalGrid->addWidget(&cardUpdateCheckIntervalLabel, 6, 0);
|
||||
personalGrid->addWidget(&cardUpdateCheckIntervalSpinBox, 6, 1);
|
||||
personalGrid->addWidget(&lastCardUpdateCheckDateLabel, 7, 1);
|
||||
|
|
@ -353,7 +375,11 @@ void GeneralSettingsPage::retranslateUi()
|
|||
tokenDatabasePathLabel.setText(tr("Token database:"));
|
||||
updateReleaseChannelLabel.setText(tr("Update channel"));
|
||||
startupUpdateCheckCheckBox.setText(tr("Check for client updates on startup"));
|
||||
startupCardUpdateCheckCheckBox.setText(tr("Automatically update card database in the background on startup"));
|
||||
startupCardUpdateCheckBehaviorSelector.setItemText(startupCardUpdateCheckBehaviorIndexNone, tr("Don't check"));
|
||||
startupCardUpdateCheckBehaviorSelector.setItemText(startupCardUpdateCheckBehaviorIndexPrompt,
|
||||
tr("Prompt for update"));
|
||||
startupCardUpdateCheckBehaviorSelector.setItemText(startupCardUpdateCheckBehaviorIndexAlways,
|
||||
tr("Always update in the background"));
|
||||
cardUpdateCheckIntervalLabel.setText(tr("Check for card database updates every"));
|
||||
cardUpdateCheckIntervalSpinBox.setSuffix(tr(" days"));
|
||||
updateNotificationCheckBox.setText(tr("Notify if a feature supported by the server is missing in my client"));
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ private:
|
|||
QGroupBox *pathsGroupBox;
|
||||
QComboBox languageBox;
|
||||
QCheckBox startupUpdateCheckCheckBox;
|
||||
QCheckBox startupCardUpdateCheckCheckBox;
|
||||
QComboBox startupCardUpdateCheckBehaviorSelector;
|
||||
QLabel cardUpdateCheckIntervalLabel;
|
||||
QSpinBox cardUpdateCheckIntervalSpinBox;
|
||||
QLabel lastCardUpdateCheckDateLabel;
|
||||
|
|
|
|||
50
cockatrice/src/dialogs/dlg_startup_card_check.cpp
Normal file
50
cockatrice/src/dialogs/dlg_startup_card_check.cpp
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#include "dlg_startup_card_check.h"
|
||||
|
||||
#include "../settings/cache_settings.h"
|
||||
|
||||
#include <QDate>
|
||||
|
||||
DlgStartupCardCheck::DlgStartupCardCheck(QWidget *parent) : QDialog(parent)
|
||||
{
|
||||
setWindowTitle(tr("Card Update Check"));
|
||||
|
||||
layout = new QVBoxLayout(this);
|
||||
|
||||
QDate lastCheckDate = SettingsCache::instance().getLastCardUpdateCheck();
|
||||
int daysAgo = lastCheckDate.daysTo(QDate::currentDate());
|
||||
|
||||
instructionLabel = new QLabel(
|
||||
tr("It has been more than %2 days since you last checked your card database for updates.\nChoose how you would "
|
||||
"like to run the card database updater.\nYou can always change this behavior in the 'General' settings tab.")
|
||||
.arg(daysAgo));
|
||||
|
||||
layout->addWidget(instructionLabel);
|
||||
|
||||
group = new QButtonGroup(this);
|
||||
|
||||
foregroundBtn = new QRadioButton(tr("Run in foreground"));
|
||||
backgroundBtn = new QRadioButton(tr("Run in background"));
|
||||
backgroundAlwaysBtn = new QRadioButton(tr("Run in background and always from now on"));
|
||||
dontPromptBtn = new QRadioButton(tr("Don't prompt again and don't run"));
|
||||
dontRunBtn = new QRadioButton(tr("Don't run this time"));
|
||||
|
||||
group->addButton(foregroundBtn, 0);
|
||||
group->addButton(backgroundBtn, 1);
|
||||
group->addButton(backgroundAlwaysBtn, 2);
|
||||
group->addButton(dontPromptBtn, 3);
|
||||
group->addButton(dontRunBtn, 4);
|
||||
|
||||
foregroundBtn->setChecked(true); // default
|
||||
|
||||
layout->addWidget(foregroundBtn);
|
||||
layout->addWidget(backgroundBtn);
|
||||
layout->addWidget(backgroundAlwaysBtn);
|
||||
layout->addWidget(dontPromptBtn);
|
||||
layout->addWidget(dontRunBtn);
|
||||
|
||||
buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
layout->addWidget(buttonBox);
|
||||
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
}
|
||||
24
cockatrice/src/dialogs/dlg_startup_card_check.h
Normal file
24
cockatrice/src/dialogs/dlg_startup_card_check.h
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef DLG_STARTUP_CARD_CHECK_H
|
||||
#define DLG_STARTUP_CARD_CHECK_H
|
||||
|
||||
#include <QButtonGroup>
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QLabel>
|
||||
#include <QRadioButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
class DlgStartupCardCheck : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DlgStartupCardCheck(QWidget *parent);
|
||||
|
||||
QVBoxLayout *layout;
|
||||
QLabel *instructionLabel;
|
||||
QButtonGroup *group;
|
||||
QRadioButton *foregroundBtn, *backgroundBtn, *backgroundAlwaysBtn, *dontPromptBtn, *dontRunBtn;
|
||||
QDialogButtonBox *buttonBox;
|
||||
};
|
||||
|
||||
#endif // DLG_STARTUP_CARD_CHECK_H
|
||||
|
|
@ -194,7 +194,9 @@ SettingsCache::SettingsCache()
|
|||
mbDownloadSpoilers = settings->value("personal/downloadspoilers", false).toBool();
|
||||
|
||||
checkUpdatesOnStartup = settings->value("personal/startupUpdateCheck", true).toBool();
|
||||
checkCardUpdatesOnStartup = settings->value("personal/startupCardUpdateCheck", true).toBool();
|
||||
startupCardUpdateCheckPromptForUpdate =
|
||||
settings->value("personal/startupCardUpdateCheckPromptForUpdate", true).toBool();
|
||||
startupCardUpdateCheckAlwaysUpdate = settings->value("personal/startupCardUpdateCheckAlwaysUpdate", false).toBool();
|
||||
cardUpdateCheckInterval = settings->value("personal/cardUpdateCheckInterval", 7).toInt();
|
||||
lastCardUpdateCheck = settings->value("personal/lastCardUpdateCheck", QDateTime::currentDateTime().date()).toDate();
|
||||
notifyAboutUpdates = settings->value("personal/updatenotification", true).toBool();
|
||||
|
|
@ -1366,10 +1368,15 @@ void SettingsCache::setCheckUpdatesOnStartup(QT_STATE_CHANGED_T value)
|
|||
settings->setValue("personal/startupUpdateCheck", checkUpdatesOnStartup);
|
||||
}
|
||||
|
||||
void SettingsCache::setCheckCardUpdatesOnStartup(QT_STATE_CHANGED_T value)
|
||||
void SettingsCache::setStartupCardUpdateCheckPromptForUpdate(bool value)
|
||||
{
|
||||
checkCardUpdatesOnStartup = static_cast<bool>(value);
|
||||
settings->setValue("personal/startupCardUpdateCheck", checkCardUpdatesOnStartup);
|
||||
startupCardUpdateCheckPromptForUpdate = value;
|
||||
settings->setValue("personal/startupCardUpdateCheckPromptForUpdate", startupCardUpdateCheckPromptForUpdate);
|
||||
}
|
||||
void SettingsCache::setStartupCardUpdateCheckAlwaysUpdate(bool value)
|
||||
{
|
||||
startupCardUpdateCheckAlwaysUpdate = value;
|
||||
settings->setValue("personal/startupCardUpdateCheckAlwaysUpdate", startupCardUpdateCheckAlwaysUpdate);
|
||||
}
|
||||
|
||||
void SettingsCache::setCardUpdateCheckInterval(int value)
|
||||
|
|
|
|||
|
|
@ -199,6 +199,8 @@ private:
|
|||
bool tabVisualDeckStorageOpen, tabServerOpen, tabAccountOpen, tabDeckStorageOpen, tabReplaysOpen, tabAdminOpen,
|
||||
tabLogOpen;
|
||||
bool checkUpdatesOnStartup;
|
||||
bool startupCardUpdateCheckPromptForUpdate;
|
||||
bool startupCardUpdateCheckAlwaysUpdate;
|
||||
bool checkCardUpdatesOnStartup;
|
||||
int cardUpdateCheckInterval;
|
||||
QDate lastCardUpdateCheck;
|
||||
|
|
@ -442,9 +444,13 @@ public:
|
|||
{
|
||||
return checkUpdatesOnStartup;
|
||||
}
|
||||
bool getCheckCardUpdatesOnStartup() const
|
||||
bool getStartupCardUpdateCheckPromptForUpdate()
|
||||
{
|
||||
return checkCardUpdatesOnStartup;
|
||||
return startupCardUpdateCheckPromptForUpdate;
|
||||
}
|
||||
bool getStartupCardUpdateCheckAlwaysUpdate()
|
||||
{
|
||||
return startupCardUpdateCheckAlwaysUpdate;
|
||||
}
|
||||
int getCardUpdateCheckInterval() const
|
||||
{
|
||||
|
|
@ -1028,7 +1034,8 @@ public slots:
|
|||
void setDefaultStartingLifeTotal(const int _defaultStartingLifeTotal);
|
||||
void setRememberGameSettings(const bool _rememberGameSettings);
|
||||
void setCheckUpdatesOnStartup(QT_STATE_CHANGED_T value);
|
||||
void setCheckCardUpdatesOnStartup(QT_STATE_CHANGED_T value);
|
||||
void setStartupCardUpdateCheckPromptForUpdate(bool value);
|
||||
void setStartupCardUpdateCheckAlwaysUpdate(bool value);
|
||||
void setCardUpdateCheckInterval(int value);
|
||||
void setLastCardUpdateCheck(QDate value);
|
||||
void setNotifyAboutUpdate(QT_STATE_CHANGED_T _notifyaboutupdate);
|
||||
|
|
|
|||
|
|
@ -408,7 +408,10 @@ void SettingsCache::setRememberGameSettings(const bool /* _rememberGameSettings
|
|||
void SettingsCache::setCheckUpdatesOnStartup(QT_STATE_CHANGED_T /* value */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setCheckCardUpdatesOnStartup(QT_STATE_CHANGED_T /* value */)
|
||||
void SettingsCache::setStartupCardUpdateCheckPromptForUpdate(bool /* value */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setStartupCardUpdateCheckAlwaysUpdate(bool /* value */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setCardUpdateCheckInterval(int /* value */)
|
||||
|
|
|
|||
|
|
@ -412,7 +412,10 @@ void SettingsCache::setRememberGameSettings(const bool /* _rememberGameSettings
|
|||
void SettingsCache::setCheckUpdatesOnStartup(QT_STATE_CHANGED_T /* value */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setCheckCardUpdatesOnStartup(QT_STATE_CHANGED_T /* value */)
|
||||
void SettingsCache::setStartupCardUpdateCheckPromptForUpdate(bool /* value */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setStartupCardUpdateCheckAlwaysUpdate(bool /* value */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setCardUpdateCheckInterval(int /* value */)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue