From 356059ec21c20a40bf9b47327930afc90b52170b Mon Sep 17 00:00:00 2001 From: Z-bin <1134636325@qq.com> Date: Mon, 20 Jul 2020 16:07:28 +0800 Subject: [PATCH 1/2] Fix HD screen parameter error --- src/main.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index d6195efd..8762c8ce 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,14 +34,13 @@ int main(int argc, char *argv[]) { //QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QApplication a(argc, argv); - - if (QApplication::desktop()->width() >= 2560) { #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); #endif - } + + QApplication a(argc, argv); + openlog(LOG_IDENT, LOG_NDELAY | LOG_NOWAIT | LOG_PID, LOG_USER); From 4052c9cb877f6251185cf497c973ae4fd2af1e77 Mon Sep 17 00:00:00 2001 From: Z-bin <1134636325@qq.com> Date: Mon, 20 Jul 2020 19:17:22 +0800 Subject: [PATCH 2/2] Use X11 or go to the screen width to determine the resolution --- debian/control | 3 ++- kylin-nm.pro | 2 +- src/main.cpp | 17 +++++++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/debian/control b/debian/control index e47417f6..fdebab42 100644 --- a/debian/control +++ b/debian/control @@ -12,7 +12,8 @@ Build-Depends: debhelper-compat (= 12), qtbase5-dev-tools, libqt5x11extras5-dev, libgsettings-qt-dev, - libkf5windowsystem-dev + libkf5windowsystem-dev, + libx11-dev, Standards-Version: 4.5.0 Rules-Requires-Root: no Homepage: https://github.com/ukui/kylin-nm diff --git a/kylin-nm.pro b/kylin-nm.pro index a54c8455..f97d0a5d 100644 --- a/kylin-nm.pro +++ b/kylin-nm.pro @@ -18,7 +18,7 @@ CONFIG += release # CONFIG += link_pkgconfig # PKGCONFIG += gsettings-qt -LIBS += -L/usr/lib/ -lgsettings-qt +LIBS += -L/usr/lib/ -lgsettings-qt -lX11 target.path = /usr/bin target.source += $$TARGET diff --git a/src/main.cpp b/src/main.cpp index 8762c8ce..e4706115 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #define LOG_IDENT "ukui_kylin_nm" @@ -33,11 +34,19 @@ int main(int argc, char *argv[]) { //QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + Display *disp = XOpenDisplay(NULL); + Screen *scrn = DefaultScreenOfDisplay(disp); + if (NULL == scrn) { + return 0; + } + int width = scrn->width; -#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) - QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); -#endif + if (width > 2560) { + #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + #endif + } QApplication a(argc, argv);