修改了设备类返回名字的方法,返回时加上了能否充值的信息。修改对应的调用代码。

This commit is contained in:
Jingfan Ke 2024-07-29 00:41:15 +08:00
parent 6cca0535bc
commit f229cd4a28
2 changed files with 5 additions and 7 deletions

View File

@ -43,7 +43,10 @@ public:
QString getName() QString getName()
{ {
if (connected) return name; if (connected) {
if (depositAllowed) return name + QString("(可充值)");
else return name + QString("(仅可消费)");
}
else return QString("未指定设备名"); else return QString("未指定设备名");
} }
}; };

View File

@ -88,13 +88,8 @@ void MainWindow::on_connectDatabaseButton_clicked()
if (!device.is_connected()) if (!device.is_connected())
{ {
QMessageBox::warning(this, QString("设备名提示"), QString("该设备名无效,请重试。")); QMessageBox::warning(this, QString("设备名提示"), QString("该设备名无效,请重试。"));
}
deviceLabel->setText(device.getName()); deviceLabel->setText(device.getName());
}
else
{
if (device.is_depositAllowed()) deviceLabel->setText(device.getName() + QString("(可充值)"));
else deviceLabel->setText(device.getName() + QString("(仅可消费)"));
}
} }