Use X11 or go to the screen width to determine the resolution

This commit is contained in:
Z-bin 2020-07-20 19:17:22 +08:00
parent 356059ec21
commit 4052c9cb87
3 changed files with 16 additions and 6 deletions

3
debian/control vendored
View File

@ -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

View File

@ -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

View File

@ -26,6 +26,7 @@
#include <QApplication>
#include <QDebug>
#include <QDesktopWidget>
#include <X11/Xlib.h>
#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);