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

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>331</width>
<height>289</height>
<height>418</height>
</rect>
</property>
<property name="windowTitle">
@@ -60,10 +60,21 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3"/>
<widget class="QListView" name="listView"/>
</item>
<item>
<widget class="QListView" name="listView"/>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>OwnID:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="edOwnID"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">