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 d6195efd..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,15 +34,22 @@ 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 (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); - 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 - } openlog(LOG_IDENT, LOG_NDELAY | LOG_NOWAIT | LOG_PID, LOG_USER);