🐞 fix(投屏模块): 修改投屏请求逻辑以及文案显示

173843 【单元测试】【多端协同】麒麟设备之间拒绝投屏时,对端无提示文案,并且后续同意投屏也无效,重启应用可恢复
This commit is contained in:
huheng@kylinos.cn 2023-06-05 10:45:39 +08:00
parent c1bb9b6e25
commit 45a6c5eb63
2 changed files with 11 additions and 7 deletions

View File

@ -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);
}

View File

@ -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: {