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