You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

maindialog.cpp 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #include <QApplication>
  2. #include <QDesktopWidget>
  3. #include <QDebug>
  4. #include "maindialog.h"
  5. #include "ui_maindialog.h"
  6. #include "rdpoptions.h"
  7. #include "rdesktoplauncher.h"
  8. MainDialog::MainDialog(QWidget *parent) :
  9. QDialog(parent),
  10. ui(new Ui::MainDialog)
  11. {
  12. ui->setupUi(this);
  13. connect(ui->lineComputer->lineEdit(), SIGNAL(returnPressed()), ui->btnConnect, SLOT(animateClick()));
  14. connect(ui->lineComputer->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)));
  15. computeResolutions();
  16. ui->lineComputer->setFocus();
  17. }
  18. MainDialog::~MainDialog()
  19. {
  20. delete ui;
  21. }
  22. void MainDialog::on_btnConnect_clicked()
  23. {
  24. RdpOptions opt;
  25. opt.setBitmapCache(ui->checkCacheBitmap->isChecked());
  26. opt.setExperience((RdpOptions::Experience)ui->comboExperience->currentIndex());
  27. opt.setFullescreen(ui->slidResolution->value() == m_resolutions.size());
  28. opt.setHost(ui->lineComputer->currentText());
  29. int meta = ui->comboMetaKeys->currentIndex();
  30. opt.setMetaKeys(meta == 0 || (opt.fullescreen() && meta == 2));
  31. opt.setPassword(ui->linePassword->text());
  32. opt.setResolution(m_resolutions.at(m_resolutions.size() - 1));
  33. opt.setUsername(ui->lineUsername->text());
  34. opt.setUseShell(ui->checkShell->isChecked());
  35. if (opt.useShell())
  36. {
  37. opt.setShell(ui->lineShellPath->text());
  38. opt.setShellWorkingDir(ui->lineShellWorkingDir->text());
  39. }
  40. int colors = ui->comboColors->currentIndex();
  41. RdpOptions::Colors c;
  42. if (colors == 0)
  43. c = RdpOptions::HighColor_15;
  44. else if (colors == 1)
  45. c = RdpOptions::HighColor_16;
  46. else if (colors == 2)
  47. c = RdpOptions::TrueColor;
  48. else if (colors == 3)
  49. c = RdpOptions::HighestQuality;
  50. opt.setColors(c);
  51. RDesktopLauncher launcher;
  52. launcher.start(opt);
  53. }
  54. void MainDialog::textChanged(QString)
  55. {
  56. ui->btnConnect->setEnabled(!ui->lineComputer->lineEdit()->text().isEmpty());
  57. }
  58. void MainDialog::computeResolutions()
  59. {
  60. m_resolutions.append(QApplication::desktop()->availableGeometry().size());
  61. ui->slidResolution->setMinimum(0);
  62. ui->slidResolution->setMaximum(m_resolutions.size());
  63. ui->slidResolution->setValue(m_resolutions.size());
  64. }
  65. void MainDialog::on_slidResolution_valueChanged(int value)
  66. {
  67. if (value < m_resolutions.size())
  68. {
  69. QSize reso = m_resolutions.at(value);
  70. ui->lblResolution->setText(QString("%1x%2").arg(reso.width()).arg(reso.height()));
  71. }
  72. else
  73. {
  74. ui->lblResolution->setText(tr("Plein écran"));
  75. }
  76. }