Skip to content

Commit

Permalink
Merge pull request #38 from Z-bin/zhou-dev
Browse files Browse the repository at this point in the history
Use X11 to get the screen width to determine the resolution
  • Loading branch information
ll-eleven authored Jul 21, 2020
2 parents ed4b1dd + 6d45bb7 commit cd67121
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tools/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <QSoundEffect>
#include <QTimer>
#include <QGSettings/QGSettings>
#include <X11/Xlib.h>

#include "ukuipower.h"
#include "mainwindow.h"
Expand Down Expand Up @@ -67,14 +68,21 @@ bool playShutdownMusic(UkuiPower &powermanager, int num)

int main(int argc, char* argv[])
{
QApplication a(argc, argv);
Display *disp = XOpenDisplay(NULL);
Screen *scrn = DefaultScreenOfDisplay(disp);
if (NULL == scrn) {
return 0;
}
int width = scrn->width;

if (QApplication::desktop()->width() >= 2560) {
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);
//for hidpi

UkuiPower powermanager(&a);
Expand Down

0 comments on commit cd67121

Please sign in to comment.