From 03d6847be357d8a9da2421f7b305eed2af430149 Mon Sep 17 00:00:00 2001 From: mvglasow Date: Wed, 23 Jul 2025 22:32:49 +0300 Subject: [PATCH] [traffic][qt] Make HttpTraffSource configurable from Qt GUI Signed-off-by: mvglasow --- qt/preferences_dialog.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/qt/preferences_dialog.cpp b/qt/preferences_dialog.cpp index acc0fa827..6836a9dea 100644 --- a/qt/preferences_dialog.cpp +++ b/qt/preferences_dialog.cpp @@ -183,6 +183,31 @@ namespace qt } #endif + QLabel * trafficHttpUrlLabel = new QLabel("Traffic API URL:"); + + QLineEdit * trafficHttpUrlLineEdit = new QLineEdit(); + { + trafficHttpUrlLineEdit->setText(QString::fromStdString(framework.LoadTrafficHttpUrl())); + connect(trafficHttpUrlLineEdit, &QLineEdit::editingFinished, [&framework, trafficHttpUrlLineEdit]() + { + framework.SaveTrafficHttpUrl(trafficHttpUrlLineEdit->text().toStdString()); + framework.SetTrafficHttpUrl(trafficHttpUrlLineEdit->text().toStdString()); + }); + } + + QCheckBox * trafficHttpEnabledCheckBox = new QCheckBox("Enable live traffic data"); + { + trafficHttpEnabledCheckBox->setChecked(framework.LoadTrafficHttpEnabled()); + connect(trafficHttpEnabledCheckBox, &QCheckBox::stateChanged, [&framework, trafficHttpUrlLabel, trafficHttpUrlLineEdit](int i) + { + bool const enable = i > 0; + framework.SaveTrafficHttpEnabled(enable); + framework.SetTrafficHttpEnabled(enable); + trafficHttpUrlLabel->setEnabled(enable); + trafficHttpUrlLineEdit->setEnabled(enable); + }); + } + QHBoxLayout * bottomLayout = new QHBoxLayout(); { QPushButton * closeButton = new QPushButton(tr("Close")); @@ -206,6 +231,9 @@ namespace qt #ifdef BUILD_DESIGNER finalLayout->addWidget(indexRegenCheckBox); #endif + finalLayout->addWidget(trafficHttpEnabledCheckBox); + finalLayout->addWidget(trafficHttpUrlLabel); + finalLayout->addWidget(trafficHttpUrlLineEdit); finalLayout->addLayout(bottomLayout); setLayout(finalLayout); }