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 #include "RBox.h"
31 
32 // workaround for src2srcml bug:
33 #ifndef RDEFAULT_RCOLOR
34 #define RDEFAULT_RCOLOR RColor()
35 #endif
36 
37 #ifndef RDEFAULT_RBOX
38 #define RDEFAULT_RBOX RBox()
39 #endif
40 
41 #ifndef RDEFAULT_QVARIANT
42 #define RDEFAULT_QVARIANT QVariant()
43 #endif
44 
45 #ifndef RDEFAULT_QSTRING
46 #define RDEFAULT_QSTRING QString()
47 #endif
48 
49 #ifndef RDEFAULT_QSTRINGLIST
50 #define RDEFAULT_QSTRINGLIST QStringList()
51 #endif
52 
53 #ifndef RDEFAULT_QLISTINT
54 #define RDEFAULT_QLISTINT QList<int>()
55 #endif
56 
62 public:
63  static void uninit();
64  static void setNoWrite(bool on = true);
65 
66  static QString getAppId();
67 
68  static double getDevicePixelRatio();
69 
70  static QString getLocale();
71  static void loadTranslations(const QString& module, const QStringList& dirs = RDEFAULT_QSTRINGLIST);
72  static QString translate(const QString& context, const QString& str);
73 
74  static QStringList getOriginalArguments();
75  static void setOriginalArguments(const QStringList& a);
76 
77  static QString getArgument(const QStringList& args, const QString& shortFlag, const QString& longFlag, const QString& def = RDEFAULT_QSTRING);
78  static QStringList getArguments(const QStringList& args, const QString& shortFlag, const QString& longFlag);
79  static int getIntArgument(const QStringList& args, const QString& shortFlag, const QString& longFlag, int def);
80  static QList<int> getIntListArgument(const QStringList& args, const QString& shortFlag, const QString& longFlag, QList<int> def = RDEFAULT_QLISTINT);
81  static double getFloatArgument(const QStringList& args, const QString& shortFlag, const QString& longFlag, double def = RNANDOUBLE);
82  static RColor getColorArgument(const QStringList& args, const QString& shortFlag, const QString& longFlag, const RColor& def = RDEFAULT_RCOLOR);
83  static RBox getBoxArgument(const QStringList& args, const QString& shortFlag, const QString& longFlag, const RBox& def = RDEFAULT_RBOX);
84  static bool testArgument(const QStringList& args, const QString& shortFlag, const QString& longFlag);
85 
86  static bool isDeployed();
87  static QString getApplicationPath();
88  static QStringList getPluginPaths();
89  static QString getPluginPath();
90  static QString getThemePath();
91 
92  static QString getStandardLocation(int sl);
93  static QString getCacheLocation();
94  static QString getDataLocation();
95  static QString getTempLocation();
96  static QString getDesktopLocation();
97  static QString getDocumentsLocation();
98  static QString getHomeLocation();
99 
100  //static void setEventBlocking(bool on);
101  //static bool isEventBlockingEnabled();
102  static bool isGuiEnabled();
103  static bool isDebuggerEnabled();
104  static bool hasQuitFlag();
105  static void setQuitFlag();
106 
107  static QString getFileName();
108  static QString getPath();
109  static QString getLaunchPath();
110  static void setLaunchPath(const QString& launchPath);
111 
112  //static QString getDefaultStyle();
113 
114  // GraphicsView Appearance Fonts
115  static void setRulerFont(const QFont& font);
116  static QFont getRulerFont();
117  static void setSnapLabelFont(const QFont& font);
118  static QFont getSnapLabelFont();
119  static QFont getInfoLabelFont();
120  static QFont getStatusBarFont();
121 
122  static RColor getSelectionColor();
123  static RColor getReferencePointColor();
124  static RColor getStartReferencePointColor();
125  static RColor getEndReferencePointColor();
126  static RColor getSecondaryReferencePointColor();
127  static RColor getTertiaryReferencePointColor();
128 
129  static bool getHighResolutionGraphicsView();
130  static bool getAutoScaleGrid();
131  static bool getAutoScaleMetaGrid();
132  static bool getAutoScalePatterns();
133  static bool getAutoZoomOnLoad();
134  static bool getColorCorrection();
135  static bool getColorCorrectionDisableForPrinting();
136  static int getColorThreshold();
137  static int getTextHeightThreshold();
138  static double getArcAngleLengthThreshold();
139  static double getMinArcAngleStep();
140  static int getDashThreshold();
141  static int getQtVersion();
142  static QString getQtVersionString();
143  static bool isQt(int majorVersion);
144  static QString getCompilerVersion();
145  static QString getOSVersion();
146  static QString getReleaseDate();
147  static QString getVersionString();
148  static QString getNumericalVersionString();
149  static int getMajorVersion();
150  static int getMinorVersion();
151  static int getRevisionVersion();
152  static int getBuildVersion();
153  static QString getRevisionString();
154  static void setFirstStart(bool on) {
155  firstStart = on;
156  }
157  static bool isFirstStart() {
158  return firstStart;
159  }
160  static void setNewVersion(bool on) {
161  newVersion = on;
162  }
163  static bool isNewVersion() {
164  return newVersion;
165  }
166  static void setPreviousVersion(int pv) {
167  previousVersion = pv;
168  }
174  static int getCurrentVersion() {
175  return getMajorVersion()*1000000 +
176  getMinorVersion()*10000 +
177  getRevisionVersion()*100 +
178  getBuildVersion();
179  }
180  static int getPreviousVersion() {
181  return previousVersion;
182  }
190  static int isUpdated(int versionCheck=-1) {
191  if (isNewVersion()) {
192  return true;
193  }
194  if (versionCheck==-1) {
195  if (getCurrentVersion()>getPreviousVersion()) {
196  return true;
197  }
198  }
199  if (getCurrentVersion()>=versionCheck && getPreviousVersion()<versionCheck) {
200  return true;
201  }
202  return false;
203  }
204 
205  static int getSnapRange();
206  static int getPickRange();
207  static int getZeroWeightWeight();
208  static int getPreviewEntities();
209  static bool getLimitZoomAndScroll();
210  static bool getShowCrosshair();
211  static void setShowCrosshair(bool on);
212  static bool getShowLargeCrosshair();
213  static void setShowLargeCrosshair(bool on);
214  static bool getShowLargeOriginAxis();
215  static void setShowLargeOriginAxis(bool on);
216  static bool getConcurrentDrawing();
217  static void setConcurrentDrawing(bool on);
218  static QLocale getNumberLocale();
219 
220  static void initRecentFiles();
221  static void addRecentFile(const QString& fileName);
222  static void removeRecentFile(const QString& fileName);
223  static QStringList getRecentFiles();
224  static void clearRecentFiles();
225 
226  static RColor getColor(const QString& key, const RColor& defaultValue=RDEFAULT_RCOLOR);
227 
228  static bool hasValue(const QString& key);
229  static QVariant getValue(const QString& key, const QVariant& defaultValue=RDEFAULT_QVARIANT);
230  static RColor getColorValue(const QString& key, const RColor& defaultValue);
231  static bool getBoolValue(const QString& key, bool defaultValue);
232  static double getDoubleValue(const QString& key, double defaultValue);
233  static int getIntValue(const QString& key, int defaultValue);
234  static QString getStringValue(const QString& key, const QString& defaultValue);
235  static QStringList getStringListValue(const QString& key, const QStringList& defaultValue);
236 
240  static QChar getCharValue(const QString& key, const QChar& defaultValue);
241 
242  static void setValue(const QString& key, const QVariant& value, bool overwrite=true);
243  static void removeValue(const QString& key);
244 
245  static void setApplicationNameOverride(const QString& n);
246  static QString getApplicationNameOverride();
247  static bool hasApplicationNameOverride();
248 
249  static QStringList getAllKeys(const QString& group);
250 
251  static QSettings* getQSettings();
252 
253  static void resetCache();
254 
255  static void setXDataEnabled(bool on);
256  static bool isXDataEnabled();
257 
258  static void setNextVersionEnabled(bool on);
259  static bool isNextVersionEnabled();
260 
261  static bool getAutoScaleLinetypePatterns();
262  static bool getUseSecondarySelectionColor();
263  static bool getUseSolidLineSelection();
264 
265  static int getMouseThreshold();
266  static bool getPositionByMousePress();
267  static bool getAllowMouseMoveInterruptions();
268 
269  static bool isTextRenderedAsText();
270  static bool isLayer0CompatibilityOn();
271  static bool getSelectBlockWithAttribute();
272  static bool getHideAttributeWithBlock();
273  static bool getImportRecomputedDimBlocks();
274  static bool getIgnoreBlockReferencePoint();
275  static bool getIgnoreAllReferencePoints();
276  static int getReferencePointSize();
277  static int getReferencePointShape();
278 
279  static bool hasDarkGuiBackground();
280  static bool hasCustomStyleSheet();
281 
282  static QStringList getPrinterNames();
283  static QString getDefaultPrinterName();
284 
285  static void appendOpenGLMessage(const QString& msg);
286  static QStringList getOpenGLMessages();
287 
288 private:
289  static bool isInitialized();
290  static void shortenRecentFiles();
291 
292 private:
293  static bool noWrite;
294  // cache for faster access:
295  static QVariantMap cache;
296 
297  // variables for very fast access:
298  static QFont* rulerFont;
299  static QFont* snapLabelFont;
300  static QFont* infoLabelFont;
301  static QFont* statusBarFont;
308  static int darkGuiBackground;
309  static int snapRange;
310  static int pickRange;
311  static int zeroWeightWeight;
312  static int showCrosshair;
313  static int showLargeCrosshair;
315  static int concurrentDrawing;
317  static int previewEntities;
318  static int limitZoomAndScroll;
322  static int mouseThreshold;
325  static double arcAngleLengthThreshold;
326  static double minArcAngleStep;
327  static int dashThreshold;
328  static int textRenderedAsText;
335  static int referencePointSize;
337  static QStringList recentFiles;
338  static QLocale* numberLocale;
339 
340  static QString applicationNameOverride;
341 
342  static QString launchPath;
343  static QString themePath;
344 
345  static QSettings* qSettings;
346 
347  static QStringList originalArguments;
348 
349  static bool quitFlag;
350 
351  static bool xDataEnabled;
352  static bool nextVersionEnabled;
353 
354  static bool firstStart;
355  static bool newVersion;
356  static int previousVersion;
357 
358  static QStringList openGLMessages;
359 };
360 
362 
363 #endif
static QVariantMap cache
Definition: RSettings.h:295
static int allowMouseMoveInterruptions
Definition: RSettings.h:324
Represents a box e.g.
Definition: RBox.h:43
static int useSecondarySelectionColor
Definition: RSettings.h:321
static RColor * tertiaryReferencePointColor
Definition: RSettings.h:307
static int getPreviousVersion()
Definition: RSettings.h:180
static int textRenderedAsText
Definition: RSettings.h:328
void testArgument(void args, void shortFlag, void longFlag)
Definition: arguments.js:28
Definition: RSettings.h:61
static void setFirstStart(bool on)
Definition: RSettings.h:154
#define RDEFAULT_QVARIANT
Definition: RSettings.h:42
static QFont * snapLabelFont
Definition: RSettings.h:299
static int limitZoomAndScroll
Definition: RSettings.h:318
void getColorArgument(void args, void shortFlag, void longFlag, void def)
Definition: arguments.js:25
static QFont * statusBarFont
Definition: RSettings.h:301
static QFont * infoLabelFont
Definition: RSettings.h:300
static int ignoreBlockReferencePoint
Definition: RSettings.h:333
static QString themePath
Definition: RSettings.h:343
static RColor * secondaryReferencePointColor
Definition: RSettings.h:306
static int layer0CompatibilityOn
Definition: RSettings.h:329
static QStringList recentFiles
Definition: RSettings.h:337
#define QCADCORE_EXPORT
Definition: core_global.h:10
static bool xDataEnabled
Definition: RSettings.h:351
static int showLargeOriginAxis
Definition: RSettings.h:314
static double minArcAngleStep
Definition: RSettings.h:326
void getIntListArgument(void args, void shortFlag, void longFlag, void def)
Definition: arguments.js:30
static int referencePointSize
Definition: RSettings.h:335
static bool newVersion
Definition: RSettings.h:355
static int ignoreAllReferencePoints
Definition: RSettings.h:334
#define RDEFAULT_RBOX
Definition: RSettings.h:38
static int referencePointShape
Definition: RSettings.h:336
static QStringList openGLMessages
Definition: RSettings.h:358
static QString applicationNameOverride
Definition: RSettings.h:340
#define RNANDOUBLE
Definition: RMath.h:71
static void setPreviousVersion(int pv)
Definition: RSettings.h:166
static int useSolidLineSelection
Definition: RSettings.h:320
static int hideAttributeWithBlock
Definition: RSettings.h:331
static RColor * startReferencePointColor
Definition: RSettings.h:304
void getFloatArgument(void args, void shortFlag, void longFlag, void def)
Definition: arguments.js:26
Color.
Definition: RColor.h:44
static QLocale * numberLocale
Definition: RSettings.h:338
static int highResolutionGraphicsView
Definition: RSettings.h:316
#define RDEFAULT_QLISTINT
Definition: RSettings.h:54
static int pickRange
Definition: RSettings.h:310
static int darkGuiBackground
Definition: RSettings.h:308
static bool firstStart
Definition: RSettings.h:354
static int autoScaleLinetypePattern
Definition: RSettings.h:319
void getBoxArgument(void args, void shortFlag, void longFlag, void def)
Definition: arguments.js:22
Q_DECLARE_METATYPE(RMath *)
static int isUpdated(int versionCheck=-1)
Definition: RSettings.h:190
static void setNewVersion(bool on)
Definition: RSettings.h:160
static int mouseThreshold
Definition: RSettings.h:322
static int previousVersion
Definition: RSettings.h:356
#define RDEFAULT_QSTRINGLIST
Definition: RSettings.h:50
static QString launchPath
Definition: RSettings.h:342
static bool isFirstStart()
Definition: RSettings.h:157
void getIntArgument(void args, void shortFlag, void longFlag, void def)
Definition: arguments.js:24
void loadTranslations(void addOns, void splash)
Loads translations for all add-ons if appropriate.
Definition: autostart.js:26
static bool isNewVersion()
Definition: RSettings.h:163
static int dashThreshold
Definition: RSettings.h:327
#define RDEFAULT_QSTRING
Definition: RSettings.h:46
static RColor * endReferencePointColor
Definition: RSettings.h:305
static bool nextVersionEnabled
Definition: RSettings.h:352
static int concurrentDrawing
Definition: RSettings.h:315
void getArgument(void args, void shortFlag, void longFlag, void def)
Definition: arguments.js:31
static int showCrosshair
Definition: RSettings.h:312
static bool noWrite
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RSettings.h:293
static int positionByMousePress
Definition: RSettings.h:323
static double arcAngleLengthThreshold
Definition: RSettings.h:325
static int previewEntities
Definition: RSettings.h:317
static int selectBlockWithAttribute
Definition: RSettings.h:330
static int getCurrentVersion()
Definition: RSettings.h:174
static int importRecomputedDimBlocks
Definition: RSettings.h:332
static QFont * rulerFont
Definition: RSettings.h:298
static int snapRange
Definition: RSettings.h:309
static int zeroWeightWeight
Definition: RSettings.h:311
static QSettings * qSettings
Definition: RSettings.h:345
void getArguments(void args, void shortFlag, void longFlag)
Definition: arguments.js:29
static RColor * referencePointColor
Definition: RSettings.h:303
static RColor * selectionColor
Definition: RSettings.h:302
#define RDEFAULT_RCOLOR
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RSettings.h:34
static bool quitFlag
Definition: RSettings.h:349
static int showLargeCrosshair
Definition: RSettings.h:313
static QStringList originalArguments
Definition: RSettings.h:347