ownid:show own id with color.

This commit is contained in:
2025-10-20 17:12:39 +08:00
parent 0c4c5ff4de
commit e74bdf2aea
2 changed files with 23 additions and 3 deletions

View File

@@ -51,6 +51,7 @@ void Connecter::RunWorker(ClientCore* clientCore)
}
ui->elbClient->clear();
clientCore_->SetRemoteID("");
ui->edOwnID->setText("");
qInfo() << QString(tr("Disconnected."));
});
connect(clientCore_, &ClientCore::sigOffline, this, [this]() {
@@ -78,6 +79,9 @@ void Connecter::HandleClients(const InfoClientVec& clients)
model_->removeRows(0, ui->listView->model()->rowCount());
for (const auto& client : clients.vec) {
auto* item = new QStandardItem(client.id);
if (client.id == GlobalData::Ins()->GetLocalID()) {
item->setForeground(QColor("red"));
}
model_->appendRow(item);
}
}
@@ -117,6 +121,7 @@ void Connecter::setState(ConnectState cs)
ui->btnConnect->setEnabled(false);
ui->btnDisconnect->setEnabled(true);
RefreshClient();
ui->edOwnID->setText(GlobalData::Ins()->GetLocalID());
connect(heatBeat_, &HeatBeat::finished, heatBeat_, &QObject::deleteLater);
break;
case CS_DISCONNECT:
@@ -165,6 +170,10 @@ std::string Connecter::getCurClient()
void Connecter::InitControl()
{
ui->edOwnID->setReadOnly(true);
ui->label->setStyleSheet("color: blue;");
ui->edOwnID->setStyleSheet("color: blue;");
ui->btnDisconnect->setEnabled(false);
ui->comboBox->setEditable(true);