From 343e1ace30e73d9df6f131d68a4ccedfa30c0141 Mon Sep 17 00:00:00 2001 From: sshane Date: Fri, 23 Jul 2021 18:48:29 -0700 Subject: [PATCH] networking: cleanup style sheets (#21696) * cleanup style sheets * set weight when needed * if disconnected is the same * no need anymore * use property * disconnected old-commit-hash: d8a6e6144ac161f2abd3541380546c64c90375d6 --- selfdrive/ui/qt/offroad/networking.cc | 54 ++++++++++++++------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/selfdrive/ui/qt/offroad/networking.cc b/selfdrive/ui/qt/offroad/networking.cc index a70150a0d0..75304d7ae2 100644 --- a/selfdrive/ui/qt/offroad/networking.cc +++ b/selfdrive/ui/qt/offroad/networking.cc @@ -200,6 +200,27 @@ WifiUI::WifiUI(QWidget *parent, WifiManager* wifi) : QWidget(parent), wifi(wifi) padding-bottom: 16px; padding-top: 16px; } + #connecting { + font-size: 32px; + font-weight: 600; + color: white; + border-radius: 0; + padding: 27px; + padding-left: 43px; + padding-right: 43px; + background-color: black; + } + #ssidLabel { + font-size: 55px; + font-weight: 300; + text-align: left; + border: none; + padding-top: 50px; + padding-bottom: 50px; + } + #ssidLabel[disconnected=false] { + font-weight: 500; + } )"); } @@ -222,34 +243,17 @@ void WifiUI::refresh() { hlayout->setSpacing(50); // Clickable SSID label - QPushButton *ssid_label = new QPushButton(network.ssid); - ssid_label->setEnabled(network.connected != ConnectedType::CONNECTED && - network.connected != ConnectedType::CONNECTING && - network.security_type != SecurityType::UNSUPPORTED); - int weight = network.connected == ConnectedType::DISCONNECTED ? 300 : 500; - ssid_label->setStyleSheet(QString(R"( - font-size: 55px; - font-weight: %1; - text-align: left; - border: none; - padding-top: 50px; - padding-bottom: 50px; - )").arg(weight)); - QObject::connect(ssid_label, &QPushButton::clicked, this, [=]() { emit connectToNetwork(network); }); - hlayout->addWidget(ssid_label, network.connected == ConnectedType::CONNECTING ? 0 : 1); + QPushButton *ssidLabel = new QPushButton(network.ssid); + ssidLabel->setObjectName("ssidLabel"); + ssidLabel->setEnabled(network.connected == ConnectedType::DISCONNECTED && + network.security_type != SecurityType::UNSUPPORTED); + ssidLabel->setProperty("disconnected", network.connected == ConnectedType::DISCONNECTED); + QObject::connect(ssidLabel, &QPushButton::clicked, this, [=]() { emit connectToNetwork(network); }); + hlayout->addWidget(ssidLabel, network.connected == ConnectedType::CONNECTING ? 0 : 1); if (network.connected == ConnectedType::CONNECTING) { QPushButton *connecting = new QPushButton("CONNECTING..."); - connecting->setStyleSheet(R"( - font-size: 32px; - font-weight: 600; - color: white; - border-radius: 0; - padding: 27px; - padding-left: 43px; - padding-right: 43px; - background-color: black; - )"); + connecting->setObjectName("connecting"); hlayout->addWidget(connecting, 2, Qt::AlignLeft); }