Tulip  4.8.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
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 const QString RemoteLocationsConfigEntry;
46  static const QString RecentDocumentsConfigEntry;
47  static const QString PluginsToRemoveConfigEntry;
48  static const QString DefaultColorConfigEntry;
49  static const QString DefaultLabelColorConfigEntry;
50  static const QString DefaultSizeConfigEntry;
51  static const QString DefaultShapeConfigEntry;
52  static const QString DefaultSelectionColorEntry;
53  static const QString FavoriteAlgorithmsEntry;
54  static const QString FirstRunEntry;
55 
56  static const QString ProxyEnabledEntry;
57  static const QString ProxyTypeEntry;
58  static const QString ProxyHostEntry;
59  static const QString ProxyPortEntry;
60  static const QString ProxyUseAuthEntry;
61  static const QString ProxyUsernameEntry;
62  static const QString ProxyPasswordEntry;
63 
64  static const QString AutomaticDisplayDefaultViews;
65  static const QString AutomaticPerfectAspectRatioEntry;
66  static const QString ViewOrthoEntry;
67  static const QString AutomaticMapMetricEntry;
68  static const QString ResultPropertyStoredEntry;
69  static const QString RunningTimeComputedEntry;
70  static const QString SeedForRandomSequenceEntry;
71 
72  static const QString WarnUserAboutGraphicsCardEntry;
73 
74  static TulipSettings &instance();
75 
76  static QString elementKey(const QString& configEntry, tlp::ElementType elem);
77 
78  void synchronizeViewSettings();
79 
80  /**
81  @brief Retrieves the list of documents recently opened with tulip.
82  */
83  QStringList recentDocuments() const;
84 
85  /**
86  @brief Registers a file in the list of recently opened documents.
87  If the list already contains 5 elements, the last one (in chronological order) will be removed.
88  */
89  void addToRecentDocuments(const QString &);
90 
91  /**
92  @brief Check recently opened documents list and remove non-existing ones
93  */
94  void checkRecentDocuments();
95 
96  /**
97  * @brief Adds a remote location from which to list plugins.
98  *
99  * @param remoteLocation The URL of the plugin server.
100  * @return void
101  **/
102  void addRemoteLocation(const QString& remoteLocation);
103 
104  /**
105  * @brief Removes a location from which to list plugins.
106  *
107  * @param remoteLocation The URL of the plugin server.
108  * @return void
109  **/
110  void removeRemoteLocation(const QString& remoteLocation);
111 
112  /**
113  * @brief Retrieves the list of locations from which to list plugins.
114  *
115  * @return const QStringList
116  **/
117  const QStringList remoteLocations() const;
118  const QStringList pluginsToRemove() const;
119 
120  void markPluginForRemoval(const QString& pluginLibrary);
121  void unmarkPluginForRemoval(const QString& pluginLibrary);
122 
123  tlp::Color defaultColor(tlp::ElementType elem);
124  void setDefaultColor(tlp::ElementType elem, const tlp::Color& color);
125 
126  tlp::Color defaultLabelColor();
127  void setDefaultLabelColor(const tlp::Color& color);
128 
129  tlp::Size defaultSize(tlp::ElementType elem);
130  void setDefaultSize(tlp::ElementType elem, const tlp::Size& size);
131 
132  int defaultShape(tlp::ElementType elem);
133  void setDefaultShape(tlp::ElementType elem, int shape);
134 
135  // in GlDefaultSelectionColorManager interface
136  tlp::Color defaultSelectionColor();
137 
138  void setDefaultSelectionColor(const tlp::Color& color);
139 
140  QSet<QString> favoriteAlgorithms() const;
141  void addFavoriteAlgorithm(const QString&name);
142  void removeFavoriteAlgorithm(const QString&name);
143 
144  // Proxy settings
145  bool isProxyEnabled() const;
146  void setProxyEnabled(bool);
147 
148  QNetworkProxy::ProxyType proxyType() const;
149  void setProxyType(QNetworkProxy::ProxyType);
150 
151  QString proxyHost() const;
152  void setProxyHost(const QString&);
153 
154  unsigned int proxyPort() const;
155  void setProxyPort(unsigned int);
156 
157  bool isUseProxyAuthentification() const;
158  void setUseProxyAuthentification(bool);
159 
160  QString proxyUsername() const;
161  void setProxyUsername(const QString&);
162 
163  QString proxyPassword() const;
164  void setProxyPassword(const QString&);
165 
166  void applyProxySettings();
167 
168  bool isFirstRun() const;
169  void setFirstRun(bool);
170 
171  bool displayDefaultViews() const;
172  void setDisplayDefaultViews(bool);
173 
174  bool isAutomaticMapMetric() const;
175  void setAutomaticMapMetric(bool);
176 
177  bool isAutomaticRatio() const;
178  void setAutomaticRatio(bool);
179 
180  bool isViewOrtho() const;
181  void setViewOrtho(bool);
182 
183  bool isResultPropertyStored() const;
184  void setResultPropertyStored(bool);
185 
186  bool isRunningTimeComputed() const;
187  void setRunningTimeComputed(bool);
188 
189  unsigned int seedOfRandomSequence() const;
190  void setSeedOfRandomSequence(unsigned int);
191  void initSeedOfRandomSequence();
192 
193  bool warnUserAboutGraphicsCard() const;
194  void setWarnUserAboutGraphicsCard(bool);
195 
196  void treatEvent(const Event &message);
197 
198 private:
199  TulipSettings();
200  static TulipSettings *_instance;
201 
202  void setFavoriteAlgorithms(const QSet<QString> &lst);
203 };
204 }
205 #endif // TULIPSETTINGS_H
206 ///@endcond