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#include <ConfigData.h>
29
30namespace Ui
31{
32class ServerConfigDlg;
33}
34
35class QNetworkAccessManager;
36class QNetworkReply;
37class GitServerCache;
38
39/**
40 * @brief The ServerConfigDlg class creates a small dialog where the user can add the user name and the user token of
41 * the remote git platform being used.
42 *
43 * This configuration is needed to use the feature of create new issues and create pull requests, as well as seeing the
44 * configuration and manage the remote repository.
45 *
46 * @class ServerConfigDlg ServerConfigDlg.h "ServerConfigDlg.h"
47 */
48class ServerConfigDlg : public QDialog
49{
50 Q_OBJECT
51
52signals:
53 void configured();
54
55public:
56 /**
57 * @brief Constructor builds the UI layout and configures some widgets based on the configuration.
58 *
59 * @param parent The parent widget if needed
60 */
61 explicit ServerConfigDlg(const QSharedPointer<GitServerCache> &gitServerCache, const GitServer::ConfigData &data,
62 QWidget *parent = nullptr);
63 /**
64 * @brief Destructor that deallocates the Ui::ServerConfigDlg class.
65 */
66 ~ServerConfigDlg() override;
67
68private:
69 Ui::ServerConfigDlg *ui = nullptr;
70 QSharedPointer<GitServerCache> mGitServerCache;
71 GitServer::ConfigData mData;
72 QNetworkAccessManager *mManager;
73
74 /**
75 * @brief Validates the provided token by the user.
76 */
77 void checkToken();
78 /**
79 * @brief Executes the Git actions based on the configuration once the validation as taken place.
80 */
81 void accept() override;
82 /**
83 * @brief testToken Method that does a light test connection to the selected server.
84 */
85 void testToken();
86
87 /**
88 * @brief onServerChanged Shows the line edit to add the GitHub Enterprise URL.
89 * @param The new shown text.
90 */
91 void onServerChanged();
92
93 /**
94 * @brief onTestSucceeded Notifies the user through the UI that the connection test succeeded.
95 */
96 void onTestSucceeded();
97
98 /**
99 * @brief onGitServerError Notifies the user that an error happened in the API connection or data exchange.
100 */
101 void onGitServerError(const QString &error);
102
103 /**
104 * @brief onDataValidated Stores the data in the settings and sends a success signal. Finally it closes the dialog.
105 */
106 void onDataValidated();
107};
108