Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
ParameterService.cpp
1// Author: Kang Lin <kl222@126.com>
2
3#include "ParameterService.h"
4#include <QSettings>
5#include <QLoggingCategory>
6
7Q_DECLARE_LOGGING_CATEGORY(Service)
8CParameterService::CParameterService(QObject *parent) : QObject(parent),
9 m_nPort(0),
10 m_bEnable(true)
11{
12}
13
14CParameterService::~CParameterService()
15{
16 qDebug(Service) << "CParameterService::~CParameterService";
17}
18
19int CParameterService::Load(const QString& szFile)
20{
21 QSettings set(szFile, QSettings::IniFormat);
22 m_nPort = set.value("Port", m_nPort).toUInt();
23 m_bEnable = set.value("Enable", m_bEnable).toBool();
24 m_szPassword = set.value("Password", m_szPassword).toString();
25 return 0;
26}
27
28int CParameterService::Save(const QString& szFile)
29{
30 QSettings set(szFile, QSettings::IniFormat);
31 set.setValue("Port", m_nPort);
32 set.setValue("Enable", m_bEnable);
33 set.setValue("Password", m_szPassword);
34 return 0;
35}
36
37quint16 CParameterService::getPort() const
38{
39 return m_nPort;
40}
41
42void CParameterService::setPort(quint16 newPort)
43{
44 if (m_nPort == newPort)
45 return;
46 m_nPort = newPort;
47 emit PortChanged();
48}
49
50bool CParameterService::getEnable() const
51{
52 return m_bEnable;
53}
54
55void CParameterService::setEnable(bool newEnable)
56{
57 if (m_bEnable == newEnable)
58 return;
59 m_bEnable = newEnable;
60 emit EnableChanged();
61}
62
63const QString &CParameterService::getPassword() const
64{
65 return m_szPassword;
66}
67
68void CParameterService::setPassword(const QString &newPassword)
69{
70 if (m_szPassword == newPassword)
71 return;
72 m_szPassword = newPassword;
73 emit PasswordChanged();
74}