Tulip  4.0.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 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 <QtNetwork/QNetworkProxy>
32 
33 /**
34  * @brief This class provides convenience functions to access the Tulip settings file (using QSettings)
35  * TulipSettings is a wrapper for QSettings providing quick access to common keys provided in the tulip configuration file.
36  * 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.
37  */
38 class TLP_QT_SCOPE TulipSettings: public QSettings {
39  Q_OBJECT
40  Q_ENUMS(DisplayProperty)
41 
42 public:
43 
44  static const QString RemoteLocationsConfigEntry;
45  static const QString RecentDocumentsConfigEntry;
46  static const QString PluginsToRemoveConfigEntry;
47  static const QString DefaultColorConfigEntry;
48  static const QString DefaultSizeConfigEntry;
49  static const QString DefaultShapeConfigEntry;
50  static const QString DefaultSelectionColorEntry;
51  static const QString FavoriteAlgorithmsEntry;
52  static const QString FirstRunEntry;
53 
54  static const QString ProxyEnabledEntry;
55  static const QString ProxyTypeEntry;
56  static const QString ProxyHostEntry;
57  static const QString ProxyPortEntry;
58  static const QString ProxyUseAuthEntry;
59  static const QString ProxyUsernameEntry;
60  static const QString ProxyPasswordEntry;
61 
62  static const QString AutomaticPerfectAspectRatioEntry;
63  static const QString AutomaticMapMetricEntry;
64 
65  static TulipSettings &instance();
66 
67  static QString elementKey(const QString& configEntry, tlp::ElementType elem);
68 
69  /**
70  @brief Retrieves the list of documents recently opened with tulip.
71  */
72  QStringList recentDocuments() const;
73 
74  /**
75  @brief Registers a file in the list of recently opened documents.
76  If the list already contains 5 elements, the last one (in chronological order) will be removed.
77  */
78  void addToRecentDocuments(const QString &);
79 
80  /**
81  @brief Check recently opened documents list and remove non-existing ones
82  */
83  void checkRecentDocuments();
84 
85  /**
86  * @brief Adds a remote location from which to list plugins.
87  *
88  * @param remoteLocation The URL of the plugin server.
89  * @return void
90  **/
91  void addRemoteLocation(const QString& remoteLocation);
92 
93  /**
94  * @brief Removes a location from which to list plugins.
95  *
96  * @param remoteLocation The URL of the plugin server.
97  * @return void
98  **/
99  void removeRemoteLocation(const QString& remoteLocation);
100 
101  /**
102  * @brief Retrieves the list of locations from which to list plugins.
103  *
104  * @return const QStringList
105  **/
106  const QStringList remoteLocations() const;
107  const QStringList pluginsToRemove() const;
108 
109  void markPluginForRemoval(const QString& pluginLibrary);
110  void unmarkPluginForRemoval(const QString& pluginLibrary);
111 
112  tlp::Color defaultColor(tlp::ElementType elem);
113  void setDefaultColor(tlp::ElementType elem, const tlp::Color& color);
114 
115  tlp::Size defaultSize(tlp::ElementType elem);
116  void setDefaultSize(tlp::ElementType elem, const tlp::Size& size);
117 
118  int defaultShape(tlp::ElementType elem);
119  void setDefaultShape(tlp::ElementType elem, int shape);
120 
121  tlp::Color defaultSelectionColor();
122  void setDefaultSelectionColor(const tlp::Color& color);
123 
124  QSet<QString> favoriteAlgorithms() const;
125  void addFavoriteAlgorithm(const QString&name);
126  void removeFavoriteAlgorithm(const QString&name);
127 
128  // Proxy settings
129  bool isProxyEnabled() const;
130  void setProxyEnabled(bool);
131 
132  QNetworkProxy::ProxyType proxyType() const;
133  void setProxyType(QNetworkProxy::ProxyType);
134 
135  QString proxyHost() const;
136  void setProxyHost(const QString&);
137 
138  unsigned int proxyPort() const;
139  void setProxyPort(unsigned int);
140 
141  bool isUseProxyAuthentification() const;
142  void setUseProxyAuthentification(bool);
143 
144  QString proxyUsername() const;
145  void setProxyUsername(const QString&);
146 
147  QString proxyPassword() const;
148  void setProxyPassword(const QString&);
149 
150  void applyProxySettings();
151 
152  bool isFirstRun() const;
153  void setFirstRun(bool);
154 
155  bool isAutomaticMapMetric() const;
156  void setAutomaticMapMetric(bool);
157 
158  bool isAutomaticRatio() const;
159  void setAutomaticRatio(bool);
160 
161 private:
162  TulipSettings();
163  static TulipSettings *_instance;
164 
165  void setFavoriteAlgorithms(const QSet<QString> &lst);
166 };
167 
168 #endif // TULIPSETTINGS_H
169 ///@endcond