Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
ParameterBase.cpp
1#include "ParameterBase.h"
2#include <QLoggingCategory>
3
4static Q_LOGGING_CATEGORY(log, "Client.Parameter.Base")
5
6CParameterBase::CParameterBase(QObject* parent)
7 : CParameterConnecter(parent)
8 , m_Net(this)
9 , m_Proxy(this)
10 , m_Record(this)
11{
12 Init();
13}
14
15CParameterBase::CParameterBase(CParameterConnecter* parent,
16 const QString& szPrefix)
17 : CParameterConnecter(parent, szPrefix)
18 , m_Net(this)
19 , m_Proxy(this)
20 , m_Record(this)
21{
22 Init();
23}
24
25int CParameterBase::Init()
26{
27 m_bShowServerName = true;
28 m_bOnlyView = false;
29 m_bLocalCursor = true;
30 m_bCursorPosition = true;
31 m_bClipboard = true;
32 m_bSupportsDesktopResize = true;
33 m_bLedState = true;
35 m_dbZoomFactor = 1;
36 return 0;
37}
38
39int CParameterBase::OnLoad(QSettings &set)
40{
41 SetName(set.value("Name", GetName()).toString());
42 SetServerName(set.value("ServerName", GetServerName()).toString());
43 SetShowServerName(set.value("ShowServerName", GetShowServerName()).toBool());
44 SetOnlyView(set.value("OnlyView", GetOnlyView()).toBool());
45 SetLocalCursor(set.value("LocalCursor", GetLocalCursor()).toBool());
46 SetCursorPosition(set.value("CursorPosition", GetCursorPosition()).toBool());
47 SetClipboard(set.value("Clipboard", GetClipboard()).toBool());
48 SetSupportsDesktopResize(set.value("SupportsDesktopResize",
49 GetSupportsDesktopResize()).toBool());
50 SetLedState(set.value("LedState", GetLedState()).toBool());
51 SetZoomFactor(set.value("Viewer/ZoomFactor", GetZoomFactor()).toDouble());
52 SetAdaptWindows(
54 set.value("Viewer/AdaptType",
55 (int)GetParameterClient()->GetAdaptWindows()).toInt());
56 return 0;
57}
58
59int CParameterBase::OnSave(QSettings &set)
60{
61 set.setValue("Name", GetName());
62 set.setValue("ServerName", GetServerName());
63 set.setValue("ShowServerName", GetShowServerName());
64 set.setValue("OnlyView", GetOnlyView());
65 set.setValue("LocalCursor", GetLocalCursor());
66 set.setValue("CursorPosition", GetCursorPosition());
67 set.setValue("Clipboard", GetClipboard());
68 set.setValue("SupportsDesktopResize", GetSupportsDesktopResize());
69 set.setValue("LedState", GetLedState());
70 set.setValue("Viewer/ZoomFactor", GetZoomFactor());
71 set.setValue("Viewer/AdaptType", (int)GetAdaptWindows());
72 return 0;
73}
74
75const QString CParameterBase::GetName() const
76{
77 return m_szName;
78}
79
80void CParameterBase::SetName(const QString& szName)
81{
82 if(m_szName == szName)
83 return;
84 m_szName = szName;
85 SetModified(true);
86 emit sigNameChanged(m_szName);
87}
88
89const QString CParameterBase::GetServerName() const
90{
91 return m_szServerName;
92}
93
94void CParameterBase::SetServerName(const QString& szName)
95{
96 if(m_szServerName == szName)
97 return;
98 m_szServerName = szName;
99 SetModified(true);
100}
101
102bool CParameterBase::GetShowServerName() const
103{
104 return m_bShowServerName;
105}
106
107void CParameterBase::SetShowServerName(bool NewShowServerName)
108{
109 if (m_bShowServerName == NewShowServerName)
110 return;
111 m_bShowServerName = NewShowServerName;
112 SetModified(true);
113 emit sigShowServerNameChanged();
114}
115
116bool CParameterBase::GetOnlyView() const
117{
118 return m_bOnlyView;
119}
120
121void CParameterBase::SetOnlyView(bool only)
122{
123 if(m_bOnlyView == only)
124 return;
125 m_bOnlyView = only;
126 SetModified(true);
127}
128
129const bool CParameterBase::GetLocalCursor() const
130{
131 return m_bLocalCursor;
132}
133
134void CParameterBase::SetLocalCursor(bool cursor)
135{
136 if(m_bLocalCursor == cursor)
137 return;
138 m_bLocalCursor = cursor;
139 SetModified(true);
140}
141
142const bool CParameterBase::GetCursorPosition() const
143{
144 return m_bCursorPosition;
145}
146
147void CParameterBase::SetCursorPosition(bool pos)
148{
149 if(m_bCursorPosition == pos)
150 return;
151 m_bCursorPosition = pos;
152 SetModified(true);
153}
154
155const bool CParameterBase::GetClipboard() const
156{
157 return m_bClipboard;
158}
159
160void CParameterBase::SetClipboard(bool c)
161{
162 if(m_bClipboard == c)
163 return;
164 m_bClipboard = c;
165 SetModified(true);
166}
167
168bool CParameterBase::GetSupportsDesktopResize() const
169{
170 return m_bSupportsDesktopResize;
171}
172
173void CParameterBase::SetSupportsDesktopResize(bool newSupportsDesktopResize)
174{
175 if(m_bSupportsDesktopResize == newSupportsDesktopResize)
176 return;
177 m_bSupportsDesktopResize = newSupportsDesktopResize;
178 SetModified(true);
179}
180
181bool CParameterBase::GetLedState() const
182{
183 return m_bLedState;
184}
185
186void CParameterBase::SetLedState(bool state)
187{
188 if(m_bLedState == state)
189 return;
190 m_bLedState = state;
191 SetModified(true);
192}
193
194CFrmViewer::ADAPT_WINDOWS CParameterBase::GetAdaptWindows()
195{
196 return m_AdaptWindows;
197}
198
199void CParameterBase::SetAdaptWindows(CFrmViewer::ADAPT_WINDOWS aw)
200{
201 if(m_AdaptWindows == aw)
202 return;
203 m_AdaptWindows = aw;
204 SetModified(true);
205 emit sigAdaptWindowsChanged(m_AdaptWindows);
206}
207
208double CParameterBase::GetZoomFactor() const
209{
210 return m_dbZoomFactor;
211}
212
213void CParameterBase::SetZoomFactor(double newZoomFactor)
214{
215 if(m_dbZoomFactor == newZoomFactor)
216 return;
217 m_dbZoomFactor = newZoomFactor;
218 SetModified(true);
219 emit sigZoomFactorChanged(m_dbZoomFactor);
220 return;
221}
222
224{
226 if(!pClient) {
227 QString szErr = "The CParameterClient is null";
228 qCritical(log) << szErr;
229 Q_ASSERT_X(false, "CParameterBase", szErr.toStdString().c_str());
230 return;
231 }
232
233 SetAdaptWindows(pClient->GetAdaptWindows());
234
235 m_Record = pClient->m_Record;
236
237 return;
238}
ADAPT_WINDOWS
The ADAPT_WINDOWS enum.
Definition FrmViewer.h:61
@ ZoomToWindow
Desktop adapt to windows.
The interface of connecter parameters.
virtual void slotSetParameterClient() override
Call after set CParameterClient.
The parameters of client.
the parameters of connecter interface.
CParameterClient * GetParameterClient()
Get CParameterClient.
int SetModified(bool bModified=true)
When setting parameters, if there is a modification, it is called.