From b81910128d6d53c1fb0bd931a0c9a5818a6aad6f Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Sat, 15 Jul 2023 18:37:41 +0800 Subject: [PATCH] ui/MapSettings: store destinations to load on widget init (#28950) Co-authored-by: Cameron Clough old-commit-hash: 187696977e32c0042b9141d6042e8dddb507fceb --- selfdrive/ui/qt/maps/map_settings.cc | 4 +++- selfdrive/ui/qt/maps/map_settings.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/qt/maps/map_settings.cc b/selfdrive/ui/qt/maps/map_settings.cc index 0b09db7bc6..c8a9627a35 100644 --- a/selfdrive/ui/qt/maps/map_settings.cc +++ b/selfdrive/ui/qt/maps/map_settings.cc @@ -83,6 +83,8 @@ MapSettings::MapSettings(bool closeable, QWidget *parent) : QFrame(parent) { QObject::connect(NavigationRequest::instance(), &NavigationRequest::locationsUpdated, this, &MapSettings::updateLocations); QObject::connect(NavigationRequest::instance(), &NavigationRequest::nextDestinationUpdated, this, &MapSettings::updateCurrentRoute); + + current_locations = NavigationRequest::instance()->currentLocations(); } void MapSettings::mousePressEvent(QMouseEvent *ev) { @@ -333,7 +335,7 @@ void NavigationRequest::parseLocationsResponse(const QString &response, bool suc } // Sort: HOME, WORK, alphabetical FAVORITES, and then most recent (as returned by API) - QJsonArray locations = doc.array(); + locations = doc.array(); std::stable_sort(locations.begin(), locations.end(), [](const QJsonValue &a, const QJsonValue &b) { if (a["save_type"] == NAV_TYPE_FAVORITE || b["save_type"] == NAV_TYPE_FAVORITE) { QString a_label = a["label"].toString(), b_label = b["label"].toString(); diff --git a/selfdrive/ui/qt/maps/map_settings.h b/selfdrive/ui/qt/maps/map_settings.h index 2326fb3724..afa4f36052 100644 --- a/selfdrive/ui/qt/maps/map_settings.h +++ b/selfdrive/ui/qt/maps/map_settings.h @@ -25,6 +25,7 @@ class NavigationRequest : public QObject { public: static NavigationRequest *instance(); + QJsonArray currentLocations() const { return locations; }; signals: void locationsUpdated(const QJsonArray &locations); @@ -36,6 +37,7 @@ private: Params params; QString prev_response; + QJsonArray locations; }; class MapSettings : public QFrame {