增加打开按钮
This commit is contained in:
parent
a2309b6572
commit
e496932138
|
@ -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<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), [=](QAbstractSocket::SocketError socketError){
|
||||
qDebug() << socketError;
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<QAbstractSocket::SocketError>();
|
||||
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();
|
||||
|
|
|
@ -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();
|
||||
|
||||
};
|
||||
|
|
106
mainwindow.ui
106
mainwindow.ui
|
@ -30,6 +30,49 @@
|
|||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="4" column="2">
|
||||
<widget class="QPushButton" name="pushButton_send">
|
||||
<property name="text">
|
||||
<string>发送</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>本机</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>根目录</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Port</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_message"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
|
@ -50,17 +93,24 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<item row="4" column="3">
|
||||
<widget class="QPushButton" name="pushButton_open">
|
||||
<property name="text">
|
||||
<string>根目录</string>
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<property name="icon">
|
||||
<iconset theme="media-playback-start"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<item row="1" column="1" colspan="3">
|
||||
<widget class="QLineEdit" name="lineEdit_ip">
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="3">
|
||||
<widget class="QLineEdit" name="lineEdit_port">
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
|
@ -70,60 +120,20 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<item row="0" column="1" colspan="3">
|
||||
<widget class="QLabel" name="label_local">
|
||||
<property name="text">
|
||||
<string>ip:port</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Port</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<item row="3" column="1" colspan="3">
|
||||
<widget class="QLineEdit" name="lineEdit_root_dir">
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>本机</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_message"/>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QPushButton" name="pushButton_send">
|
||||
<property name="text">
|
||||
<string>发送</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="lineEdit_ip">
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
|
BIN
preview.png
BIN
preview.png
Binary file not shown.
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 37 KiB |
Loading…
Reference in New Issue