e19e4e67afe1fa48a098b28faf2295044b9978d8
[speedfreak] / Client / settingsdialog.cpp
1 #include "settingsdialog.h"
2 #include "ui_settingsdialog.h"
3
4 SettingsDialog::SettingsDialog(QWidget *parent) :
5     QDialog(parent),
6     ui(new Ui::SettingsDialog)
7 {
8     ui->setupUi(this);
9     this->setWindowTitle("Settings");
10     this->ui->regEMailLineEdit->setText("@meili.fi");
11     instructionsDialog = new InstructionsDialog;
12 }
13
14 SettingsDialog::~SettingsDialog()
15 {
16     delete ui;
17 }
18
19 void SettingsDialog::changeEvent(QEvent *e)
20 {
21     QDialog::changeEvent(e);
22     switch (e->type()) {
23     case QEvent::LanguageChange:
24         ui->retranslateUi(this);
25         break;
26     default:
27         break;
28     }
29 }
30
31 //
32 // Help
33 //
34 void SettingsDialog::on_pushButtonHelp_clicked()
35 {
36     instructionsDialog->show();
37 }
38
39 //
40 // Registrate
41 //
42 void SettingsDialog::on_registratePushButton_clicked()
43 {
44     // Send username, password and email to SpeedFreak server
45     this->regUsername = ui->regUserNameLineEdit->text();
46     this->regPassword = ui->regPasswordLineEdit->text();
47     this->regEmail = ui->regEMailLineEdit->text();
48
49     emit sendregistration();
50
51     close();
52 }
53
54 // Next 6 functions can be removed if Settingsdialog is implemented without
55 // own copy of username, password & email
56 void SettingsDialog::setRegUserName(QString username)
57 {
58     this->regUsername = username;
59 }
60
61 void SettingsDialog::setRegPassword(QString password)
62 {
63     this->regPassword = password;
64 }
65
66 void SettingsDialog::setRegEmail(QString email)
67 {
68     this->regEmail = email;
69 }
70
71 QString SettingsDialog::getRegUserName()
72 {
73     return this->regUsername;
74 }
75
76 QString SettingsDialog::getRegPassword()
77 {
78     return this->regPassword;
79 }
80
81 QString SettingsDialog::getRegEmail()
82 {
83     return this->regEmail;
84 }
85
86 //
87 // Set / Change user
88 //
89 void SettingsDialog::on_setUserPushButton_clicked()
90 {
91     this->username = ui->setUserUsernameLineEdit->text();
92     this->password = ui->setUserPasswordLineEdit->text();
93
94     emit userNameChanged();
95     close();
96 }
97
98 // Next 4 functions can be removed if Settingsdialog is implemented without
99 // own copy of username & password
100 void SettingsDialog::setUserName(QString username)
101 {
102     this->username = username;
103 }
104
105 void SettingsDialog::setPassword(QString password)
106 {
107     this->password = password;
108 }
109
110 QString SettingsDialog::getUserName()
111 {
112     return this->username;
113 }
114
115 QString SettingsDialog::getPassword()
116 {
117     return this->password;
118 }
119