ui: fix pair button shows on paired device (#32109)

old-commit-hash: ba98786ee3
pull/32199/head
Dean Lee 1 year ago committed by GitHub
parent 31f5956c49
commit 9fcc783447
  1. 6
      selfdrive/ui/qt/offroad/settings.cc
  2. 9
      selfdrive/ui/qt/widgets/prime.cc
  3. 5
      selfdrive/ui/ui.h

@ -255,8 +255,8 @@ DevicePanel::DevicePanel(SettingsWindow *parent) : ListWidget(parent) {
}); });
addItem(translateBtn); addItem(translateBtn);
QObject::connect(uiState(), &UIState::primeChanged, [this] (bool prime) { QObject::connect(uiState(), &UIState::primeTypeChanged, [this] (PrimeType type) {
pair_device->setVisible(!prime); pair_device->setVisible(type == PrimeType::UNPAIRED);
}); });
QObject::connect(uiState(), &UIState::offroadTransition, [=](bool offroad) { QObject::connect(uiState(), &UIState::offroadTransition, [=](bool offroad) {
for (auto btn : findChildren<ButtonControl *>()) { for (auto btn : findChildren<ButtonControl *>()) {
@ -344,7 +344,7 @@ void DevicePanel::poweroff() {
} }
void DevicePanel::showEvent(QShowEvent *event) { void DevicePanel::showEvent(QShowEvent *event) {
pair_device->setVisible(!uiState()->primeType()); pair_device->setVisible(uiState()->primeType() == PrimeType::UNPAIRED);
ListWidget::showEvent(event); ListWidget::showEvent(event);
} }

@ -235,7 +235,7 @@ SetupWidget::SetupWidget(QWidget* parent) : QFrame(parent) {
mainLayout->addWidget(content); mainLayout->addWidget(content);
primeUser->setVisible(uiState()->primeType()); primeUser->setVisible(uiState()->hasPrime());
mainLayout->setCurrentIndex(1); mainLayout->setCurrentIndex(1);
setStyleSheet(R"( setStyleSheet(R"(
@ -269,15 +269,16 @@ void SetupWidget::replyFinished(const QString &response, bool success) {
} }
QJsonObject json = doc.object(); QJsonObject json = doc.object();
bool is_paired = json["is_paired"].toBool();
PrimeType prime_type = static_cast<PrimeType>(json["prime_type"].toInt()); PrimeType prime_type = static_cast<PrimeType>(json["prime_type"].toInt());
uiState()->setPrimeType(prime_type); uiState()->setPrimeType(is_paired ? prime_type : PrimeType::UNPAIRED);
if (!json["is_paired"].toBool()) { if (!is_paired) {
mainLayout->setCurrentIndex(0); mainLayout->setCurrentIndex(0);
} else { } else {
popup->reject(); popup->reject();
primeUser->setVisible(prime_type); primeUser->setVisible(uiState()->hasPrime());
mainLayout->setCurrentIndex(1); mainLayout->setCurrentIndex(1);
} }
} }

@ -53,7 +53,8 @@ typedef enum UIStatus {
} UIStatus; } UIStatus;
enum PrimeType { enum PrimeType {
UNKNOWN = -1, UNKNOWN = -2,
UNPAIRED = -1,
NONE = 0, NONE = 0,
MAGENTA = 1, MAGENTA = 1,
LITE = 2, LITE = 2,
@ -114,7 +115,7 @@ public:
void setPrimeType(PrimeType type); void setPrimeType(PrimeType type);
inline PrimeType primeType() const { return prime_type; } inline PrimeType primeType() const { return prime_type; }
inline bool hasPrime() const { return prime_type != PrimeType::UNKNOWN && prime_type != PrimeType::NONE; } inline bool hasPrime() const { return prime_type > PrimeType::NONE; }
int fb_w = 0, fb_h = 0; int fb_w = 0, fb_h = 0;

Loading…
Cancel
Save