3#include "DlgSetFreeRDP.h"
4#include "ui_DlgSetFreeRDP.h"
5#include "ParameterNetUI.h"
9#include <QFileSystemModel>
11#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
12 #include <QMediaDevices>
13 #include <QAudioDevice>
15 #include <QAudioDeviceInfo>
18#include "DlgDesktopSize.h"
19#include <QLoggingCategory>
20static Q_LOGGING_CATEGORY(log,
"FreeRDP.Parameter.Dlg")
25 , m_pSettings(pSettings)
26 , m_pFileModel(
nullptr)
28 , m_pRecordUI(
nullptr)
30 setAttribute(Qt::WA_DeleteOnClose);
33 ui->leName->setText(m_pSettings->GetName());
36 ui->leDomain->setText(m_pSettings->GetDomain());
37 ui->wNet->SetParameter(&m_pSettings->m_Net);
39 ui->cbOnlyView->setChecked(m_pSettings->GetOnlyView());
40 ui->cbClipboard->setChecked(m_pSettings->GetClipboard());
41 ui->cbShowServerName->setChecked(m_pSettings->GetShowServerName());
44 m_pProxyUI->SetParameter(&m_pSettings->m_Proxy);
45 ui->tabWidget->insertTab(1, m_pProxyUI, m_pProxyUI->windowIcon(), tr(
"Proxy"));
48 m_pRecordUI->SetParameter(&m_pSettings->m_Record);
49 ui->tabWidget->addTab(m_pRecordUI, m_pRecordUI->windowIcon(), tr(
"Record"));
53 ui->cbAllMonitor->setChecked(m_pSettings->GetUseMultimon());
55 int width = GetScreenGeometry().width();
56 int height = GetScreenGeometry().height();
57 QString curSize = QString::number(width) +
"×" + QString::number(height);
58 UINT32 desktopWidth = 0, desktopHeight = 0;
59 desktopWidth = m_pSettings->GetDesktopWidth();
60 desktopHeight = m_pSettings->GetDesktopHeight();
61 if(width == desktopWidth && height == desktopHeight)
63 ui->rbLocalScreen->setChecked(
true);
64 ui->cbDesktopSize->setCurrentText(curSize);
66 ui->rbSelect->setChecked(
true);
67 curSize = QString::number(desktopWidth)
68 +
"×" + QString::number(desktopHeight);
69 ui->cbDesktopSize->setCurrentText(curSize);
72 ui->cbColorDepth->addItem(tr(
"8 bits"), 8);
73 ui->cbColorDepth->addItem(tr(
"16 bits"), 16);
74 ui->cbColorDepth->addItem(tr(
"24 bits"), 24);
75 ui->cbColorDepth->addItem(tr(
"32 bits"), 32);
76 int nIndex = ui->cbColorDepth->findData(
77 m_pSettings->GetColorDepth());
79 ui->cbColorDepth->setCurrentIndex(nIndex);
81 ui->sbReconnect->setValue(m_pSettings->GetReconnectInterval());
84 ui->cbPrinter->setChecked(m_pSettings->GetRedirectionPrinter());
87 ui->gbAudio->setEnabled(HasAudioOutput() || HasAudioInput());
88 if(m_pSettings->GetRedirectionSound() == CParameterFreeRDP::RedirecionSoundType::Disable)
89 ui->rbAudioDisable->setChecked(
true);
90 if(m_pSettings->GetRedirectionSound() == CParameterFreeRDP::RedirecionSoundType::Local)
91 ui->rbAudioLocal->setChecked(
true);
92 if(m_pSettings->GetRedirectionSound() == CParameterFreeRDP::RedirecionSoundType::Remote)
93 ui->rbAudioRemote->setChecked(
true);
94 QString szRdpSndParameters
95 = tr(
"- [sys:<sys>,][dev:<dev>,][format:<format>,][rate:<rate>,][channel:<channel>]\n"
96 #
if defined (Q_OS_WINDOWS) || defined(Q_OS_WIN) || defined(Q_OS_WIN32) || defined(Q_OS_WINRT)
98 #elif defined(Q_OS_IOS)
101 #elif defined (Q_OS_ANDROID)
103 #elif defined (Q_OS_LINUX) || defined (Q_OS_UNIX)
106 "- sys:oss,dev:1,format:1\n"
110 QString szRdpSnd = tr(
"Options for redirection of audio output:\n") + szRdpSndParameters;
111 ui->leRdpSnd->setToolTip(szRdpSnd);
112 ui->leRdpSnd->setStatusTip(szRdpSnd);
113 ui->leRdpSnd->setWhatsThis(szRdpSnd);
114 ui->leRdpSnd->setEnabled(HasAudioOutput());
115 ui->leRdpSnd->setText(m_pSettings->GetRedirectionSoundParameters());
117 QString szAudin = tr(
"Options for redirection of audio input:\n") + szRdpSndParameters;
118 ui->leAudin->setToolTip(szAudin);
119 ui->leAudin->setStatusTip(szAudin);
120 ui->leAudin->setWhatsThis(szAudin);
121 ui->leAudin->setText(m_pSettings->GetRedirectionMicrophoneParameters());
122 if(HasAudioInput()) {
123 ui->cbAudin->setChecked(m_pSettings->GetRedirectionMicrophone());
125 ui->cbAudin->setChecked(
false);
126 ui->cbAudin->setEnabled(
false);
127 ui->leAudin->setEnabled(
false);
131 m_pFileModel=
new QFileSystemModel();
132 m_pFileModel->setNameFilterDisables(
false);
133 m_pFileModel->setFilter(QDir::Drives | QDir::Dirs | QDir::NoDotAndDotDot);
134 m_pFileModel->setRootPath(
"");
135 ui->tvDrive->setModel(m_pFileModel);
136 ui->tvDrive->setEditTriggers(QAbstractItemView::NoEditTriggers);
137 int count = m_pFileModel->columnCount();
138 for(
int i = 1; i < count; i++)
139 ui->tvDrive->hideColumn(i);
140 bool check = connect(ui->tvDrive->selectionModel(),
141 SIGNAL(selectionChanged(
const QItemSelection &,
142 const QItemSelection &)),
144 SLOT(slotSelectionChanged(QItemSelection,QItemSelection)));
146 QStringList lstDrives = m_pSettings->GetRedirectionDrives();
147 foreach(
auto path, lstDrives)
150 if(!path.isEmpty()) {
151 index = m_pFileModel->index(path);
152 ui->tvDrive->setCurrentIndex(index);
155 ShowDriveSelected(lstDrives.size());
158CDlgSetFreeRDP::~CDlgSetFreeRDP()
163void CDlgSetFreeRDP::on_pbOk_clicked()
167 if(!ui->wNet->CheckValidity(
true)) {
168 ui->tabWidget->setCurrentIndex(0);
172 ui->tabWidget->setCurrentWidget(m_pProxyUI);
176 ui->tabWidget->setCurrentWidget(m_pRecordUI);
180 m_pSettings->SetName(ui->leName->text());
183 m_pSettings->SetDomain(ui->leDomain->text());
184 nRet = ui->wNet->Accept();
187 nRet = m_pProxyUI->
Accept();
190 nRet = m_pRecordUI->Accept();
193 m_pSettings->SetOnlyView(ui->cbOnlyView->isChecked());
194 m_pSettings->SetClipboard(ui->cbClipboard->isChecked());
195 m_pSettings->SetShowServerName(ui->cbShowServerName->isChecked());
198 m_pSettings->SetUseMultimon(ui->cbAllMonitor->isChecked());
199 QString szSize = ui->cbDesktopSize->currentText();
200 int index = szSize.indexOf(
"×");
203 UINT32 width = szSize.left(index).toInt();
204 UINT32 height = szSize.right(szSize.length() - index - 1).toInt();
205 m_pSettings->SetDesktopWidth(width);
206 m_pSettings->SetDesktopHeight(height);
208 m_pSettings->SetColorDepth(ui->cbColorDepth->currentData().toInt());
209 m_pSettings->SetReconnectInterval(ui->sbReconnect->value());
212 m_pSettings->SetRedirectionPrinter(ui->cbPrinter->isChecked());
213 if(HasAudioOutput()) {
214 CParameterFreeRDP::RedirecionSoundType tRdirectionSound
215 = CParameterFreeRDP::RedirecionSoundType::Disable;
216 if(ui->rbAudioDisable->isChecked())
217 tRdirectionSound = CParameterFreeRDP::RedirecionSoundType::Disable;
218 else if(ui->rbAudioLocal->isChecked())
219 tRdirectionSound = CParameterFreeRDP::RedirecionSoundType::Local;
220 else if(ui->rbAudioRemote->isChecked())
221 tRdirectionSound = CParameterFreeRDP::RedirecionSoundType::Remote;
222 m_pSettings->SetRedirectionSound(tRdirectionSound);
224 m_pSettings->SetRedirectionSound(
225 CParameterFreeRDP::RedirecionSoundType::Disable);
227 m_pSettings->SetRedirectionSoundParameters(ui->leRdpSnd->text());
229 m_pSettings->SetRedirectionMicrophone(ui->cbAudin->isChecked());
231 m_pSettings->SetRedirectionMicrophone(
false);
232 m_pSettings->SetRedirectionMicrophoneParameters(ui->leAudin->text());
234 QStringList lstDrives;
236 QModelIndexList selected = ui->tvDrive->selectionModel()->selectedRows(0);
237 QList<QModelIndex>::iterator it;
238 QModelIndex modelIndex;
240 for (it = selected.begin(); it != selected.end(); ++it)
243 szPath = m_pFileModel->filePath(modelIndex);
244 if(!szPath.isEmpty())
245 lstDrives.append(szPath);
247 m_pSettings->SetRedirectionDrives(lstDrives);
252void CDlgSetFreeRDP::on_pbCancel_clicked()
257void CDlgSetFreeRDP::on_rbLocalScreen_clicked(
bool checked)
260 int width = GetScreenGeometry().width();
261 int height = GetScreenGeometry().height();
262 QString curSize = QString::number(width) +
"×" + QString::number(height);
263 ui->rbLocalScreen->setText(tr(
"Local screen") +
": " + curSize);
264 if(ui->cbDesktopSize->findText(curSize) == -1)
265 InsertDesktopSize(width, height);
266 ui->cbDesktopSize->setCurrentText(curSize);
269QRect CDlgSetFreeRDP::GetScreenGeometry()
272 QScreen* pScreen = QApplication::primaryScreen();
273 if(ui->cbAllMonitor->isChecked())
276 r = pScreen->virtualGeometry();
292 r = pScreen->geometry();
297int CDlgSetFreeRDP::UpdateDesktopSize()
299 ui->cbDesktopSize->clear();
300 QStringList lstDesktopSizes;
301 lstDesktopSizes <<
"640×480"
318 ui->cbDesktopSize->addItems(lstDesktopSizes);
320 int width = GetScreenGeometry().width();
321 int height = GetScreenGeometry().height();
322 QString curSize = QString::number(width) +
"×" + QString::number(height);
323 ui->rbLocalScreen->setText(tr(
"Local screen") +
": " + curSize);
324 if(ui->cbDesktopSize->findText(curSize) == -1)
325 InsertDesktopSize(width, height);
329int CDlgSetFreeRDP::InsertDesktopSize(QString szSize)
332 int nIndex = szSize.indexOf(
"×");
336 w = szSize.left(nIndex).toInt(&ok);
338 h = szSize.right(szSize.length() - nIndex - 1).toInt(&ok);
342 return InsertDesktopSize(w, h);
345int CDlgSetFreeRDP::InsertDesktopSize(
int width,
int height)
347 QString curSize = QString::number(width) +
"×" + QString::number(height);
348 if(ui->cbDesktopSize->findText(curSize) > -1)
351 int nCount = ui->cbDesktopSize->count();
352 for(
int i = 0; i < nCount; i++)
354 QString curText = ui->cbDesktopSize->itemText(i);
355 int nIndex = curText.indexOf(
"×");
358 int w = curText.left(nIndex).toInt();
359 int h = curText.right(curText.length() - nIndex - 1).toInt();
362 ui->cbDesktopSize->insertItem(i, curSize);
364 }
else if(w == width) {
367 ui->cbDesktopSize->insertItem(i, curSize);
374 QString curText = ui->cbDesktopSize->itemText(j);
375 int nIndex = curText.indexOf(
"×");
379 int w = curText.left(nIndex).toInt();
380 int h = curText.right(curText.length() - nIndex - 1).toInt();
382 ui->cbDesktopSize->insertItem(j, curSize);
387 ui->cbDesktopSize->insertItem(j, curSize);
389 }
else if(h == height)
401 if(ui->cbDesktopSize->findText(curSize) == -1)
402 ui->cbDesktopSize->addItem(curSize);
408void CDlgSetFreeRDP::on_rbAudioDisable_toggled(
bool checked)
410 ui->leRdpSnd->setEnabled(!checked);
413void CDlgSetFreeRDP::on_rbAudioLocal_toggled(
bool checked)
415 ui->leRdpSnd->setEnabled(checked);
418void CDlgSetFreeRDP::on_rbAudioRemote_toggled(
bool checked)
420 ui->leRdpSnd->setEnabled(!checked);
421 ui->leAudin->setEnabled(!checked);
422 ui->cbAudin->setEnabled(!checked);
425bool CDlgSetFreeRDP::HasAudioOutput()
427#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
428 auto d = QMediaDevices::defaultAudioOutput();
431 return !QAudioDeviceInfo::defaultOutputDevice().isNull();
435bool CDlgSetFreeRDP::HasAudioInput()
437#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
438 auto d = QMediaDevices::defaultAudioInput();
441 return !QAudioDeviceInfo::defaultInputDevice().isNull();
445void CDlgSetFreeRDP::on_pbSizeEdit_clicked()
449 for(
int i = 0; i < ui->cbDesktopSize->count(); i++)
450 lstSize << ui->cbDesktopSize->itemText(i);
451 dlg.SetDesktopSizes(lstSize);
452 if(QDialog::Accepted == dlg.exec())
454 ui->cbDesktopSize->clear();
455 foreach(
auto s, dlg.GetDesktopSize())
457 InsertDesktopSize(s);
462void CDlgSetFreeRDP::on_pbDriveClearAll_clicked()
464 ui->tvDrive->clearSelection();
465 ShowDriveSelected(0);
468void CDlgSetFreeRDP::slotSelectionChanged(
const QItemSelection &selected,
469 const QItemSelection &deselected)
471 QModelIndexList s = ui->tvDrive->selectionModel()->selectedRows(0);
472 ShowDriveSelected(s.size());
475int CDlgSetFreeRDP::ShowDriveSelected(
int counts)
477 ui->lbDriveSelected->setText(tr(
"Selected counts: ") + QString::number(counts));
481void CDlgSetFreeRDP::on_cbAllMonitor_stateChanged(
int arg1)
483 on_rbLocalScreen_clicked(
true);
[Declare CParameterFreeRDP]
bool CheckValidity(bool validity=false)
Check parameters validity.
int Accept()
Accept parameters.
virtual bool CheckValidity(bool validity=false)
Check parameters validity.