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