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