#include "mainwindow.h" #include "ui_mainwindow.h" #include #include #include #include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->hostip->setText("www.forlinx.com"); setWindowState(Qt::WindowMaximized); setWindowFlags(Qt::FramelessWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); GlobalInit(); ui->hostip->installEventFilter(this); myprocess = new QProcess(this); connect(myprocess, SIGNAL(readyReadStandardOutput()),this, SLOT(result())); connect(myprocess, SIGNAL(readyReadStandardError()),this, SLOT(result())); ping_process = new QProcess(this); connect(ping_process, SIGNAL(readyReadStandardOutput()),this, SLOT(ping_result())); connect(ping_process, SIGNAL(readyReadStandardError()),this, SLOT(ping_result())); connect(ui->exitBtn, &QPushButton::clicked, this, [=](){ close(); }); } MainWindow::~MainWindow() { delete ui; } bool MainWindow::eventFilter(QObject *watched, QEvent *event) { static bool mFocusIn = false; if (event->type()==QEvent::FocusIn) { mFocusIn = true; } else if (event->type()==QEvent::FocusOut) { PlatformInputContextBase->FocusOut(watched); mFocusIn = false; } if (mFocusIn && event->type() == QEvent::MouseButtonPress) { QMouseEvent *e = (QMouseEvent *)event; PlatformInputContextBase->FocusIn(watched, e->globalPos()); } return QMainWindow::eventFilter(watched,event); } void MainWindow::result() { QString abc = myprocess->readAllStandardOutput(); if(abc.length()>1)ui->result->append(abc.trimmed()); QString efg = myprocess->readAllStandardError(); if(efg.length()>1)ui->result->append(efg.trimmed()); } void MainWindow::ping_result() { QString abc = ping_process->readAllStandardOutput(); if(abc.length()>1)ui->result->append(abc.trimmed()); QString efg = ping_process->readAllStandardError(); if(efg.length()>1)ui->result->append(efg.trimmed()); } void MainWindow::on_connect_clicked() { ui->result->clear(); if (ui->comboBox->currentText() == "ME909"){ // if (myprocess->state() == QProcess::NotRunning) myprocess->start("/usr/bin/fltest_ec20.sh &"); } else{ // if (myprocess->state() == QProcess::NotRunning) myprocess->start("/usr/bin/quectelCM &"); } } void MainWindow::on_ping_clicked() { ui->result->clear(); if(ui->hostip->text() == QString("")) { QMessageBox::about(this,"error","hostname cannot be empty!"); return; } if (ping_process->state() == QProcess::NotRunning){ ping_process->start(QString("ping -I usb0 -c 5 ")+ui->hostip->text()); ui->result->append(QString("ping -I usb0 -c 5 ")+ui->hostip->text()); } }