2024-07-22 16:48:02 +00:00
|
|
|
/*
|
|
|
|
|
* 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/>.
|
|
|
|
|
*/
|
2024-08-01 00:13:01 +00:00
|
|
|
|
2024-07-22 16:48:02 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
2024-08-01 00:13:01 +00:00
|
|
|
#include "IConfigScopes.h"
|
|
|
|
|
|
2024-08-03 00:17:29 +00:00
|
|
|
#include <QObject>
|
2024-07-22 16:48:02 +00:00
|
|
|
#include <QSettings>
|
|
|
|
|
#include <QVariant>
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
|
namespace synergy::gui {
|
|
|
|
|
|
2024-08-03 00:17:29 +00:00
|
|
|
/// @brief Encapsulates Qt config for both user and global scopes.
|
|
|
|
|
class ConfigScopes : public QObject, public IConfigScopes {
|
2024-08-08 17:41:59 +00:00
|
|
|
using QSettingsProxy = synergy::gui::proxy::QSettingsProxy;
|
|
|
|
|
|
2024-08-03 00:17:29 +00:00
|
|
|
Q_OBJECT
|
2024-07-22 16:48:02 +00:00
|
|
|
|
|
|
|
|
public:
|
2024-08-01 00:13:01 +00:00
|
|
|
explicit ConfigScopes();
|
2024-08-07 14:05:18 +00:00
|
|
|
~ConfigScopes() override = default;
|
2024-08-03 00:17:29 +00:00
|
|
|
|
|
|
|
|
void signalReady() override;
|
|
|
|
|
void save() override;
|
|
|
|
|
bool scopeContains(
|
|
|
|
|
const QString &name, Scope scope = Scope::Current) const override;
|
|
|
|
|
bool isActiveScopeWritable() const override;
|
|
|
|
|
void setInScope(
|
2024-08-01 00:13:01 +00:00
|
|
|
const QString &name, const QVariant &value,
|
|
|
|
|
Scope scope = Scope::Current) override;
|
2024-08-03 00:17:29 +00:00
|
|
|
QVariant getFromScope(
|
2024-07-22 16:48:02 +00:00
|
|
|
const QString &name, const QVariant &defaultValue = QVariant(),
|
2024-08-01 00:13:01 +00:00
|
|
|
Scope scope = Scope::Current) const override;
|
2024-08-03 00:17:29 +00:00
|
|
|
void setActiveScope(Scope scope = Scope::User) override;
|
|
|
|
|
Scope activeScope() const override;
|
2024-08-08 17:41:59 +00:00
|
|
|
QSettingsProxy &activeSettings() override;
|
|
|
|
|
const QSettingsProxy &activeSettings() const override;
|
2024-08-09 13:03:48 +00:00
|
|
|
QString activeFilePath() const;
|
2024-07-22 16:48:02 +00:00
|
|
|
|
2024-08-03 00:17:29 +00:00
|
|
|
signals:
|
|
|
|
|
void ready();
|
|
|
|
|
void saving();
|
2024-07-22 16:48:02 +00:00
|
|
|
|
|
|
|
|
private:
|
2024-08-03 00:17:29 +00:00
|
|
|
Scope m_currentScope = Scope::User;
|
2024-07-22 16:48:02 +00:00
|
|
|
std::unique_ptr<QSettings> m_pUserSettings;
|
|
|
|
|
std::unique_ptr<QSettings> m_pSystemSettings;
|
2024-08-08 17:41:59 +00:00
|
|
|
QSettingsProxy m_userSettingsProxy;
|
|
|
|
|
QSettingsProxy m_systemSettingsProxy;
|
2024-07-22 16:48:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace synergy::gui
|