nav: add page to settings (#21208)
* add navigation panel to settings * am/pm display and dynamic widthpull/21219/head
parent
a8b6178c1e
commit
3c197953bc
|
@ -186,6 +186,7 @@ std::unordered_map<std::string, uint32_t> keys = {
|
|||
{"LiveParameters", PERSISTENT},
|
||||
{"MapboxToken", PERSISTENT},
|
||||
{"NavDestination", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_OFF},
|
||||
{"NavSettingTime24h", PERSISTENT},
|
||||
{"OpenpilotEnabledToggle", PERSISTENT},
|
||||
{"PandaFirmware", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT},
|
||||
{"PandaFirmwareHex", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT},
|
||||
|
|
|
@ -30,7 +30,7 @@ if arch != 'aarch64':
|
|||
|
||||
if maps:
|
||||
base_libs += ['qmapboxgl']
|
||||
widgets_src += ["qt/maps/map_helpers.cc", "qt/maps/map.cc"]
|
||||
widgets_src += ["qt/maps/map_helpers.cc", "qt/maps/map_settings.cc", "qt/maps/map.cc"]
|
||||
qt_env['CPPDEFINES'] = ["ENABLE_MAPS"]
|
||||
|
||||
widgets = qt_env.Library("qt_widgets", widgets_src, LIBS=base_libs)
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include "selfdrive/common/util.h"
|
||||
#include "selfdrive/common/swaglog.h"
|
||||
#include "selfdrive/common/params.h"
|
||||
#include "selfdrive/ui/ui.h"
|
||||
#include "selfdrive/ui/qt/util.h"
|
||||
#include "selfdrive/ui/qt/maps/map_helpers.h"
|
||||
|
@ -46,8 +45,8 @@ MapWindow::MapWindow(const QMapboxGLSettings &settings) : m_settings(settings) {
|
|||
connect(this, &MapWindow::ETAChanged, map_eta, &MapETA::updateETA);
|
||||
|
||||
const int h = 180;
|
||||
const int w = 500;
|
||||
map_eta->setGeometry(0, 1080 - h, w, h);
|
||||
map_eta->setFixedHeight(h);
|
||||
map_eta->move(0, 1080 - h);
|
||||
map_eta->setVisible(false);
|
||||
|
||||
// Routing
|
||||
|
@ -608,10 +607,11 @@ void MapInstructions::updateInstructions(QMap<QString, QVariant> banner){
|
|||
MapETA::MapETA(QWidget * parent) : QWidget(parent){
|
||||
QHBoxLayout *layout_outer = new QHBoxLayout;
|
||||
layout_outer->setContentsMargins(20, 25, 20, 25);
|
||||
layout_outer->setSpacing(20);
|
||||
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
eta = new QLabel("12:26");
|
||||
eta = new QLabel;
|
||||
eta->setAlignment(Qt::AlignCenter);
|
||||
|
||||
auto eta_unit = new QLabel("eta");
|
||||
|
@ -672,7 +672,11 @@ void MapETA::updateETA(float s, float s_typical, float d) {
|
|||
|
||||
// ETA
|
||||
auto eta_time = QDateTime::currentDateTime().addSecs(s).time();
|
||||
eta->setText(eta_time.toString("HH:mm"));
|
||||
if (params.getBool("NavSettingTime24h")) {
|
||||
eta->setText(eta_time.toString("HH:mm"));
|
||||
} else {
|
||||
eta->setText(eta_time.toString("h:mm a"));
|
||||
}
|
||||
|
||||
// Remaining time
|
||||
if (s < 3600) {
|
||||
|
@ -680,7 +684,7 @@ void MapETA::updateETA(float s, float s_typical, float d) {
|
|||
time_unit->setText("min");
|
||||
} else {
|
||||
int hours = int(s) / 3600;
|
||||
time->setText(QString::number(hours) + ":" + QString::number(int((s - hours * 3600) / 60)));
|
||||
time->setText(QString::number(hours) + ":" + QString::number(int((s - hours * 3600) / 60)).rightJustified(2, '0'));
|
||||
time_unit->setText("hr");
|
||||
}
|
||||
|
||||
|
@ -708,4 +712,6 @@ void MapETA::updateETA(float s, float s_typical, float d) {
|
|||
|
||||
distance_str.setNum(num, 'f', num < 100 ? 1 : 0);
|
||||
distance->setText(distance_str);
|
||||
|
||||
adjustSize();
|
||||
}
|
||||
|
|
|
@ -23,7 +23,9 @@
|
|||
#include <QMap>
|
||||
#include <QPixmap>
|
||||
|
||||
#include "selfdrive/common/params.h"
|
||||
#include "cereal/messaging/messaging.h"
|
||||
|
||||
class MapInstructions : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -52,6 +54,7 @@ private:
|
|||
QLabel *time_unit;
|
||||
QLabel *distance;
|
||||
QLabel *distance_unit;
|
||||
Params params;
|
||||
|
||||
public:
|
||||
MapETA(QWidget * parent=nullptr);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
#include "map_settings.h"
|
||||
|
||||
#include "selfdrive/ui/qt/widgets/controls.h"
|
||||
|
||||
|
||||
MapPanel::MapPanel(QWidget* parent) : QWidget(parent) {
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
Params params = Params();
|
||||
|
||||
QString dongle = QString::fromStdString(params.get("DongleId", false));
|
||||
// TODO: Add buttons for home/work shortcuts
|
||||
|
||||
layout->addWidget(new ParamControl("NavSettingTime24h",
|
||||
"Show ETA in 24h format",
|
||||
"Use 24h format instead of am/pm",
|
||||
"",
|
||||
this));
|
||||
layout->addStretch();
|
||||
setLayout(layout);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
#include <QWidget>
|
||||
|
||||
class MapPanel : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MapPanel(QWidget* parent = nullptr);
|
||||
};
|
|
@ -6,6 +6,11 @@
|
|||
#ifndef QCOM
|
||||
#include "selfdrive/ui/qt/offroad/networking.h"
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_MAPS
|
||||
#include "selfdrive/ui/qt/maps/map_settings.h"
|
||||
#endif
|
||||
|
||||
#include "selfdrive/common/params.h"
|
||||
#include "selfdrive/common/util.h"
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
|
@ -350,33 +355,39 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) {
|
|||
QObject::connect(device, &DevicePanel::reviewTrainingGuide, this, &SettingsWindow::reviewTrainingGuide);
|
||||
QObject::connect(device, &DevicePanel::showDriverView, this, &SettingsWindow::showDriverView);
|
||||
|
||||
QPair<QString, QWidget *> panels[] = {
|
||||
QList<QPair<QString, QWidget *>> panels = {
|
||||
{"Device", device},
|
||||
{"Network", network_panel(this)},
|
||||
{"Toggles", new TogglesPanel(this)},
|
||||
{"Software", new SoftwarePanel(this)},
|
||||
};
|
||||
|
||||
sidebar_layout->addSpacing(45);
|
||||
#ifdef ENABLE_MAPS
|
||||
if (!Params().get("MapboxToken").empty()){
|
||||
panels.push_back({"Navigation", new MapPanel(this)});
|
||||
}
|
||||
#endif
|
||||
const int padding = panels.size() > 3 ? 25 : 35;
|
||||
|
||||
nav_btns = new QButtonGroup();
|
||||
for (auto &[name, panel] : panels) {
|
||||
QPushButton *btn = new QPushButton(name);
|
||||
btn->setCheckable(true);
|
||||
btn->setChecked(nav_btns->buttons().size() == 0);
|
||||
btn->setStyleSheet(R"(
|
||||
btn->setStyleSheet(QString(R"(
|
||||
QPushButton {
|
||||
color: grey;
|
||||
border: none;
|
||||
background: none;
|
||||
font-size: 65px;
|
||||
font-weight: 500;
|
||||
padding-top: 35px;
|
||||
padding-bottom: 35px;
|
||||
padding-top: %1px;
|
||||
padding-bottom: %1px;
|
||||
}
|
||||
QPushButton:checked {
|
||||
color: white;
|
||||
}
|
||||
)");
|
||||
)").arg(padding));
|
||||
|
||||
nav_btns->addButton(btn);
|
||||
sidebar_layout->addWidget(btn, 0, Qt::AlignRight);
|
||||
|
|
Loading…
Reference in New Issue