diff --git a/selfdrive/assets/navigation/screenshot.png b/selfdrive/assets/navigation/screenshot.png new file mode 100644 index 0000000000..f78dd1d47b --- /dev/null +++ b/selfdrive/assets/navigation/screenshot.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5cc130b4cfbaab862fd6ac2fa32c983a28af5a0d4493a765fb13d2eb1bd7ea7d +size 1337564 diff --git a/selfdrive/ui/qt/maps/map_settings.cc b/selfdrive/ui/qt/maps/map_settings.cc index 7e57f21cb5..ab03838bb2 100644 --- a/selfdrive/ui/qt/maps/map_settings.cc +++ b/selfdrive/ui/qt/maps/map_settings.cc @@ -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) { diff --git a/selfdrive/ui/qt/maps/map_settings.h b/selfdrive/ui/qt/maps/map_settings.h index 38a65e3f1f..2eb462d671 100644 --- a/selfdrive/ui/qt/maps/map_settings.h +++ b/selfdrive/ui/qt/maps/map_settings.h @@ -6,6 +6,7 @@ #include #include #include +#include #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; diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index c2cbe441a4..1d0eba0dcd 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -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();