mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-01 11:32:21 +08:00
sidebar: draw network strength without images (#21185)
* draw network strength without images * Trigger Build old-commit-hash: 48696105ae5901ccfc5b5f41792dca48f09ed651
This commit is contained in:
@@ -55,7 +55,7 @@ void Sidebar::updateState(const UIState &s) {
|
||||
|
||||
auto deviceState = sm["deviceState"].getDeviceState();
|
||||
setProperty("netType", network_type[deviceState.getNetworkType()]);
|
||||
setProperty("netStrength", signal_imgs[deviceState.getNetworkStrength()]);
|
||||
setProperty("netStrength", (int)deviceState.getNetworkStrength());
|
||||
|
||||
auto last_ping = deviceState.getLastAthenaPingTime();
|
||||
if (last_ping == 0) {
|
||||
@@ -102,7 +102,14 @@ void Sidebar::paintEvent(QPaintEvent *event) {
|
||||
p.drawImage(60, 1080 - 180 - 40, home_img);
|
||||
|
||||
// network
|
||||
p.drawImage(58, 196, net_strength);
|
||||
int x = 58;
|
||||
const QColor gray(0x54, 0x54, 0x54);
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
p.setBrush(i < net_strength ? Qt::white : gray);
|
||||
p.drawEllipse(x, 196, 27, 27);
|
||||
x += 37;
|
||||
}
|
||||
|
||||
configFont(p, "Open Sans", 35, "Regular");
|
||||
p.setPen(QColor(0xff, 0xff, 0xff));
|
||||
const QRect r = QRect(50, 247, 100, 50);
|
||||
|
||||
@@ -13,7 +13,7 @@ class Sidebar : public QFrame {
|
||||
Q_PROPERTY(int tempVal MEMBER temp_val NOTIFY valueChanged);
|
||||
Q_PROPERTY(QColor tempStatus MEMBER temp_status NOTIFY valueChanged);
|
||||
Q_PROPERTY(QString netType MEMBER net_type NOTIFY valueChanged);
|
||||
Q_PROPERTY(QImage netStrength MEMBER net_strength NOTIFY valueChanged);
|
||||
Q_PROPERTY(int netStrength MEMBER net_strength NOTIFY valueChanged);
|
||||
|
||||
public:
|
||||
explicit Sidebar(QWidget* parent = 0);
|
||||
@@ -41,13 +41,6 @@ private:
|
||||
{cereal::DeviceState::NetworkType::CELL4_G, "LTE"},
|
||||
{cereal::DeviceState::NetworkType::CELL5_G, "5G"}
|
||||
};
|
||||
const QMap<cereal::DeviceState::NetworkStrength, QImage> signal_imgs = {
|
||||
{cereal::DeviceState::NetworkStrength::UNKNOWN, QImage("../assets/images/network_0.png")},
|
||||
{cereal::DeviceState::NetworkStrength::POOR, QImage("../assets/images/network_1.png")},
|
||||
{cereal::DeviceState::NetworkStrength::MODERATE, QImage("../assets/images/network_2.png")},
|
||||
{cereal::DeviceState::NetworkStrength::GOOD, QImage("../assets/images/network_3.png")},
|
||||
{cereal::DeviceState::NetworkStrength::GREAT, QImage("../assets/images/network_4.png")},
|
||||
};
|
||||
|
||||
const QRect settings_btn = QRect(50, 35, 200, 117);
|
||||
const QColor good_color = QColor(255, 255, 255);
|
||||
@@ -61,5 +54,5 @@ private:
|
||||
int temp_val = 0;
|
||||
QColor temp_status = warning_color;
|
||||
QString net_type;
|
||||
QImage net_strength;
|
||||
int net_strength = 0;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user