1#include "TagDlg.h"
2#include "ui_TagDlg.h"
3
4#include <GitTags.h>
5#include <GitQlientStyles.h>
6
7#include <QFile>
8
9TagDlg::TagDlg(const QSharedPointer<GitBase> &git, const QString &sha, QWidget *parent)
10 : QDialog(parent)
11 , ui(new Ui::TagDlg)
12 , mGit(git)
13 , mSha(sha)
14{
15 setStyleSheet(GitQlientStyles::getStyles());
16
17 ui->setupUi(this);
18
19 connect(ui->leTagName, &QLineEdit::returnPressed, this, &TagDlg::accept);
20 connect(ui->leTagMessage, &QLineEdit::returnPressed, this, &TagDlg::accept);
21
22 connect(ui->pbAccept, &QPushButton::clicked, this, &TagDlg::accept);
23 connect(ui->pbCancel, &QPushButton::clicked, this, &QDialog::reject);
24}
25
26TagDlg::~TagDlg()
27{
28 delete ui;
29}
30
31void TagDlg::accept()
32{
33 auto tagName = ui->leTagName->text();
34 auto tagMessage = ui->leTagMessage->text();
35
36 if (!tagName.isEmpty() && !tagMessage.isEmpty())
37 {
38 tagName = tagName.trimmed();
39 tagName = tagName.replace(" ", "_");
40
41 tagMessage = tagMessage.trimmed();
42
43 QScopedPointer<GitTags> git(new GitTags(mGit));
44 auto ret = git->addTag(tagName, tagMessage, mSha);
45
46 if (ret.success)
47 QDialog::accept();
48 }
49}
50