mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 20:03:53 +08:00
UI: auto wide detection on PC (#22392)
* UI: auto wide detection on PC * invert width * cleanup
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "selfdrive/common/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/widgets/controls.h"
|
||||
#include "selfdrive/ui/qt/widgets/scrollview.h"
|
||||
@@ -102,7 +101,7 @@ MapPanel::MapPanel(QWidget* parent) : QWidget(parent) {
|
||||
|
||||
QLabel *screenshot = new QLabel;
|
||||
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);
|
||||
|
||||
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)) {
|
||||
emit completedTraining();
|
||||
} else {
|
||||
image.load(IMG_PATH + "step" + QString::number(currentIndex) + ".png");
|
||||
image.load(img_path + "step" + QString::number(currentIndex) + ".png");
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void TrainingGuide::showEvent(QShowEvent *event) {
|
||||
img_path = width() == WIDE_WIDTH ? "../assets/training_wide/" : "../assets/training/";
|
||||
boundingRect = width() == WIDE_WIDTH ? boundingRectWide : boundingRectStandard;
|
||||
|
||||
currentIndex = 0;
|
||||
image.load(IMG_PATH + "step0.png");
|
||||
image.load(img_path + "step0.png");
|
||||
}
|
||||
|
||||
void TrainingGuide::paintEvent(QPaintEvent *event) {
|
||||
|
||||
@@ -72,8 +72,8 @@ private:
|
||||
QRect(303, 755, 718, 189),
|
||||
};
|
||||
|
||||
const QString IMG_PATH = WIDE_UI ? "../assets/training_wide/" : "../assets/training/";
|
||||
const QVector<QRect> boundingRect = WIDE_UI ? boundingRectWide : boundingRectStandard;
|
||||
QString img_path;
|
||||
QVector<QRect> boundingRect;
|
||||
|
||||
signals:
|
||||
void completedTraining();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <string>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QScreen>
|
||||
#include <QWidget>
|
||||
|
||||
#ifdef QCOM2
|
||||
@@ -15,13 +16,14 @@
|
||||
|
||||
const QString ASSET_PATH = ":/";
|
||||
|
||||
const bool WIDE_UI = Hardware::TICI() || getenv("WIDE_UI") != nullptr;
|
||||
const int vwp_w = WIDE_UI ? 2160 : 1920;
|
||||
const int vwp_h = 1080;
|
||||
const int WIDE_WIDTH = 2160;
|
||||
|
||||
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);
|
||||
w->setFixedSize(vwp_w*scale, vwp_h*scale);
|
||||
|
||||
w->setFixedSize(QSize(wide ? WIDE_WIDTH : 1920, 1080) * scale);
|
||||
w->show();
|
||||
|
||||
#ifdef QCOM2
|
||||
|
||||
Reference in New Issue
Block a user