mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
[DeckEditor] Show info in PrintingSelector dock when override printings enabled (#6554)
* don't hide printing selector dock * extract warning message to separate file * create printing disabled info widget
This commit is contained in:
parent
948ec9e042
commit
3c48d92663
13 changed files with 176 additions and 67 deletions
|
|
@ -47,6 +47,7 @@ set(cockatrice_SOURCES
|
|||
src/interface/widgets/dialogs/dlg_tip_of_the_day.cpp
|
||||
src/interface/widgets/dialogs/dlg_update.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/filters/deck_filter_string.cpp
|
||||
src/filters/filter_builder.cpp
|
||||
|
|
@ -178,6 +179,7 @@ set(cockatrice_SOURCES
|
|||
src/interface/widgets/deck_editor/deck_editor_printing_selector_dock_widget.cpp
|
||||
src/interface/widgets/deck_editor/deck_list_style_proxy.cpp
|
||||
src/interface/widgets/deck_editor/deck_state_manager.cpp
|
||||
src/interface/widgets/deck_editor/printing_disabled_info_widget.cpp
|
||||
src/interface/widgets/general/background_sources.cpp
|
||||
src/interface/widgets/general/display/background_plate_widget.cpp
|
||||
src/interface/widgets/general/display/banner_widget.cpp
|
||||
|
|
|
|||
|
|
@ -187,10 +187,8 @@ void DeckEditorDatabaseDisplayWidget::databaseCustomMenu(QPoint point)
|
|||
QAction *addToDeck, *addToSideboard, *selectPrinting, *edhRecCommander, *edhRecCard;
|
||||
addToDeck = menu.addAction(tr("Add to Deck"));
|
||||
addToSideboard = menu.addAction(tr("Add to Sideboard"));
|
||||
if (!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
|
||||
selectPrinting = menu.addAction(tr("Select Printing"));
|
||||
connect(selectPrinting, &QAction::triggered, this, [this, card] { deckEditor->showPrintingSelector(); });
|
||||
}
|
||||
selectPrinting = menu.addAction(tr("Select Printing"));
|
||||
connect(selectPrinting, &QAction::triggered, this, [this, card] { deckEditor->showPrintingSelector(); });
|
||||
if (canBeCommander(card.getInfo())) {
|
||||
edhRecCommander = menu.addAction(tr("Show on EDHRec (Commander)"));
|
||||
connect(edhRecCommander, &QAction::triggered, this,
|
||||
|
|
|
|||
|
|
@ -713,14 +713,12 @@ void DeckEditorDeckDockWidget::offsetCountAtIndex(const QModelIndex &idx, bool i
|
|||
|
||||
void DeckEditorDeckDockWidget::decklistCustomMenu(QPoint point)
|
||||
{
|
||||
if (!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
|
||||
QMenu menu;
|
||||
QMenu menu;
|
||||
|
||||
QAction *selectPrinting = menu.addAction(tr("Select Printing"));
|
||||
connect(selectPrinting, &QAction::triggered, deckEditor, &AbstractTabDeckEditor::showPrintingSelector);
|
||||
QAction *selectPrinting = menu.addAction(tr("Select Printing"));
|
||||
connect(selectPrinting, &QAction::triggered, deckEditor, &AbstractTabDeckEditor::showPrintingSelector);
|
||||
|
||||
menu.exec(deckView->mapToGlobal(point));
|
||||
}
|
||||
menu.exec(deckView->mapToGlobal(point));
|
||||
}
|
||||
|
||||
void DeckEditorDeckDockWidget::refreshShortcuts()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#include "deck_editor_printing_selector_dock_widget.h"
|
||||
|
||||
#include "../../../client/settings/cache_settings.h"
|
||||
#include "../../../interface/widgets/tabs/abstract_tab_deck_editor.h"
|
||||
#include "printing_disabled_info_widget.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
|
|
@ -14,6 +16,11 @@ DeckEditorPrintingSelectorDockWidget::DeckEditorPrintingSelectorDockWidget(Abstr
|
|||
setFloating(false);
|
||||
|
||||
createPrintingSelectorDock();
|
||||
printingDisabledInfoWidget = new PrintingDisabledInfoWidget(this);
|
||||
|
||||
setVisibleWidget(SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference());
|
||||
connect(&SettingsCache::instance(), &SettingsCache::overrideAllCardArtWithPersonalPreferenceChanged, this,
|
||||
&DeckEditorPrintingSelectorDockWidget::setVisibleWidget);
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
|
@ -26,10 +33,9 @@ void DeckEditorPrintingSelectorDockWidget::createPrintingSelectorDock()
|
|||
printingSelectorFrame->setObjectName("printingSelectorFrame");
|
||||
printingSelectorFrame->addWidget(printingSelector);
|
||||
|
||||
auto *printingSelectorDockContents = new QWidget();
|
||||
printingSelectorDockContents = new QWidget();
|
||||
printingSelectorDockContents->setObjectName("printingSelectorDockContents");
|
||||
printingSelectorDockContents->setLayout(printingSelectorFrame);
|
||||
setWidget(printingSelectorDockContents);
|
||||
|
||||
installEventFilter(deckEditor);
|
||||
connect(printingSelector, &PrintingSelector::prevCardRequested, deckEditor->getDeckDockWidget(),
|
||||
|
|
@ -42,3 +48,13 @@ void DeckEditorPrintingSelectorDockWidget::retranslateUi()
|
|||
{
|
||||
setWindowTitle(tr("Printing Selector"));
|
||||
}
|
||||
|
||||
void DeckEditorPrintingSelectorDockWidget::setVisibleWidget(bool overridePrintings)
|
||||
{
|
||||
if (overridePrintings) {
|
||||
setWidget(printingDisabledInfoWidget);
|
||||
} else {
|
||||
setWidget(printingSelectorDockContents);
|
||||
printingSelector->updateDisplay();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@
|
|||
|
||||
#include <QDockWidget>
|
||||
|
||||
class PrintingDisabledInfoWidget;
|
||||
class TabDeckEditor;
|
||||
|
||||
class DeckEditorPrintingSelectorDockWidget : public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -20,10 +22,16 @@ public:
|
|||
explicit DeckEditorPrintingSelectorDockWidget(AbstractTabDeckEditor *parent);
|
||||
void createPrintingSelectorDock();
|
||||
void retranslateUi();
|
||||
|
||||
PrintingSelector *printingSelector;
|
||||
|
||||
private:
|
||||
AbstractTabDeckEditor *deckEditor;
|
||||
QWidget *printingSelectorDockContents;
|
||||
PrintingDisabledInfoWidget *printingDisabledInfoWidget;
|
||||
|
||||
private slots:
|
||||
void setVisibleWidget(bool overridePrintings);
|
||||
};
|
||||
|
||||
#endif // DECK_EDITOR_PRINTING_SELECTOR_DOCK_WIDGET_H
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
#include "printing_disabled_info_widget.h"
|
||||
|
||||
#include "../dialogs/override_printing_warning.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QStyle>
|
||||
#include <qguiapplication.h>
|
||||
|
||||
PrintingDisabledInfoWidget::PrintingDisabledInfoWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
auto layout = new QVBoxLayout(this);
|
||||
layout->setObjectName("PrintingDisabledInfoWidgetFrame");
|
||||
setLayout(layout);
|
||||
|
||||
QLabel *imageLabel = new QLabel(this);
|
||||
imageLabel->setAlignment(Qt::AlignCenter);
|
||||
QIcon icon = style()->standardIcon(QStyle::SP_MessageBoxWarning);
|
||||
imageLabel->setPixmap(icon.pixmap({60, 60}));
|
||||
|
||||
textLabel = new QLabel(this);
|
||||
textLabel->setWordWrap(true);
|
||||
textLabel->setAlignment(Qt::AlignCenter);
|
||||
|
||||
settingsButton = new QPushButton(this);
|
||||
connect(settingsButton, &QPushButton::clicked, this, &PrintingDisabledInfoWidget::disableOverridePrintings);
|
||||
|
||||
auto buttonLayout = new QHBoxLayout(this);
|
||||
buttonLayout->addStretch();
|
||||
buttonLayout->addWidget(settingsButton);
|
||||
buttonLayout->addStretch();
|
||||
|
||||
layout->addStretch();
|
||||
layout->addWidget(imageLabel);
|
||||
layout->addWidget(textLabel);
|
||||
layout->addLayout(buttonLayout);
|
||||
layout->addStretch();
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
||||
void PrintingDisabledInfoWidget::retranslateUi()
|
||||
{
|
||||
textLabel->setText(
|
||||
tr("The Printing Selector is disabled because you have currently enabled the setting to override all "
|
||||
"selected printings with personal set preferences.\n\n"
|
||||
"This setting means you'll only see the default printing for each card, instead of being able to select a "
|
||||
"printing, and will not see the printings other people have selected.\n\n"));
|
||||
settingsButton->setText(tr("Enable printings again"));
|
||||
}
|
||||
|
||||
void PrintingDisabledInfoWidget::disableOverridePrintings()
|
||||
{
|
||||
OverridePrintingWarning::execMessageBox(this, false);
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef COCKATRICE_PRINTING_DISABLED_INFO_WIDGET_H
|
||||
#define COCKATRICE_PRINTING_DISABLED_INFO_WIDGET_H
|
||||
#include <QWidget>
|
||||
|
||||
class QPushButton;
|
||||
class QLabel;
|
||||
|
||||
class PrintingDisabledInfoWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QLabel *textLabel;
|
||||
QPushButton *settingsButton;
|
||||
|
||||
private slots:
|
||||
void disableOverridePrintings();
|
||||
|
||||
public:
|
||||
explicit PrintingDisabledInfoWidget(QWidget *parent);
|
||||
|
||||
void retranslateUi();
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_PRINTING_DISABLED_INFO_WIDGET_H
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
#include "../interface/widgets/utility/get_text_with_max.h"
|
||||
#include "../interface/widgets/utility/sequence_edit.h"
|
||||
#include "../main.h"
|
||||
#include "override_printing_warning.h"
|
||||
|
||||
#include <../../client/settings/card_counter_settings.h>
|
||||
#include <QAbstractButton>
|
||||
|
|
@ -680,32 +681,9 @@ void AppearanceSettingsPage::overrideAllCardArtWithPersonalPreferenceToggled(QT_
|
|||
{
|
||||
bool enable = static_cast<bool>(value);
|
||||
|
||||
QString message;
|
||||
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?");
|
||||
}
|
||||
bool accepted = OverridePrintingWarning::execMessageBox(this, enable);
|
||||
|
||||
QMessageBox::StandardButton result =
|
||||
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 (!accepted) {
|
||||
// If user cancels, revert the checkbox/state back
|
||||
QTimer::singleShot(0, this, [this, enable]() {
|
||||
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
|
||||
|
|
@ -61,9 +61,6 @@ AbstractTabDeckEditor::AbstractTabDeckEditor(TabSupervisor *_tabSupervisor) : Ta
|
|||
cardInfoDockWidget = new DeckEditorCardInfoDockWidget(this);
|
||||
filterDockWidget = new DeckEditorFilterDockWidget(this);
|
||||
printingSelectorDockWidget = new DeckEditorPrintingSelectorDockWidget(this);
|
||||
connect(&SettingsCache::instance(), &SettingsCache::overrideAllCardArtWithPersonalPreferenceChanged, this, [this] {
|
||||
printingSelectorDockWidget->setHidden(SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference());
|
||||
});
|
||||
|
||||
// Connect deck signals to this tab
|
||||
connect(deckStateManager, &DeckStateManager::isModifiedChanged, this, &AbstractTabDeckEditor::onDeckModified);
|
||||
|
|
|
|||
|
|
@ -60,10 +60,6 @@ void TabDeckEditor::createMenus()
|
|||
registerDockWidget(viewMenu, filterDockWidget);
|
||||
registerDockWidget(viewMenu, printingSelectorDockWidget);
|
||||
|
||||
if (SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
|
||||
dockToActions[printingSelectorDockWidget].menu->setEnabled(false);
|
||||
}
|
||||
|
||||
connect(&SettingsCache::instance(), &SettingsCache::overrideAllCardArtWithPersonalPreferenceChanged, this,
|
||||
[this](bool enabled) { dockToActions[printingSelectorDockWidget].menu->setEnabled(!enabled); });
|
||||
|
||||
|
|
@ -148,12 +144,6 @@ void TabDeckEditor::loadLayout()
|
|||
restoreGeometry(layouts.getDeckEditorGeometry());
|
||||
}
|
||||
|
||||
if (SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
|
||||
if (!printingSelectorDockWidget->isHidden()) {
|
||||
printingSelectorDockWidget->setHidden(true);
|
||||
}
|
||||
}
|
||||
|
||||
cardDatabaseDockWidget->setMinimumSize(layouts.getDeckEditorCardDatabaseSize());
|
||||
cardDatabaseDockWidget->setMaximumSize(layouts.getDeckEditorCardDatabaseSize());
|
||||
|
||||
|
|
@ -183,9 +173,6 @@ void TabDeckEditor::restartLayout()
|
|||
dockWidget->setFloating(false);
|
||||
}
|
||||
|
||||
// Printing selector special case
|
||||
printingSelectorDockWidget->setVisible(!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference());
|
||||
|
||||
addDockWidget(Qt::LeftDockWidgetArea, cardDatabaseDockWidget);
|
||||
addDockWidget(Qt::RightDockWidgetArea, deckDockWidget);
|
||||
addDockWidget(Qt::RightDockWidgetArea, cardInfoDockWidget);
|
||||
|
|
|
|||
|
|
@ -102,13 +102,6 @@ void TabDeckEditorVisual::createMenus()
|
|||
registerDockWidget(viewMenu, filterDockWidget);
|
||||
registerDockWidget(viewMenu, printingSelectorDockWidget);
|
||||
|
||||
if (SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
|
||||
dockToActions[printingSelectorDockWidget].menu->setEnabled(false);
|
||||
}
|
||||
|
||||
connect(&SettingsCache::instance(), &SettingsCache::overrideAllCardArtWithPersonalPreferenceChanged, this,
|
||||
[this](bool enabled) { dockToActions[printingSelectorDockWidget].menu->setEnabled(!enabled); });
|
||||
|
||||
viewMenu->addSeparator();
|
||||
|
||||
aResetLayout = viewMenu->addAction(QString());
|
||||
|
|
@ -279,12 +272,6 @@ void TabDeckEditorVisual::loadLayout()
|
|||
restoreGeometry(layouts.getDeckEditorGeometry());
|
||||
}
|
||||
|
||||
if (SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
|
||||
if (!printingSelectorDockWidget->isHidden()) {
|
||||
printingSelectorDockWidget->setHidden(true);
|
||||
}
|
||||
}
|
||||
|
||||
cardInfoDockWidget->setMinimumSize(layouts.getDeckEditorCardSize());
|
||||
cardInfoDockWidget->setMaximumSize(layouts.getDeckEditorCardSize());
|
||||
|
||||
|
|
@ -310,7 +297,7 @@ void TabDeckEditorVisual::restartLayout()
|
|||
deckDockWidget->setVisible(true);
|
||||
cardInfoDockWidget->setVisible(true);
|
||||
filterDockWidget->setVisible(false);
|
||||
printingSelectorDockWidget->setVisible(!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference());
|
||||
printingSelectorDockWidget->setVisible(true);
|
||||
|
||||
setCentralWidget(centralWidget);
|
||||
addDockWidget(Qt::RightDockWidgetArea, deckDockWidget);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue