From c9d4dfe99fbc49e5db16292200e7daef3295dfb3 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Wed, 23 Jun 2021 04:24:55 +0800 Subject: [PATCH] DevicePanel: set specific stylesheet for reboot & poweroff buttons (#21364) * set specific stylesheet for reboot&poweroff buttons * remove hack * fix css in network panel --- selfdrive/ui/qt/offroad/networking.cc | 7 +++++-- selfdrive/ui/qt/offroad/settings.cc | 12 ++---------- selfdrive/ui/qt/widgets/controls.cc | 2 -- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/selfdrive/ui/qt/offroad/networking.cc b/selfdrive/ui/qt/offroad/networking.cc index 2d36287a97..30f65cf9fb 100644 --- a/selfdrive/ui/qt/offroad/networking.cc +++ b/selfdrive/ui/qt/offroad/networking.cc @@ -53,6 +53,7 @@ void Networking::attemptInitialization() { QVBoxLayout* vlayout = new QVBoxLayout(wifiScreen); if (show_advanced) { QPushButton* advancedSettings = new QPushButton("Advanced"); + advancedSettings->setObjectName("advancedBtn"); advancedSettings->setStyleSheet("margin-right: 30px;"); advancedSettings->setFixedSize(350, 100); connect(advancedSettings, &QPushButton::released, [=]() { main_layout->setCurrentWidget(an); }); @@ -62,6 +63,7 @@ void Networking::attemptInitialization() { } wifiWidget = new WifiUI(this, wifi); + wifiWidget->setObjectName("wifiWidget"); connect(wifiWidget, &WifiUI::connectToNetwork, this, &Networking::connectToNetwork); vlayout->addWidget(new ScrollView(wifiWidget, this), 1); @@ -72,7 +74,7 @@ void Networking::attemptInitialization() { main_layout->addWidget(an); setStyleSheet(R"( - QPushButton { + #wifiWidget > QPushButton, #back_btn, #advancedBtn { font-size: 50px; margin: 0px; padding: 15px; @@ -81,7 +83,7 @@ void Networking::attemptInitialization() { color: #dddddd; background-color: #444444; } - QPushButton:disabled { + #wifiWidget > QPushButton:disabled { color: #777777; background-color: #222222; } @@ -140,6 +142,7 @@ AdvancedNetworking::AdvancedNetworking(QWidget* parent, WifiManager* wifi): QWid // Back button QPushButton* back = new QPushButton("Back"); + back->setObjectName("back_btn"); back->setFixedSize(500, 100); connect(back, &QPushButton::released, [=]() { emit backPress(); }); main_layout->addWidget(back, 0, Qt::AlignLeft); diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index 4ec5b6ebe0..113a2c016b 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -178,6 +178,7 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) { power_layout->setSpacing(30); QPushButton *reboot_btn = new QPushButton("Reboot"); + reboot_btn->setStyleSheet("height: 120px;border-radius: 15px;background-color: #393939;"); power_layout->addWidget(reboot_btn); QObject::connect(reboot_btn, &QPushButton::released, [=]() { if (ConfirmationDialog::confirm("Are you sure you want to reboot?", this)) { @@ -186,7 +187,7 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) { }); QPushButton *poweroff_btn = new QPushButton("Power Off"); - poweroff_btn->setStyleSheet("background-color: #E22C2C;"); + poweroff_btn->setStyleSheet("height: 120px;border-radius: 15px;background-color: #E22C2C;"); power_layout->addWidget(poweroff_btn); QObject::connect(poweroff_btn, &QPushButton::released, [=]() { if (ConfirmationDialog::confirm("Are you sure you want to power off?", this)) { @@ -195,15 +196,6 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) { }); main_layout->addLayout(power_layout); - - setStyleSheet(R"( - QPushButton { - padding: 0; - height: 120px; - border-radius: 15px; - background-color: #393939; - } - )"); } SoftwarePanel::SoftwarePanel(QWidget* parent) : QWidget(parent) { diff --git a/selfdrive/ui/qt/widgets/controls.cc b/selfdrive/ui/qt/widgets/controls.cc index b20fefe9e1..ca98de06e2 100644 --- a/selfdrive/ui/qt/widgets/controls.cc +++ b/selfdrive/ui/qt/widgets/controls.cc @@ -54,8 +54,6 @@ AbstractControl::AbstractControl(const QString &title, const QString &desc, cons description->setVisible(!description->isVisible()); }); } - - setStyleSheet("background-color: transparent;"); } void AbstractControl::hideEvent(QHideEvent *e) {