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 getStartReferencePointColor();
102  static RColor getEndReferencePointColor();
103  static RColor getSecondaryReferencePointColor();
104 
105  static bool getHighResolutionGraphicsView();
106  static bool getAutoScaleGrid();
107  static bool getAutoScaleMetaGrid();
108  static bool getAutoScalePatterns();
109  static bool getAutoZoomOnLoad();
110  static bool getColorCorrection();
111  static int getColorThreshold();
112  static int getTextHeightThreshold();
113  static double getArcAngleLengthThreshold();
114  static double getMinArcAngleStep();
115  static int getDashThreshold();
116  static int getQtVersion();
117  static QString getQtVersionString();
118  static bool isQt(int majorVersion);
119  static QString getCompilerVersion();
120  static QString getOSVersion();
121  static QString getReleaseDate();
122  static QString getVersionString();
123  static QString getNumericalVersionString();
124  static int getMajorVersion();
125  static int getMinorVersion();
126  static int getRevisionVersion();
127  static int getBuildVersion();
128  static QString getRevisionString();
129  static void setFirstStart(bool on) {
130  firstStart = on;
131  }
132  static bool isFirstStart() {
133  return firstStart;
134  }
135  static void setNewVersion(bool on) {
136  newVersion = on;
137  }
138  static bool isNewVersion() {
139  return newVersion;
140  }
141  static void setPreviousVersion(int pv) {
142  previousVersion = pv;
143  }
149  static int getCurrentVersion() {
150  return getMajorVersion()*1000000 +
151  getMinorVersion()*10000 +
152  getRevisionVersion()*100 +
153  getBuildVersion();
154  }
155  static int getPreviousVersion() {
156  return previousVersion;
157  }
158 
159  static int getSnapRange();
160  static int getPickRange();
161  static int getZeroWeightWeight();
162  static int getPreviewEntities();
163  static bool getLimitZoomAndScroll();
164  static bool getShowCrosshair();
165  static void setShowCrosshair(bool on);
166  static bool getShowLargeCrosshair();
167  static void setShowLargeCrosshair(bool on);
168  static bool getShowLargeOriginAxis();
169  static void setShowLargeOriginAxis(bool on);
170  static bool getConcurrentDrawing();
171  static void setConcurrentDrawing(bool on);
172  static QLocale getNumberLocale();
173 
174  static void initRecentFiles();
175  static void addRecentFile(const QString& fileName);
176  static void removeRecentFile(const QString& fileName);
177  static QStringList getRecentFiles();
178  static void clearRecentFiles();
179 
180  static RColor getColor(const QString& key, const RColor& defaultValue=RDEFAULT_RCOLOR);
181 
182  static bool hasValue(const QString& key);
183  static QVariant getValue(const QString& key, const QVariant& defaultValue=RDEFAULT_QVARIANT);
184  static RColor getColorValue(const QString& key, const RColor& defaultValue);
185  static bool getBoolValue(const QString& key, bool defaultValue);
186  static double getDoubleValue(const QString& key, double defaultValue);
187  static int getIntValue(const QString& key, int defaultValue);
188  static QString getStringValue(const QString& key, const QString& defaultValue);
189  static QStringList getStringListValue(const QString& key, const QStringList& defaultValue);
190 
194  static QChar getCharValue(const QString& key, const QChar& defaultValue);
195 
196  static void setValue(const QString& key, const QVariant& value, bool overwrite=true);
197  static void removeValue(const QString& key);
198 
199  static void setApplicationNameOverride(const QString& n);
200  static bool hasApplicationNameOverride();
201 
202  static QStringList getAllKeys(const QString& group);
203 
204  static QSettings* getQSettings();
205 
206  static void resetCache();
207 
208  static void setXDataEnabled(bool on);
209  static bool isXDataEnabled();
210 
211  static void setNextVersionEnabled(bool on);
212  static bool isNextVersionEnabled();
213 
214  static bool getAutoScaleLinetypePatterns();
215  static bool getUseSecondarySelectionColor();
216  static bool getUseSolidLineSelection();
217 
218  static int getMouseThreshold();
219  static bool getPositionByMousePress();
220  static bool getAllowMouseMoveInterruptions();
221 
222  static bool isTextRenderedAsText();
223  static bool isLayer0CompatibilityOn();
224  static bool getSelectBlockWithAttribute();
225  static bool getHideAttributeWithBlock();
226  static bool getImportRecomputedDimBlocks();
227  static bool getIgnoreBlockReferencePoint();
228  static bool getIgnoreAllReferencePoints();
229 
230  static bool hasDarkGuiBackground();
231  static bool hasCustomStyleSheet();
232 
233  static QStringList getPrinterNames();
234  static QString getDefaultPrinterName();
235 
236 private:
237  static bool isInitialized();
238  static void shortenRecentFiles();
239 
240 private:
241  static bool noWrite;
242  // cache for faster access:
243  static QVariantMap cache;
244 
245  // variables for very fast access:
246  static QFont* rulerFont;
247  static QFont* snapLabelFont;
248  static QFont* infoLabelFont;
249  static QFont* statusBarFont;
255  static int darkGuiBackground;
256  static int snapRange;
257  static int pickRange;
258  static int zeroWeightWeight;
259  static int showCrosshair;
260  static int showLargeCrosshair;
262  static int concurrentDrawing;
264  static int previewEntities;
265  static int limitZoomAndScroll;
269  static int mouseThreshold;
272  static double arcAngleLengthThreshold;
273  static double minArcAngleStep;
274  static int dashThreshold;
275  static int textRenderedAsText;
282  static QStringList recentFiles;
283  static QLocale* numberLocale;
284 
285  static QString applicationNameOverride;
286 
287  static QString launchPath;
288 
289  static QSettings* qSettings;
290 
291  static QStringList originalArguments;
292 
293  static bool quitFlag;
294 
295  static bool xDataEnabled;
296  static bool nextVersionEnabled;
297 
298  static bool firstStart;
299  static bool newVersion;
300  static int previousVersion;
301 };
302 
304 
305 #endif
static QVariantMap cache
Definition: RSettings.h:243
static int allowMouseMoveInterruptions
Definition: RSettings.h:271
static int useSecondarySelectionColor
Definition: RSettings.h:268
static int getPreviousVersion()
Definition: RSettings.h:155
static int textRenderedAsText
Definition: RSettings.h:275
Definition: RSettings.h:48
static void setFirstStart(bool on)
Definition: RSettings.h:129
#define RDEFAULT_QVARIANT
Definition: RSettings.h:37
static QFont * snapLabelFont
Definition: RSettings.h:247
static int limitZoomAndScroll
Definition: RSettings.h:265
static QFont * statusBarFont
Definition: RSettings.h:249
static QFont * infoLabelFont
Definition: RSettings.h:248
static int ignoreBlockReferencePoint
Definition: RSettings.h:280
static RColor * secondaryReferencePointColor
Definition: RSettings.h:254
static int layer0CompatibilityOn
Definition: RSettings.h:276
static QStringList recentFiles
Definition: RSettings.h:282
#define QCADCORE_EXPORT
Definition: core_global.h:10
static bool xDataEnabled
Definition: RSettings.h:295
static int showLargeOriginAxis
Definition: RSettings.h:261
static double minArcAngleStep
Definition: RSettings.h:273
static bool newVersion
Definition: RSettings.h:299
static int ignoreAllReferencePoints
Definition: RSettings.h:281
static QString applicationNameOverride
Definition: RSettings.h:285
static void setPreviousVersion(int pv)
Definition: RSettings.h:141
static int useSolidLineSelection
Definition: RSettings.h:267
static int hideAttributeWithBlock
Definition: RSettings.h:278
static RColor * startReferencePointColor
Definition: RSettings.h:252
Color.
Definition: RColor.h:42
static QLocale * numberLocale
Definition: RSettings.h:283
static int highResolutionGraphicsView
Definition: RSettings.h:263
static int pickRange
Definition: RSettings.h:257
static int darkGuiBackground
Definition: RSettings.h:255
static bool firstStart
Definition: RSettings.h:298
static int autoScaleLinetypePattern
Definition: RSettings.h:266
Q_DECLARE_METATYPE(RMath *)
static void setNewVersion(bool on)
Definition: RSettings.h:135
static int mouseThreshold
Definition: RSettings.h:269
static int previousVersion
Definition: RSettings.h:300
#define RDEFAULT_QSTRINGLIST
Definition: RSettings.h:41
static QString launchPath
Definition: RSettings.h:287
static bool isFirstStart()
Definition: RSettings.h:132
void loadTranslations(void addOns, void splash)
Loads translations for all add-ons if appropriate.
Definition: autostart.js:39
static bool isNewVersion()
Definition: RSettings.h:138
static int dashThreshold
Definition: RSettings.h:274
static RColor * endReferencePointColor
Definition: RSettings.h:253
static bool nextVersionEnabled
Definition: RSettings.h:296
static int concurrentDrawing
Definition: RSettings.h:262
static int showCrosshair
Definition: RSettings.h:259
static bool noWrite
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RSettings.h:241
static int positionByMousePress
Definition: RSettings.h:270
static double arcAngleLengthThreshold
Definition: RSettings.h:272
static int previewEntities
Definition: RSettings.h:264
static int selectBlockWithAttribute
Definition: RSettings.h:277
static int getCurrentVersion()
Definition: RSettings.h:149
static int importRecomputedDimBlocks
Definition: RSettings.h:279
static QFont * rulerFont
Definition: RSettings.h:246
static int snapRange
Definition: RSettings.h:256
static int zeroWeightWeight
Definition: RSettings.h:258
static QSettings * qSettings
Definition: RSettings.h:289
static RColor * referencePointColor
Definition: RSettings.h:251
static RColor * selectionColor
Definition: RSettings.h:250
#define RDEFAULT_RCOLOR
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RSettings.h:33
static bool quitFlag
Definition: RSettings.h:293
static int showLargeCrosshair
Definition: RSettings.h:260
static QStringList originalArguments
Definition: RSettings.h:291