~ubuntu-branches/ubuntu/wily/udj-desktop-client/wily

« back to all changes in this revision

Viewing changes to src/SetPasswordDialog.cpp

  • Committer: Package Import Robot
  • Author(s): Nathan Handler
  • Date: 2012-11-14 15:29:07 UTC
  • mfrom: (1.2.1) (4.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20121114152907-8uj9bwcima77vu28
Tags: 0.6.3-1
* New upstream release
* debian/copyright: Add stanzas for new upstream files
* debian/rules:
  - Do not install ./usr/share/doc/udj/UDJ.1
  - Remove /usr/share/doc/udj directory if it is empty
* debian/control:
  - Bump Standards-Version to 3.9.4 (no changes)
  - Use my @debian.org address for the Maintainer field

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * Copyright 2011 Kurtis L. Nusbaum
3
 
 *
4
 
 * This file is part of UDJ.
5
 
 *
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.
10
 
 *
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.
15
 
 *
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/>.
18
 
 */
19
 
 
20
 
#include "SetPasswordDialog.hpp"
21
 
#include "DataStore.hpp"
22
 
#include <QMessageBox>
23
 
#include <QLineEdit>
24
 
#include <QFormLayout>
25
 
 
26
 
 
27
 
namespace UDJ{
28
 
 
29
 
 
30
 
SetPasswordDialog::SetPasswordDialog(DataStore *dataStore, QWidget *parent, Qt::WindowFlags f)
31
 
  :DialogWithLoaderWidget(
32
 
    tr("Setting Player Password..."),
33
 
    tr("Set Password"),
34
 
    tr("Cancel"),
35
 
    false,
36
 
    parent,
37
 
    f),
38
 
  dataStore(dataStore)
39
 
{
40
 
  setWindowTitle(tr("Set Player Password"));
41
 
  setModal(true);
42
 
  setupUi();
43
 
  connect(dataStore, SIGNAL(playerPasswordSet()), this, SLOT(closeDialog()));
44
 
  connect(
45
 
    dataStore,
46
 
    SIGNAL(playerPasswordSetError(const QString&)),
47
 
    this,
48
 
    SLOT(onPlayerPasswordSetError(const QString&)));
49
 
 
50
 
}
51
 
 
52
 
void SetPasswordDialog::onPlayerPasswordSetError(const QString& errMessage){
53
 
  this->showMainWidget();
54
 
  QMessageBox::critical(
55
 
    this,
56
 
    tr("Couldn't Change Password"),
57
 
    errMessage
58
 
  );
59
 
}
60
 
 
61
 
void SetPasswordDialog::accept(){
62
 
  QString password = passwordEdit->text();
63
 
  if(password!=""){
64
 
    this->showLoadingText();
65
 
    dataStore->setPlayerPassword(password);
66
 
  }
67
 
  else{
68
 
    QMessageBox::critical(
69
 
      this,
70
 
      tr("Blank Password"),
71
 
      tr("The password must not be blank." )
72
 
    );
73
 
  }
74
 
}
75
 
 
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);
83
 
}
84
 
 
85
 
 
86
 
 
87
 
} //end namespace UDJ
88
 
 
89