diff --git a/FileTrans b/FileTrans index 47ba68c..dc6fc8f 100644 Binary files a/FileTrans and b/FileTrans differ diff --git a/mainwindow.cpp b/mainwindow.cpp index 7c220c8..66b4f5e 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -200,6 +200,31 @@ void MainWindow::on_pushButton_send_pressed() }); } +void MainWindow::on_pushButton_open_pressed() +{ + QString s = ui->lineEdit_message->text(); + if (s == "") + return; + qint64 port = ui->lineEdit_port->text().toInt(); + QTcpSocket *tcpSocket1 = new QTcpSocket(this); + connect(tcpSocket1, QOverload::of(&QAbstractSocket::error), [=](QAbstractSocket::SocketError socketError){ + qDebug() << socketError; + QMetaEnum metaEnum = QMetaEnum::fromType(); + QString errorString = metaEnum.valueToKey(socketError); + ui->textBrowser->append("[" + QDateTime::currentDateTime().toString("HH:mm:ss") + "] " + errorString); + }); + tcpSocket1->connectToHost(QHostAddress(ui->lineEdit_ip->text()), port); + connect(tcpSocket1, &QTcpSocket::connected, [=](){ + QJsonObject JO; + JO.insert("type", "play"); + JO.insert("message", s); + QString s = QJsonDocument(JO).toJson(QJsonDocument::Compact); + tcpSocket1->write(s.toUtf8()); + tcpSocket1->close(); + ui->textBrowser->append("[" + QDateTime::currentDateTime().toString("HH:mm:ss") + "] open " + s); + }); +} + void MainWindow::on_pushButton_capture_pressed() { qint64 port = ui->lineEdit_port->text().toInt(); diff --git a/mainwindow.h b/mainwindow.h index d355c0b..9b7945d 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -55,6 +55,7 @@ private slots: void newConnect(); void readyRead(); void on_pushButton_send_pressed(); + void on_pushButton_open_pressed(); void on_pushButton_capture_pressed(); }; diff --git a/mainwindow.ui b/mainwindow.ui index a6bfef5..3cddfe9 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -30,6 +30,49 @@ + + + + 发送 + + + false + + + + + + + 本机 + + + Qt::AlignCenter + + + + + + + 根目录 + + + Qt::AlignCenter + + + + + + + Port + + + Qt::AlignCenter + + + + + + @@ -50,17 +93,24 @@ - - + + - 根目录 + - - Qt::AlignCenter + + - + + + + false + + + + false @@ -70,60 +120,20 @@ - + ip:port - - - - Port - - - Qt::AlignCenter - - - - + false - - - - 本机 - - - Qt::AlignCenter - - - - - - - - - - 发送 - - - false - - - - - - - false - - - diff --git a/preview.png b/preview.png index 36250fe..7afcbe6 100644 Binary files a/preview.png and b/preview.png differ