Tulip  6.0.0
Large graphs analysis and drawing
TulipSettings.h
1 /*
2  *
3  * This file is part of Tulip (https://tulip.labri.fr)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef TULIPSETTINGS_H
22 #define TULIPSETTINGS_H
23 
24 #include <QSettings>
25 #include <QNetworkProxy>
26 #include <QString>
27 
28 #include <tulip/GlGraphRenderingParameters.h>
29 #include <tulip/Size.h>
30 #include <tulip/Graph.h>
31 
32 namespace tlp {
33 
34 /**
35  * @brief This class provides convenience functions to access the Tulip settings file (using
36  * QSettings)
37  * TulipSettings is a wrapper for QSettings providing quick access to common keys provided in the
38  * tulip configuration file.
39  * This object does not mask any method from the QSettings class, which mean that the user can
40  * still access custom keys by invoking the QSettings::value method.
41  */
42 class TLP_QT_SCOPE TulipSettings : public QSettings, GlDefaultSelectionColorManager, Observable {
43  Q_OBJECT
44  Q_ENUMS(DisplayProperty)
45 
46 public:
47  static TulipSettings &instance();
48 
49  static QString elementKey(const QString &configEntry, tlp::ElementType elem);
50 
51  static void synchronizeSettings();
52 
53  static void synchronizeViewSettings();
54 
55  /**
56  @brief Retrieves the list of documents recently opened with tulip.
57  */
58  static QStringList recentDocuments();
59 
60  /**
61  @brief Registers a file in the list of recently opened documents.
62  If the list already contains 5 elements, the last one (in chronological order) will be removed.
63  */
64  static void addToRecentDocuments(const QString &);
65 
66  /**
67  @brief Check recently opened documents list and remove non-existing ones
68  */
69  static void checkRecentDocuments();
70 
71  static tlp::Color defaultColor(tlp::ElementType elem, bool tulipDefault = false);
72  static void setDefaultColor(tlp::ElementType elem, const tlp::Color &color);
73 
74  static tlp::Color defaultLabelColor(bool tulipDefault = false);
75  static void setDefaultLabelColor(const tlp::Color &color);
76 
77  static tlp::Size defaultSize(tlp::ElementType elem, bool tulipDefault = false);
78  static void setDefaultSize(tlp::ElementType elem, const tlp::Size &size);
79 
80  static int defaultShape(tlp::ElementType elem, bool tulipDefault = false);
81  static void setDefaultShape(tlp::ElementType elem, int shape);
82 
83  // in GlDefaultSelectionColorManager interface
84  tlp::Color defaultSelectionColor(bool tulipDefault = false) override;
85 
86  static tlp::Color getDefaultSelectionColor(bool tulipDefault = false);
87  static void setDefaultSelectionColor(const tlp::Color &color);
88 
89  static QSet<QString> favoriteAlgorithms();
90  static void addFavoriteAlgorithm(const QString &name);
91  static void removeFavoriteAlgorithm(const QString &name);
92 
93  // Proxy settings
94  static bool isProxyEnabled();
95  static void setProxyEnabled(bool);
96 
97  static QNetworkProxy::ProxyType proxyType();
98  static void setProxyType(QNetworkProxy::ProxyType);
99 
100  static QString proxyHost();
101  static void setProxyHost(const QString &);
102 
103  static unsigned int proxyPort();
104  static void setProxyPort(unsigned int);
105 
106  static bool isUseProxyAuthentification();
107  static void setUseProxyAuthentification(bool);
108 
109  static QString proxyUsername();
110  static void setProxyUsername(const QString &);
111 
112  static QString proxyPassword();
113  static void setProxyPassword(const QString &);
114 
115  static void applyProxySettings();
116 
117  static bool isFirstRun();
118  static void setFirstRun(bool);
119 
120  static bool isFirstTulipMMRun();
121  static bool userHasLaunchedTulipMM(const std::string &mmVersion);
122  static void setFirstTulipMMRun(bool);
123 
124  static bool displayDefaultViews();
125  static void setDisplayDefaultViews(bool);
126 
127  static bool isAutomaticMapMetric();
128  static void setAutomaticMapMetric(bool);
129 
130  static bool isAutomaticCentering();
131  static void setAutomaticCentering(bool);
132 
133  static bool isAutomaticRatio();
134  static void setAutomaticRatio(bool);
135 
136  static bool isViewOrtho();
137  static void setViewOrtho(bool);
138 
139  static bool isResultPropertyStored();
140  static void setResultPropertyStored(bool);
141 
142  enum LogPluginCall { NoLog = 0, LogCall = 1, LogCallWithExecutionTime = 2 };
143  static unsigned int logPluginCall();
144  static void setLogPluginCall(unsigned int);
145 
146  static bool isUseTlpbFileFormat();
147  static void setUseTlpbFileFormat(bool);
148 
149  static unsigned int seedOfRandomSequence();
150  static void setSeedOfRandomSequence(unsigned int);
151  static void initSeedOfRandomSequence();
152 
153  static bool warnUserAboutGraphicsCard();
154  static void setWarnUserAboutGraphicsCard(bool);
155 
156  static bool isDisplayInDarkMode();
157  static void setDisplayInDarkMode(bool);
158 
159  static bool loggerAnchored();
160  static void setLoggerAnchored(bool);
161 
162  static QStringList recentPerspectiveFiles();
163  static void setRecentPerspectiveFiles(QStringList &doc);
164 
165  void treatEvent(const Event &message) override;
166 
167 private:
168  TulipSettings();
169  static TulipSettings *_instance;
170 
171  void setFavoriteAlgorithms(const QSet<QString> &lst);
172 };
173 } // namespace tlp
174 #endif // TULIPSETTINGS_H
175 ///@endcond
ElementType
Definition: Graph.h:50
void setSeedOfRandomSequence(unsigned int seed=UINT_MAX)
Gives the value of the seed used for further initialization of a random sequence (with further calls ...