2026-07-14 01:37:06 +00:00
|
|
|
#pragma once
|
|
|
|
|
#include <QByteArray>
|
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
|
|
class QSettings;
|
|
|
|
|
|
|
|
|
|
class ConfigHelper
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
static ConfigHelper& instance();
|
|
|
|
|
static int runElevatedWriteCommandIfRequested();
|
|
|
|
|
static bool writeFileWithElevationIfNeeded(const QString& path, const QByteArray& data,
|
|
|
|
|
QString* errorMessage = nullptr);
|
|
|
|
|
static bool removeFileWithElevationIfNeeded(const QString& path, QString* errorMessage = nullptr);
|
|
|
|
|
QString getValue(const QString& section, const QString& key) const;
|
2026-07-10 02:45:13 +00:00
|
|
|
bool setValue(const QString& section, const QString& key, const QString& value);
|
|
|
|
|
QString configPath() const;
|
|
|
|
|
QString installRoot() const;
|
|
|
|
|
QString runtimeRoot() const;
|
|
|
|
|
QString updateRoot() const;
|
2026-07-14 01:37:06 +00:00
|
|
|
QString runtimeRelativePath() const;
|
|
|
|
|
QString lastError() const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
ConfigHelper();
|
|
|
|
|
bool migrateLegacyIniIfNeeded();
|
|
|
|
|
void enterRegistryGroup(QSettings& settings) const;
|
|
|
|
|
bool syncRegistryFromConfigFileIfChanged();
|
|
|
|
|
bool readRegistryValue(const QString& key, QString* value) const;
|
|
|
|
|
bool writeRegistryValue(const QString& key, const QString& value);
|
|
|
|
|
QString readFileValue(const QString& key) const;
|
|
|
|
|
QString m_configPath;
|
|
|
|
|
QString m_registryInstallId;
|
|
|
|
|
QString m_error;
|
|
|
|
|
};
|