fix(Tray): 托盘传感器显示修改

This commit is contained in:
lidg
2026-11-09 18:16:54 +08:00
parent a8b2b31ce7
commit c248954b87
14 changed files with 170 additions and 51 deletions
+15 -10
View File
@@ -7,6 +7,7 @@ SquareTrayButton::SquareTrayButton(int trayIndex, int loadedCount, QWidget *pare
: QAbstractButton(parent)
, m_trayId(0)
, m_planned(false)
, m_sensorPresent(true)
{
setCheckable(true);
setCursor(Qt::PointingHandCursor);
@@ -14,16 +15,17 @@ SquareTrayButton::SquareTrayButton(int trayIndex, int loadedCount, QWidget *pare
}
void SquareTrayButton::setTrayInfo(int trayId, const QString &code, int loadedCount,
const QString &status, bool present)
const QString &status, bool databasePresent,
bool sensorPresent)
{
m_trayId = trayId;
m_sensorPresent = sensorPresent;
const QString displayCode = code.isEmpty() ? QString("托盘 %1").arg(trayId) : code;
const QString displayStatus = present ? status : "离位";
setText(QString("%1\n7 x 7\n%2 %3/49")
.arg(displayCode)
.arg(displayStatus)
.arg(loadedCount));
setEnabled(present);
setText(sensorPresent
? QString("%1\n7 x 7\n%2:%3/49")
.arg(displayCode).arg(status).arg(loadedCount)
: QString("%1\n7 x 7\n不在位:0/49").arg(displayCode));
setEnabled(databasePresent);
update();
}
@@ -51,11 +53,14 @@ void SquareTrayButton::paintEvent(QPaintEvent *event)
painter.setRenderHint(QPainter::Antialiasing, true);
const QRectF rect = QRectF(1, 1, width() - 2, height() - 2);
const QColor background = isChecked() ? QColor("#00897b")
const QColor background = !m_sensorPresent ? QColor("#90a4ae")
: isChecked() ? QColor("#00897b")
: m_planned ? QColor("#f9a825") : QColor("#eceff1");
const QColor border = isChecked() ? QColor("#004d40")
const QColor border = !m_sensorPresent ? QColor("#78909c")
: isChecked() ? QColor("#004d40")
: m_planned ? QColor("#ef6c00") : QColor("#b0bec5");
const QColor textColor = isChecked() ? QColor("#ffffff") : QColor("#263238");
const QColor textColor = !m_sensorPresent || isChecked()
? QColor("#ffffff") : QColor("#263238");
painter.setPen(QPen(border, 2));
painter.setBrush(background);