From db37bdd5e7c337271d15ec6275a821c30846b81c Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 22 Sep 2022 21:13:23 +0200 Subject: [PATCH 1/2] Enabling high-DPI scaling in QApplication --- src/klayout_main/klayout_main/klayout.cc | 1 + src/lay/lay/layApplication.cc | 20 ++++++++++++++------ src/lay/lay/layApplication.h | 7 +++++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/klayout_main/klayout_main/klayout.cc b/src/klayout_main/klayout_main/klayout.cc index 40cca527b..49ca8aa86 100644 --- a/src/klayout_main/klayout_main/klayout.cc +++ b/src/klayout_main/klayout_main/klayout.cc @@ -302,6 +302,7 @@ klayout_main_cont (int &argc, char **argv) if (non_ui_mode) { app.reset (new lay::NonGuiApplication (argc, argv)); } else { + lay::GuiApplication::initialize (); app.reset (new lay::GuiApplication (argc, argv)); lay::enable_signal_handler_gui (true); } diff --git a/src/lay/lay/layApplication.cc b/src/lay/lay/layApplication.cc index fe517860e..5aee10b73 100644 --- a/src/lay/lay/layApplication.cc +++ b/src/lay/lay/layApplication.cc @@ -1434,12 +1434,6 @@ GuiApplication::GuiApplication (int &argc, char **argv) setStyle (new lay::BackgroundAwareTreeStyle (0)); setWindowIcon (QIcon (QString::fromUtf8 (":/logo.png"))); -#if QT_VERSION >= 0x040500 - setAttribute (Qt::AA_DontShowIconsInMenus, false); -#endif -#if QT_VERSION >= 0x050000 - setAttribute (Qt::AA_UseHighDpiPixmaps, true); -#endif } GuiApplication::~GuiApplication () @@ -1453,6 +1447,20 @@ GuiApplication::~GuiApplication () shutdown (); } +void +GuiApplication::initialize () +{ +#if QT_VERSION >= 0x040500 + QCoreApplication::setAttribute (Qt::AA_DontShowIconsInMenus, false); +#endif +#if QT_VERSION >= 0x050000 + QCoreApplication::setAttribute (Qt::AA_UseHighDpiPixmaps, true); +#endif +#if QT_VERSION >= 0x050600 + QCoreApplication::setAttribute (Qt::AA_EnableHighDpiScaling, true); +#endif +} + bool GuiApplication::notify (QObject *receiver, QEvent *e) { diff --git a/src/lay/lay/layApplication.h b/src/lay/lay/layApplication.h index e5794cefd..6b42e1318 100644 --- a/src/lay/lay/layApplication.h +++ b/src/lay/lay/layApplication.h @@ -390,6 +390,13 @@ public: QApplication *qapp_gui () { return this; } + /** + * @brief Does some pre-initialization + * + * Must be called before the GuiApplication object is created + */ + static void initialize (); + /** * @brief Reimplementation of notify from QApplication */ From 836cb9f6f67ef7538435e6c7fdc2b983172e5666 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 23 Sep 2022 22:00:33 +0200 Subject: [PATCH 2/2] Added doc and icon to dependencies. --- src/klayout.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/klayout.pro b/src/klayout.pro index 897d5b516..8c29c0b11 100644 --- a/src/klayout.pro +++ b/src/klayout.pro @@ -112,7 +112,7 @@ equals(HAVE_RUBY, "1") { plugins.depends += lay - klayout_main.depends += plugins $$MAIN_DEPENDS + klayout_main.depends += doc icons plugins $$MAIN_DEPENDS } else {