File indexing completed on 2024-11-24 04:54:31
0001 /* 0002 SPDX-FileCopyrightText: 2022 Aditya Mehra <aix.m@outlook.com> 0003 SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 #ifndef GLOBALSETTINGS_H 0007 #define GLOBALSETTINGS_H 0008 0009 #include <QSettings> 0010 #include <QCoreApplication> 0011 #include <QDebug> 0012 0013 #define SettingPropertyKey(type, name, setOption, signalName, settingKey, defaultValue) \ 0014 inline type name() const { return m_settings.value(settingKey, defaultValue).value<type>(); } \ 0015 inline void setOption (const type &value) { m_settings.setValue(settingKey, value); emit signalName(); qDebug() << "emitted"; } 0016 0017 class QSettings; 0018 class GlobalSettings : public QObject 0019 0020 { 0021 Q_OBJECT 0022 Q_PROPERTY(bool firstRun READ firstRun WRITE setFirstRun NOTIFY firstRunChanged) 0023 Q_PROPERTY(int virtualMouseSpeed READ virtualMouseSpeed WRITE setVirtualMouseSpeed NOTIFY virtualMouseSpeedChanged) 0024 Q_PROPERTY(int virtualScrollSpeed READ virtualScrollSpeed WRITE setVirtualScrollSpeed NOTIFY virtualScrollSpeedChanged) 0025 Q_PROPERTY(double virtualMouseSize READ virtualMouseSize WRITE setVirtualMouseSize NOTIFY virtualMouseSizeChanged) 0026 Q_PROPERTY(bool soundEffects READ soundEffects WRITE setSoundEffects NOTIFY soundEffectsChanged) 0027 Q_PROPERTY(QString defaultSearchEngine READ defaultSearchEngine WRITE setDefaultSearchEngine NOTIFY defaultSearchEngineChanged) 0028 Q_PROPERTY(bool adblockEnabled READ adblockEnabled WRITE setAdblockEnabled NOTIFY adBlockEnabledChanged) 0029 0030 public: 0031 explicit GlobalSettings(QObject *parent=nullptr); 0032 0033 bool firstRun() const; 0034 int virtualMouseSpeed() const; 0035 int virtualScrollSpeed() const; 0036 double virtualMouseSize() const; 0037 bool soundEffects() const; 0038 QString defaultSearchEngine() const; 0039 bool adblockEnabled() const; 0040 0041 public Q_SLOTS: 0042 void setFirstRun(bool firstRun); 0043 void setVirtualMouseSpeed(int virtualMouseSpeed); 0044 void setVirtualScrollSpeed(int virtualScrollSpeed); 0045 void setVirtualMouseSize(double virtualMouseSize); 0046 void setSoundEffects(bool soundEffects); 0047 void setDefaultSearchEngine(QString defaultSearchEngine); 0048 void clearDefaultProfileCache(); 0049 void setAdblockEnabled(bool adblockEnabled); 0050 0051 Q_SIGNALS: 0052 void firstRunChanged(); 0053 void virtualMouseSpeedChanged(int virtualMouseSpeed); 0054 void virtualScrollSpeedChanged(int virtualScrollSpeed); 0055 void virtualMouseSizeChanged(int virtualMouseSize); 0056 void soundEffectsChanged(); 0057 void focusOnVKeyboard(); 0058 void focusOffVKeyboard(); 0059 void defaultSearchEngineChanged(); 0060 void adBlockEnabledChanged(); 0061 0062 private: 0063 QSettings m_settings; 0064 }; 0065 0066 #endif // GLOBALSETTINGS_H