4#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
5#include <QRegExpValidator>
8#include <QRegularExpression>
9#include <QRegularExpressionValidator>
12#include "ParameterWakeOnLan.h"
14CParameterWakeOnLan::CParameterWakeOnLan(QObject *parent)
18 , m_HostState(HostState::Offline)
20 , m_bSavePassword(false)
29 set.beginGroup(
"WakeOnLan");
30 SetEnable(set.value(
"Enable", GetEnable()).toBool());
31 SetMac(set.value(
"Mac", GetMac()).toString());
33 set.value(
"BoardAddress", GetBroadcastAddress()).toString());
35 SetPort(set.value(
"Port", GetPort()).toUInt());
36 SetPassword(set.value(
"Password", GetPassword()).toString());
37 SetSavePassword(set.value(
"Password/Save", GetSavePassword()).toBool());
38 SetRepeat(set.value(
"Repeat", GetRepeat()).toInt());
45int CParameterWakeOnLan::OnSave(QSettings &set)
48 set.beginGroup(
"WakeOnLan");
49 set.setValue(
"Enable", GetEnable());
50 set.setValue(
"Mac", GetMac());
51 set.setValue(
"BoardAddress", GetBroadcastAddress());
53 set.setValue(
"Port", GetPort());
54 set.setValue(
"Password", GetPassword());
55 set.setValue(
"Password/Save", GetSavePassword());
56 set.setValue(
"Repeat", GetRepeat());
65#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
66 QRegExp rxMac(
"^[A-Fa-f0-9]{2}(-[A-Fa-f0-9]{2}){5}$|^[A-Fa-f0-9]{2}(:[A-Fa-f0-9]{2}){5}$");
67 QRegExpValidator macValidator(rxMac,
this);
68 QRegExp rxIP(
"^((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)$");
69 QRegExpValidator ipValidator(rxIP,
this);
70 QRegExp rxPassword(
"(.{6})?|^[A-Fa-f0-9]{2}(-[A-Fa-f0-9]{2}){5}$|^[A-Fa-f0-9]{2}(:[A-Fa-f0-9]{2}){5}$");
71 QRegExpValidator passwordValidator(rxPassword,
this);
73 QRegularExpression rxMac(
"^[A-Fa-f0-9]{2}(-[A-Fa-f0-9]{2}){5}$|^[A-Fa-f0-9]{2}(:[A-Fa-f0-9]{2}){5}$");
74 QRegularExpressionValidator macValidator(rxMac,
this);
75 QRegularExpression rxIP(
"^((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)$");
76 QRegularExpressionValidator ipValidator(rxIP,
this);
77 QRegularExpression rxPassword(
"(.{6})?|^[A-Fa-f0-9]{2}(-[A-Fa-f0-9]{2}){5}$|^[A-Fa-f0-9]{2}(:[A-Fa-f0-9]{2}){5}$");
78 QRegularExpressionValidator passwordValidator(rxPassword,
this);
82 QString szMac = GetMac();
84 if(QValidator::Acceptable != macValidator.validate(szMac, pos))
86 QString szBroadAddress = GetBroadcastAddress();
87 if(QValidator::Acceptable != ipValidator.validate(szBroadAddress, pos))
89 QString szPassword = GetPassword();
90 if(QValidator::Acceptable != passwordValidator.validate(szPassword, pos))
96void CParameterWakeOnLan::slotSetParameterClient()
104const bool CParameterWakeOnLan::GetEnable()
const
109int CParameterWakeOnLan::SetEnable(
bool bEnable)
111 if(m_bEnable == bEnable)
118const QString CParameterWakeOnLan::GetMac()
const
123int CParameterWakeOnLan::SetMac(
const QString &szMac)
132const QString CParameterWakeOnLan::GetBroadcastAddress()
const
134 return m_szBoardcastAddress;
137int CParameterWakeOnLan::SetBroadcastAddress(
const QString &szBroadcastAddress)
139 if(m_szBoardcastAddress == szBroadcastAddress)
141 m_szBoardcastAddress = szBroadcastAddress;
148 return m_szNetworkInteface;
151int CParameterWakeOnLan::SetNetworkInterface(
const QString& szName)
153 if(m_szNetworkInteface == szName)
155 m_szNetworkInteface = szName;
160const quint16 CParameterWakeOnLan::GetPort()
const
165int CParameterWakeOnLan::SetPort(quint16 port)
174const QString CParameterWakeOnLan::GetPassword()
const
179int CParameterWakeOnLan::SetPassword(
const QString &szPassword)
181 if(m_szPassword == szPassword)
183 m_szPassword = szPassword;
188const bool CParameterWakeOnLan::GetSavePassword()
const
190 return m_bSavePassword;
195 if(m_bSavePassword == save)
197 m_bSavePassword = save;
202const int CParameterWakeOnLan::GetRepeat()
const
207int CParameterWakeOnLan::SetRepeat(
int nRepeat)
209 if(m_nRepeat == nRepeat)
223 if(m_nInterval == nInterval)
225 m_nInterval = nInterval;
244CParameterWakeOnLan::HostState CParameterWakeOnLan::GetHostState()
const
249void CParameterWakeOnLan::SetHostState(HostState newHostState)
251 if (m_HostState == newHostState)
253 m_HostState = newHostState;
254 emit sigHostStateChanged();
the parameters of connecter interface.
CParameterClient * GetParameterClient()
Get CParameterClient.
virtual int OnLoad(QSettings &set) override
Unit: ms.
int SetTimeOut(int nTimeout)
Unit: ms.
int SetSavePassword(bool save)
Set save password.
int SetInterval(int nInterval)
Unit: ms.
const QString GetNetworkInterface() const
Get network interface.
virtual bool OnCheckValidity() override
Check validity.
const int GetTimeOut() const
Unit: ms.
const int GetInterval() const
Unit: ms.
int SetModified(bool bModified=true)
When setting parameters, if there is a modification, it is called.