Merge pull request #44 from Z-bin/master

Use X11 to get the screen width to determine the resolution
This commit is contained in:
chenlelin 2020-07-20 20:04:44 +08:00 committed by GitHub
commit 62f51cb865
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 8 deletions

3
debian/control vendored
View File

@ -12,7 +12,8 @@ Build-Depends: debhelper-compat (= 12),
qtbase5-dev-tools, qtbase5-dev-tools,
libqt5x11extras5-dev, libqt5x11extras5-dev,
libgsettings-qt-dev, libgsettings-qt-dev,
libkf5windowsystem-dev libkf5windowsystem-dev,
libx11-dev,
Standards-Version: 4.5.0 Standards-Version: 4.5.0
Rules-Requires-Root: no Rules-Requires-Root: no
Homepage: https://github.com/ukui/kylin-nm Homepage: https://github.com/ukui/kylin-nm

View File

@ -18,7 +18,7 @@ CONFIG += release
# CONFIG += link_pkgconfig # CONFIG += link_pkgconfig
# PKGCONFIG += gsettings-qt # PKGCONFIG += gsettings-qt
LIBS += -L/usr/lib/ -lgsettings-qt LIBS += -L/usr/lib/ -lgsettings-qt -lX11
target.path = /usr/bin target.path = /usr/bin
target.source += $$TARGET target.source += $$TARGET

View File

@ -26,6 +26,7 @@
#include <QApplication> #include <QApplication>
#include <QDebug> #include <QDebug>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <X11/Xlib.h>
#define LOG_IDENT "ukui_kylin_nm" #define LOG_IDENT "ukui_kylin_nm"
@ -33,15 +34,22 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
//QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); //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); 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); openlog(LOG_IDENT, LOG_NDELAY | LOG_NOWAIT | LOG_PID, LOG_USER);