ui: fix pair button shows on paired device (#32109)
old-commit-hash: ba98786ee317750034881710f0b4b5a7a5a60474
This commit is contained in:
@@ -255,8 +255,8 @@ DevicePanel::DevicePanel(SettingsWindow *parent) : ListWidget(parent) {
|
||||
});
|
||||
addItem(translateBtn);
|
||||
|
||||
QObject::connect(uiState(), &UIState::primeChanged, [this] (bool prime) {
|
||||
pair_device->setVisible(!prime);
|
||||
QObject::connect(uiState(), &UIState::primeTypeChanged, [this] (PrimeType type) {
|
||||
pair_device->setVisible(type == PrimeType::UNPAIRED);
|
||||
});
|
||||
QObject::connect(uiState(), &UIState::offroadTransition, [=](bool offroad) {
|
||||
for (auto btn : findChildren<ButtonControl *>()) {
|
||||
@@ -344,7 +344,7 @@ void DevicePanel::poweroff() {
|
||||
}
|
||||
|
||||
void DevicePanel::showEvent(QShowEvent *event) {
|
||||
pair_device->setVisible(!uiState()->primeType());
|
||||
pair_device->setVisible(uiState()->primeType() == PrimeType::UNPAIRED);
|
||||
ListWidget::showEvent(event);
|
||||
}
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ SetupWidget::SetupWidget(QWidget* parent) : QFrame(parent) {
|
||||
|
||||
mainLayout->addWidget(content);
|
||||
|
||||
primeUser->setVisible(uiState()->primeType());
|
||||
primeUser->setVisible(uiState()->hasPrime());
|
||||
mainLayout->setCurrentIndex(1);
|
||||
|
||||
setStyleSheet(R"(
|
||||
@@ -269,15 +269,16 @@ void SetupWidget::replyFinished(const QString &response, bool success) {
|
||||
}
|
||||
|
||||
QJsonObject json = doc.object();
|
||||
bool is_paired = json["is_paired"].toBool();
|
||||
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);
|
||||
} else {
|
||||
popup->reject();
|
||||
|
||||
primeUser->setVisible(prime_type);
|
||||
primeUser->setVisible(uiState()->hasPrime());
|
||||
mainLayout->setCurrentIndex(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,8 @@ typedef enum UIStatus {
|
||||
} UIStatus;
|
||||
|
||||
enum PrimeType {
|
||||
UNKNOWN = -1,
|
||||
UNKNOWN = -2,
|
||||
UNPAIRED = -1,
|
||||
NONE = 0,
|
||||
MAGENTA = 1,
|
||||
LITE = 2,
|
||||
@@ -114,7 +115,7 @@ public:
|
||||
|
||||
void setPrimeType(PrimeType 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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user