Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
DlgSettingsVnc.cpp
1// Author: Kang Lin <kl222@126.com>
2
3#include <QMessageBox>
4#include <QLoggingCategory>
5#include "DlgSettingsVnc.h"
6#include "ui_DlgSettingsVnc.h"
7#include "rfb/encodings.h"
8
9#ifdef HAVE_ICE
10 #include "Ice.h"
11#endif
12
13#undef SetPort
14
15static Q_LOGGING_CATEGORY(log, "VNC.Settings")
16
17CDlgSettingsVnc::CDlgSettingsVnc(CParameterVnc *pPara, QWidget *parent) :
18 QDialog(parent),
19 ui(new Ui::CDlgSettingsVnc),
20 m_pPara(pPara)
21{
22 setAttribute(Qt::WA_DeleteOnClose);
23 ui->setupUi(this);
24
25 ui->wNet->SetParameter(&m_pPara->m_Net);
26
27 m_pProxyUI = new CParameterProxyUI(ui->tabWidget);
28 m_pProxyUI->SetParameter(&m_pPara->m_Proxy);
29 ui->tabWidget->insertTab(1, m_pProxyUI, tr("Proxy"));
30
31 m_pRecordUI = new CParameterRecordUI(ui->tabWidget);
32 m_pRecordUI->SetParameter(&m_pPara->m_Record);
33 ui->tabWidget->addTab(m_pRecordUI, m_pRecordUI->windowIcon(), tr("Record"));
34
35#ifdef HAVE_ICE
36 ui->gpIce->show();
37#else
38 ui->gpIce->hide();
39#endif
40
41 // Server
42 bool ice = false;
43#ifdef HAVE_ICE
44 ice = CICE::Instance()->GetParameter()->getIce();
45#endif
46 if(ice)
47 {
48 if(m_pPara->GetIce())
49 {
50 ui->gpIce->setChecked(true);
51 ui->wNet->setEnabled(false);
52 } else {
53 ui->gpIce->setChecked(false);
54 }
55 } else {
56 ui->gpIce->setEnabled(false);
57 }
58
59 ui->lePeerUser->setText(m_pPara->GetPeerUser());
60
61 ui->leName->setText(m_pPara->GetName());
62
63 ui->cbOnlyView->setChecked(m_pPara->GetOnlyView());
64 ui->cbShowServerName->setChecked(m_pPara->GetShowServerName());
65
66 ui->cbShared->setChecked(m_pPara->GetShared());
67 ui->cbRealTimeUpdate->setChecked(!m_pPara->GetBufferEndRefresh());
68 ui->cbLocalCursor->setChecked(m_pPara->GetLocalCursor());
69 ui->cbCursorPosition->setChecked(m_pPara->GetCursorPosition());
70 ui->cbResizeWindows->setChecked(m_pPara->GetSupportsDesktopResize());
71 ui->cbLedState->setChecked(m_pPara->GetLedState());
72 ui->cbClipboard->setChecked(m_pPara->GetClipboard());
73
74 // Compress
75 ui->cbCompressAutoSelect->setChecked(m_pPara->GetAutoSelect());
76#ifdef HAVE_H264
77 ui->rbH264->setVisible(true);
78#else
79 ui->rbH264->setVisible(false);
80#endif
81 switch(m_pPara->GetPreferredEncoding())
82 {
83 case rfb::encodingTight:
84 ui->rbTight->setChecked(true);
85 break;
86 case rfb::encodingRaw:
87 ui->rbRaw->setChecked(true);
88 break;
89 case rfb::encodingRRE:
90 ui->rbRRE->setChecked(true);
91 break;
92 case rfb::encodingZRLE:
93 ui->rbZRLE->setChecked(true);
94 break;
95 case rfb::encodingCoRRE:
96 ui->rbCoRRE->setChecked(true);
97 break;
98 case rfb::encodingCopyRect:
99 ui->rbCopyRect->setChecked(true);
100 break;
101 case rfb::encodingHextile:
102 ui->rbHextile->setChecked(true);
103 break;
104#ifdef HAVE_H264
105 case rfb::encodingH264:
106 ui->rbH264->setChecked(true);
107 break;
108#endif
109 }
110
111 switch(m_pPara->GetColorLevel())
112 {
113 case CParameterVnc::Full:
114 ui->rbFull->setChecked(true);
115 break;
116 case CParameterVnc::Medium:
117 ui->rbMeduim->setChecked(true);
118 break;
119 case CParameterVnc::Low:
120 ui->rbLow->setChecked(true);
121 break;
122 case CParameterVnc::VeryLow:
123 ui->rbVeryLow->setChecked(true);
124 break;
125 }
126
127 ui->cbCompress->setChecked(m_pPara->GetEnableCompressLevel());
128 ui->spCompressLevel->setValue(m_pPara->GetCompressLevel());
129 ui->cbJPEG->setChecked(!m_pPara->GetNoJpeg());
130 ui->spJPEGLevel->setValue(m_pPara->GetQualityLevel());
131
132 if(m_pPara->GetAutoSelect())
133 {
134 ui->spCompressLevel->setEnabled(false);
135 ui->spJPEGLevel->setEnabled(false);
136 } else {
137 ui->spCompressLevel->setEnabled(m_pPara->GetEnableCompressLevel());
138 ui->spJPEGLevel->setEnabled(!m_pPara->GetNoJpeg());
139 }
140}
141
142CDlgSettingsVnc::~CDlgSettingsVnc()
143{
144 qDebug(log) << "CDlgSettingsVnc::~CDlgSettingsVnc()";
145 delete ui;
146}
147
148void CDlgSettingsVnc::on_pbOK_clicked()
149{
150 int nRet = 0;
151 if(!m_pPara)
152 return;
153
154 if(!ui->wNet->CheckValidity(true)) {
155 ui->tabWidget->setCurrentIndex(0);
156 return;
157 }
158
159 if(!m_pProxyUI->CheckValidity(true)) {
160 ui->tabWidget->setCurrentWidget(m_pProxyUI);
161 return;
162 }
163
164 if(!m_pRecordUI->CheckValidity(true)) {
165 ui->tabWidget->setCurrentWidget(m_pRecordUI);
166 return;
167 }
168
169 // Server
170 bool ice = false;
171#ifdef HAVE_ICE
172 ice = CICE::Instance()->GetParameter()->getIce();
173#endif
174 if(ui->gpIce->isChecked() && ice)
175 {
176 m_pPara->SetIce(true);
177 m_pPara->SetPeerUser(ui->lePeerUser->text());
178 } else {
179 m_pPara->SetIce(false);
180 }
181
182 nRet = ui->wNet->Accept();
183 if(nRet) return;
184 nRet = m_pProxyUI->Accept();
185 if(nRet) return;
186 nRet = m_pRecordUI->Accept();
187 if(nRet) return;
188
189 m_pPara->SetName(ui->leName->text());
190 m_pPara->SetShared(ui->cbShared->isChecked());
191 m_pPara->SetBufferEndRefresh(!ui->cbRealTimeUpdate->isChecked());
192 m_pPara->SetLocalCursor(ui->cbLocalCursor->isChecked());
193 m_pPara->SetCursorPosition(ui->cbCursorPosition->isChecked());
194 m_pPara->SetSupportsDesktopResize(ui->cbResizeWindows->isChecked());
195 m_pPara->SetLedState(ui->cbLedState->isChecked());
196 m_pPara->SetClipboard(ui->cbClipboard->isChecked());
197 m_pPara->SetShowServerName(ui->cbShowServerName->isChecked());
198
199 // Compress
200 m_pPara->SetAutoSelect(ui->cbCompressAutoSelect->isChecked());
201 if(m_pPara->GetAutoSelect()) {
202 m_pPara->SetPreferredEncoding(rfb::encodingTight);
203 m_pPara->SetColorLevel(CParameterVnc::Full);
204 m_pPara->SetCompressLevel(2);
205 m_pPara->SetQualityLevel(8);
206 } else {
207 if(ui->rbTight->isChecked()) m_pPara->SetPreferredEncoding(rfb::encodingTight);
208 if(ui->rbRaw->isChecked()) m_pPara->SetPreferredEncoding(rfb::encodingRaw);
209 if(ui->rbRRE->isChecked()) m_pPara->SetPreferredEncoding(rfb::encodingRRE);
210 if(ui->rbZRLE->isChecked()) m_pPara->SetPreferredEncoding(rfb::encodingZRLE);
211 if(ui->rbCoRRE->isChecked()) m_pPara->SetPreferredEncoding(rfb::encodingCoRRE);
212 if(ui->rbCopyRect->isChecked()) m_pPara->SetPreferredEncoding(rfb::encodingCopyRect);
213 if(ui->rbHextile->isChecked()) m_pPara->SetPreferredEncoding(rfb::encodingHextile);
214#ifdef HAVE_H264
215 if(ui->rbH264->isChecked()) m_pPara->SetPreferredEncoding(rfb::encodingH264);
216#endif
217
218 if(ui->rbFull->isChecked()) m_pPara->SetColorLevel(CParameterVnc::Full);
219 if(ui->rbMeduim->isChecked()) m_pPara->SetColorLevel(CParameterVnc::Medium);
220 if(ui->rbLow->isChecked()) m_pPara->SetColorLevel(CParameterVnc::Low);
221 if(ui->rbVeryLow->isChecked()) m_pPara->SetColorLevel(CParameterVnc::VeryLow);
222
223 m_pPara->SetEnableCompressLevel(ui->cbCompress->isChecked());
224 m_pPara->SetCompressLevel(ui->spCompressLevel->value());
225 m_pPara->SetNoJpeg(!ui->cbJPEG->isChecked());
226 m_pPara->SetQualityLevel(ui->spJPEGLevel->value());
227 }
228
229 accept();
230}
231
232void CDlgSettingsVnc::on_pbCancel_clicked()
233{
234 reject();
235}
236
237void CDlgSettingsVnc::on_cbCompressAutoSelect_stateChanged(int arg1)
238{
239 m_pPara->SetAutoSelect(arg1);
240 if(m_pPara->GetAutoSelect())
241 {
242 ui->gpPreferredEncodeing->setEnabled(false);
243 ui->gpColorLevel->setEnabled(false);
244 ui->cbJPEG->setEnabled(false);
245 ui->spJPEGLevel->setEnabled(false);
246 ui->cbCompress->setEnabled(false);
247 ui->spCompressLevel->setEnabled(false);
248 } else {
249 ui->gpPreferredEncodeing->setEnabled(true);
250 ui->gpColorLevel->setEnabled(true);
251 ui->cbJPEG->setEnabled(true);
252 if(ui->cbJPEG->isChecked())
253 ui->spJPEGLevel->setEnabled(true);
254 ui->cbCompress->setEnabled(true);
255 if(ui->cbCompress->isChecked())
256 ui->spCompressLevel->setEnabled(true);
257 }
258}
259
260void CDlgSettingsVnc::on_cbCompress_stateChanged(int arg1)
261{
262 m_pPara->SetCompressLevel(arg1);
263
264 ui->spCompressLevel->setEnabled(m_pPara->GetEnableCompressLevel());
265}
266
267void CDlgSettingsVnc::on_cbJPEG_stateChanged(int arg1)
268{
269 m_pPara->SetNoJpeg(!arg1);
270
271 ui->spJPEGLevel->setEnabled(!m_pPara->GetNoJpeg());
272}
273
274void CDlgSettingsVnc::on_gpIce_clicked(bool checked)
275{
276 ui->wNet->setEnabled(!checked);
277}
static CICE * Instance()
Single instance.
Definition Ice.cpp:55
The proxy parameter UI.
bool CheckValidity(bool validity=false)
Check parameters validity.
int Accept()
Accept parameters.
virtual bool CheckValidity(bool validity=false)
Check parameters validity.