mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-06 00:36:32 +08:00
MapPanel: refresh only when visible and destination changes (#25739)
rebuild widgets only when mappanel is visible
old-commit-hash: ef767f6332
This commit is contained in:
@@ -156,6 +156,7 @@ MapPanel::MapPanel(QWidget* parent) : QWidget(parent) {
|
||||
|
||||
void MapPanel::showEvent(QShowEvent *event) {
|
||||
updateCurrentRoute();
|
||||
refresh();
|
||||
}
|
||||
|
||||
void MapPanel::clear() {
|
||||
@@ -184,18 +185,25 @@ void MapPanel::updateCurrentRoute() {
|
||||
}
|
||||
|
||||
void MapPanel::parseResponse(const QString &response, bool success) {
|
||||
stack->setCurrentIndex((uiState()->prime_type || success) ? 0 : 1);
|
||||
if (!success) return;
|
||||
|
||||
if (!success) {
|
||||
return;
|
||||
cur_destinations = response;
|
||||
if (isVisible()) {
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
QJsonDocument doc = QJsonDocument::fromJson(response.trimmed().toUtf8());
|
||||
void MapPanel::refresh() {
|
||||
stack->setCurrentIndex(uiState()->prime_type ? 0 : 1);
|
||||
if (cur_destinations == prev_destinations) return;
|
||||
|
||||
QJsonDocument doc = QJsonDocument::fromJson(cur_destinations.trimmed().toUtf8());
|
||||
if (doc.isNull()) {
|
||||
qDebug() << "JSON Parse failed on navigation locations";
|
||||
return;
|
||||
}
|
||||
|
||||
prev_destinations = cur_destinations;
|
||||
clear();
|
||||
|
||||
bool has_recents = false;
|
||||
|
||||
@@ -23,8 +23,10 @@ public:
|
||||
|
||||
private:
|
||||
void showEvent(QShowEvent *event) override;
|
||||
void refresh();
|
||||
|
||||
Params params;
|
||||
QString prev_destinations, cur_destinations;
|
||||
QStackedWidget *stack;
|
||||
QPushButton *home_button, *work_button;
|
||||
QLabel *home_address, *work_address;
|
||||
|
||||
Reference in New Issue
Block a user