50 lines
1.1 KiB
C++
50 lines
1.1 KiB
C++
// ConfigManager.h
|
|
#pragma once
|
|
|
|
#include "channelConfig.h"
|
|
#include <QObject>
|
|
#include <QString>
|
|
#include <QFile>
|
|
#include <QJsonDocument>
|
|
#include "export.hpp"
|
|
|
|
class DIAGRAM_DESIGNER_PUBLIC ConfigManager : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
static ConfigManager* instance();
|
|
|
|
// 加载配置
|
|
bool loadConfig(const QString& configFile = "");
|
|
|
|
// 保存配置
|
|
bool saveConfig();
|
|
|
|
// 获取配置
|
|
ChannelConfig getHttpConfig() const;
|
|
ChannelConfig getWebSocketConfig() const;
|
|
|
|
// 更新配置
|
|
void setHttpConfig(const ChannelConfig& config);
|
|
void setWebSocketConfig(const ChannelConfig& config);
|
|
|
|
// 获取配置路径
|
|
QString configFilePath() const;
|
|
|
|
signals:
|
|
void configLoaded();
|
|
void configSaved();
|
|
void httpConfigChanged(const ChannelConfig& config);
|
|
void websocketConfigChanged(const ChannelConfig& config);
|
|
private:
|
|
ConfigManager(QObject* parent = nullptr);
|
|
bool createDefaultConfig();
|
|
ChannelConfig getDefaultHttpConfig() const;
|
|
ChannelConfig getDefaultWebSocketConfig() const;
|
|
|
|
ChannelConfig m_httpConfig;
|
|
ChannelConfig m_websocketConfig;
|
|
QString m_configFile;
|
|
};
|