mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-07-25 16:12:08 +08:00
@@ -218,23 +218,13 @@ VisualsPanel::VisualsPanel(QWidget *parent) : QWidget(parent) {
|
|||||||
"VisualStyleOverheadThreshold", tr("Visual Style Overhead Threshold"),
|
"VisualStyleOverheadThreshold", tr("Visual Style Overhead Threshold"),
|
||||||
tr("Sets the speed (in mph) where the display transitions between normal and overhead view."),
|
tr("Sets the speed (in mph) where the display transitions between normal and overhead view."),
|
||||||
"", {10, 80}, 5, false, nullptr, false);
|
"", {10, 80}, 5, false, nullptr, false);
|
||||||
auto updateThresholdLabel = [this]() {
|
auto updateThresholdLabel = [=]() {
|
||||||
bool metric = params.getBool("IsMetric");
|
int mph = QString::fromStdString(params.get("VisualStyleOverheadThreshold")).toInt();
|
||||||
int mph_value = QString::fromStdString(params.get("VisualStyleOverheadThreshold")).toInt();
|
visual_style_overhead_threshold_settings->setLabel(QString("%1 mph").arg(mph));
|
||||||
int display_value = metric ? static_cast<int>(std::round(mph_value * 1.60934 / 5.0) * 5) : mph_value;
|
|
||||||
QString unit = metric ? "km/h" : "mph";
|
|
||||||
visual_style_overhead_threshold_settings->setLabel(QString("%1 %2").arg(display_value).arg(unit));
|
|
||||||
};
|
};
|
||||||
connect(visual_style_overhead_threshold_settings, &OptionControlSP::updateLabels, updateThresholdLabel);
|
connect(visual_style_overhead_threshold_settings, &OptionControlSP::updateLabels, updateThresholdLabel);
|
||||||
updateThresholdLabel();
|
updateThresholdLabel();
|
||||||
list->addItem(visual_style_overhead_threshold_settings);
|
list->addItem(visual_style_overhead_threshold_settings);
|
||||||
param_watcher->addParam("IsMetric");
|
|
||||||
connect(param_watcher, &ParamWatcher::paramChanged,
|
|
||||||
[updateThresholdLabel](const QString ¶m_name, const QString &) {
|
|
||||||
if (param_name == "IsMetric") {
|
|
||||||
updateThresholdLabel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Visuals: Display Metrics below Chevron
|
// Visuals: Display Metrics below Chevron
|
||||||
std::vector<QString> chevron_info_settings_texts{tr("Off"), tr("Distance"), tr("Speed"), tr("Time"), tr("All")};
|
std::vector<QString> chevron_info_settings_texts{tr("Off"), tr("Distance"), tr("Speed"), tr("Time"), tr("All")};
|
||||||
|
|||||||
Reference in New Issue
Block a user