2
* Copyright 2011 Kurtis L. Nusbaum
4
* This file is part of UDJ.
6
* UDJ is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 2 of the License, or
9
* (at your option) any later version.
11
* UDJ is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with UDJ. If not, see <http://www.gnu.org/licenses/>.
20
#include "SetPasswordDialog.hpp"
21
#include "DataStore.hpp"
22
#include <QMessageBox>
24
#include <QFormLayout>
30
SetPasswordDialog::SetPasswordDialog(DataStore *dataStore, QWidget *parent, Qt::WindowFlags f)
31
:DialogWithLoaderWidget(
32
tr("Setting Player Password..."),
40
setWindowTitle(tr("Set Player Password"));
43
connect(dataStore, SIGNAL(playerPasswordSet()), this, SLOT(closeDialog()));
46
SIGNAL(playerPasswordSetError(const QString&)),
48
SLOT(onPlayerPasswordSetError(const QString&)));
52
void SetPasswordDialog::onPlayerPasswordSetError(const QString& errMessage){
53
this->showMainWidget();
54
QMessageBox::critical(
56
tr("Couldn't Change Password"),
61
void SetPasswordDialog::accept(){
62
QString password = passwordEdit->text();
64
this->showLoadingText();
65
dataStore->setPlayerPassword(password);
68
QMessageBox::critical(
71
tr("The password must not be blank." )
76
void SetPasswordDialog::setupUi(){
77
QWidget *passwordWidget = new QWidget();
78
passwordEdit = new QLineEdit(dataStore->getPlayerPassword());
79
QFormLayout *layout = new QFormLayout();
80
layout->addRow(tr("Password:"), passwordEdit);
81
passwordWidget->setLayout(layout);
82
setMainWidget(passwordWidget);