Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
DeckZoneDialog Class Reference

Modal dialog asking for the name and parent zone of a new custom deck zone. More...

#include <deck_zone_dialog.h>

Inheritance diagram for DeckZoneDialog:
[legend]
Collaboration diagram for DeckZoneDialog:
[legend]

Public Member Functions

 DeckZoneDialog (QWidget *parent=nullptr, const QString &initialBoardName={}, const std::function< QString(const QString &)> &_nameValidator={}, bool _allowBoardSelection=true)
 Constructs the dialog and runs the initial validation pass.
QString getZoneName () const
 The trimmed zone name entered by the user.
QString getBoardName () const
 The internal name of the board zone selected in the combo.
void setZoneName (const QString &zoneName)
 Prefills the name field, e.g. with the current name when renaming.

Static Public Member Functions

static QString promptForNewZone (QWidget *parent, const QString &initialBoardName, QString *chosenBoardName, const std::function< QString(const QString &)> &nameValidator={})
 Prompts the user for a new custom zone name and the board zone to nest it under.
static QString promptForRename (QWidget *parent, const QString &currentZoneName, const std::function< QString(const QString &)> &nameValidator={})
 Prompts the user for a new name for an existing custom zone.

Protected Member Functions

void changeEvent (QEvent *event) override

Private Member Functions

void retranslateUi ()
 Sets every user-visible string. Runs on construction and on runtime language changes.
void validateName ()
 Validates the current input, toggling Ok and the inline error label.

Private Attributes

QLabel * nameLabel
QLineEdit * nameEdit
QLabel * errorLabel
QLabel * boardLabel
QComboBox * boardCombo
QDialogButtonBox * buttonBox
std::function< QString(const QString &)> nameValidator
bool allowBoardSelection

Detailed Description

Modal dialog asking for the name and parent zone of a new custom deck zone.

Menus construct the dialog transiently around exec(), so validation state only ever reflects the name currently typed.

Constructor & Destructor Documentation

◆ DeckZoneDialog()

DeckZoneDialog::DeckZoneDialog ( QWidget * parent = nullptr,
const QString & initialBoardName = {},
const std::function< QString(const QString &)> & _nameValidator = {},
bool _allowBoardSelection = true )
explicit

Constructs the dialog and runs the initial validation pass.

Parameters
parentThe parent widget for the dialog
initialBoardNameThe board zone to preselect in the combo. Unknown names fall back to main.
_nameValidatorGiven the trimmed candidate name, returns an empty string when it is usable, otherwise a user-facing error message. May be empty.
_allowBoardSelectionWhen false the parent-zone combo is hidden and the dialog acts as a rename prompt for an existing zone.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ changeEvent()

void DeckZoneDialog::changeEvent ( QEvent * event)
overrideprotected
Here is the call graph for this function:

◆ getBoardName()

QString DeckZoneDialog::getBoardName ( ) const
nodiscard

The internal name of the board zone selected in the combo.

Here is the caller graph for this function:

◆ getZoneName()

QString DeckZoneDialog::getZoneName ( ) const
nodiscard

The trimmed zone name entered by the user.

Here is the caller graph for this function:

◆ promptForNewZone()

QString DeckZoneDialog::promptForNewZone ( QWidget * parent,
const QString & initialBoardName,
QString * chosenBoardName,
const std::function< QString(const QString &)> & nameValidator = {} )
static

Prompts the user for a new custom zone name and the board zone to nest it under.

Convenience wrapper that runs DeckZoneDialog modally.

Parameters
parentThe parent widget for the dialog
initialBoardNameThe board zone to preselect in the dialog. Unknown names fall back to main.
chosenBoardName(out) The internal name of the board zone the user chose
nameValidatorOptional validator forwarded to the dialog
Returns
The trimmed zone name, or an empty string if the user cancelled
Here is the call graph for this function:
Here is the caller graph for this function:

◆ promptForRename()

QString DeckZoneDialog::promptForRename ( QWidget * parent,
const QString & currentZoneName,
const std::function< QString(const QString &)> & nameValidator = {} )
static

Prompts the user for a new name for an existing custom zone.

Same inline validation as promptForNewZone, but without a parent-zone picker.

Parameters
parentThe parent widget for the dialog
currentZoneNameThe current name, prefilled for editing
nameValidatorValidator deciding whether a candidate name is usable. It sees the current name too, so callers wanting to allow unchanged names must special-case that themselves.
Returns
The trimmed new name, or an empty string if the user cancelled
Here is the call graph for this function:
Here is the caller graph for this function:

◆ retranslateUi()

void DeckZoneDialog::retranslateUi ( )
private

Sets every user-visible string. Runs on construction and on runtime language changes.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setZoneName()

void DeckZoneDialog::setZoneName ( const QString & zoneName)

Prefills the name field, e.g. with the current name when renaming.

Parameters
zoneNameThe text to put into the name field, selected for quick editing

◆ validateName()

void DeckZoneDialog::validateName ( )
private

Validates the current input, toggling Ok and the inline error label.

Here is the caller graph for this function:

Member Data Documentation

◆ allowBoardSelection

bool DeckZoneDialog::allowBoardSelection
private

◆ boardCombo

QComboBox* DeckZoneDialog::boardCombo
private

◆ boardLabel

QLabel* DeckZoneDialog::boardLabel
private

◆ buttonBox

QDialogButtonBox* DeckZoneDialog::buttonBox
private

◆ errorLabel

QLabel* DeckZoneDialog::errorLabel
private

◆ nameEdit

QLineEdit* DeckZoneDialog::nameEdit
private

◆ nameLabel

QLabel* DeckZoneDialog::nameLabel
private

◆ nameValidator

std::function<QString(const QString &)> DeckZoneDialog::nameValidator
private

The documentation for this class was generated from the following files: