mainwindow.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. #include "akWorker.h"
  4. #include "../../airkiss.h"
  5. #include <QFileDialog>
  6. MainWindow::MainWindow(QWidget *parent) :
  7. QMainWindow(parent),
  8. ui(new Ui::MainWindow)
  9. {
  10. ui->setupUi(this);
  11. wk = 0;
  12. }
  13. MainWindow::~MainWindow()
  14. {
  15. delete ui;
  16. }
  17. void MainWindow::showMsg(QString m)
  18. {
  19. ui->peres->appendPlainText(m);
  20. }
  21. void MainWindow::workerExit()
  22. {
  23. if (wk)
  24. {
  25. QString str = "启动";
  26. ui->pbparese->setText(str);
  27. ui->pbst->setText(str);
  28. delete wk;
  29. wk = NULL;
  30. }
  31. }
  32. void MainWindow::on_pbst_clicked()
  33. {
  34. if (wk)
  35. {
  36. delete wk;
  37. wk = 0;
  38. ui->pbst->setText(QString("启动"));
  39. }
  40. else
  41. {
  42. wk = new akWorker;
  43. connect(wk, SIGNAL(showMsg(QString)),
  44. this, SLOT(showMsg(QString)));
  45. connect(wk, SIGNAL(finished()),
  46. this, SLOT(workerExit()));
  47. ui->peres->clear();
  48. wk->lenOut = ui->cblen->isChecked();
  49. wk->cmpExit = ui->cbcmpe->isChecked();
  50. wk->start("", ui->nossid->isChecked(), ui->sbport->value());
  51. ui->pbst->setText(QString("停止"));
  52. }
  53. }
  54. void MainWindow::on_pbparese_clicked()
  55. {
  56. QString file;
  57. file = ui->lepath->currentText();
  58. if (file.isEmpty())
  59. return;
  60. if (wk)
  61. {
  62. delete wk;
  63. wk = 0;
  64. ui->pbparese->setText(QString("启动"));
  65. }
  66. else
  67. {
  68. wk = new akWorker;
  69. connect(wk, SIGNAL(showMsg(QString)),
  70. this, SLOT(showMsg(QString)));
  71. connect(wk, SIGNAL(finished()),
  72. this, SLOT(workerExit()));
  73. wk->start(file);
  74. ui->pbparese->setText(QString("停止"));
  75. }
  76. }
  77. void MainWindow::on_pbpath_clicked()
  78. {
  79. QString dir;
  80. dir = QFileDialog::getOpenFileName(this, "选择文件", "./");
  81. if (!dir.isEmpty())
  82. {
  83. ui->lepath->setCurrentText(dir);
  84. }
  85. }
  86. void MainWindow::on_cblen_toggled(bool checked)
  87. {
  88. if (wk)
  89. wk->lenOut = checked;
  90. }
  91. void MainWindow::on_cbcmpe_toggled(bool checked)
  92. {
  93. if (wk)
  94. wk->cmpExit = checked;
  95. }