1#include "gituserconfigdialog.h"
2#include "ui_gituserconfigdialog.h"
3#include "gitmanager.h"
4#include "../widgets/infomessagebox.h"
5
6GitUserConfigDialog::GitUserConfigDialog(const QString& folder, QWidget *parent) :
7 QDialog(parent),
8 ui(new Ui::GitUserConfigDialog),
9 mFolder(folder)
10{
11 ui->setupUi(this);
12 GitManager manager;
13 ui->txtUserName->setText(manager.getUserName(folder));
14 ui->txtUserEmail->setText(manager.getUserEmail(folder));
15 checkInfo();
16}
17
18GitUserConfigDialog::~GitUserConfigDialog()
19{
20 delete ui;
21}
22
23void GitUserConfigDialog::checkInfo()
24{
25 ui->btnOk->setEnabled(!ui->txtUserEmail->text().isEmpty()
26 && !ui->txtUserName->text().isEmpty());
27}
28
29void GitUserConfigDialog::on_btnOk_clicked()
30{
31 GitManager manager;
32 QString output;
33 if (!manager.setUserName(mFolder, ui->txtUserName->text(),output)) {
34 InfoMessageBox infoBox;
35 infoBox.showMessage(output);
36 reject();
37 }
38 if (!manager.setUserEmail(mFolder, ui->txtUserEmail->text(),output)) {
39 InfoMessageBox infoBox;
40 infoBox.showMessage(output);
41 reject();
42 }
43 accept();
44}
45
46
47void GitUserConfigDialog::on_btnCancel_clicked()
48{
49 reject();
50}
51
52void GitUserConfigDialog::closeEvent(QCloseEvent * /*event*/)
53{
54 reject();
55}
56
57
58void GitUserConfigDialog::on_txtUserName_textChanged(const QString &/*arg1*/)
59{
60 checkInfo();
61}
62
63
64void GitUserConfigDialog::on_txtUserEmail_textChanged(const QString &/*arg1*/)
65{
66 checkInfo();
67}
68
69