mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-13 13:22:22 +08:00
ui: change sidebar font to Inter (#24931)
* change sidebar to inter * clean up metric color rect radius * fix text placement * simplify rect placement old-commit-hash: 963de402115a4eb8eb7944c5f5233e47dea31543
This commit is contained in:
+23
-16
@@ -4,13 +4,13 @@
|
||||
|
||||
#include "selfdrive/ui/qt/util.h"
|
||||
|
||||
void Sidebar::drawMetric(QPainter &p, const QString &label, QColor c, int y) {
|
||||
const QRect rect = {30, y, 240, label.contains("\n") ? 124 : 100};
|
||||
void Sidebar::drawMetric(QPainter &p, const QPair<QString, QString> &label, QColor c, int y) {
|
||||
const QRect rect = {30, y, 240, 126};
|
||||
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(QBrush(c));
|
||||
p.setClipRect(rect.x() + 6, rect.y(), 18, rect.height(), Qt::ClipOperation::ReplaceClip);
|
||||
p.drawRoundedRect(QRect(rect.x() + 6, rect.y() + 6, 100, rect.height() - 12), 10, 10);
|
||||
p.setClipRect(rect.x() + 4, rect.y(), 18, rect.height(), Qt::ClipOperation::ReplaceClip);
|
||||
p.drawRoundedRect(QRect(rect.x() + 4, rect.y() + 4, 100, 118), 18, 18);
|
||||
p.setClipping(false);
|
||||
|
||||
QPen pen = QPen(QColor(0xff, 0xff, 0xff, 0x55));
|
||||
@@ -20,9 +20,16 @@ void Sidebar::drawMetric(QPainter &p, const QString &label, QColor c, int y) {
|
||||
p.drawRoundedRect(rect, 20, 20);
|
||||
|
||||
p.setPen(QColor(0xff, 0xff, 0xff));
|
||||
configFont(p, "Open Sans", 35, "Bold");
|
||||
const QRect r = QRect(rect.x() + 30, rect.y(), rect.width() - 40, rect.height());
|
||||
p.drawText(r, Qt::AlignCenter, label);
|
||||
configFont(p, "Inter", 35, "SemiBold");
|
||||
|
||||
QRect label_rect = getTextRect(p, Qt::AlignCenter, label.first);
|
||||
label_rect.setWidth(218);
|
||||
label_rect.moveLeft(rect.left() + 22);
|
||||
label_rect.moveTop(rect.top() + 19);
|
||||
p.drawText(label_rect, Qt::AlignCenter, label.first);
|
||||
|
||||
label_rect.moveTop(rect.top() + 65);
|
||||
p.drawText(label_rect, Qt::AlignCenter, label.second);
|
||||
}
|
||||
|
||||
Sidebar::Sidebar(QWidget *parent) : QFrame(parent) {
|
||||
@@ -57,26 +64,26 @@ void Sidebar::updateState(const UIState &s) {
|
||||
ItemStatus connectStatus;
|
||||
auto last_ping = deviceState.getLastAthenaPingTime();
|
||||
if (last_ping == 0) {
|
||||
connectStatus = ItemStatus{"CONNECT\nOFFLINE", warning_color};
|
||||
connectStatus = ItemStatus{{"CONNECT", "OFFLINE"}, warning_color};
|
||||
} else {
|
||||
connectStatus = nanos_since_boot() - last_ping < 80e9 ? ItemStatus{"CONNECT\nONLINE", good_color} : ItemStatus{"CONNECT\nERROR", danger_color};
|
||||
connectStatus = nanos_since_boot() - last_ping < 80e9 ? ItemStatus{{"CONNECT", "ONLINE"}, good_color} : ItemStatus{{"CONNECT", "ERROR"}, danger_color};
|
||||
}
|
||||
setProperty("connectStatus", QVariant::fromValue(connectStatus));
|
||||
|
||||
ItemStatus tempStatus = {"TEMP\nHIGH", danger_color};
|
||||
ItemStatus tempStatus = {{"TEMP", "HIGH"}, danger_color};
|
||||
auto ts = deviceState.getThermalStatus();
|
||||
if (ts == cereal::DeviceState::ThermalStatus::GREEN) {
|
||||
tempStatus = {"TEMP\nGOOD", good_color};
|
||||
tempStatus = {{"TEMP", "GOOD"}, good_color};
|
||||
} else if (ts == cereal::DeviceState::ThermalStatus::YELLOW) {
|
||||
tempStatus = {"TEMP\nOK", warning_color};
|
||||
tempStatus = {{"TEMP", "OK"}, warning_color};
|
||||
}
|
||||
setProperty("tempStatus", QVariant::fromValue(tempStatus));
|
||||
|
||||
ItemStatus pandaStatus = {"VEHICLE\nONLINE", good_color};
|
||||
ItemStatus pandaStatus = {{"VEHICLE", "ONLINE"}, good_color};
|
||||
if (s.scene.pandaType == cereal::PandaState::PandaType::UNKNOWN) {
|
||||
pandaStatus = {"NO\nPANDA", danger_color};
|
||||
pandaStatus = {{"NO", "PANDA"}, danger_color};
|
||||
} else if (s.scene.started && !sm["liveLocationKalman"].getLiveLocationKalman().getGpsOK()) {
|
||||
pandaStatus = {"GPS\nSEARCH", warning_color};
|
||||
pandaStatus = {{"GPS", "SEARCH"}, warning_color};
|
||||
}
|
||||
setProperty("pandaStatus", QVariant::fromValue(pandaStatus));
|
||||
}
|
||||
@@ -103,7 +110,7 @@ void Sidebar::paintEvent(QPaintEvent *event) {
|
||||
x += 37;
|
||||
}
|
||||
|
||||
configFont(p, "Open Sans", 35, "Regular");
|
||||
configFont(p, "Inter", 35, "Regular");
|
||||
p.setPen(QColor(0xff, 0xff, 0xff));
|
||||
const QRect r = QRect(50, 247, 100, 50);
|
||||
p.drawText(r, Qt::AlignCenter, net_type);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "common/params.h"
|
||||
#include "selfdrive/ui/ui.h"
|
||||
|
||||
typedef QPair<QString, QColor> ItemStatus;
|
||||
typedef QPair<QPair<QString, QString>, QColor> ItemStatus;
|
||||
Q_DECLARE_METATYPE(ItemStatus);
|
||||
|
||||
class Sidebar : public QFrame {
|
||||
@@ -30,7 +30,7 @@ public slots:
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void drawMetric(QPainter &p, const QString &label, QColor c, int y);
|
||||
void drawMetric(QPainter &p, const QPair<QString, QString> &label, QColor c, int y);
|
||||
|
||||
QPixmap home_img, settings_img;
|
||||
const QMap<cereal::DeviceState::NetworkType, QString> network_type = {
|
||||
|
||||
Reference in New Issue
Block a user