From ae41194e4b6728e7998e9813ad6eef2d5db0ad34 Mon Sep 17 00:00:00 2001 From: Max-Wilhelm Bruker Date: Fri, 18 Jun 2010 21:15:19 +0200 Subject: [PATCH] forgot to add some files :) --- cockatrice/src/dlg_create_token.cpp | 85 +++++++++++++++++++++++++++++ cockatrice/src/dlg_create_token.h | 28 ++++++++++ 2 files changed, 113 insertions(+) create mode 100644 cockatrice/src/dlg_create_token.cpp create mode 100644 cockatrice/src/dlg_create_token.h diff --git a/cockatrice/src/dlg_create_token.cpp b/cockatrice/src/dlg_create_token.cpp new file mode 100644 index 00000000..01260542 --- /dev/null +++ b/cockatrice/src/dlg_create_token.cpp @@ -0,0 +1,85 @@ +#include +#include "dlg_create_token.h" + +DlgCreateToken::DlgCreateToken(QWidget *parent) + : QDialog(parent) +{ + nameLabel = new QLabel(tr("&Name:")); + nameEdit = new QLineEdit; + nameLabel->setBuddy(nameEdit); + + colorLabel = new QLabel(tr("C&olor:")); + colorEdit = new QComboBox; + colorEdit->addItem(tr("white"), "w"); + colorEdit->addItem(tr("blue"), "u"); + colorEdit->addItem(tr("black"), "b"); + colorEdit->addItem(tr("red"), "r"); + colorEdit->addItem(tr("green"), "g"); + colorEdit->addItem(tr("multicolor"), "m"); + colorEdit->addItem(tr("colorless"), ""); + colorLabel->setBuddy(colorEdit); + + ptLabel = new QLabel(tr("&P/T:")); + ptEdit = new QLineEdit; + ptLabel->setBuddy(ptEdit); + + annotationLabel = new QLabel(tr("&Annotation:")); + annotationEdit = new QLineEdit; + annotationLabel->setBuddy(annotationEdit); + + okButton = new QPushButton(tr("&OK")); + okButton->setDefault(true); + cancelButton = new QPushButton(tr("&Cancel")); + + QGridLayout *grid = new QGridLayout; + grid->addWidget(nameLabel, 0, 0); + grid->addWidget(nameEdit, 0, 1); + grid->addWidget(colorLabel, 1, 0); + grid->addWidget(colorEdit, 1, 1); + grid->addWidget(ptLabel, 2, 0); + grid->addWidget(ptEdit, 2, 1); + grid->addWidget(annotationLabel, 3, 0); + grid->addWidget(annotationEdit, 3, 1); + + QHBoxLayout *buttonLayout = new QHBoxLayout; + buttonLayout->addStretch(); + buttonLayout->addWidget(okButton); + buttonLayout->addWidget(cancelButton); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addLayout(grid); + mainLayout->addLayout(buttonLayout); + setLayout(mainLayout); + + setWindowTitle(tr("Create token")); + setFixedHeight(sizeHint().height()); + setMinimumWidth(300); + + connect(okButton, SIGNAL(clicked()), this, SLOT(actOk())); + connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject())); +} + +void DlgCreateToken::actOk() +{ + accept(); +} + +QString DlgCreateToken::getName() const +{ + return nameEdit->text(); +} + +QString DlgCreateToken::getColor() const +{ + return colorEdit->itemData(colorEdit->currentIndex()).toString(); +} + +QString DlgCreateToken::getPT() const +{ + return ptEdit->text(); +} + +QString DlgCreateToken::getAnnotation() const +{ + return annotationEdit->text(); +} diff --git a/cockatrice/src/dlg_create_token.h b/cockatrice/src/dlg_create_token.h new file mode 100644 index 00000000..a328239c --- /dev/null +++ b/cockatrice/src/dlg_create_token.h @@ -0,0 +1,28 @@ +#ifndef DLG_CREATETOKEN_H +#define DLG_CREATETOKEN_H + +#include +#include + +class QLabel; +class QComboBox; +class QPushButton; + +class DlgCreateToken : public QDialog { + Q_OBJECT +public: + DlgCreateToken(QWidget *parent = 0); + QString getName() const; + QString getColor() const; + QString getPT() const; + QString getAnnotation() const; +private slots: + void actOk(); +private: + QLabel *nameLabel, *colorLabel, *ptLabel, *annotationLabel; + QComboBox *colorEdit; + QLineEdit *nameEdit, *ptEdit, *annotationEdit; + QPushButton *okButton, *cancelButton; +}; + +#endif