mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-06-23 12:12:07 +08:00
Merge branch 'master' into visual-style
This commit is contained in:
@@ -80,7 +80,7 @@ DevicePanelSP::DevicePanelSP(SettingsWindowSP *parent) : DevicePanel(parent) {
|
||||
connect(maxTimeOffroad, &OptionControlSP::updateLabels, maxTimeOffroad, &MaxTimeOffroad::refresh);
|
||||
addItem(maxTimeOffroad);
|
||||
|
||||
toggleDeviceBootMode = new ButtonParamControlSP("DeviceBootMode", tr("Wake-Up Behavior"), "", "", {"Default", "Offroad"}, 375, true);
|
||||
toggleDeviceBootMode = new ButtonParamControlSP("DeviceBootMode", tr("Wake-Up Behavior"), "", "", {"Default", "Offroad"}, 375, true);
|
||||
addItem(toggleDeviceBootMode);
|
||||
|
||||
connect(toggleDeviceBootMode, &ButtonParamControlSP::buttonClicked, this, [=](int index) {
|
||||
@@ -129,9 +129,8 @@ DevicePanelSP::DevicePanelSP(SettingsWindowSP *parent) : DevicePanel(parent) {
|
||||
offroadBtn->setFixedWidth(power_layout->sizeHint().width());
|
||||
QObject::connect(offroadBtn, &PushButtonSP::clicked, this, &DevicePanelSP::setOffroadMode);
|
||||
|
||||
QVBoxLayout *power_group_layout = new QVBoxLayout();
|
||||
power_group_layout = new QVBoxLayout();
|
||||
power_group_layout->setSpacing(25);
|
||||
power_group_layout->addWidget(offroadBtn, 0, Qt::AlignHCenter);
|
||||
power_group_layout->addLayout(power_layout);
|
||||
|
||||
addItem(power_group_layout);
|
||||
@@ -143,7 +142,7 @@ DevicePanelSP::DevicePanelSP(SettingsWindowSP *parent) : DevicePanel(parent) {
|
||||
buttons["quietModeBtn"],
|
||||
};
|
||||
|
||||
QObject::connect(uiState(), &UIState::offroadTransition, [=](bool offroad) {
|
||||
QObject::connect(uiState(), &UIState::offroadTransition, [=](bool _offroad) {
|
||||
for (auto btn : findChildren<PushButtonSP*>()) {
|
||||
bool always_enabled = std::find(always_enabled_btns.begin(), always_enabled_btns.end(), btn) != always_enabled_btns.end();
|
||||
|
||||
@@ -151,6 +150,8 @@ DevicePanelSP::DevicePanelSP(SettingsWindowSP *parent) : DevicePanel(parent) {
|
||||
btn->setEnabled(offroad);
|
||||
}
|
||||
}
|
||||
offroad = _offroad;
|
||||
updateState();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -201,7 +202,7 @@ void DevicePanelSP::updateState() {
|
||||
}
|
||||
|
||||
bool offroad_mode_param = params.getBool("OffroadMode");
|
||||
offroadBtn->setText(offroad_mode_param ? tr("Exit Always Offroad") : tr("Always Offroad"));
|
||||
offroadBtn->setText(offroad_mode_param ? tr("Exit Always Offroad") : tr("Enable Always Offroad"));
|
||||
offroadBtn->setStyleSheet(offroad_mode_param ? alwaysOffroadStyle : autoOffroadStyle);
|
||||
|
||||
DeviceSleepModeStatus currStatus = DeviceSleepModeStatus::DEFAULT;
|
||||
@@ -216,4 +217,10 @@ void DevicePanelSP::updateState() {
|
||||
} else {
|
||||
interactivityTimeout->setLabel(timeoutValue + "s");
|
||||
}
|
||||
|
||||
if (offroad and not offroad_mode_param) {
|
||||
power_group_layout->insertWidget(0, offroadBtn, 0, Qt::AlignHCenter);
|
||||
} else {
|
||||
AddWidgetAt(0, offroadBtn);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ private:
|
||||
ButtonParamControlSP *toggleDeviceBootMode;
|
||||
Brightness *brightness;
|
||||
OptionControlSP *interactivityTimeout;
|
||||
QVBoxLayout *power_group_layout;
|
||||
bool offroad;
|
||||
|
||||
const QString alwaysOffroadStyle = R"(
|
||||
PushButtonSP {
|
||||
|
||||
Reference in New Issue
Block a user