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 #include <QDebug>
0007 #include <QFile>
0008 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0009 #include <QtWebEngine/QQuickWebEngineProfile>
0010 #else
0011 #include <QtWebEngineQuick/QQuickWebEngineProfile>
0012 #endif
0013 #include "globalSettings.h"
0014 
0015 GlobalSettings::GlobalSettings(QObject *parent) :
0016     QObject(parent)
0017 {
0018 }
0019 
0020 bool GlobalSettings::firstRun() const
0021 {
0022     return m_settings.value(QStringLiteral("firstRun"), true).toBool();
0023 }
0024 
0025 void GlobalSettings::setFirstRun(bool firstRun)
0026 {
0027     if (GlobalSettings::firstRun() == firstRun) {
0028         return;
0029     }
0030 
0031     m_settings.setValue(QStringLiteral("firstRun"), firstRun);
0032     Q_EMIT firstRunChanged();
0033 }
0034 
0035 int GlobalSettings::virtualMouseSpeed() const
0036 {
0037     return m_settings.value(QStringLiteral("virtualMouseSpeed"), 10).toInt();
0038 }
0039 
0040 void GlobalSettings::setVirtualMouseSpeed(int virtualMouseSpeed)
0041 {
0042     if (GlobalSettings::virtualMouseSpeed() == virtualMouseSpeed) {
0043         return;
0044     }
0045 
0046     m_settings.setValue(QStringLiteral("virtualMouseSpeed"), virtualMouseSpeed);
0047     Q_EMIT virtualMouseSpeedChanged(virtualMouseSpeed);
0048 }
0049 
0050 int GlobalSettings::virtualScrollSpeed() const
0051 {
0052     return m_settings.value(QStringLiteral("virtualScrollSpeed"), 15).toInt();
0053 }
0054 
0055 void GlobalSettings::setVirtualScrollSpeed(int virtualScrollSpeed)
0056 {
0057     if (GlobalSettings::virtualScrollSpeed() == virtualScrollSpeed) {
0058         return;
0059     }
0060 
0061     m_settings.setValue(QStringLiteral("virtualScrollSpeed"), virtualScrollSpeed);
0062     Q_EMIT virtualScrollSpeedChanged(virtualScrollSpeed);
0063 }
0064 
0065 double GlobalSettings::virtualMouseSize() const
0066 {
0067     return m_settings.value(QStringLiteral("virtualMouseSize"), 1).toDouble();
0068 }
0069 
0070 void GlobalSettings::setVirtualMouseSize(double virtualMouseSize)
0071 {
0072     if (GlobalSettings::virtualMouseSize() == virtualMouseSize) {
0073         return;
0074     }
0075 
0076     m_settings.setValue(QStringLiteral("virtualMouseSize"), virtualMouseSize);
0077     Q_EMIT virtualMouseSizeChanged(virtualMouseSize);
0078 }
0079 
0080 void GlobalSettings::clearDefaultProfileCache()
0081 {
0082     auto *profile = QQuickWebEngineProfile::defaultProfile();
0083     profile->clearHttpCache();
0084     qDebug() << "in Clear Cache";
0085 }
0086 
0087 bool GlobalSettings::soundEffects() const
0088 {
0089     return m_settings.value(QStringLiteral("soundEffects"), true).toBool();
0090 }
0091 
0092 void GlobalSettings::setSoundEffects(bool soundEffects)
0093 {
0094     if (GlobalSettings::soundEffects() == soundEffects) {
0095         return;
0096     }
0097 
0098     m_settings.setValue(QStringLiteral("soundEffects"), soundEffects);
0099     Q_EMIT soundEffectsChanged();
0100 }
0101 
0102 QString GlobalSettings::defaultSearchEngine() const
0103 {
0104     return QStringLiteral("Google");
0105 }
0106 
0107 void GlobalSettings::setDefaultSearchEngine(QString defaultSearchEngine)
0108 {
0109     if (GlobalSettings::defaultSearchEngine() == defaultSearchEngine) {
0110         return;
0111     }
0112     m_settings.setValue(QStringLiteral("defaultSearchEgnine"), defaultSearchEngine);
0113     Q_EMIT defaultSearchEngineChanged();
0114 }
0115 
0116 bool GlobalSettings::adblockEnabled() const
0117 {
0118     return m_settings.value(QStringLiteral("adblockEnabled"), true).toBool();
0119 }
0120 
0121 void GlobalSettings::setAdblockEnabled(bool adblockEnabled)
0122 {
0123     if (GlobalSettings::adblockEnabled() == adblockEnabled) {
0124         return;
0125     }
0126 
0127     m_settings.setValue(QStringLiteral("adblockEnabled"), adblockEnabled);
0128     Q_EMIT adBlockEnabledChanged();
0129 }