ui: cleanup setMainWindow (#28768)

* cleanup

* revert that

---------

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
This commit is contained in:
Dean Lee 2023-07-10 07:46:50 +08:00 committed by GitHub
parent e346839c68
commit 289fd32699
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View File

@ -1,15 +1,15 @@
#include "selfdrive/ui/qt/qt_window.h"
void setMainWindow(QWidget *w) {
const float scale = util::getenv("SCALE", 1.0f);
const QSize sz = QGuiApplication::primaryScreen()->size();
if (Hardware::PC() && sz.width() <= 1920 && sz.height() <= 1080 && getenv("SCALE") == nullptr) {
if (Hardware::PC() && scale == 1.0 && !(sz - DEVICE_SCREEN_SIZE).isValid()) {
w->setMinimumSize(QSize(640, 480)); // allow resize smaller than fullscreen
w->setMaximumSize(QSize(2160, 1080));
w->setMaximumSize(DEVICE_SCREEN_SIZE);
w->resize(sz);
} else {
const float scale = util::getenv("SCALE", 1.0f);
const bool wide = (sz.width() >= WIDE_WIDTH) ^ (getenv("INVERT_WIDTH") != NULL);
w->setFixedSize(QSize(wide ? WIDE_WIDTH : 1920, 1080) * scale);
w->setFixedSize(DEVICE_SCREEN_SIZE * scale);
}
w->show();

View File

@ -15,7 +15,6 @@
#include "system/hardware/hw.h"
const QString ASSET_PATH = ":/";
const int WIDE_WIDTH = 2160;
const QSize DEVICE_SCREEN_SIZE = {2160, 1080};
void setMainWindow(QWidget *w);