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 <QSettings>
27#include <QVector>
28
29/*!
30 \brief The GitQlientSettings is an overloaded implementation of the QSettings that tries to help the user when a config
31 parameter is modified by triggering a signal to notify the UI.
32
33*/
34class GitQlientSettings
35{
36public:
37 /*!
38 \brief Default constructor.
39
40 */
41 GitQlientSettings() = default;
42 GitQlientSettings(const QString &gitRepoPath);
43 ~GitQlientSettings() { }
44
45 /*!
46 \brief Sets a value for a given \p key.
47
48 \param key The key.
49 \param value The new value for the key.
50 */
51 void setGlobalValue(const QString &key, const QVariant &value);
52
53 /**
54 * @brief getGlobalValue Returns the value for a given @p key.
55 * @param key The key.
56 * @param defaultValue (optional) A default value in case the key doesn't exist.
57 */
58 QVariant globalValue(const QString &key, const QVariant &defaultValue = QVariant());
59
60 /**
61 * @brief setLocalValue Sets a value for a given @p repo with a @p key and @p value.
62 * @param repo The local repo to store the config value.
63 * @param key The key.
64 * @param value The new value for the key.
65 */
66 void setLocalValue(const QString &key, const QVariant &value);
67
68 /**
69 * @brief getLocalValue Returns the value for a given @p repo and a given @p key.
70 * @param repo The repo to retrieve where the key from.
71 * @param key The key
72 * @param defaultValue (optional) A default value in case the key doesn't exist.
73 */
74 QVariant localValue(const QString &key, const QVariant &defaultValue = QVariant());
75
76 /*!
77 \brief Stores that a project is opened. This is used to recalculate which projects are the most used.
78
79 \param projectPath The project path of the repository.
80 */
81 void setProjectOpened(const QString &projectPath);
82 /*!
83 * \brief Gets all the recent used projects.
84 *
85 * \return QStringList Projects list.
86 */
87 QStringList getRecentProjects() const;
88 /*!
89 * \brief saveRecentProjects Saves the project in \p projectPath in the recent projects config value.
90 * \param projectPath The project path to save.
91 */
92 void saveRecentProjects(const QString &projectPath);
93
94 /**
95 * @brief clearRecentProjects Clears the recent projects list.
96 */
97 void clearRecentProjects();
98 /*!
99 * \brief saveMostUsedProjects Saves the project in \p projectPath in the most used projects config value.
100 * \param projectPath The project path to save.
101 */
102 void saveMostUsedProjects(const QString &projectPath);
103
104 /**
105 * @brief clearMostUsedProjects Clears the most used projects list.
106 */
107 void clearMostUsedProjects();
108
109 /*!
110 \brief Gets all the most used projects.
111
112 \return QStringList Projects list.
113 */
114 QStringList getMostUsedProjects() const;
115
116 static QString PinnedRepos;
117 static QString SplitFileDiffView;
118
119private:
120 QSettings globalSettings;
121 QString mGitRepoPath;
122};
123