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