diff --git a/pcscreenmanage/pcscreenmanage.cpp b/pcscreenmanage/pcscreenmanage.cpp index 4865b3c..e305fa1 100644 --- a/pcscreenmanage/pcscreenmanage.cpp +++ b/pcscreenmanage/pcscreenmanage.cpp @@ -85,9 +85,6 @@ void PcScreenManage::connectService(const QString host, PcScreenManage::DeviceTy void PcScreenManage::setConnectionRespond(bool isAgree) { if (isAgree) { - m_messageTcpSocket = m_tcpServer->nextPendingConnection(); - connect(m_messageTcpSocket, &QTcpSocket::readyRead, this, &PcScreenManage::onMessageReadyRead); - connect(m_messageTcpSocket, &QTcpSocket::disconnected, this, &PcScreenManage::slotSocketDisconnect); quint32 addrOrigin = m_messageTcpSocket->peerAddress().toIPv4Address(); QHostAddress addrHost = QHostAddress(addrOrigin); m_address = addrHost.toString(); @@ -95,6 +92,7 @@ void PcScreenManage::setConnectionRespond(bool isAgree) qInfo() << "Remote host " + m_address + " connected!"; } else { // 拒绝 + qInfo() << "The current connection request has been rejected!"; ScreenManageMsg message; message.set_msg(ScreenManageMsg::REFUSE); sendMessage(message); @@ -255,6 +253,9 @@ void PcScreenManage::slotServerNewConnection() qWarning() << "The current screen projection service is already connected!"; return; } + m_messageTcpSocket = m_tcpServer->nextPendingConnection(); + connect(m_messageTcpSocket, &QTcpSocket::readyRead, this, &PcScreenManage::onMessageReadyRead); + connect(m_messageTcpSocket, &QTcpSocket::disconnected, this, &PcScreenManage::slotSocketDisconnect); Q_EMIT sigRequestReceived(ScreenMsg::SharingRequest); } diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index 511ddea..1685149 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -1023,8 +1023,8 @@ void MainWindow::slotConnectRequest(QString deviceName) void MainWindow::slotConnectDenied() { deleterDialog(); - QString str1 = QString(tr("The other party has refused your screen projection request!")); - QString str2 = QString(tr("Failed to cast the screen. Please contact the other party and try again.")); + QString str1 = QString(tr("The other party has rejected your connection request!")); + QString str2 = QString(tr("Connection failed. Please contact the other party and try again.")); m_messageBox = new MessageDialog(this); m_messageBox->setText(str1, str2); m_messageBox->setIconPixmap(QIcon::fromTheme("dialog-error")); @@ -1346,14 +1346,17 @@ void MainWindow::slotRequestReceived(PcScreenManage::ScreenMsg msg) m_messageBox = new MessageDialog(this); m_messageBox->setText(str1, str2); m_messageBox->setIconPixmap(QIcon::fromTheme("dialog-error")); - QPushButton *againBtn = m_messageBox->addButton(QString(tr("Again"))); - QPushButton *closeBtn = m_messageBox->addButton(QString(tr("Close"))); + QPushButton *againBtn = m_messageBox->addButton(QString(tr("RECONNECT"))); + QPushButton *closeBtn = m_messageBox->addButton(QString(tr("CLOSE"))); connect(m_messageBox, &MessageDialog::buttonClicked, this, [=](QPushButton *btn) { if (againBtn == btn) { // 重新连接 m_pcScreen->connectService(m_connectInfo.address); + } else { + m_connectedWin->restoreScreenButton(); } }); + connect(m_messageBox, &MessageDialog::sigClose, this, [=]() { m_connectedWin->restoreScreenButton(); }); moveMessageBox(); } break; case PcScreenManage::ScreenMsg::Successfully: {