More connecting client-server functionality to GUI.
[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("@");
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();      //using close() hides popup-window which reports error from server
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
96     //close();  //using close() hides popup-window which reports error from server
97 }
98
99 // Next 4 functions can be removed if Settingsdialog is implemented without
100 // own copy of username & password
101 void SettingsDialog::setUserName(QString username)
102 {
103     this->username = username;
104 }
105
106 void SettingsDialog::setPassword(QString password)
107 {
108     this->password = password;
109 }
110
111 QString SettingsDialog::getUserName()
112 {
113     return this->username;
114 }
115
116 QString SettingsDialog::getPassword()
117 {
118     return this->password;
119 }
120
121 void SettingsDialog::setLabelInfoToUser(QString infoText)
122 {
123     this->ui->labelInfoToUser->setText(infoText);
124 }