玉兔远程控制 0.1.0-bate8
载入中...
搜索中...
未找到
DlgSetFreeRDP.cpp
1// Author: Kang Lin <kl222@126.com>
2
3#if HAVE_OPENSSL
4#include <openssl/tls1.h>
5#endif
6
7#include "DlgSetFreeRDP.h"
8#include "ui_DlgSetFreeRDP.h"
9#include "ParameterNetUI.h"
10
11#include <QApplication>
12#include <QScreen>
13#include <QFileSystemModel>
14#include <QButtonGroup>
15#include <QLoggingCategory>
16
17#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
18 #include <QMediaDevices>
19 #include <QAudioDevice>
20#else
21 #include <QAudioDeviceInfo>
22#endif
23
24#include "DlgDesktopSize.h"
25#include "freerdp/version.h"
26
27static Q_LOGGING_CATEGORY(log, "FreeRDP.Parameter.Dlg")
28
29CDlgSetFreeRDP::CDlgSetFreeRDP(CParameterFreeRDP *pSettings, QWidget *parent) :
30 QDialog(parent)
31 , ui(new Ui::CDlgSetFreeRDP)
32 , m_pSettings(pSettings)
33 , m_pFileModel(nullptr)
34 , m_pProxyUI(nullptr)
35 , m_pRecordUI(nullptr)
36 , m_pButtonGroup(nullptr)
37{
38 setAttribute(Qt::WA_DeleteOnClose);
39 ui->setupUi(this);
40
41 ui->leName->setText(m_pSettings->GetName());
42
43 // Server
44 ui->leDomain->setText(m_pSettings->GetDomain());
45 ui->wNet->SetParameter(&m_pSettings->m_Net);
46
47 ui->cbOnlyView->setChecked(m_pSettings->GetOnlyView());
48 ui->cbClipboard->setChecked(m_pSettings->GetClipboard());
49 ui->cbShowServerName->setChecked(m_pSettings->GetShowServerName());
50
51 m_pProxyUI = new CParameterProxyUI(ui->tabWidget);
52 m_pProxyUI->SetParameter(&m_pSettings->m_Proxy);
53 InsertView(m_pProxyUI, 1);
54
55 m_pRecordUI = new CParameterRecordUI(ui->tabWidget);
56 m_pRecordUI->SetParameter(&m_pSettings->m_Record);
57 QList<QWidget *> ws;
58 ws << m_pRecordUI;
59 AddViewers(ws);
60
61 // Display
62 // It has to be the first. GetScreenGeometry depends on it
63 ui->cbAllMonitor->setChecked(m_pSettings->GetUseMultimon());
64 UpdateDesktopSize();
65 int width = GetScreenGeometry().width();
66 int height = GetScreenGeometry().height();
67 QString curSize = QString::number(width) + "×" + QString::number(height);
68 UINT32 desktopWidth = 0, desktopHeight = 0;
69 desktopWidth = m_pSettings->GetDesktopWidth();
70 desktopHeight = m_pSettings->GetDesktopHeight();
71 if(width == desktopWidth && height == desktopHeight)
72 {
73 ui->rbLocalScreen->setChecked(true);
74 ui->cbDesktopSize->setCurrentText(curSize);
75 } else {
76 ui->rbSelect->setChecked(true);
77 curSize = QString::number(desktopWidth)
78 + "×" + QString::number(desktopHeight);
79 ui->cbDesktopSize->setCurrentText(curSize);
80 }
81
82 ui->cbColorDepth->addItem(tr("8 bits"), 8);
83 ui->cbColorDepth->addItem(tr("16 bits"), 16);
84 ui->cbColorDepth->addItem(tr("24 bits"), 24);
85 ui->cbColorDepth->addItem(tr("32 bits"), 32);
86 int nIndex = ui->cbColorDepth->findData(
87 m_pSettings->GetColorDepth());
88 if(-1 != nIndex)
89 ui->cbColorDepth->setCurrentIndex(nIndex);
90
91 ui->sbReconnect->setValue(m_pSettings->GetReconnectInterval());
92
93 // Redirection printer
94 ui->cbPrinter->setChecked(m_pSettings->GetRedirectionPrinter());
95
96 ui->cbEnableLocalInputMethod->setChecked(m_pSettings->GetEnableLocalInputMethod());
97
98 // Redirection audio output
99 ui->gbAudio->setEnabled(HasAudioOutput() || HasAudioInput());
100 if(m_pSettings->GetRedirectionSound() == CParameterFreeRDP::RedirecionSoundType::Disable)
101 ui->rbAudioDisable->setChecked(true);
102 if(m_pSettings->GetRedirectionSound() == CParameterFreeRDP::RedirecionSoundType::Local)
103 ui->rbAudioLocal->setChecked(true);
104 if(m_pSettings->GetRedirectionSound() == CParameterFreeRDP::RedirecionSoundType::Remote)
105 ui->rbAudioRemote->setChecked(true);
106 QString szRdpSndParameters
107 = tr("- [sys:<sys>,][dev:<dev>,][format:<format>,][rate:<rate>,][channel:<channel>]\n"
108 #if defined (Q_OS_WINDOWS) || defined(Q_OS_WIN) || defined(Q_OS_WIN32) || defined(Q_OS_WINRT)
109 "- sys:winmm"
110 #elif defined(Q_OS_IOS)
111 "- sys:ios\n"
112 "- sys:mac"
113 #elif defined (Q_OS_ANDROID)
114 "- sys:opensles"
115 #elif defined (Q_OS_LINUX) || defined (Q_OS_UNIX)
116 "- sys:alsa\n"
117 "- sys:oss\n"
118 "- sys:oss,dev:1,format:1\n"
119 "- sys:sndio"
120 #endif
121 );
122 QString szRdpSnd = tr("Options for redirection of audio output:\n") + szRdpSndParameters;
123 ui->leRdpSnd->setToolTip(szRdpSnd);
124 ui->leRdpSnd->setStatusTip(szRdpSnd);
125 ui->leRdpSnd->setWhatsThis(szRdpSnd);
126 ui->leRdpSnd->setEnabled(HasAudioOutput());
127 ui->leRdpSnd->setText(m_pSettings->GetRedirectionSoundParameters());
128 // Redirection audio input
129 QString szAudin = tr("Options for redirection of audio input:\n") + szRdpSndParameters;
130 ui->leAudin->setToolTip(szAudin);
131 ui->leAudin->setStatusTip(szAudin);
132 ui->leAudin->setWhatsThis(szAudin);
133 ui->leAudin->setText(m_pSettings->GetRedirectionMicrophoneParameters());
134 if(HasAudioInput()) {
135 ui->cbAudin->setChecked(m_pSettings->GetRedirectionMicrophone());
136 } else {
137 ui->cbAudin->setChecked(false);
138 ui->cbAudin->setEnabled(false);
139 ui->leAudin->setEnabled(false);
140 }
141
142 // Drive
143 m_pFileModel= new QFileSystemModel();
144 m_pFileModel->setNameFilterDisables(false);
145 m_pFileModel->setFilter(QDir::Drives | QDir::Dirs | QDir::NoDotAndDotDot);
146 m_pFileModel->setRootPath("");
147 ui->tvDrive->setModel(m_pFileModel);
148 ui->tvDrive->setEditTriggers(QAbstractItemView::NoEditTriggers);
149 int count = m_pFileModel->columnCount();
150 for(int i = 1; i < count; i++)
151 ui->tvDrive->hideColumn(i);
152 bool check = connect(ui->tvDrive->selectionModel(),
153 SIGNAL(selectionChanged(const QItemSelection &,
154 const QItemSelection &)),
155 this,
156 SLOT(slotSelectionChanged(QItemSelection,QItemSelection)));
157 Q_ASSERT(check);
158 QStringList lstDrives = m_pSettings->GetRedirectionDrives();
159 foreach(auto path, lstDrives)
160 {
161 QModelIndex index;
162 if(!path.isEmpty()) {
163 index = m_pFileModel->index(path);
164 ui->tvDrive->setCurrentIndex(index);
165 }
166 }
167 ShowDriveSelected(lstDrives.size());
168
169 // Security
170 ui->cbSecurityEnable->setChecked(m_pSettings->GetNegotiateSecurityLayer());
171 on_cbSecurityEnable_stateChanged(ui->cbSecurityEnable->checkState());
172 CParameterFreeRDP::Security security = m_pSettings->GetSecurity();
173 if(CParameterFreeRDP::Security::RDP & (uint)security)
174 ui->cbSecurityRDP->setChecked(true);
175 if(CParameterFreeRDP::Security::TLS & (uint)security)
176 ui->cbSecurityTls->setChecked(true);
177 if(CParameterFreeRDP::Security::NLA & (uint)security)
178 ui->cbSecurityNLA->setChecked(true);
179 if(CParameterFreeRDP::Security::NLA_Ext & (uint)security)
180 ui->cbSecurityNlaExt->setChecked(true);
181 if(CParameterFreeRDP::Security::RDSAAD & (uint)security)
182 ui->cbSecurityRDSAAD->setChecked(true);
183 if(CParameterFreeRDP::Security::RDSTLS & (uint)security)
184 ui->cbSecurityRDSTLS->setChecked(true);
185#if FREERDP_VERSION_MAJOR >= 3
186 ui->cbSecurityRDSAAD->setVisible(true);
187 ui->cbSecurityRDSTLS->setVisible(true);
188#else
189 ui->cbSecurityRDSAAD->setVisible(false);
190 ui->cbSecurityRDSTLS->setVisible(false);
191#endif
192 // Tls version
193 switch(m_pSettings->GetTlsVersion())
194 {
195 case TLS1_VERSION:
196 ui->rbTls1_0->setChecked(true);
197 break;
198 case TLS1_1_VERSION:
199 ui->rbTls1_1->setChecked(true);
200 break;
201 case TLS1_2_VERSION:
202 ui->rbTls1_2->setChecked(true);
203 break;
204 case TLS1_3_VERSION:
205 ui->rbTls1_3->setChecked(true);
206 break;
207 }
208
209 // Initial default performance flags
210 m_vPerformanceFlags[CONNECTION_TYPE_MODEM - 1] = PERF_DISABLE_WALLPAPER | PERF_DISABLE_FULLWINDOWDRAG | PERF_DISABLE_MENUANIMATIONS | PERF_DISABLE_THEMING;
211 m_vPerformanceFlags[CONNECTION_TYPE_BROADBAND_LOW - 1] = PERF_DISABLE_WALLPAPER | PERF_DISABLE_FULLWINDOWDRAG | PERF_DISABLE_MENUANIMATIONS;
212 m_vPerformanceFlags[CONNECTION_TYPE_SATELLITE - 1] = PERF_DISABLE_WALLPAPER | PERF_ENABLE_DESKTOP_COMPOSITION | PERF_DISABLE_FULLWINDOWDRAG | PERF_DISABLE_MENUANIMATIONS;
213 m_vPerformanceFlags[CONNECTION_TYPE_BROADBAND_HIGH - 1] = PERF_DISABLE_WALLPAPER | PERF_ENABLE_DESKTOP_COMPOSITION | PERF_DISABLE_FULLWINDOWDRAG | PERF_DISABLE_MENUANIMATIONS;
214 m_vPerformanceFlags[CONNECTION_TYPE_WAN - 1] = PERF_ENABLE_FONT_SMOOTHING | PERF_ENABLE_DESKTOP_COMPOSITION;
215 m_vPerformanceFlags[CONNECTION_TYPE_LAN - 1] = PERF_ENABLE_FONT_SMOOTHING | PERF_ENABLE_DESKTOP_COMPOSITION;
216 m_vPerformanceFlags[CONNECTION_TYPE_AUTODETECT - 1] = PERF_ENABLE_FONT_SMOOTHING | PERF_ENABLE_DESKTOP_COMPOSITION;
217 // Load performance flags
218 if(m_pSettings->GetConnectType() > 0 && m_pSettings->GetPerformanceFlags() > 0)
219 m_vPerformanceFlags[m_pSettings->GetConnectType() - 1] = m_pSettings->GetPerformanceFlags();
220 // Connect type
221 ui->cbConnectType->addItem(tr("Modem(56 kbps)"), CONNECTION_TYPE_MODEM);
222 ui->cbConnectType->addItem(tr("Broadband low(256 kbps - 2 Mbps)"), CONNECTION_TYPE_BROADBAND_LOW);
223 ui->cbConnectType->addItem(tr("Satellite(2 Mbps - 16 Mbps, High latency)"), CONNECTION_TYPE_SATELLITE);
224 ui->cbConnectType->addItem(tr("Broadband high(2 Mbps - 10 Mbps)"), CONNECTION_TYPE_BROADBAND_HIGH);
225 ui->cbConnectType->addItem(tr("Wan(10 Mbps or higher speed, High latency)"), CONNECTION_TYPE_WAN);
226 ui->cbConnectType->addItem(tr("Lan(10 Mbps or higher speed)"), CONNECTION_TYPE_LAN);
227 ui->cbConnectType->addItem(tr("Automatically detect"), CONNECTION_TYPE_AUTODETECT);
228 ui->cbConnectType->setCurrentIndex(ui->cbConnectType->findData(m_pSettings->GetConnectType()));
229
230}
231
232CDlgSetFreeRDP::~CDlgSetFreeRDP()
233{
234 delete ui;
235}
236
237// [Check validity and accept]
238void CDlgSetFreeRDP::on_pbOk_clicked()
239{
240 int nRet = 0;
241
242 if(!ui->wNet->CheckValidity(true)) {
243 ui->tabWidget->setCurrentIndex(0);
244 return;
245 }
246 if(!m_pProxyUI->CheckValidity(true)) {
247 ui->tabWidget->setCurrentWidget(m_pProxyUI);
248 return;
249 }
250 if(!m_pRecordUI->CheckValidity(true)) {
251 ui->tabWidget->setCurrentWidget(m_pRecordUI);
252 return;
253 }
254
255 m_pSettings->SetName(ui->leName->text());
256
257 // Server
258 m_pSettings->SetDomain(ui->leDomain->text());
259 nRet = ui->wNet->Accept();
260 if(nRet) return;
261
262 nRet = m_pProxyUI->Accept();
263 if(nRet) return;
264
265 nRet = m_pRecordUI->Accept();
266 if(nRet) return;
267
268 m_pSettings->SetOnlyView(ui->cbOnlyView->isChecked());
269 m_pSettings->SetClipboard(ui->cbClipboard->isChecked());
270 m_pSettings->SetShowServerName(ui->cbShowServerName->isChecked());
271
272 // Display
273 m_pSettings->SetUseMultimon(ui->cbAllMonitor->isChecked());
274 QString szSize = ui->cbDesktopSize->currentText();
275 int index = szSize.indexOf("×");
276 if(-1 < index)
277 {
278 UINT32 width = szSize.left(index).toInt();
279 UINT32 height = szSize.right(szSize.length() - index - 1).toInt();
280 m_pSettings->SetDesktopWidth(width);
281 m_pSettings->SetDesktopHeight(height);
282 }
283 m_pSettings->SetColorDepth(ui->cbColorDepth->currentData().toInt());
284 m_pSettings->SetReconnectInterval(ui->sbReconnect->value());
285
286 // Redirection
287 m_pSettings->SetRedirectionPrinter(ui->cbPrinter->isChecked());
288 m_pSettings->SetEnableLocalInputMethod(ui->cbEnableLocalInputMethod->isChecked());
289 if(HasAudioOutput()) {
290 CParameterFreeRDP::RedirecionSoundType tRdirectionSound
291 = CParameterFreeRDP::RedirecionSoundType::Disable;
292 if(ui->rbAudioDisable->isChecked())
293 tRdirectionSound = CParameterFreeRDP::RedirecionSoundType::Disable;
294 else if(ui->rbAudioLocal->isChecked())
295 tRdirectionSound = CParameterFreeRDP::RedirecionSoundType::Local;
296 else if(ui->rbAudioRemote->isChecked())
297 tRdirectionSound = CParameterFreeRDP::RedirecionSoundType::Remote;
298 m_pSettings->SetRedirectionSound(tRdirectionSound);
299 } else {
300 m_pSettings->SetRedirectionSound(
301 CParameterFreeRDP::RedirecionSoundType::Disable);
302 }
303 m_pSettings->SetRedirectionSoundParameters(ui->leRdpSnd->text());
304 if(HasAudioInput())
305 m_pSettings->SetRedirectionMicrophone(ui->cbAudin->isChecked());
306 else
307 m_pSettings->SetRedirectionMicrophone(false);
308 m_pSettings->SetRedirectionMicrophoneParameters(ui->leAudin->text());
309
310 QStringList lstDrives;
311 //获取选中的行,默认获取选中行的第一列数据(0),列的索引值和上面一样0、1、2、3......
312 QModelIndexList selected = ui->tvDrive->selectionModel()->selectedRows(0);
313 QList<QModelIndex>::iterator it;
314 QModelIndex modelIndex;
315 QString szPath;
316 for (it = selected.begin(); it != selected.end(); ++it)
317 {
318 modelIndex = *it;
319 szPath = m_pFileModel->filePath(modelIndex);
320 if(!szPath.isEmpty())
321 lstDrives.append(szPath);
322 }
323 m_pSettings->SetRedirectionDrives(lstDrives);
324
325 // Security
326 m_pSettings->SetNegotiateSecurityLayer(ui->cbSecurityEnable->isChecked());
327 uint security = 0;
328 if(ui->cbSecurityRDP->isChecked())
329 security |= CParameterFreeRDP::Security::RDP;
330 if(ui->cbSecurityTls->isChecked())
331 security |= CParameterFreeRDP::Security::TLS;
332 if(ui->cbSecurityNLA->isChecked())
333 security |= CParameterFreeRDP::Security::NLA;
334 if(ui->cbSecurityNlaExt->isChecked())
335 security |= CParameterFreeRDP::Security::NLA_Ext;
336 if(ui->cbSecurityRDSTLS->isChecked())
337 security |= CParameterFreeRDP::Security::RDSTLS;
338 if(ui->cbSecurityRDSAAD->isChecked())
339 security |= CParameterFreeRDP::Security::RDSAAD;
340 m_pSettings->SetSecurity((CParameterFreeRDP::Security)security);
341
342 // Tls version
343 if(ui->rbTls1_0->isChecked())
344 m_pSettings->SetTlsVersion(TLS1_VERSION);
345 else if(ui->rbTls1_1->isChecked())
346 m_pSettings->SetTlsVersion(TLS1_1_VERSION);
347 else if(ui->rbTls1_2->isChecked())
348 m_pSettings->SetTlsVersion(TLS1_2_VERSION);
349 else if(ui->rbTls1_3->isChecked())
350 m_pSettings->SetTlsVersion(TLS1_3_VERSION);
351
352 // Connect type
353 m_pSettings->SetConnectType(ui->cbConnectType->currentData().toUInt());
354 // Performance flags
355 UINT32 performanceFlags = 0;
356 if(!ui->cbDesktopBackground->isChecked())
357 performanceFlags |= PERF_DISABLE_WALLPAPER;
358 if(!ui->cbWindowDrag->isChecked())
359 performanceFlags |= PERF_DISABLE_FULLWINDOWDRAG;
360 if(!ui->cbMenuAnims->isChecked())
361 performanceFlags |= PERF_DISABLE_MENUANIMATIONS;
362 if(!ui->cbThemes->isChecked())
363 performanceFlags |= PERF_DISABLE_THEMING;
364 if(ui->cbFontSmoothing->isChecked())
365 performanceFlags |= PERF_ENABLE_FONT_SMOOTHING;
366 if(ui->cbDesktopCompositing->isChecked())
367 performanceFlags |= PERF_ENABLE_DESKTOP_COMPOSITION;
368 m_pSettings->SetPerformanceFlags(performanceFlags);
369
370 accept();
371}
372// [Check validity and accept]
373
374void CDlgSetFreeRDP::on_pbCancel_clicked()
375{
376 reject();
377}
378
379void CDlgSetFreeRDP::on_rbLocalScreen_clicked(bool checked)
380{
381 if(!checked) return;
382 int width = GetScreenGeometry().width();
383 int height = GetScreenGeometry().height();
384 QString curSize = QString::number(width) + "×" + QString::number(height);
385 ui->rbLocalScreen->setText(tr("Local screen") + ": " + curSize);
386 if(ui->cbDesktopSize->findText(curSize) == -1)
387 InsertDesktopSize(width, height);
388 ui->cbDesktopSize->setCurrentText(curSize);
389}
390
391QRect CDlgSetFreeRDP::GetScreenGeometry()
392{
393 QRect r;
394 QScreen* pScreen = QApplication::primaryScreen();
395 if(ui->cbAllMonitor->isChecked())
396 {
397 //TODO: check this is a virtual geometry
398 r = pScreen->virtualGeometry();
399 /*
400 auto lstScreen = QApplication::screens();
401 qDebug(log) << "Screen counts:" << lstScreen.count();
402 int i = 0;
403 foreach(auto pScreen, lstScreen)
404 {
405 //r = r.united(pScreen->geometry());
406 qDebug(log)
407 << "ID:" << i++
408 << "geometry:" << pScreen->geometry()
409 << "availableGeometry:" << pScreen->availableGeometry()
410 << "virtualGeometry" << pScreen->virtualGeometry()
411 << "availableVirtualGeometry" << pScreen->availableVirtualGeometry();
412 }//*/
413 } else {
414 r = pScreen->geometry();
415 }
416 return r;
417}
418
419int CDlgSetFreeRDP::UpdateDesktopSize()
420{
421 ui->cbDesktopSize->clear();
422 QStringList lstDesktopSizes;
423 lstDesktopSizes <<"640×480"
424 <<"800×600"
425 <<"1024×600"
426 <<"1024×768"
427 <<"1280×720"
428 <<"1280×854"
429 <<"1280×960"
430 <<"1280×1024"
431 <<"1366×768"
432 <<"1400×1050"
433 <<"1440×900"
434 <<"1600×900"
435 <<"1600×1024"
436 <<"1600×1200"
437 <<"1680×1050"
438 <<"1920×1080"
439 <<"1920×1200";
440 ui->cbDesktopSize->addItems(lstDesktopSizes);
441
442 int width = GetScreenGeometry().width();
443 int height = GetScreenGeometry().height();
444 QString curSize = QString::number(width) + "×" + QString::number(height);
445 ui->rbLocalScreen->setText(tr("Local screen") + ": " + curSize);
446 if(ui->cbDesktopSize->findText(curSize) == -1)
447 InsertDesktopSize(width, height);
448 return 0;
449}
450
451int CDlgSetFreeRDP::InsertDesktopSize(QString szSize)
452{
453 int w, h;
454 int nIndex = szSize.indexOf("×");
455 if(nIndex > -1)
456 {
457 bool ok = false;
458 w = szSize.left(nIndex).toInt(&ok);
459 if(ok)
460 h = szSize.right(szSize.length() - nIndex - 1).toInt(&ok);
461 if(!ok)
462 return -1;
463 }
464 return InsertDesktopSize(w, h);
465}
466
467int CDlgSetFreeRDP::InsertDesktopSize(int width, int height)
468{
469 QString curSize = QString::number(width) + "×" + QString::number(height);
470 if(ui->cbDesktopSize->findText(curSize) > -1)
471 return 0;
472
473 int nCount = ui->cbDesktopSize->count();
474 for(int i = 0; i < nCount; i++)
475 {
476 QString curText = ui->cbDesktopSize->itemText(i);
477 int nIndex = curText.indexOf("×");
478 if(nIndex > -1)
479 {
480 int w = curText.left(nIndex).toInt();
481 int h = curText.right(curText.length() - nIndex - 1).toInt();
482 if(w > width)
483 {
484 ui->cbDesktopSize->insertItem(i, curSize);
485 return 0;
486 } else if(w == width) {
487 if(h > height)
488 {
489 ui->cbDesktopSize->insertItem(i, curSize);
490 return 0;
491 } if(h == height) {
492 return 0;
493 } else {
494 int j = i + 1;
495 while(j < nCount) {
496 QString curText = ui->cbDesktopSize->itemText(j);
497 int nIndex = curText.indexOf("×");
498 if(-1 >= nIndex) {
499 j++;
500 } else {
501 int w = curText.left(nIndex).toInt();
502 int h = curText.right(curText.length() - nIndex - 1).toInt();
503 if(w != width) {
504 ui->cbDesktopSize->insertItem(j, curSize);
505 return 0;
506 } else {
507 if(h > height)
508 {
509 ui->cbDesktopSize->insertItem(j, curSize);
510 return 0;
511 } else if(h == height)
512 return 0;
513 else
514 j++;
515 }
516 }
517 }
518 }
519 }
520 }
521 }
522
523 if(ui->cbDesktopSize->findText(curSize) == -1)
524 ui->cbDesktopSize->addItem(curSize);
525
526 return 0;
527}
528
529
530void CDlgSetFreeRDP::on_rbAudioDisable_toggled(bool checked)
531{
532 ui->leRdpSnd->setEnabled(!checked);
533}
534
535void CDlgSetFreeRDP::on_rbAudioLocal_toggled(bool checked)
536{
537 ui->leRdpSnd->setEnabled(checked);
538}
539
540void CDlgSetFreeRDP::on_rbAudioRemote_toggled(bool checked)
541{
542 ui->leRdpSnd->setEnabled(!checked);
543 ui->leAudin->setEnabled(!checked);
544 ui->cbAudin->setEnabled(!checked);
545}
546
547bool CDlgSetFreeRDP::HasAudioOutput()
548{
549#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
550 auto d = QMediaDevices::defaultAudioOutput();
551 return !d.isNull();
552#else
553 return !QAudioDeviceInfo::defaultOutputDevice().isNull();
554#endif
555}
556
557bool CDlgSetFreeRDP::HasAudioInput()
558{
559#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
560 auto d = QMediaDevices::defaultAudioInput();
561 return !d.isNull();
562#else
563 return !QAudioDeviceInfo::defaultInputDevice().isNull();
564#endif
565}
566
567void CDlgSetFreeRDP::on_pbSizeEdit_clicked()
568{
569 CDlgDesktopSize dlg;
570 QStringList lstSize;
571 for(int i = 0; i < ui->cbDesktopSize->count(); i++)
572 lstSize << ui->cbDesktopSize->itemText(i);
573 dlg.SetDesktopSizes(lstSize);
574 if(QDialog::Accepted == dlg.exec())
575 {
576 ui->cbDesktopSize->clear();
577 foreach(auto s, dlg.GetDesktopSize())
578 {
579 InsertDesktopSize(s);
580 }
581 }
582}
583
584void CDlgSetFreeRDP::on_pbDriveClearAll_clicked()
585{
586 ui->tvDrive->clearSelection();
587 ShowDriveSelected(0);
588}
589
590void CDlgSetFreeRDP::slotSelectionChanged(const QItemSelection &selected,
591 const QItemSelection &deselected)
592{
593 QModelIndexList s = ui->tvDrive->selectionModel()->selectedRows(0);
594 ShowDriveSelected(s.size());
595}
596
597int CDlgSetFreeRDP::ShowDriveSelected(int counts)
598{
599 ui->lbDriveSelected->setText(tr("Selected counts: ") + QString::number(counts));
600 return 0;
601}
602
603void CDlgSetFreeRDP::on_cbAllMonitor_stateChanged(int arg1)
604{
605 on_rbLocalScreen_clicked(true);
606}
607
608void CDlgSetFreeRDP::on_cbSecurityEnable_stateChanged(int arg1)
609{
610 if(m_pButtonGroup) {
611 m_pButtonGroup->deleteLater();
612 m_pButtonGroup = nullptr;
613 }
614 if(!ui->cbSecurityEnable->isChecked()) {
615 m_pButtonGroup = new QButtonGroup(this);
616 m_pButtonGroup->addButton(ui->cbSecurityRDP);
617 m_pButtonGroup->addButton(ui->cbSecurityTls);
618 m_pButtonGroup->addButton(ui->cbSecurityNLA);
619 m_pButtonGroup->addButton(ui->cbSecurityNlaExt);
620 m_pButtonGroup->addButton(ui->cbSecurityRDSAAD);
621 m_pButtonGroup->addButton(ui->cbSecurityRDSTLS);
622 }
623}
624
625void CDlgSetFreeRDP::on_cbConnectType_currentIndexChanged(int index)
626{
627 UINT32 type = ui->cbConnectType->itemData(index).toUInt();
628 if(0 >= type || CONNECTION_TYPE_AUTODETECT < type)
629 return;
630
631 UINT32 performanceFlags = m_vPerformanceFlags[type - 1];
632 if(CONNECTION_TYPE_AUTODETECT == type)
633 {
634 performanceFlags = PERF_ENABLE_FONT_SMOOTHING | PERF_ENABLE_DESKTOP_COMPOSITION;
635 }
636
637 ui->cbDesktopBackground->setChecked(!(PERF_DISABLE_WALLPAPER & performanceFlags));
638 ui->cbWindowDrag->setChecked(!(PERF_DISABLE_FULLWINDOWDRAG & performanceFlags));
639 ui->cbMenuAnims->setChecked(!(PERF_DISABLE_MENUANIMATIONS & performanceFlags));
640 ui->cbThemes->setChecked(!(PERF_DISABLE_THEMING & performanceFlags));
641 ui->cbFontSmoothing->setChecked(PERF_ENABLE_FONT_SMOOTHING & performanceFlags);
642 ui->cbDesktopCompositing->setChecked(PERF_ENABLE_DESKTOP_COMPOSITION & performanceFlags);
643
644 ui->cbDesktopBackground->setEnabled(!(CONNECTION_TYPE_AUTODETECT == type));
645 ui->cbWindowDrag->setEnabled(!(CONNECTION_TYPE_AUTODETECT == type));
646 ui->cbMenuAnims->setEnabled(!(CONNECTION_TYPE_AUTODETECT == type));
647 ui->cbThemes->setEnabled(!(CONNECTION_TYPE_AUTODETECT == type));
648 ui->cbFontSmoothing->setEnabled(!(CONNECTION_TYPE_AUTODETECT == type));
649 ui->cbDesktopCompositing->setEnabled(!(CONNECTION_TYPE_AUTODETECT == type));
650}
651
652void CDlgSetFreeRDP::InsertView(QWidget* pView, int pos)
653{
654 int nWidth = 0;
655 int nHeigth = 0;
656 if(!pView) return;
657 nWidth = qMax(nWidth, pView->frameSize().width());
658 nHeigth = qMax(nHeigth, pView->frameSize().height());
659
660 bool bScroll = false;
661 QScreen* pScreen = QApplication::primaryScreen();
662 QSize size = this->size();
663 if(nWidth > size.width() || nHeigth > size.height())
664 bScroll = true;
665 // [connect accepted to slotAccept of widget]
666
667 QString szMsg;
668 if(bScroll)
669 {
670 QScrollArea* pScroll = new QScrollArea(ui->tabWidget);
671 if(!pScroll) return;
672 pScroll->setWidget(pView);
673 pView = pScroll;
674 }
675 ui->tabWidget->insertTab(pos, pView, pView->windowIcon(), pView->windowTitle());
676 bool check = false;
677 check = connect(this, SIGNAL(accepted()), pView, SLOT(slotAccept()));
678 if(!check)
679 {
680 szMsg = "Class '" + QString(pView->metaObject()->className())
681 + "' must has slot slotAccept(), please add it. "
682 + "Or the class derived from CParameterUI";
683 qCritical(log) << szMsg;
684 }
685 Q_ASSERT_X(check, "CParameterDlgSettings", szMsg.toStdString().c_str());
686
687 // [connect accepted to slotAccept of widget]
688}
689
690void CDlgSetFreeRDP::AddViewers(const QList<QWidget *> &wViewer)
691{
692 int nWidth = 0;
693 int nHeigth = 0;
694 foreach(auto p, wViewer) {
695 if(!p) continue;
696 nWidth = qMax(nWidth, p->frameSize().width());
697 nHeigth = qMax(nHeigth, p->frameSize().height());
698 }
699 bool bScroll = false;
700 QScreen* pScreen = QApplication::primaryScreen();
701 QSize size = this->size();
702 if(nWidth > size.width() || nHeigth > size.height())
703 bScroll = true;
704 // [connect accepted to slotAccept of widget]
705 foreach(auto p, wViewer)
706 {
707 QString szMsg;
708 QWidget* pView = p;
709 if(bScroll)
710 {
711 QScrollArea* pScroll = new QScrollArea(ui->tabWidget);
712 if(!pScroll) continue;
713 pScroll->setWidget(p);
714 pView = pScroll;
715 }
716 ui->tabWidget->addTab(pView, p->windowIcon(), p->windowTitle());
717 bool check = false;
718 check = connect(this, SIGNAL(accepted()), p, SLOT(slotAccept()));
719 if(!check)
720 {
721 szMsg = "Class '" + QString(p->metaObject()->className())
722 + "' must has slot slotAccept(), please add it. "
723 + "Or the class derived from CParameterUI";
724 qCritical(log) << szMsg;
725 }
726 Q_ASSERT_X(check, "CParameterDlgSettings", szMsg.toStdString().c_str());
727 }
728 // [connect accepted to slotAccept of widget]
729}
[Declare CParameterFreeRDP]
The proxy parameter UI
bool CheckValidity(bool validity=false)
检查参数的有效性
int Accept()
接受参数