mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-21 01:42:15 -07:00
create new dlg window
This commit is contained in:
parent
e4cfe08113
commit
54f0bb1895
4 changed files with 89 additions and 4 deletions
|
|
@ -48,6 +48,7 @@ set(cockatrice_SOURCES
|
|||
src/dialogs/dlg_load_deck_from_clipboard.cpp
|
||||
src/dialogs/dlg_load_remote_deck.cpp
|
||||
src/dialogs/dlg_manage_sets.cpp
|
||||
src/dialogs/dlg_move_top_cards_until.cpp
|
||||
src/dialogs/dlg_register.cpp
|
||||
src/dialogs/dlg_roll_dice.cpp
|
||||
src/dialogs/dlg_settings.cpp
|
||||
|
|
|
|||
54
cockatrice/src/dialogs/dlg_move_top_cards_until.cpp
Normal file
54
cockatrice/src/dialogs/dlg_move_top_cards_until.cpp
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#include "dlg_move_top_cards_until.h"
|
||||
|
||||
#include "trice_limits.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QSpinBox>
|
||||
#include <QString>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
|
||||
DlgMoveTopCardsUntil::DlgMoveTopCardsUntil(QWidget *parent, QString _expr, uint _numberOfHits) : QDialog(parent)
|
||||
{
|
||||
exprLabel = new QLabel(tr("Card name (or search expressions):"));
|
||||
|
||||
exprEdit = new QLineEdit(this);
|
||||
exprEdit->setFocus();
|
||||
exprEdit->setText(_expr);
|
||||
exprLabel->setBuddy(exprEdit);
|
||||
|
||||
numberOfHitsLabel = new QLabel(tr("Number of hits:"));
|
||||
numberOfHitsEdit = new QSpinBox(this);
|
||||
numberOfHitsEdit->setRange(1, 99);
|
||||
numberOfHitsEdit->setValue(_numberOfHits);
|
||||
numberOfHitsLabel->setBuddy(numberOfHitsEdit);
|
||||
|
||||
auto *grid = new QGridLayout;
|
||||
grid->addWidget(numberOfHitsLabel, 0, 0);
|
||||
grid->addWidget(numberOfHitsEdit, 0, 1);
|
||||
|
||||
buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
|
||||
auto *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addWidget(exprLabel);
|
||||
mainLayout->addWidget(exprEdit);
|
||||
mainLayout->addItem(grid);
|
||||
mainLayout->addWidget(buttonBox);
|
||||
|
||||
setLayout(mainLayout);
|
||||
setWindowTitle(tr("Put top cards on stack until..."));
|
||||
}
|
||||
|
||||
QString DlgMoveTopCardsUntil::getExpr() const
|
||||
{
|
||||
return exprEdit->text();
|
||||
}
|
||||
|
||||
uint DlgMoveTopCardsUntil::getNumberOfHits() const
|
||||
{
|
||||
return numberOfHitsEdit->text().toUInt();
|
||||
}
|
||||
26
cockatrice/src/dialogs/dlg_move_top_cards_until.h
Normal file
26
cockatrice/src/dialogs/dlg_move_top_cards_until.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef DLG_MOVE_TOP_CARDS_UNTIL_H
|
||||
#define DLG_MOVE_TOP_CARDS_UNTIL_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QSpinBox>
|
||||
#include <QString>
|
||||
|
||||
class DlgMoveTopCardsUntil : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QLabel *exprLabel, *numberOfHitsLabel;
|
||||
QLineEdit *exprEdit;
|
||||
QSpinBox *numberOfHitsEdit;
|
||||
QDialogButtonBox *buttonBox;
|
||||
|
||||
public:
|
||||
explicit DlgMoveTopCardsUntil(QWidget *parent = nullptr, QString expr = QString(), uint numberOfHits = 1);
|
||||
[[nodiscard]] QString getExpr() const;
|
||||
[[nodiscard]] uint getNumberOfHits() const;
|
||||
};
|
||||
|
||||
#endif // DLG_MOVE_TOP_CARDS_UNTIL_H
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
#include "../../client/ui/theme_manager.h"
|
||||
#include "../../deck/deck_loader.h"
|
||||
#include "../../dialogs/dlg_create_token.h"
|
||||
#include "../../dialogs/dlg_move_top_cards_until.h"
|
||||
#include "../../dialogs/dlg_roll_dice.h"
|
||||
#include "../../main.h"
|
||||
#include "../../settings/cache_settings.h"
|
||||
|
|
@ -1333,13 +1334,16 @@ void Player::actMoveTopCardsUntil()
|
|||
moveTopCardTimer->stop();
|
||||
movingCardsUntil = false;
|
||||
QString expr = previousMovingCardsUntilExpr;
|
||||
uint numberOfHits = 1;
|
||||
for (;;) {
|
||||
bool ok;
|
||||
expr = QInputDialog::getText(game, "Put top cards on stack until", "Card name (or search expressions)", {},
|
||||
expr, &ok);
|
||||
if (!ok) {
|
||||
DlgMoveTopCardsUntil dlg(game, expr, numberOfHits);
|
||||
if (!dlg.exec()) {
|
||||
return;
|
||||
}
|
||||
|
||||
expr = dlg.getExpr();
|
||||
numberOfHits = dlg.getNumberOfHits();
|
||||
|
||||
movingCardsUntilFilter = FilterString(expr);
|
||||
if (movingCardsUntilFilter.valid()) {
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue