fixed scaling for 1.5+ scale on windows

This commit is contained in:
fourtf 2018-06-24 23:58:29 +02:00
parent 4075ac9279
commit ba5c3555b8
2 changed files with 16 additions and 11 deletions

View file

@ -35,8 +35,7 @@ int main(int argc, char *argv[])
{ {
QApplication::setAttribute(Qt::AA_Use96Dpi, true); QApplication::setAttribute(Qt::AA_Use96Dpi, true);
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
// QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true); QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true);
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
#endif #endif
// QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL, true); // QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL, true);
QApplication a(argc, argv); QApplication a(argc, argv);

View file

@ -144,12 +144,12 @@ void BaseWindow::init()
layout->addWidget(this->ui_.layoutBase); layout->addWidget(this->ui_.layoutBase);
} }
// DPI // DPI
auto dpi = util::getWindowDpi(this->winId()); // auto dpi = util::getWindowDpi(this->winId());
if (dpi) { // if (dpi) {
this->scale = dpi.value() / 96.f; // this->scale = dpi.value() / 96.f;
} // }
#endif #endif
#ifdef USEWINSDK #ifdef USEWINSDK
@ -418,10 +418,16 @@ bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message, long *r
float _scale = dpi / 96.f; float _scale = dpi / 96.f;
auto *prcNewWindow = reinterpret_cast<RECT *>(msg->lParam); static bool firstResize = true;
SetWindowPos(msg->hwnd, nullptr, prcNewWindow->left, prcNewWindow->top,
prcNewWindow->right - prcNewWindow->left, if (!firstResize) {
prcNewWindow->bottom - prcNewWindow->top, SWP_NOZORDER | SWP_NOACTIVATE); auto *prcNewWindow = reinterpret_cast<RECT *>(msg->lParam);
SetWindowPos(msg->hwnd, nullptr, prcNewWindow->left, prcNewWindow->top,
prcNewWindow->right - prcNewWindow->left,
prcNewWindow->bottom - prcNewWindow->top,
SWP_NOZORDER | SWP_NOACTIVATE);
}
firstResize = false;
this->nativeScale_ = _scale; this->nativeScale_ = _scale;
this->updateScale(); this->updateScale();