UI: auto wide detection on PC (#22392)

* UI: auto wide detection on PC

* invert width

* cleanup
pull/22393/head
Adeeb Shihadeh 4 years ago committed by GitHub
parent 7051aa91d7
commit 23ae67bbf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      selfdrive/ui/qt/maps/map_settings.cc
  2. 7
      selfdrive/ui/qt/offroad/onboarding.cc
  3. 4
      selfdrive/ui/qt/offroad/onboarding.h
  4. 10
      selfdrive/ui/qt/qt_window.h

@ -4,7 +4,6 @@
#include "selfdrive/common/util.h" #include "selfdrive/common/util.h"
#include "selfdrive/ui/qt/util.h" #include "selfdrive/ui/qt/util.h"
#include "selfdrive/ui/qt/qt_window.h"
#include "selfdrive/ui/qt/request_repeater.h" #include "selfdrive/ui/qt/request_repeater.h"
#include "selfdrive/ui/qt/widgets/controls.h" #include "selfdrive/ui/qt/widgets/controls.h"
#include "selfdrive/ui/qt/widgets/scrollview.h" #include "selfdrive/ui/qt/widgets/scrollview.h"
@ -102,7 +101,7 @@ MapPanel::MapPanel(QWidget* parent) : QWidget(parent) {
QLabel *screenshot = new QLabel; QLabel *screenshot = new QLabel;
QPixmap pm = QPixmap("../assets/navigation/screenshot.png"); QPixmap pm = QPixmap("../assets/navigation/screenshot.png");
screenshot->setPixmap(pm.scaledToWidth(vwp_w * 0.5, Qt::SmoothTransformation)); screenshot->setPixmap(pm.scaledToWidth(1080, Qt::SmoothTransformation));
no_prime_layout->addWidget(screenshot, 0, Qt::AlignHCenter); no_prime_layout->addWidget(screenshot, 0, Qt::AlignHCenter);
QLabel *signup = new QLabel("Get turn-by-turn directions displayed and more with a comma \nprime subscription. Sign up now: https://connect.comma.ai"); QLabel *signup = new QLabel("Get turn-by-turn directions displayed and more with a comma \nprime subscription. Sign up now: https://connect.comma.ai");

@ -29,14 +29,17 @@ void TrainingGuide::mouseReleaseEvent(QMouseEvent *e) {
if (currentIndex >= (boundingRect.size() - 1)) { if (currentIndex >= (boundingRect.size() - 1)) {
emit completedTraining(); emit completedTraining();
} else { } else {
image.load(IMG_PATH + "step" + QString::number(currentIndex) + ".png"); image.load(img_path + "step" + QString::number(currentIndex) + ".png");
update(); update();
} }
} }
void TrainingGuide::showEvent(QShowEvent *event) { void TrainingGuide::showEvent(QShowEvent *event) {
img_path = width() == WIDE_WIDTH ? "../assets/training_wide/" : "../assets/training/";
boundingRect = width() == WIDE_WIDTH ? boundingRectWide : boundingRectStandard;
currentIndex = 0; currentIndex = 0;
image.load(IMG_PATH + "step0.png"); image.load(img_path + "step0.png");
} }
void TrainingGuide::paintEvent(QPaintEvent *event) { void TrainingGuide::paintEvent(QPaintEvent *event) {

@ -72,8 +72,8 @@ private:
QRect(303, 755, 718, 189), QRect(303, 755, 718, 189),
}; };
const QString IMG_PATH = WIDE_UI ? "../assets/training_wide/" : "../assets/training/"; QString img_path;
const QVector<QRect> boundingRect = WIDE_UI ? boundingRectWide : boundingRectStandard; QVector<QRect> boundingRect;
signals: signals:
void completedTraining(); void completedTraining();

@ -3,6 +3,7 @@
#include <string> #include <string>
#include <QApplication> #include <QApplication>
#include <QScreen>
#include <QWidget> #include <QWidget>
#ifdef QCOM2 #ifdef QCOM2
@ -15,13 +16,14 @@
const QString ASSET_PATH = ":/"; const QString ASSET_PATH = ":/";
const bool WIDE_UI = Hardware::TICI() || getenv("WIDE_UI") != nullptr; const int WIDE_WIDTH = 2160;
const int vwp_w = WIDE_UI ? 2160 : 1920;
const int vwp_h = 1080;
inline void setMainWindow(QWidget *w) { inline void setMainWindow(QWidget *w) {
const bool wide = (QGuiApplication::primaryScreen()->size().width() >= WIDE_WIDTH) ^
(getenv("INVERT_WIDTH") != NULL);
const float scale = util::getenv("SCALE", 1.0f); const float scale = util::getenv("SCALE", 1.0f);
w->setFixedSize(vwp_w*scale, vwp_h*scale);
w->setFixedSize(QSize(wide ? WIDE_WIDTH : 1920, 1080) * scale);
w->show(); w->show();
#ifdef QCOM2 #ifdef QCOM2

Loading…
Cancel
Save