Tulip  5.2.0
Large graphs analysis and drawing
TulipSettings.h
1 /*
2  *
3  * This file is part of Tulip (http://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  void synchronizeViewSettings();
52 
53  /**
54  @brief Retrieves the list of documents recently opened with tulip.
55  */
56  QStringList recentDocuments() const;
57 
58  /**
59  @brief Registers a file in the list of recently opened documents.
60  If the list already contains 5 elements, the last one (in chronological order) will be removed.
61  */
62  void addToRecentDocuments(const QString &);
63 
64  /**
65  @brief Check recently opened documents list and remove non-existing ones
66  */
67  void checkRecentDocuments();
68 
69  /**
70  * @brief Adds a remote location from which to list plugins.
71  *
72  * @param remoteLocation The URL of the plugin server.
73  * @return void
74  **/
75  void addRemoteLocation(const QString &remoteLocation);
76 
77  /**
78  * @brief Removes a location from which to list plugins.
79  *
80  * @param remoteLocation The URL of the plugin server.
81  * @return void
82  **/
83  void removeRemoteLocation(const QString &remoteLocation);
84 
85  /**
86  * @brief Retrieves the list of locations from which to list plugins.
87  *
88  * @return const QStringList
89  **/
90  const QStringList remoteLocations() const;
91  const QStringList pluginsToRemove() const;
92 
93  void markPluginForRemoval(const QString &pluginLibrary);
94  void unmarkPluginForRemoval(const QString &pluginLibrary);
95 
96  tlp::Color defaultColor(tlp::ElementType elem, bool tulipDefault = false);
97  void setDefaultColor(tlp::ElementType elem, const tlp::Color &color);
98 
99  tlp::Color defaultLabelColor(bool tulipDefault = false);
100  void setDefaultLabelColor(const tlp::Color &color);
101 
102  tlp::Size defaultSize(tlp::ElementType elem, bool tulipDefault = false);
103  void setDefaultSize(tlp::ElementType elem, const tlp::Size &size);
104 
105  int defaultShape(tlp::ElementType elem, bool tulipDefault = false);
106  void setDefaultShape(tlp::ElementType elem, int shape);
107 
108  // in GlDefaultSelectionColorManager interface
109  tlp::Color defaultSelectionColor(bool tulipDefault = false) override;
110 
111  void setDefaultSelectionColor(const tlp::Color &color);
112 
113  QSet<QString> favoriteAlgorithms() const;
114  void addFavoriteAlgorithm(const QString &name);
115  void removeFavoriteAlgorithm(const QString &name);
116 
117  // Proxy settings
118  bool isProxyEnabled() const;
119  void setProxyEnabled(bool);
120 
121  QNetworkProxy::ProxyType proxyType() const;
122  void setProxyType(QNetworkProxy::ProxyType);
123 
124  QString proxyHost() const;
125  void setProxyHost(const QString &);
126 
127  unsigned int proxyPort() const;
128  void setProxyPort(unsigned int);
129 
130  bool isUseProxyAuthentification() const;
131  void setUseProxyAuthentification(bool);
132 
133  QString proxyUsername() const;
134  void setProxyUsername(const QString &);
135 
136  QString proxyPassword() const;
137  void setProxyPassword(const QString &);
138 
139  void applyProxySettings();
140 
141  bool isFirstRun() const;
142  void setFirstRun(bool);
143 
144  bool isFirstTulipMMRun() const;
145  void setFirstTulipMMRun(bool);
146 
147  bool displayDefaultViews() const;
148  void setDisplayDefaultViews(bool);
149 
150  bool isAutomaticMapMetric() const;
151  void setAutomaticMapMetric(bool);
152 
153  bool isAutomaticCentering() const;
154  void setAutomaticCentering(bool);
155 
156  bool isAutomaticRatio() const;
157  void setAutomaticRatio(bool);
158 
159  bool isViewOrtho() const;
160  void setViewOrtho(bool);
161 
162  bool isResultPropertyStored() const;
163  void setResultPropertyStored(bool);
164 
165  _DEPRECATED bool isRunningTimeComputed() const;
166  _DEPRECATED void setRunningTimeComputed(bool);
167 
168  enum LogPluginCall { NoLog = 0, LogCall = 1, LogCallWithExecutionTime = 2 };
169  unsigned int logPluginCall() const;
170  void setLogPluginCall(unsigned int);
171 
172  bool isUseTlpbFileFormat() const;
173  void setUseTlpFileFormat(bool);
174 
175  unsigned int seedOfRandomSequence() const;
176  void setSeedOfRandomSequence(unsigned int);
177  void initSeedOfRandomSequence();
178 
179  bool warnUserAboutGraphicsCard() const;
180  void setWarnUserAboutGraphicsCard(bool);
181 
182  bool showStatusBar() const;
183  void setShowStatusBar(bool);
184 
185  bool loggerAnchored() const;
186  void setLoggerAnchored(bool);
187 
188  void treatEvent(const Event &message) override;
189 
190 private:
191  TulipSettings();
192  static TulipSettings *_instance;
193 
194  void setFavoriteAlgorithms(const QSet<QString> &lst);
195 };
196 }
197 #endif // TULIPSETTINGS_H
198 ///@endcond
ElementType
Definition: Graph.h:48
void setSeedOfRandomSequence(unsigned int seed=UINT_MAX)
Gives the value of the seed used for further initialization of a random sequence (with further calls ...