1 | #include "PullDlg.h" |
2 | #include "ui_PullDlg.h" |
3 | |
4 | #include <GitQlientStyles.h> |
5 | #include <GitRemote.h> |
6 | |
7 | #include <QMessageBox> |
8 | #include <QPushButton> |
9 | |
10 | PullDlg::PullDlg(QSharedPointer<GitBase> git, const QString &text, QWidget *parent) |
11 | : QDialog(parent) |
12 | , ui(new Ui::PullDlg) |
13 | , mGit(git) |
14 | { |
15 | ui->setupUi(this); |
16 | |
17 | ui->lText->setText(text); |
18 | ui->buttonBox->button(QDialogButtonBox::Ok)->setText("Pull" ); |
19 | |
20 | setStyleSheet(GitQlientStyles::getStyles()); |
21 | } |
22 | |
23 | PullDlg::~PullDlg() |
24 | { |
25 | delete ui; |
26 | } |
27 | |
28 | void PullDlg::accept() |
29 | { |
30 | QScopedPointer<GitRemote> git(new GitRemote(mGit)); |
31 | |
32 | QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
33 | const auto ret = git->pull(); |
34 | QApplication::restoreOverrideCursor(); |
35 | |
36 | if (ret.success) |
37 | { |
38 | emit signalRepositoryUpdated(); |
39 | |
40 | QDialog::accept(); |
41 | } |
42 | else |
43 | { |
44 | if (ret.output.contains("error: could not apply" , Qt::CaseInsensitive) |
45 | && ret.output.contains("causing a conflict" , Qt::CaseInsensitive)) |
46 | { |
47 | emit signalPullConflict(); |
48 | } |
49 | else |
50 | { |
51 | QMessageBox msgBox(QMessageBox::Critical, tr("Error while pulling" ), |
52 | QString(tr("There were problems during the pull operation. Please, see the detailed " |
53 | "description for more information." )), |
54 | QMessageBox::Ok, this); |
55 | msgBox.setDetailedText(ret.output); |
56 | msgBox.setStyleSheet(GitQlientStyles::getStyles()); |
57 | msgBox.exec(); |
58 | } |
59 | } |
60 | } |
61 | |