Cockatrice/cockatrice/src/game_graphics/dialogs/dlg_create_token.h
BruebachL 154d5d4906 [Client] Choose a token's printing in the create-token dialog (#7815)
* Refactor printing selector onto a host interface

Move the deck-editor coupling out of PrintingSelector behind PrintingSelectorHost so the same widget can run where there is no deck. The deck editor keeps its behaviour through DeckEditorPrintingSelectorHost; a selection-only host hides deck controls, reports a picked printing, and highlights it in the grid.

* Add a printings tab to the token dialog

The token list and the printing selector now share one tabbed surface. Picking a printing sets the provider id used by the live preview and by the created token, while an untouched dialog keeps the existing preference lookup. Names with no printings show a placeholder instead of an empty grid.

* 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.

* Use the shared layout helper in the token tabs

Replace the hand-built zero-margin layouts with QtUtils::makeLayout, which is the helper the printing selector already uses.
2026-11-10 10:12:06 +01:00

75 lines
2.1 KiB
C++

/**
* @file dlg_create_token.h
* @ingroup GameDialogs
*/
//! \todo Document this file.
#ifndef DLG_CREATETOKEN_H
#define DLG_CREATETOKEN_H
#include "../../interface/widgets/printing_selector/printing_selector_selection_host.h"
#include <QDialog>
#include <QList>
#include <QString>
#include <QStringList>
#include <libcockatrice/game/player/token_info.h>
#include <qtmetamacros.h>
class QLabel;
class QLineEdit;
class QComboBox;
class QCheckBox;
class QRadioButton;
class QTabWidget;
class QTreeView;
class CardDatabaseModel;
class TokenDisplayModel;
class TokenPreviewWidget;
class PrintingSelector;
class QModelIndex;
class QWidget;
class DlgCreateToken : public QDialog
{
Q_OBJECT
public:
explicit DlgCreateToken(const QStringList &_predefinedTokens, QWidget *parent = nullptr);
[[nodiscard]] TokenInfo getTokenInfo() const;
protected:
void closeEvent(QCloseEvent *event) override;
private slots:
void faceDownCheckBoxToggled(bool checked);
void tokenSelectionChanged(const QModelIndex &current, const QModelIndex &previous);
void updateSearch(const QString &search);
void syncPrintingsToToken();
void updatePreview();
void actChooseTokenFromAll(bool checked);
void actChooseTokenFromDeck(bool checked);
void actOk();
void actReject();
private:
CardDatabaseModel *cardDatabaseModel;
TokenDisplayModel *cardDatabaseDisplayModel;
QStringList predefinedTokens;
QLabel *nameLabel, *colorLabel, *ptLabel, *annotationLabel;
QComboBox *colorEdit;
QLineEdit *nameEdit, *ptEdit, *annotationEdit;
QCheckBox *destroyCheckBox;
QCheckBox *faceDownCheckBox;
QRadioButton *chooseTokenFromAllRadioButton, *chooseTokenFromDeckRadioButton;
TokenPreviewWidget *pic;
QTreeView *chooseTokenView;
QTabWidget *tokenSourceTabs;
PrintingSelector *printingSelector;
PrintingSelectorSelectionHost printingSelectorHost;
QString explicitProviderId;
QString explicitProviderName;
[[nodiscard]] TokenInfo tokenDraft() const;
void updateSearchFieldWithoutUpdatingFilter(const QString &newValue) const;
};
#endif