mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-10 20:13:24 -08:00
Address printing selector review feedback
Hold the deck editor printing-selector host by value, since its deck editor is known at construction. Emit printingSelected for every left-click pick instead of gating it on selection-only mode; consumers that do not want picks simply do not connect.
This commit is contained in:
parent
f372fdda42
commit
177536b07a
4 changed files with 8 additions and 12 deletions
|
|
@ -14,7 +14,7 @@
|
|||
#include <qnamespace.h>
|
||||
|
||||
DeckEditorPrintingSelectorDockWidget::DeckEditorPrintingSelectorDockWidget(AbstractTabDeckEditor *parent)
|
||||
: QDockWidget(parent), deckEditor(parent)
|
||||
: QDockWidget(parent), deckEditor(parent), printingSelectorHost(parent)
|
||||
{
|
||||
setObjectName("printingSelectorDock");
|
||||
|
||||
|
|
@ -33,12 +33,9 @@ DeckEditorPrintingSelectorDockWidget::DeckEditorPrintingSelectorDockWidget(Abstr
|
|||
retranslateUi();
|
||||
}
|
||||
|
||||
DeckEditorPrintingSelectorDockWidget::~DeckEditorPrintingSelectorDockWidget() = default;
|
||||
|
||||
void DeckEditorPrintingSelectorDockWidget::createPrintingSelectorDock()
|
||||
{
|
||||
printingSelectorHost = std::make_unique<DeckEditorPrintingSelectorHost>(deckEditor);
|
||||
printingSelector = new PrintingSelector(this, printingSelectorHost.get());
|
||||
printingSelector = new PrintingSelector(this, &printingSelectorHost);
|
||||
printingSelector->setObjectName("printingSelector");
|
||||
auto *printingSelectorFrame = new QVBoxLayout;
|
||||
printingSelectorFrame->setObjectName("printingSelectorFrame");
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@
|
|||
#ifndef DECK_EDITOR_PRINTING_SELECTOR_DOCK_WIDGET_H
|
||||
#define DECK_EDITOR_PRINTING_SELECTOR_DOCK_WIDGET_H
|
||||
|
||||
#include "deck_editor_printing_selector_host.h"
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <memory>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
class DeckEditorPrintingSelectorHost;
|
||||
class PrintingDisabledInfoWidget;
|
||||
class AbstractTabDeckEditor;
|
||||
class PrintingSelector;
|
||||
|
|
@ -22,7 +22,6 @@ class DeckEditorPrintingSelectorDockWidget : public QDockWidget
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit DeckEditorPrintingSelectorDockWidget(AbstractTabDeckEditor *parent);
|
||||
~DeckEditorPrintingSelectorDockWidget() override;
|
||||
void createPrintingSelectorDock();
|
||||
void retranslateUi();
|
||||
|
||||
|
|
@ -30,7 +29,7 @@ public:
|
|||
|
||||
private:
|
||||
AbstractTabDeckEditor *deckEditor;
|
||||
std::unique_ptr<DeckEditorPrintingSelectorHost> printingSelectorHost;
|
||||
DeckEditorPrintingSelectorHost printingSelectorHost;
|
||||
QWidget *printingSelectorDockContents;
|
||||
PrintingDisabledInfoWidget *printingDisabledInfoWidget;
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ signals:
|
|||
void cardAmountsChanged(const QMap<QString, ZoneCounts> &uuidToAmounts);
|
||||
|
||||
/**
|
||||
* A printing was picked while the selector runs in selection-only mode.
|
||||
* A printing was picked in the selector.
|
||||
* @param card The picked card and printing.
|
||||
*/
|
||||
void printingSelected(const ExactCard &card);
|
||||
|
|
|
|||
|
|
@ -117,10 +117,10 @@ PrintingSelectorCardOverlayWidget::PrintingSelectorCardOverlayWidget(QWidget *pa
|
|||
cardInfoPicture->setCard(_rootCard);
|
||||
mainLayout->addWidget(cardInfoPicture);
|
||||
|
||||
// In a selection-only host a click picks this printing instead of changing a deck.
|
||||
// A left click reports the printing; consumers that only want a pick connect to the signal.
|
||||
connect(cardInfoPicture, &CardInfoPictureWidget::cardClicked, this,
|
||||
[this](QMouseEvent *event, const ExactCard &card) {
|
||||
if (host->isSelectionOnly() && event->button() == Qt::LeftButton) {
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
emit printingSelected(card);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue