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