|
|
@ -4,6 +4,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "selfdrive/common/util.h" |
|
|
|
#include "selfdrive/common/util.h" |
|
|
|
#include "selfdrive/ui/qt/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/request_repeater.h" |
|
|
|
#include "selfdrive/ui/qt/widgets/controls.h" |
|
|
|
#include "selfdrive/ui/qt/widgets/controls.h" |
|
|
|
#include "selfdrive/ui/qt/widgets/scrollview.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) { |
|
|
|
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; |
|
|
|
const int icon_size = 200; |
|
|
|
|
|
|
|
|
|
|
|
// Home
|
|
|
|
// Home
|
|
|
@ -57,6 +61,36 @@ MapPanel::MapPanel(QWidget* parent) : QWidget(parent) { |
|
|
|
ScrollView *recent_scroller = new ScrollView(recent_widget, this); |
|
|
|
ScrollView *recent_scroller = new ScrollView(recent_widget, this); |
|
|
|
main_layout->addWidget(recent_scroller, 1); |
|
|
|
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(); |
|
|
|
clear(); |
|
|
|
|
|
|
|
|
|
|
|
std::string dongle_id = params.get("DongleId"); |
|
|
|
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"; |
|
|
|
std::string url = "https://api.commadotai.com/v1/navigation/" + dongle_id + "/locations"; |
|
|
|
RequestRepeater* repeater = new RequestRepeater(this, QString::fromStdString(url), "ApiCache_NavDestinations", 30); |
|
|
|
RequestRepeater* repeater = new RequestRepeater(this, QString::fromStdString(url), "ApiCache_NavDestinations", 30); |
|
|
|
QObject::connect(repeater, &RequestRepeater::receivedResponse, this, &MapPanel::parseResponse); |
|
|
|
QObject::connect(repeater, &RequestRepeater::receivedResponse, this, &MapPanel::parseResponse); |
|
|
|
|
|
|
|
QObject::connect(repeater, &RequestRepeater::failedResponse, this, &MapPanel::failedResponse); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Destination set while offline
|
|
|
|
// Destination set while offline
|
|
|
@ -199,6 +234,12 @@ void MapPanel::parseResponse(const QString &response) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
recent_layout->addStretch(); |
|
|
|
recent_layout->addStretch(); |
|
|
|
|
|
|
|
stack->setCurrentIndex(0); |
|
|
|
|
|
|
|
repaint(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MapPanel::failedResponse(const QString &response) { |
|
|
|
|
|
|
|
stack->setCurrentIndex(1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MapPanel::navigateTo(const QJsonObject &place) { |
|
|
|
void MapPanel::navigateTo(const QJsonObject &place) { |
|
|
|