1 | #pragma once |
2 | |
3 | /**************************************************************************************** |
4 | ** GitQlient is an application to manage and operate one or several Git repositories. With |
5 | ** GitQlient you will be able to add commits, branches and manage all the options Git provides. |
6 | ** Copyright (C) 2021 Francesc Martinez |
7 | ** |
8 | ** LinkedIn: www.linkedin.com/in/cescmm/ |
9 | ** Web: www.francescmm.com |
10 | ** |
11 | ** This program is free software; you can redistribute it and/or |
12 | ** modify it under the terms of the GNU Lesser General Public |
13 | ** License as published by the Free Software Foundation; either |
14 | ** version 2 of the License, or (at your option) any later version. |
15 | ** |
16 | ** This program is distributed in the hope that it will be useful, |
17 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 | ** Lesser General Public License for more details. |
20 | ** |
21 | ** You should have received a copy of the GNU Lesser General Public |
22 | ** License along with this library; if not, write to the Free Software |
23 | ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
24 | ***************************************************************************************/ |
25 | |
26 | #include <QDialog> |
27 | |
28 | class GitConfig; |
29 | |
30 | namespace Ui |
31 | { |
32 | class CreateRepoDlg; |
33 | } |
34 | |
35 | /** |
36 | * @brief Defines how the CreateRepoDlg behaviour will be configured. |
37 | * |
38 | * @enum CreateRepoDlgType |
39 | */ |
40 | enum class CreateRepoDlgType |
41 | { |
42 | CLONE, |
43 | INIT |
44 | }; |
45 | |
46 | /** |
47 | * @brief The CreateRepoDlg creates a dialog to handle repositories when they are not already cloned. The dialog can be |
48 | * configured in two different ways: |
49 | * - Clone: The dialog will clone a repository based on its URL and a selected destination folder. |
50 | * - Init: The dialog will init a new repository that doesn't have a mirror remotely. |
51 | * |
52 | * @class CreateRepoDlg CreateRepoDlg.h "CreateRepoDlg.h" |
53 | */ |
54 | class CreateRepoDlg : public QDialog |
55 | { |
56 | Q_OBJECT |
57 | |
58 | signals: |
59 | /** |
60 | * @brief Signal emitted when the user accepts the configuration to notify other widgets that that the user wants to |
61 | * open the repo after init or clone it. |
62 | * |
63 | * @param path The path to the new repository. |
64 | */ |
65 | void signalOpenWhenFinish(const QString &path); |
66 | |
67 | public: |
68 | /** |
69 | * @brief Default constructor that takes the configuration to init or clone a new repository. |
70 | * |
71 | * @param type Defines how the dialog is configured. |
72 | * @param git The Git object to perform repository operations. |
73 | * @param parent The parent widget if needed. |
74 | */ |
75 | explicit CreateRepoDlg(CreateRepoDlgType type, QSharedPointer<GitConfig> git, QWidget *parent = nullptr); |
76 | /** |
77 | * @brief Destructor of the class. |
78 | */ |
79 | ~CreateRepoDlg() override; |
80 | |
81 | /** |
82 | * @brief Once all the validations ar passed, the dialog performs the configured action. |
83 | */ |
84 | void accept() override; |
85 | |
86 | private: |
87 | Ui::CreateRepoDlg *ui; |
88 | CreateRepoDlgType mType; |
89 | QSharedPointer<GitConfig> mGit; |
90 | |
91 | /** |
92 | * @brief Opens a file dialog configured to select the destination folder of the repository. |
93 | */ |
94 | void selectFolder(); |
95 | /** |
96 | * @brief Extracts the project name from the URL when cloning a repository. |
97 | * @param url The url from the remote repository |
98 | */ |
99 | void addDefaultName(const QString &url); |
100 | /** |
101 | * @brief Allows the user to configure the local repository email and user name. |
102 | */ |
103 | void showGitControls(); |
104 | }; |
105 | |