mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 03:03:57 +08:00
cabana: enable Hi-DPI support on MacOS (#27965)
old-commit-hash: 475903e244
This commit is contained in:
@@ -110,7 +110,7 @@ void sigTermHandler(int s) {
|
||||
qApp->quit();
|
||||
}
|
||||
|
||||
void initApp(int argc, char *argv[]) {
|
||||
void initApp(int argc, char *argv[], bool disable_hidpi) {
|
||||
Hardware::set_display_power(true);
|
||||
Hardware::set_brightness(65);
|
||||
|
||||
@@ -118,13 +118,13 @@ void initApp(int argc, char *argv[]) {
|
||||
std::signal(SIGINT, sigTermHandler);
|
||||
std::signal(SIGTERM, sigTermHandler);
|
||||
|
||||
if (disable_hidpi) {
|
||||
#ifdef __APPLE__
|
||||
{
|
||||
// Get the devicePixelRatio, and scale accordingly to maintain 1:1 rendering
|
||||
QApplication tmp(argc, argv);
|
||||
qputenv("QT_SCALE_FACTOR", QString::number(1.0 / tmp.devicePixelRatio() ).toLocal8Bit());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
setQtSurfaceFormat();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ void clearLayout(QLayout* layout);
|
||||
void setQtSurfaceFormat();
|
||||
QString timeAgo(const QDateTime &date);
|
||||
void swagLogMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);
|
||||
void initApp(int argc, char *argv[]);
|
||||
void initApp(int argc, char *argv[], bool disable_hidpi = true);
|
||||
QWidget* topWidget (QWidget* widget);
|
||||
QPixmap loadPixmap(const QString &fileName, const QSize &size = {}, Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio);
|
||||
QPixmap bootstrapPixmap(const QString &id);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
int main(int argc, char *argv[]) {
|
||||
QCoreApplication::setApplicationName("Cabana");
|
||||
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
||||
initApp(argc, argv);
|
||||
initApp(argc, argv, false);
|
||||
QApplication app(argc, argv);
|
||||
app.setApplicationDisplayName("Cabana");
|
||||
app.setWindowIcon(QIcon(":cabana-icon.png"));
|
||||
|
||||
Reference in New Issue
Block a user