mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-08 17:13:57 -07:00
extract warning message to separate file
This commit is contained in:
parent
e9a47df73a
commit
afed3853a5
4 changed files with 62 additions and 25 deletions
|
|
@ -47,6 +47,7 @@ set(cockatrice_SOURCES
|
||||||
src/interface/widgets/dialogs/dlg_tip_of_the_day.cpp
|
src/interface/widgets/dialogs/dlg_tip_of_the_day.cpp
|
||||||
src/interface/widgets/dialogs/dlg_update.cpp
|
src/interface/widgets/dialogs/dlg_update.cpp
|
||||||
src/interface/widgets/dialogs/dlg_view_log.cpp
|
src/interface/widgets/dialogs/dlg_view_log.cpp
|
||||||
|
src/interface/widgets/dialogs/override_printing_warning.cpp
|
||||||
src/interface/widgets/dialogs/tip_of_the_day.cpp
|
src/interface/widgets/dialogs/tip_of_the_day.cpp
|
||||||
src/filters/deck_filter_string.cpp
|
src/filters/deck_filter_string.cpp
|
||||||
src/filters/filter_builder.cpp
|
src/filters/filter_builder.cpp
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#include "../interface/widgets/utility/get_text_with_max.h"
|
#include "../interface/widgets/utility/get_text_with_max.h"
|
||||||
#include "../interface/widgets/utility/sequence_edit.h"
|
#include "../interface/widgets/utility/sequence_edit.h"
|
||||||
#include "../main.h"
|
#include "../main.h"
|
||||||
|
#include "override_printing_warning.h"
|
||||||
|
|
||||||
#include <../../client/settings/card_counter_settings.h>
|
#include <../../client/settings/card_counter_settings.h>
|
||||||
#include <QAbstractButton>
|
#include <QAbstractButton>
|
||||||
|
|
@ -680,32 +681,9 @@ void AppearanceSettingsPage::overrideAllCardArtWithPersonalPreferenceToggled(QT_
|
||||||
{
|
{
|
||||||
bool enable = static_cast<bool>(value);
|
bool enable = static_cast<bool>(value);
|
||||||
|
|
||||||
QString message;
|
bool accepted = OverridePrintingWarning::execMessageBox(this, enable);
|
||||||
if (enable) {
|
|
||||||
message = tr("Enabling this feature will disable the use of the Printing Selector.\n\n"
|
|
||||||
"You will not be able to manage printing preferences on a per-deck basis, "
|
|
||||||
"or see printings other people have selected for their decks.\n\n"
|
|
||||||
"You will have to use the Set Manager, available through Card Database -> Manage Sets.\n\n"
|
|
||||||
"Are you sure you would like to enable this feature?");
|
|
||||||
} else {
|
|
||||||
message =
|
|
||||||
tr("Disabling this feature will enable the Printing Selector.\n\n"
|
|
||||||
"You can now choose printings on a per-deck basis in the Deck Editor and configure which printing "
|
|
||||||
"gets added to a deck by default by pinning it in the Printing Selector.\n\n"
|
|
||||||
"You can also use the Set Manager to adjust custom sort order for printings in the Printing Selector"
|
|
||||||
" (other sort orders like alphabetical or release date are available).\n\n"
|
|
||||||
"Are you sure you would like to disable this feature?");
|
|
||||||
}
|
|
||||||
|
|
||||||
QMessageBox::StandardButton result =
|
if (!accepted) {
|
||||||
QMessageBox::question(this, tr("Confirm Change"), message, QMessageBox::Yes | QMessageBox::No);
|
|
||||||
|
|
||||||
if (result == QMessageBox::Yes) {
|
|
||||||
SettingsCache::instance().setOverrideAllCardArtWithPersonalPreference(value);
|
|
||||||
// Caches are now invalid.
|
|
||||||
CardPictureLoader::clearPixmapCache();
|
|
||||||
CardPictureLoader::clearNetworkCache();
|
|
||||||
} else {
|
|
||||||
// If user cancels, revert the checkbox/state back
|
// If user cancels, revert the checkbox/state back
|
||||||
QTimer::singleShot(0, this, [this, enable]() {
|
QTimer::singleShot(0, this, [this, enable]() {
|
||||||
overrideAllCardArtWithPersonalPreferenceCheckBox.blockSignals(true);
|
overrideAllCardArtWithPersonalPreferenceCheckBox.blockSignals(true);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
#include "override_printing_warning.h"
|
||||||
|
|
||||||
|
#include "../../card_picture_loader/card_picture_loader.h"
|
||||||
|
#include "../../client/settings/cache_settings.h"
|
||||||
|
|
||||||
|
bool OverridePrintingWarning::execMessageBox(QWidget *parent, bool enable)
|
||||||
|
{
|
||||||
|
QString message;
|
||||||
|
if (enable) {
|
||||||
|
message =
|
||||||
|
QObject::tr("Enabling this feature will disable the use of the Printing Selector.\n\n"
|
||||||
|
"You will not be able to manage printing preferences on a per-deck basis, "
|
||||||
|
"or see printings other people have selected for their decks.\n\n"
|
||||||
|
"You will have to use the Set Manager, available through Card Database -> Manage Sets.\n\n"
|
||||||
|
"Are you sure you would like to enable this feature?");
|
||||||
|
} else {
|
||||||
|
message = QObject::tr(
|
||||||
|
"Disabling this feature will enable the Printing Selector.\n\n"
|
||||||
|
"You can now choose printings on a per-deck basis in the Deck Editor and configure which printing "
|
||||||
|
"gets added to a deck by default by pinning it in the Printing Selector.\n\n"
|
||||||
|
"You can also use the Set Manager to adjust custom sort order for printings in the Printing Selector"
|
||||||
|
" (other sort orders like alphabetical or release date are available).\n\n"
|
||||||
|
"Are you sure you would like to disable this feature?");
|
||||||
|
}
|
||||||
|
|
||||||
|
QMessageBox::StandardButton result =
|
||||||
|
QMessageBox::question(parent, QObject::tr("Confirm Change"), message, QMessageBox::Yes | QMessageBox::No);
|
||||||
|
|
||||||
|
if (result == QMessageBox::Yes) {
|
||||||
|
SettingsCache::instance().setOverrideAllCardArtWithPersonalPreference(static_cast<Qt::CheckState>(enable));
|
||||||
|
// Caches are now invalid.
|
||||||
|
CardPictureLoader::clearPixmapCache();
|
||||||
|
CardPictureLoader::clearNetworkCache();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
#ifndef COCKATRICE_OVERRIDE_PRINTING_WARN_H
|
||||||
|
#define COCKATRICE_OVERRIDE_PRINTING_WARN_H
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
namespace OverridePrintingWarning
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Pops up the warning message for the changing the override printing setting.
|
||||||
|
* If the user clicks accept, then this also handles changing the setting and resetting the card image cache.
|
||||||
|
*
|
||||||
|
* @param parent The parent widget
|
||||||
|
* @param enable Whether the user is trying to enable or disable the setting
|
||||||
|
* @return Whether the user clicked accept. All other ways of closing the window returns false.
|
||||||
|
*/
|
||||||
|
bool execMessageBox(QWidget *parent, bool enable);
|
||||||
|
|
||||||
|
} // namespace OverridePrintingWarning
|
||||||
|
|
||||||
|
#endif // COCKATRICE_OVERRIDE_PRINTING_WARN_H
|
||||||
Loading…
Add table
Add a link
Reference in a new issue