LoginWidget::LoginWidget (QWidget *parent, Qt::WindowFlags f) : QWidget (parent, f), numberEdit (new QLineEdit (this)), passwordEdit (new QLineEdit (this)), codeEdit (new QLineEdit (this)), commitButton (new QPushButton (this)), verifyButton (new QPushButton (this)), messageLabel (new QLabel (this)) { QGridLayout *gridLayout = new QGridLayout (this); gridLayout->addWidget (new QLabel (tr ("Number")), 0, 0); gridLayout->addWidget (numberEdit, 0, 1); gridLayout->addWidget (new QLabel (tr ("Password")), 1, 0); gridLayout->addWidget (passwordEdit, 1, 1); gridLayout->addWidget (commitButton, 2, 0); gridLayout->addWidget (messageLabel, 2, 1); gridLayout->addWidget (codeEdit, 3, 0); gridLayout->addWidget (verifyButton, 3, 1); codeEdit->setEnabled (false); verifyButton->setEnabled (false); passwordEdit->setEchoMode (QLineEdit::Password); commitButton->setText (tr ("Login")); verifyButton->setText (tr ("Confirm")); connect (commitButton, SIGNAL (clicked ()), this, SLOT (onCommitButtonClicked ())); connect (verifyButton, SIGNAL (clicked ()), this, SLOT (onverifyButtonClicked())); connect (passwordEdit, SIGNAL (returnPressed()), commitButton, SLOT (click())); connect (numberEdit, SIGNAL (selectionChanged()), messageLabel, SLOT (clear())); setLayout (gridLayout); setFixedSize (gridLayout->sizeHint()); setBackgroundRole (QPalette::WindowText); }
void LoginWidget::requestVerify (const QByteArray &data) { QImage img = QImage::fromData (QByteArray::fromBase64 (data)); if (img.isNull()) { // FIXME return; } messageLabel->setPixmap (QPixmap::fromImage (img)); codeEdit->setEnabled (true); verifyButton->setEnabled (true); codeEdit->show(); verifyButton->show(); connect (commitButton, SIGNAL (clicked ()), this, SLOT (onCommitButtonClicked ())); }
GraphicBoard::GraphicBoard(int width, int height, QWidget *parent) : width(width), height(height), QWidget(parent) { Language *language; QStringList langList; langList.push_back("Russian"); langList.push_back("English"); QString gameLang = QInputDialog::getItem(this, tr("Choose language of the game"), tr("Выберите язык игры"), langList); if (gameLang == "Russian"){ language = new RussianLang; } else{ language = new EnglishLang; } tableLayout = new QGridLayout; for (int i = 0; i < height; ++i) { buttons.push_back(QVector<ButtonCell*>(width)); for (int j = 0; j < width; ++j) { buttons[i][j] = new ButtonCell(language); buttons[i][j]->connectToPanel(this); tableLayout->addWidget(buttons[i][j], i, j); } } gamePanel = new QHBoxLayout(this); gameBoardPanel = new QVBoxLayout; gameBoardPanel->addLayout(tableLayout); wordPanel = new QHBoxLayout; currentWord = new QLabel(""); commitButton = new QPushButton("Enter!"); commitGiveUp = new QPushButton("Give Up"); wordPanel->addWidget(commitGiveUp); wordPanel->addWidget(currentWord); wordPanel->addWidget(commitButton); gameBoardPanel->addLayout(wordPanel); firstPlayerScore = new QLabel(tr("0"), this); firstPlayerWords = new QListWidget(this); firstPlayerPanel = new QVBoxLayout(this); firstPlayerPanel->addWidget(firstPlayerScore); firstPlayerPanel->addWidget(firstPlayerWords); secondPlayerScore = new QLabel(tr("0"), this); secondPlayerWords = new QListWidget(this); secondPlayerPanel = new QVBoxLayout(this); secondPlayerPanel->addWidget(secondPlayerScore); secondPlayerPanel->addWidget(secondPlayerWords); gamePanel->addLayout(firstPlayerPanel); gamePanel->addLayout(gameBoardPanel); gamePanel->addLayout(secondPlayerPanel); setLayout(gamePanel); int players = QInputDialog::getInt(this, tr("Enter number of players"), tr("Введите число игроков"), 1, 1, 2); if (players == 2) { gameManager = new GameManager(language, width, height, players); } else { QStringList list; list.push_back(tr("EASY")); list.push_back("MEDIUM"); list.push_back(tr("HARD")); list.push_back("HARDEST"); QString level = QInputDialog::getItem(this, tr("Choose level"), tr("Выберите сложность"), list); gameManager = new GameManager(language, width, height, players, level); } connectToPlayers(gameManager->getFirstPlayer(), gameManager->getSecondPlayer()); gameManager->getFirstPlayer()->connectToInterface(this); gameManager->getSecondPlayer()->connectToInterface(this); QString word = gameManager->getFirstWord(); for (int i = 0; i < width; ++i) { buttons[height/2][i]->setText(QString(word[i])); } for (int i = 0; i < width; ++i) { buttons[height/2][i]->setMenu(NULL); } connect(commitButton, SIGNAL(clicked()), this, SLOT(onCommitButtonClicked())); connect(commitGiveUp, SIGNAL(clicked()), this, SLOT(onCommitGiveUpClicked())); connect(gameManager, SIGNAL(gameEnded(const QString&)), this, SLOT(finishGame(const QString&))); connect(this, SIGNAL(quit()), parent, SLOT(resetField())); }
m_commitSceneContentsCheckBox->setText(tr("Put Scene Contents")); formLayout->addRow("", m_commitSceneContentsCheckBox); } mainLayout->addLayout(formLayout); container->setLayout(mainLayout); beginHLayout(); addWidget(container, false); endHLayout(); m_commitButton = new QPushButton(tr("Put")); m_commitButton->setEnabled(false); connect(m_commitButton, SIGNAL(clicked()), this, SLOT(onCommitButtonClicked())); m_cancelButton = new QPushButton(tr("Cancel")); connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(reject())); addButtonBarWidget(m_commitButton, m_cancelButton); // 0. Connect for svn errors (that may occurs everythings) connect(&m_thread, SIGNAL(error(const QString &)), this, SLOT(onError(const QString &))); // 1. Getting status (with show-updates enabled...) connect(&m_thread, SIGNAL(statusRetrieved(const QString &)), this, SLOT(onStatusRetrieved(const QString &))); m_thread.getSVNStatus(m_workingDir, m_files, true); }