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 <QFrame> |
27 | |
28 | class QToolButton; |
29 | class QPushButton; |
30 | class GitBase; |
31 | class GitCache; |
32 | class GitTags; |
33 | class GitCache; |
34 | class QNetworkAccessManager; |
35 | class QProgressBar; |
36 | class GitQlientUpdater; |
37 | class QButtonGroup; |
38 | class QHBoxLayout; |
39 | class PomodoroButton; |
40 | |
41 | /*! |
42 | \brief Enum used to configure the different views handled by the Controls widget. |
43 | |
44 | */ |
45 | enum class ControlsMainViews |
46 | { |
47 | History, |
48 | Diff, |
49 | Blame, |
50 | Merge, |
51 | GitServer, |
52 | BuildSystem, |
53 | Config |
54 | }; |
55 | |
56 | /*! |
57 | \brief The Controls class creates the layout to store all the buttons that acts over the UI current view and the most |
58 | used Git actions. |
59 | |
60 | */ |
61 | class Controls : public QFrame |
62 | { |
63 | Q_OBJECT |
64 | |
65 | signals: |
66 | /*! |
67 | \brief Signal triggered when the user wants to go to the main repository view. |
68 | |
69 | */ |
70 | void signalGoRepo(); |
71 | /*! |
72 | \brief Signal triggered when the user selects the diff view. |
73 | |
74 | */ |
75 | void signalGoDiff(); |
76 | /*! |
77 | \brief Signal triggered when the user selects the Blame&History view. |
78 | |
79 | */ |
80 | void signalGoBlame(); |
81 | /*! |
82 | \brief Signal triggered when the user selects the merge conflict resolution view. |
83 | |
84 | */ |
85 | void signalGoMerge(); |
86 | |
87 | /** |
88 | * @brief signalGoManagement Signal triggered when the user selected the Git remote platform view. |
89 | */ |
90 | void signalGoServer(); |
91 | |
92 | /** |
93 | * @brief signalGoBuildSystem Signal triggered when the user selected the Build System view. |
94 | */ |
95 | void signalGoBuildSystem(); |
96 | /*! |
97 | * \brief Signal triggered when trying to pull and a conflict happens. |
98 | */ |
99 | void signalPullConflict(); |
100 | |
101 | /** |
102 | * @brief signalRefreshPRsCache Signal that refreshes PRs cache. |
103 | */ |
104 | void signalRefreshPRsCache(); |
105 | |
106 | /** |
107 | * @brief requestReload Signal triggered when the user forces a full refresh of the repository data. |
108 | */ |
109 | void requestFullReload(); |
110 | |
111 | /** |
112 | * @brief requestReload Signal triggered when the user forces a refresh of the references of the repository. |
113 | */ |
114 | void requestReferencesReload(); |
115 | |
116 | /** |
117 | * @brief goConfig Signal triggered when the user seleced the config view. |
118 | */ |
119 | void goConfig(); |
120 | |
121 | public: |
122 | /*! |
123 | \brief Default constructor. |
124 | |
125 | \param git The git object to perform Git operations. |
126 | \param parent The parent widget if needed. |
127 | */ |
128 | explicit Controls(const QSharedPointer<GitCache> &cache, const QSharedPointer<GitBase> &git, |
129 | QWidget *parent = nullptr); |
130 | |
131 | /** |
132 | * @brief Destructor. |
133 | */ |
134 | ~Controls(); |
135 | /*! |
136 | \brief Process the toggled button and triggers its corresponding action. |
137 | |
138 | \param view The view the user selected. |
139 | */ |
140 | void toggleButton(ControlsMainViews view); |
141 | /*! |
142 | \brief Sets the current SHA. |
143 | |
144 | \param sha The SHA hash. |
145 | */ |
146 | void setCurrentSha(const QString &sha) { mCurrentSha = sha; } |
147 | /*! |
148 | \brief Set all the buttons as enabled. |
149 | |
150 | \param enabled True to enable, false otherwise. |
151 | */ |
152 | void enableButtons(bool enabled); |
153 | /*! |
154 | \brief Performs the fetch action. Can be triggered manually or by a timer. |
155 | |
156 | */ |
157 | void fetchAll(); |
158 | /*! |
159 | \brief Activates the merge warning frame. |
160 | |
161 | */ |
162 | void activateMergeWarning(); |
163 | /*! |
164 | \brief Disables the merge warning frame. |
165 | |
166 | */ |
167 | void disableMergeWarning(); |
168 | /*! |
169 | \brief Disables the diff button and view. |
170 | |
171 | */ |
172 | void disableDiff(); |
173 | /*! |
174 | \brief Enables the diff button and view. |
175 | |
176 | */ |
177 | void enableDiff(); |
178 | /*! |
179 | \brief Gets the current selected button/view. |
180 | |
181 | \return ControlsMainViews The value of the current selected button. |
182 | */ |
183 | ControlsMainViews getCurrentSelectedButton() const; |
184 | |
185 | private: |
186 | QString mCurrentSha; |
187 | QSharedPointer<GitCache> mCache; |
188 | QSharedPointer<GitBase> mGit; |
189 | QSharedPointer<GitTags> mGitTags; |
190 | QToolButton *mHistory = nullptr; |
191 | QToolButton *mDiff = nullptr; |
192 | QToolButton *mBlame = nullptr; |
193 | QToolButton *mPullBtn = nullptr; |
194 | QToolButton *mPullOptions = nullptr; |
195 | QToolButton *mPushBtn = nullptr; |
196 | QToolButton *mRefreshBtn = nullptr; |
197 | QToolButton *mConfigBtn = nullptr; |
198 | QToolButton *mGitPlatform = nullptr; |
199 | QToolButton *mBuildSystem = nullptr; |
200 | PomodoroButton *mPomodoro = nullptr; |
201 | QToolButton *mVersionCheck = nullptr; |
202 | QPushButton *mMergeWarning = nullptr; |
203 | GitQlientUpdater *mUpdater = nullptr; |
204 | QButtonGroup *mBtnGroup = nullptr; |
205 | bool mGoGitServerView = false; |
206 | |
207 | /*! |
208 | \brief Pulls the current branch. |
209 | |
210 | */ |
211 | void pullCurrentBranch(); |
212 | /*! |
213 | \brief Pushes the current local branch changes. |
214 | |
215 | */ |
216 | void pushCurrentBranch(); |
217 | /*! |
218 | \brief Prunes all branches, tags and stashes. |
219 | |
220 | */ |
221 | void pruneBranches(); |
222 | |
223 | /** |
224 | * @brief createGitPlatformButton Createst the git platform button if the user has enabled it. |
225 | */ |
226 | void createGitPlatformButton(QHBoxLayout *layout); |
227 | |
228 | /** |
229 | * @brief createBuildSystemButton Creates the build system platform button if the user has enabled it. |
230 | */ |
231 | void configBuildSystemButton(); |
232 | |
233 | bool eventFilter(QObject *obj, QEvent *event); |
234 | }; |
235 | |