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