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