deskflow/src/lib/gui/config/ConfigScopes.h
Nick Bolton 321418fcf8
Improve handling of Qt-related warnings and errors (#7431)
* Load .env from app dir

* Use `OutputDebugStringA` on Windows

* Improved string manipulation in logger and better use of OutputDebugStringA

* Use noquote for path

* Apply TLS setting after activation

* Restart after activation

* Move skip debug message to correct place

* Only print settings path on create, not shown

* Merge common and global libs

* Reduce code duplication around constants, version, etc

* Simplify sprintf code

* Use snprintf

* Add error test menu

* Coverage for dotenv

* Coverage for Logger

* Add missing include

* Add init when no Git SHA

* Update ChangeLog

* Add spellings

* Set debugging on for release build

* Remove unused variable

* Remove bad comment

* Fixed copyright date

* Remove import

* Move URL const back to GUI

* Remove dead code and duplication

* Fixed/ignored lint warnings
2024-08-09 14:03:48 +01:00

68 lines
2 KiB
C++

/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2020 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "IConfigScopes.h"
#include <QObject>
#include <QSettings>
#include <QVariant>
#include <memory>
namespace synergy::gui {
/// @brief Encapsulates Qt config for both user and global scopes.
class ConfigScopes : public QObject, public IConfigScopes {
using QSettingsProxy = synergy::gui::proxy::QSettingsProxy;
Q_OBJECT
public:
explicit ConfigScopes();
~ConfigScopes() override = default;
void signalReady() override;
void save() override;
bool scopeContains(
const QString &name, Scope scope = Scope::Current) const override;
bool isActiveScopeWritable() const override;
void setInScope(
const QString &name, const QVariant &value,
Scope scope = Scope::Current) override;
QVariant getFromScope(
const QString &name, const QVariant &defaultValue = QVariant(),
Scope scope = Scope::Current) const override;
void setActiveScope(Scope scope = Scope::User) override;
Scope activeScope() const override;
QSettingsProxy &activeSettings() override;
const QSettingsProxy &activeSettings() const override;
QString activeFilePath() const;
signals:
void ready();
void saving();
private:
Scope m_currentScope = Scope::User;
std::unique_ptr<QSettings> m_pUserSettings;
std::unique_ptr<QSettings> m_pSystemSettings;
QSettingsProxy m_userSettingsProxy;
QSettingsProxy m_systemSettingsProxy;
};
} // namespace synergy::gui