mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-05 00:05:59 +08:00
qt/util.h: new functions getBrand&getBrandVersion (#21238)
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "selfdrive/common/swaglog.h"
|
||||
#include "selfdrive/common/timing.h"
|
||||
#include "selfdrive/common/util.h"
|
||||
#include "selfdrive/ui/qt/util.h"
|
||||
#include "selfdrive/ui/qt/widgets/drive_stats.h"
|
||||
#include "selfdrive/ui/qt/widgets/setup.h"
|
||||
|
||||
@@ -102,8 +103,7 @@ OffroadHome::OffroadHome(QWidget* parent) : QFrame(parent) {
|
||||
QObject::connect(alert_notification, &QPushButton::released, this, &OffroadHome::openAlerts);
|
||||
header_layout->addWidget(alert_notification, 0, Qt::AlignHCenter | Qt::AlignRight);
|
||||
|
||||
std::string brand = Params().getBool("Passive") ? "dashcam" : "openpilot";
|
||||
QLabel* version = new QLabel(QString::fromStdString(brand + " v" + Params().get("Version")));
|
||||
QLabel* version = new QLabel(getBrandVersion());
|
||||
version->setStyleSheet(R"(font-size: 55px;)");
|
||||
header_layout->addWidget(version, 0, Qt::AlignHCenter | Qt::AlignRight);
|
||||
|
||||
|
||||
@@ -157,8 +157,7 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) {
|
||||
}
|
||||
}, "", this));
|
||||
|
||||
QString brand = params.getBool("Passive") ? "dashcam" : "openpilot";
|
||||
offroad_btns.append(new ButtonControl("Uninstall " + brand, "UNINSTALL", "", [=]() {
|
||||
offroad_btns.append(new ButtonControl("Uninstall " + getBrand(), "UNINSTALL", "", [=]() {
|
||||
if (ConfirmationDialog::confirm("Are you sure you want to uninstall?", this)) {
|
||||
Params().putBool("DoUninstall", true);
|
||||
}
|
||||
@@ -228,7 +227,6 @@ void SoftwarePanel::showEvent(QShowEvent *event) {
|
||||
|
||||
void SoftwarePanel::updateLabels() {
|
||||
Params params = Params();
|
||||
std::string brand = params.getBool("Passive") ? "dashcam" : "openpilot";
|
||||
QList<QPair<QString, std::string>> dev_params = {
|
||||
{"Git Branch", params.get("GitBranch")},
|
||||
{"Git Commit", params.get("GitCommit").substr(0, 10)},
|
||||
@@ -236,7 +234,6 @@ void SoftwarePanel::updateLabels() {
|
||||
{"OS Version", Hardware::get_os_version()},
|
||||
};
|
||||
|
||||
QString version = QString::fromStdString(brand + " v" + params.get("Version").substr(0, 14)).trimmed();
|
||||
QString lastUpdateTime = "";
|
||||
|
||||
std::string last_update_param = params.get("LastUpdateTime");
|
||||
@@ -246,7 +243,7 @@ void SoftwarePanel::updateLabels() {
|
||||
}
|
||||
|
||||
if (labels.size() < dev_params.size()) {
|
||||
versionLbl = new LabelControl("Version", version, QString::fromStdString(params.get("ReleaseNotes")).trimmed());
|
||||
versionLbl = new LabelControl("Version", getBrandVersion(), QString::fromStdString(params.get("ReleaseNotes")).trimmed());
|
||||
layout()->addWidget(versionLbl);
|
||||
layout()->addWidget(horizontal_line());
|
||||
|
||||
@@ -267,7 +264,7 @@ void SoftwarePanel::updateLabels() {
|
||||
layout()->addWidget(updateButton);
|
||||
layout()->addWidget(horizontal_line());
|
||||
} else {
|
||||
versionLbl->setText(version);
|
||||
versionLbl->setText(getBrandVersion());
|
||||
lastUpdateTimeLbl->setText(lastUpdateTime);
|
||||
updateButton->setText("CHECK");
|
||||
updateButton->setEnabled(true);
|
||||
|
||||
@@ -2,6 +2,17 @@
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "selfdrive/common/params.h"
|
||||
|
||||
|
||||
inline QString getBrand() {
|
||||
return Params().getBool("Passive") ? "dashcam" : "openpilot";
|
||||
}
|
||||
|
||||
inline QString getBrandVersion() {
|
||||
return getBrand() + " v" + QString::fromStdString(Params().get("Version")).left(14).trimmed();
|
||||
}
|
||||
|
||||
inline void configFont(QPainter &p, const QString &family, int size, const QString &style) {
|
||||
QFont f(family);
|
||||
f.setPixelSize(size);
|
||||
|
||||
Reference in New Issue
Block a user