TightVNC launcher
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.

dialog.cpp 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*************************************************************************
  2. * Copyright (C) 2014 by Andrius Štikonas <andrius@stikonas.eu> *
  3. * *
  4. * This program is free software; you can redistribute it and/or modify *
  5. * it under the terms of the GNU General Public License as published by *
  6. * the Free Software Foundation; either version 3 of the License, or *
  7. * (at your option) any later version. *
  8. * *
  9. * This program is distributed in the hope that it will be useful, *
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  12. * GNU General Public License for more details. *
  13. * *
  14. * You should have received a copy of the GNU General Public License *
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.*
  16. *************************************************************************/
  17. #include <QFile>
  18. #include <QProcess>
  19. #include <QTextStream>
  20. #include "dialog.h"
  21. #include "ui_dialog.h"
  22. Dialog::Dialog(QWidget *parent) :
  23. QDialog(parent),
  24. ui(new Ui::Dialog)
  25. {
  26. ui->setupUi(this);
  27. QObject::connect(ui->buttonQuit, &QPushButton::clicked, this, &Dialog::reject);
  28. QObject::connect(ui->buttonStart, &QPushButton::clicked, this, &Dialog::connectToClients);
  29. }
  30. Dialog::~Dialog()
  31. {
  32. delete ui;
  33. }
  34. void Dialog::connectToClients()
  35. {
  36. QString line, command = QStringLiteral("tvnserver");
  37. if(connected)
  38. {
  39. QStringList arguments;
  40. arguments << QStringLiteral("-controlservice") << QStringLiteral("-disconnectall") << line;
  41. QProcess *process = new QProcess();
  42. process->start(command, arguments);
  43. connected = false;
  44. ui->buttonStart->setText(QStringLiteral("Start streaming"));
  45. return;
  46. }
  47. QFile file(QStringLiteral("clients.txt"));
  48. if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
  49. return;
  50. QTextStream in(&file);
  51. while (!in.atEnd()) {
  52. line = in.readLine();
  53. if (line != QString())
  54. {
  55. QStringList arguments;
  56. arguments << QStringLiteral("-controlservice") << QStringLiteral("-connect") << line;
  57. QProcess *process = new QProcess();
  58. process->start(command, arguments);
  59. }
  60. }
  61. connected = true;
  62. ui->buttonStart->setText(QStringLiteral("Disconnect"));
  63. return;
  64. }