Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
deck_zone_dialog.h
Go to the documentation of this file.
1
6
7#ifndef DECK_ZONE_DIALOG_H
8#define DECK_ZONE_DIALOG_H
9
10#include <QDialog>
11#include <QString>
12#include <functional>
13#include <qtmetamacros.h>
14
15class QComboBox;
16class QDialogButtonBox;
17class QLabel;
18class QLineEdit;
19class QWidget;
20
27class DeckZoneDialog : public QDialog
28{
29 Q_OBJECT
30
31public:
43 explicit DeckZoneDialog(QWidget *parent = nullptr,
44 const QString &initialBoardName = {},
45 const std::function<QString(const QString &)> &_nameValidator = {},
46 bool _allowBoardSelection = true);
47
51 [[nodiscard]] QString getZoneName() const;
52
56 [[nodiscard]] QString getBoardName() const;
57
63 void setZoneName(const QString &zoneName);
64
77 static QString promptForNewZone(QWidget *parent,
78 const QString &initialBoardName,
79 QString *chosenBoardName,
80 const std::function<QString(const QString &)> &nameValidator = {});
81
94 static QString promptForRename(QWidget *parent,
95 const QString &currentZoneName,
96 const std::function<QString(const QString &)> &nameValidator = {});
97
98protected:
99 void changeEvent(QEvent *event) override;
100
101private:
106 void retranslateUi();
107
111 void validateName();
112
113 QLabel *nameLabel;
114 QLineEdit *nameEdit;
115 QLabel *errorLabel;
116 QLabel *boardLabel;
117 QComboBox *boardCombo;
118 QDialogButtonBox *buttonBox;
119 std::function<QString(const QString &)> nameValidator;
121};
122
123#endif // DECK_ZONE_DIALOG_H
QComboBox * boardCombo
Definition deck_zone_dialog.h:117
void retranslateUi()
Sets every user-visible string. Runs on construction and on runtime language changes.
Definition deck_zone_dialog.cpp:96
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.
Definition deck_zone_dialog.cpp:126
bool allowBoardSelection
Definition deck_zone_dialog.h:120
QString getBoardName() const
The internal name of the board zone selected in the combo.
Definition deck_zone_dialog.cpp:76
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.
Definition deck_zone_dialog.cpp:142
void validateName()
Validates the current input, toggling Ok and the inline error label.
Definition deck_zone_dialog.cpp:111
QDialogButtonBox * buttonBox
Definition deck_zone_dialog.h:118
QString getZoneName() const
The trimmed zone name entered by the user.
Definition deck_zone_dialog.cpp:71
QLabel * nameLabel
Definition deck_zone_dialog.h:113
void setZoneName(const QString &zoneName)
Prefills the name field, e.g. with the current name when renaming.
Definition deck_zone_dialog.cpp:81
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.
Definition deck_zone_dialog.cpp:16
QLabel * errorLabel
Definition deck_zone_dialog.h:115
QLabel * boardLabel
Definition deck_zone_dialog.h:116
QLineEdit * nameEdit
Definition deck_zone_dialog.h:114
void changeEvent(QEvent *event) override
Definition deck_zone_dialog.cpp:87
std::function< QString(const QString &)> nameValidator
Definition deck_zone_dialog.h:119