#include "mainwindow.h" #include "ui_mainwindow.h" #include #include #include #include #include void MainWindow::GetDefault(){ QScreen *screen = QGuiApplication::primaryScreen(); QRect geometry = screen->geometry(); int screenWidth = geometry.width(); int screenHeight = geometry.height(); QString current= QString("%1x%2").arg(screenWidth).arg(screenHeight); int idx = ui->resolution_comboBox->findText(current); if(idx >= 0){ ui->resolution_comboBox->setCurrentIndex(idx); }else{ ui->resolution_comboBox->insertItem(0,current); ui->resolution_comboBox->setCurrentIndex(0); } QProcess process; process.start("xfreerdp --help"); process.waitForFinished(); QByteArray output = process.readAllStandardOutput(); if (process.exitCode() != 0) { ui->textBrowser->setText("You need to install xfreerdp!"); QMessageBox::warning(this,"NOT FOUND XFREERDP", "You need to install xfreerdp!",QMessageBox::Yes); exit(0); }else{ ui->textBrowser->setText(QString::fromLocal8Bit(output).trimmed()); } } MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); ui->port_text->setValidator(new QRegExpValidator(QRegExp("[0-9]{5}"))); GetDefault(); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_cancel_button_clicked() { exit(0); } void MainWindow::on_connect_button_clicked() { QString host = ui->host_text->text(); QString port = ui->port_text->text(); QString domain = ui->domain_text->text(); QString username = ui->username_text->text(); QString password = ui->password_text->text(); QString resolution = ui->resolution_comboBox->currentText(); QString bpp = ui->bpp_comboBox->currentText(); QString network= ui->network_comboBox->currentText(); QString audio_mode= ui->audio_comboBox->currentText(); bool full_screen = ui->full_screen_box->isChecked(); bool dynamic_resolution = ui->dynamic_resolution_box->isChecked(); bool compression = ui->compression_box->isChecked(); bool glyph_cache = ui->glyph_cache_box->isChecked(); bool bitmap_cache = ui->bitmap_cache_box->isChecked(); bool async_input = ui->async_input_box->isChecked(); bool async_update = ui->async_update_box->isChecked(); QString shared_directory_name_text = ui->shared_directory_name_text->text(); QString share_directory_text = ui->share_directory_text->text(); QString other_options_text = ui->other_options_text->toPlainText(); QString exec_command = ""; exec_command += QString("/v:'%1':%2").arg(host).arg(port); exec_command += domain!="" ? QString(" /d:'%1'").arg(domain) :"" ; exec_command += QString(" /u:'%1'").arg(username); exec_command += QString(" /p:'%1'").arg(password); exec_command += QString(" /size:%1").arg(resolution); exec_command += QString(" /bpp:%1").arg(bpp); exec_command += QString(" /network:%1").arg(network); exec_command += QString(" /audio-mode:%1").arg(audio_mode); exec_command += full_screen ? " /f" : ""; exec_command += dynamic_resolution ? " /dynamic-resolution" : ""; exec_command += compression ? " /compression" : ""; exec_command += glyph_cache ? " +glyph-cache" : ""; exec_command += bitmap_cache ? " /bitmap-cache" : ""; exec_command += async_input ? " /async-input" : ""; exec_command += async_update ? " /async-update" : ""; exec_command += (!shared_directory_name_text.isEmpty() && !share_directory_text.isEmpty()) ? QString(" /drive:%1,%2").arg(shared_directory_name_text).arg(share_directory_text) : ""; exec_command += QString(" %1").arg(other_options_text); QString command = QString("xfreerdp %1").arg(exec_command); qDebug()<