fix margin after setting DPI

old-commit-hash: 7954256a09
commatwo_master
Comma Device 4 years ago
parent 4770c6d1c9
commit 20df6ce147
  1. 11
      selfdrive/ui/qt/offroad/settings.cc
  2. 4
      selfdrive/ui/qt/widgets/drive_stats.cc

@ -19,9 +19,8 @@
#include "widgets/toggle.hpp" #include "widgets/toggle.hpp"
#include "widgets/offroad_alerts.hpp" #include "widgets/offroad_alerts.hpp"
#include "common/params.h" #include "selfdrive/common/params.h"
#include "common/util.h" #include "selfdrive/common/util.h"
#include "selfdrive/hardware/hw.h" #include "selfdrive/hardware/hw.h"
QFrame* horizontal_line(QWidget* parent = 0){ QFrame* horizontal_line(QWidget* parent = 0){
@ -45,17 +44,19 @@ QWidget* labelWidget(QString labelName, QString labelContent){
ParamsToggle::ParamsToggle(QString param, QString title, QString description, QString icon_path, QWidget *parent): QFrame(parent) , param(param) { ParamsToggle::ParamsToggle(QString param, QString title, QString description, QString icon_path, QWidget *parent): QFrame(parent) , param(param) {
QHBoxLayout *layout = new QHBoxLayout; QHBoxLayout *layout = new QHBoxLayout;
layout->setMargin(0);
layout->setSpacing(50); layout->setSpacing(50);
// Parameter image // Parameter image
const int img_size = 80;
if (icon_path.length()) { if (icon_path.length()) {
QPixmap pix(icon_path); QPixmap pix(icon_path);
QLabel *icon = new QLabel(); QLabel *icon = new QLabel();
icon->setPixmap(pix.scaledToWidth(80, Qt::SmoothTransformation)); icon->setPixmap(pix.scaledToWidth(img_size, Qt::SmoothTransformation));
icon->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); icon->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
layout->addWidget(icon); layout->addWidget(icon);
} else { } else {
layout->addSpacing(80); layout->addSpacing(img_size);
} }
// Name of the parameter // Name of the parameter

@ -25,6 +25,7 @@ void clearLayouts(QLayout* layout) {
QLayout* build_stat(QString name, int stat) { QLayout* build_stat(QString name, int stat) {
QVBoxLayout* layout = new QVBoxLayout; QVBoxLayout* layout = new QVBoxLayout;
layout->setMargin(0);
QLabel* metric = new QLabel(QString("%1").arg(stat)); QLabel* metric = new QLabel(QString("%1").arg(stat));
metric->setStyleSheet(R"( metric->setStyleSheet(R"(
@ -64,6 +65,7 @@ void DriveStats::parseResponse(QString response) {
auto week = json["week"].toObject(); auto week = json["week"].toObject();
QGridLayout* gl = new QGridLayout(); QGridLayout* gl = new QGridLayout();
gl->setMargin(0);
int all_distance = all["distance"].toDouble() * (metric ? MILE_TO_KM : 1); int all_distance = all["distance"].toDouble() * (metric ? MILE_TO_KM : 1);
gl->addWidget(new QLabel("ALL TIME"), 0, 0, 1, 3); gl->addWidget(new QLabel("ALL TIME"), 0, 0, 1, 3);
@ -84,6 +86,7 @@ void DriveStats::parseResponse(QString response) {
DriveStats::DriveStats(QWidget* parent) : QWidget(parent) { DriveStats::DriveStats(QWidget* parent) : QWidget(parent) {
vlayout = new QVBoxLayout(this); vlayout = new QVBoxLayout(this);
vlayout->setMargin(0);
setLayout(vlayout); setLayout(vlayout);
setStyleSheet(R"( setStyleSheet(R"(
QLabel { QLabel {
@ -92,6 +95,7 @@ DriveStats::DriveStats(QWidget* parent) : QWidget(parent) {
} }
)"); )");
// TODO: do we really need to update this frequently?
QString dongleId = QString::fromStdString(Params().get("DongleId")); QString dongleId = QString::fromStdString(Params().get("DongleId"));
QString url = "https://api.commadotai.com/v1.1/devices/" + dongleId + "/stats"; QString url = "https://api.commadotai.com/v1.1/devices/" + dongleId + "/stats";
RequestRepeater* repeater = new RequestRepeater(this, url, 13); RequestRepeater* repeater = new RequestRepeater(this, url, 13);

Loading…
Cancel
Save