1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #include "checkoutdialog.h" |
6 | |
7 | #include <QLabel> |
8 | #include <QLineEdit> |
9 | #include <QGridLayout> |
10 | #include <QPushButton> |
11 | #include <QFileDialog> |
12 | #include <QUrl> |
13 | #include <QDebug> |
14 | |
15 | CheckoutDialog::CheckoutDialog(QWidget *parent, Qt::WindowFlags f) |
16 | : QDialog (parent, f) |
17 | , labelRepos(new QLabel) |
18 | , labelLocal(new QLabel) |
19 | , labelUser(new QLabel) |
20 | , labelPasswd(new QLabel) |
21 | , editRepos(new QLineEdit) |
22 | , editLocal(new QLineEdit) |
23 | , editUser(new QLineEdit) |
24 | , editPasswd(new QLineEdit) |
25 | , pbtSelLocal(new QPushButton) |
26 | , pbtOk(new QPushButton) |
27 | , vLayoutPbt(new QVBoxLayout) |
28 | , gLayout(new QGridLayout) |
29 | { |
30 | this->setWindowTitle(QDialog::tr("Checkout Repos" )); |
31 | this->setMinimumWidth(500); |
32 | |
33 | labelRepos->setText(QLabel::tr("Remote Repos: " )); |
34 | labelRepos->setAlignment(Qt::AlignRight); |
35 | labelLocal->setText(QLabel::tr("Target path: " )); |
36 | labelLocal->setAlignment(Qt::AlignRight); |
37 | labelUser->setText(QLabel::tr("User: " )); |
38 | labelUser->setAlignment(Qt::AlignRight); |
39 | labelPasswd->setText(QLabel::tr("Password: " )); |
40 | labelPasswd->setAlignment(Qt::AlignRight); |
41 | |
42 | editPasswd->setEchoMode(QLineEdit::EchoMode::Password); |
43 | |
44 | pbtSelLocal->setText("..." ); |
45 | pbtSelLocal->setFixedSize(20, 20); |
46 | |
47 | pbtOk->setText(QPushButton::tr("Ok" )); |
48 | vLayoutPbt->addWidget(pbtOk); |
49 | vLayoutPbt->setMargin(4); |
50 | |
51 | gLayout->addWidget(labelRepos, 0, 0); |
52 | gLayout->addWidget(editRepos, 0, 1); |
53 | gLayout->addWidget(labelLocal, 1, 0); |
54 | gLayout->addWidget(editLocal, 1, 1); |
55 | gLayout->addWidget(pbtSelLocal, 1, 2, Qt::AlignLeft); |
56 | gLayout->addWidget(labelUser, 2, 0); |
57 | gLayout->addWidget(editUser, 2, 1); |
58 | gLayout->addWidget(labelPasswd, 3, 0); |
59 | gLayout->addWidget(editPasswd, 3, 1); |
60 | |
61 | gLayout->addLayout(vLayoutPbt, 4, 1, 1, 3, Qt::AlignRight); |
62 | setLayout(gLayout); |
63 | |
64 | QObject::connect(pbtSelLocal, &QPushButton::clicked, [=](){ |
65 | QString directory = QFileDialog::getExistingDirectory(this); |
66 | if (!directory.isEmpty()) { |
67 | editLocal->setText(directory); |
68 | } |
69 | }); |
70 | |
71 | QObject::connect(pbtOk, &QPushButton::clicked, [=]() { |
72 | checkoutRepos(editRepos->text(), editLocal->text(), editUser->text(), editPasswd->text()); |
73 | this->close(); |
74 | }); |
75 | } |
76 | |