QCAD
Open Source 2D CAD
RSettings.h
Go to the documentation of this file.
1 
20 #ifndef RSETTINGS_H
21 #define RSETTINGS_H
22 
23 #include "core_global.h"
24 
25 #include <QDir>
26 #include <QSettings>
27 #include <QFont>
28 
29 #include "RColor.h"
30 
31 // workaround for src2srcml bug:
32 #ifndef RDEFAULT_RCOLOR
33 #define RDEFAULT_RCOLOR RColor()
34 #endif
35 
36 #ifndef RDEFAULT_QVARIANT
37 #define RDEFAULT_QVARIANT QVariant()
38 #endif
39 
40 #ifndef RDEFAULT_QSTRINGLIST
41 #define RDEFAULT_QSTRINGLIST QStringList()
42 #endif
43 
49 public:
50  static void uninit();
51 
52  static QString getAppId();
53 
54  static double getDevicePixelRatio();
55 
56  static QString getLocale();
57  static void loadTranslations(const QString& module, const QStringList& dirs = RDEFAULT_QSTRINGLIST);
58  static QString translate(const QString& context, const QString& str);
59 
60  static QStringList getOriginalArguments();
61  static void setOriginalArguments(const QStringList& a);
62 
63  static bool isDeployed();
64  static QString getApplicationPath();
65  static QStringList getPluginPaths();
66  static QString getPluginPath();
67 
68  static QString getStandardLocation(int sl);
69  static QString getCacheLocation();
70  static QString getDataLocation();
71  static QString getTempLocation();
72  static QString getDesktopLocation();
73  static QString getDocumentsLocation();
74  static QString getHomeLocation();
75 
76  //static void setEventBlocking(bool on);
77  //static bool isEventBlockingEnabled();
78  static bool isGuiEnabled();
79  static bool isDebuggerEnabled();
80  static bool hasQuitFlag();
81  static void setQuitFlag();
82 
83  static QString getFileName();
84  static QString getPath();
85  static QString getLaunchPath();
86  static void setLaunchPath(const QString& launchPath);
87 
88  static QString getDefaultStyle();
89 
90  // GraphicsView Appearance Fonts
91  static void setRulerFont(const QFont& font);
92  static QFont getRulerFont();
93  static void setSnapLabelFont(const QFont& font);
94  static QFont getSnapLabelFont();
95  static QFont getInfoLabelFont();
96  static QFont getStatusBarFont();
97 
98  static RColor getSelectionColor();
99  static RColor getReferencePointColor();
100  static RColor getSecondaryReferencePointColor();
101 
102  static bool getHighResolutionGraphicsView();
103  static bool getAutoScaleGrid();
104  static bool getAutoScaleMetaGrid();
105  static bool getAutoScalePatterns();
106  static bool getAutoZoomOnLoad();
107  static bool getColorCorrection();
108  static int getColorThreshold();
109  static int getTextHeightThreshold();
110  static double getArcAngleLengthThreshold();
111  static double getMinArcAngleStep();
112  static int getDashThreshold();
113  static int getQtVersion();
114  static QString getQtVersionString();
115  static bool isQt(int majorVersion);
116  static QString getCompilerVersion();
117  static QString getOSVersion();
118  static QString getReleaseDate();
119  static QString getVersionString();
120  static QString getNumericalVersionString();
121  static int getMajorVersion();
122  static int getMinorVersion();
123  static int getRevisionVersion();
124  static int getBuildVersion();
125  static QString getRevisionString();
126  static void setFirstStart(bool on) {
127  firstStart = on;
128  }
129  static bool isFirstStart() {
130  return firstStart;
131  }
132  static void setNewVersion(bool on) {
133  newVersion = on;
134  }
135  static bool isNewVersion() {
136  return newVersion;
137  }
138  static void setPreviousVersion(int pv) {
139  previousVersion = pv;
140  }
146  static int getCurrentVersion() {
147  return getMajorVersion()*1000000 +
148  getMinorVersion()*10000 +
149  getRevisionVersion()*100 +
150  getBuildVersion();
151  }
152  static int getPreviousVersion() {
153  return previousVersion;
154  }
155 
156  static int getSnapRange();
157  static int getPickRange();
158  static int getZeroWeightWeight();
159  static int getPreviewEntities();
160  static bool getLimitZoomAndScroll();
161  static bool getShowCrosshair();
162  static void setShowCrosshair(bool on);
163  static bool getShowLargeCrosshair();
164  static void setShowLargeCrosshair(bool on);
165  static bool getShowLargeOriginAxis();
166  static void setShowLargeOriginAxis(bool on);
167  static bool getConcurrentDrawing();
168  static void setConcurrentDrawing(bool on);
169  static QLocale getNumberLocale();
170 
171  static void initRecentFiles();
172  static void addRecentFile(const QString& fileName);
173  static void removeRecentFile(const QString& fileName);
174  static QStringList getRecentFiles();
175  static void clearRecentFiles();
176 
177  static RColor getColor(const QString& key, const RColor& defaultValue=RDEFAULT_RCOLOR);
178 
179  static bool hasValue(const QString& key);
180  static QVariant getValue(const QString& key, const QVariant& defaultValue=RDEFAULT_QVARIANT);
181  static RColor getColorValue(const QString& key, const RColor& defaultValue);
182  static bool getBoolValue(const QString& key, bool defaultValue);
183  static double getDoubleValue(const QString& key, double defaultValue);
184  static int getIntValue(const QString& key, int defaultValue);
185  static QString getStringValue(const QString& key, const QString& defaultValue);
186  static QStringList getStringListValue(const QString& key, const QStringList& defaultValue);
187 
188  static void setValue(const QString& key, const QVariant& value, bool overwrite=true);
189  static void removeValue(const QString& key);
190 
191  static void setApplicationNameOverride(const QString& n);
192  static bool hasApplicationNameOverride();
193 
194  static QStringList getAllKeys(const QString& group);
195 
196  static QSettings* getQSettings();
197 
198  static void resetCache();
199 
200  static void setXDataEnabled(bool on);
201  static bool isXDataEnabled();
202 
203  static void setNextVersionEnabled(bool on);
204  static bool isNextVersionEnabled();
205 
206  static bool getAutoScaleLinetypePatterns();
207  static bool getUseSecondarySelectionColor();
208  static bool getUseSolidLineSelection();
209 
210  static int getMouseThreshold();
211  static bool getPositionByMousePress();
212  static bool getAllowMouseMoveInterruptions();
213 
214  static bool isTextRenderedAsText();
215  static bool isLayer0CompatibilityOn();
216  static bool getSelectBlockWithAttribute();
217  static bool getHideAttributeWithBlock();
218 
219  static bool hasDarkGuiBackground();
220  static bool hasCustomStyleSheet();
221 
222 private:
223  static bool isInitialized();
224  static void shortenRecentFiles();
225 
226 private:
227  // cache for faster access:
228  static QVariantMap cache;
229 
230  // variables for very fast access:
231  static QFont* rulerFont;
232  static QFont* snapLabelFont;
233  static QFont* infoLabelFont;
234  static QFont* statusBarFont;
238  static int darkGuiBackground;
239  static int snapRange;
240  static int pickRange;
241  static int zeroWeightWeight;
242  static int showCrosshair;
243  static int showLargeCrosshair;
245  static int concurrentDrawing;
247  static int previewEntities;
248  static int limitZoomAndScroll;
252  static int mouseThreshold;
255  static double arcAngleLengthThreshold;
256  static double minArcAngleStep;
257  static int dashThreshold;
258  static int textRenderedAsText;
262  static QStringList recentFiles;
263  static QLocale* numberLocale;
264 
265  static QString applicationNameOverride;
266 
267  static QString launchPath;
268 
269  static QSettings* qSettings;
270 
271  static QStringList originalArguments;
272 
273  static bool quitFlag;
274 
275  static bool xDataEnabled;
276  static bool nextVersionEnabled;
277 
278  static bool firstStart;
279  static bool newVersion;
280  static int previousVersion;
281 };
282 
284 
285 #endif
static QVariantMap cache
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RSettings.h:228
static int allowMouseMoveInterruptions
Definition: RSettings.h:254
static int useSecondarySelectionColor
Definition: RSettings.h:251
static int getPreviousVersion()
Definition: RSettings.h:152
static int textRenderedAsText
Definition: RSettings.h:258
Definition: RSettings.h:48
static void setFirstStart(bool on)
Definition: RSettings.h:126
#define RDEFAULT_QVARIANT
Definition: RSettings.h:37
static QFont * snapLabelFont
Definition: RSettings.h:232
static int limitZoomAndScroll
Definition: RSettings.h:248
static QFont * statusBarFont
Definition: RSettings.h:234
static QFont * infoLabelFont
Definition: RSettings.h:233
static RColor * secondaryReferencePointColor
Definition: RSettings.h:237
static int layer0CompatibilityOn
Definition: RSettings.h:259
static QStringList recentFiles
Definition: RSettings.h:262
#define QCADCORE_EXPORT
Definition: core_global.h:10
static bool xDataEnabled
Definition: RSettings.h:275
static int showLargeOriginAxis
Definition: RSettings.h:244
static double minArcAngleStep
Definition: RSettings.h:256
static bool newVersion
Definition: RSettings.h:279
static QString applicationNameOverride
Definition: RSettings.h:265
static void setPreviousVersion(int pv)
Definition: RSettings.h:138
static int useSolidLineSelection
Definition: RSettings.h:250
static int hideAttributeWithBlock
Definition: RSettings.h:261
Color.
Definition: RColor.h:42
static QLocale * numberLocale
Definition: RSettings.h:263
static int highResolutionGraphicsView
Definition: RSettings.h:246
static int pickRange
Definition: RSettings.h:240
static int darkGuiBackground
Definition: RSettings.h:238
static bool firstStart
Definition: RSettings.h:278
static int autoScaleLinetypePattern
Definition: RSettings.h:249
Q_DECLARE_METATYPE(RMath *)
static void setNewVersion(bool on)
Definition: RSettings.h:132
static int mouseThreshold
Definition: RSettings.h:252
static int previousVersion
Definition: RSettings.h:280
#define RDEFAULT_QSTRINGLIST
Definition: RSettings.h:41
static QString launchPath
Definition: RSettings.h:267
static bool isFirstStart()
Definition: RSettings.h:129
void loadTranslations(void addOns, void splash)
Loads translations for all add-ons if appropriate.
Definition: autostart.js:36
static bool isNewVersion()
Definition: RSettings.h:135
static int dashThreshold
Definition: RSettings.h:257
static bool nextVersionEnabled
Definition: RSettings.h:276
static int concurrentDrawing
Definition: RSettings.h:245
static int showCrosshair
Definition: RSettings.h:242
static int positionByMousePress
Definition: RSettings.h:253
static double arcAngleLengthThreshold
Definition: RSettings.h:255
static int previewEntities
Definition: RSettings.h:247
static int selectBlockWithAttribute
Definition: RSettings.h:260
static int getCurrentVersion()
Definition: RSettings.h:146
static QFont * rulerFont
Definition: RSettings.h:231
static int snapRange
Definition: RSettings.h:239
static int zeroWeightWeight
Definition: RSettings.h:241
static QSettings * qSettings
Definition: RSettings.h:269
static RColor * referencePointColor
Definition: RSettings.h:236
static RColor * selectionColor
Definition: RSettings.h:235
#define RDEFAULT_RCOLOR
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RSettings.h:33
static bool quitFlag
Definition: RSettings.h:273
static int showLargeCrosshair
Definition: RSettings.h:243
static QStringList originalArguments
Definition: RSettings.h:271