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