mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-23 17:23:44 +08:00
nav: show settings without token (#21624)
* map settings always in sidebar * show screenshot when no prime * remove print * repaint to fix star sizing * checked in sconsscript * match designs old-commit-hash: 190409c9387ade9bc988b6603ac6f41248e0a5fd
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5cc130b4cfbaab862fd6ac2fa32c983a28af5a0d4493a765fb13d2eb1bd7ea7d
|
||||
size 1337564
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "selfdrive/common/util.h"
|
||||
#include "selfdrive/ui/qt/util.h"
|
||||
#include "selfdrive/ui/qt/qt_window.h"
|
||||
#include "selfdrive/ui/qt/request_repeater.h"
|
||||
#include "selfdrive/ui/qt/widgets/controls.h"
|
||||
#include "selfdrive/ui/qt/widgets/scrollview.h"
|
||||
@@ -13,7 +14,10 @@ static QString shorten(const QString &str, int max_len) {
|
||||
}
|
||||
|
||||
MapPanel::MapPanel(QWidget* parent) : QWidget(parent) {
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
stack = new QStackedWidget;
|
||||
|
||||
QWidget * main_widget = new QWidget;
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(main_widget);
|
||||
const int icon_size = 200;
|
||||
|
||||
// Home
|
||||
@@ -57,6 +61,36 @@ MapPanel::MapPanel(QWidget* parent) : QWidget(parent) {
|
||||
ScrollView *recent_scroller = new ScrollView(recent_widget, this);
|
||||
main_layout->addWidget(recent_scroller, 1);
|
||||
|
||||
QWidget * no_prime_widget = new QWidget;
|
||||
QVBoxLayout *no_prime_layout = new QVBoxLayout(no_prime_widget);
|
||||
QLabel *signup_header = new QLabel("Try the Navigation Beta");
|
||||
signup_header->setStyleSheet(R"(font-size: 75px; color: white; font-weight:600;)");
|
||||
signup_header->setAlignment(Qt::AlignCenter);
|
||||
|
||||
no_prime_layout->addWidget(signup_header);
|
||||
no_prime_layout->addSpacing(50);
|
||||
|
||||
QLabel *screenshot = new QLabel;
|
||||
QPixmap pm = QPixmap("../assets/navigation/screenshot.png");
|
||||
screenshot->setPixmap(pm.scaledToWidth(vwp_w * 0.5, Qt::SmoothTransformation));
|
||||
no_prime_layout->addWidget(screenshot, 0, Qt::AlignHCenter);
|
||||
|
||||
QLabel *signup = new QLabel("Get turn-by-turn directions displayed and more with a comma \nprime subscription. Sign up now: https://connect.comma.ai");
|
||||
signup->setStyleSheet(R"(font-size: 45px; color: white; font-weight:300;)");
|
||||
signup->setAlignment(Qt::AlignCenter);
|
||||
|
||||
no_prime_layout->addSpacing(50);
|
||||
no_prime_layout->addWidget(signup);
|
||||
|
||||
no_prime_layout->addStretch();
|
||||
|
||||
stack->addWidget(main_widget);
|
||||
stack->addWidget(no_prime_widget);
|
||||
stack->setCurrentIndex(1);
|
||||
|
||||
QVBoxLayout *wrapper = new QVBoxLayout(this);
|
||||
wrapper->addWidget(stack);
|
||||
|
||||
clear();
|
||||
|
||||
std::string dongle_id = params.get("DongleId");
|
||||
@@ -66,6 +100,7 @@ MapPanel::MapPanel(QWidget* parent) : QWidget(parent) {
|
||||
std::string url = "https://api.commadotai.com/v1/navigation/" + dongle_id + "/locations";
|
||||
RequestRepeater* repeater = new RequestRepeater(this, QString::fromStdString(url), "ApiCache_NavDestinations", 30);
|
||||
QObject::connect(repeater, &RequestRepeater::receivedResponse, this, &MapPanel::parseResponse);
|
||||
QObject::connect(repeater, &RequestRepeater::failedResponse, this, &MapPanel::failedResponse);
|
||||
}
|
||||
|
||||
// Destination set while offline
|
||||
@@ -199,6 +234,12 @@ void MapPanel::parseResponse(const QString &response) {
|
||||
}
|
||||
|
||||
recent_layout->addStretch();
|
||||
stack->setCurrentIndex(0);
|
||||
repaint();
|
||||
}
|
||||
|
||||
void MapPanel::failedResponse(const QString &response) {
|
||||
stack->setCurrentIndex(1);
|
||||
}
|
||||
|
||||
void MapPanel::navigateTo(const QJsonObject &place) {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
#include <QStackedWidget>
|
||||
|
||||
#include "selfdrive/common/params.h"
|
||||
|
||||
@@ -16,10 +17,12 @@ public:
|
||||
|
||||
void navigateTo(const QJsonObject &place);
|
||||
void parseResponse(const QString &response);
|
||||
void failedResponse(const QString &response);
|
||||
void clear();
|
||||
|
||||
private:
|
||||
Params params;
|
||||
QStackedWidget *stack;
|
||||
QPushButton *home_button, *work_button;
|
||||
QLabel *home_address, *work_address;
|
||||
QVBoxLayout *recent_layout;
|
||||
|
||||
@@ -335,12 +335,11 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) {
|
||||
};
|
||||
|
||||
#ifdef ENABLE_MAPS
|
||||
if (!Params().get("MapboxToken").empty()) {
|
||||
auto map_panel = new MapPanel(this);
|
||||
panels.push_back({"Navigation", map_panel});
|
||||
QObject::connect(map_panel, &MapPanel::closeSettings, this, &SettingsWindow::closeSettings);
|
||||
}
|
||||
auto map_panel = new MapPanel(this);
|
||||
panels.push_back({"Navigation", map_panel});
|
||||
QObject::connect(map_panel, &MapPanel::closeSettings, this, &SettingsWindow::closeSettings);
|
||||
#endif
|
||||
|
||||
const int padding = panels.size() > 3 ? 25 : 35;
|
||||
|
||||
nav_btns = new QButtonGroup();
|
||||
|
||||
Reference in New Issue
Block a user