From bfebbd05d33a59a2c1c6d5f5d8afbdcb00928210 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Fri, 11 Feb 2022 13:49:45 +0600 Subject: [PATCH 1/3] qt: Compatibility improvements * Patch to build with Qt 5.11 and later by jriwanek * Attempt to fix viewport on hardware renderers --- src/qt/qt_hardwarerenderer.cpp | 10 +++++----- src/qt/qt_main.cpp | 2 ++ src/qt/qt_renderercommon.hpp | 1 + src/qt/qt_rendererstack.cpp | 4 ---- src/qt/qt_softwarerenderer.cpp | 4 ++++ 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/qt/qt_hardwarerenderer.cpp b/src/qt/qt_hardwarerenderer.cpp index b322cbaf2..1a89b93be 100644 --- a/src/qt/qt_hardwarerenderer.cpp +++ b/src/qt/qt_hardwarerenderer.cpp @@ -32,7 +32,7 @@ extern "C" { void HardwareRenderer::resizeGL(int w, int h) { - glViewport(0, 0, w * devicePixelRatio(), h * devicePixelRatio()); + glViewport(0, 0, qRound(w * devicePixelRatio()), qRound(h * devicePixelRatio())); } #define PROGRAM_VERTEX_ATTRIBUTE 0 @@ -141,11 +141,11 @@ void HardwareRenderer::paintGL() { QVector verts, texcoords; QMatrix4x4 mat; mat.setToIdentity(); - mat.ortho(QRect(0, 0, width(), height())); + mat.ortho(QRectF(0, 0, (qreal)width(), (qreal)height())); verts.push_back(QVector2D((float)destination.x(), (float)destination.y())); - verts.push_back(QVector2D((float)destination.x(), (float)destination.y() + destination.height())); - verts.push_back(QVector2D((float)destination.x() + destination.width(), (float)destination.y() + destination.height())); - verts.push_back(QVector2D((float)destination.x() + destination.width(), (float)destination.y())); + verts.push_back(QVector2D((float)destination.x(), (float)destination.y() + (float)destination.height())); + verts.push_back(QVector2D((float)destination.x() + (float)destination.width(), (float)destination.y() + (float)destination.height())); + verts.push_back(QVector2D((float)destination.x() + (float)destination.width(), (float)destination.y())); texcoords.push_back(QVector2D((float)source.x() / 2048.f, (float)(source.y()) / 2048.f)); texcoords.push_back(QVector2D((float)source.x() / 2048.f, (float)(source.y() + source.height()) / 2048.f)); texcoords.push_back(QVector2D((float)(source.x() + source.width()) / 2048.f, (float)(source.y() + source.height()) / 2048.f)); diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index 51412dab7..78a0fc33f 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -134,7 +134,9 @@ int main(int argc, char* argv[]) { QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); +#endif QApplication app(argc, argv); qt_set_sequence_auto_mnemonic(false); Q_INIT_RESOURCE(qt_resources); diff --git a/src/qt/qt_renderercommon.hpp b/src/qt/qt_renderercommon.hpp index a62aa9aa2..f55f3ee03 100644 --- a/src/qt/qt_renderercommon.hpp +++ b/src/qt/qt_renderercommon.hpp @@ -7,6 +7,7 @@ #include #include #include +#include class QWidget; diff --git a/src/qt/qt_rendererstack.cpp b/src/qt/qt_rendererstack.cpp index 52d82fc92..16987099f 100644 --- a/src/qt/qt_rendererstack.cpp +++ b/src/qt/qt_rendererstack.cpp @@ -138,10 +138,6 @@ void RendererStack::mousePressEvent(QMouseEvent *event) { mousedata.mousebuttons |= event->button(); } - if (main_window->frameGeometry().contains(event->pos()) && !geometry().contains(event->pos())) - { - main_window->windowHandle()->startSystemMove(); - } event->accept(); } void RendererStack::wheelEvent(QWheelEvent *event) diff --git a/src/qt/qt_softwarerenderer.cpp b/src/qt/qt_softwarerenderer.cpp index 1245fd70a..13d727e83 100644 --- a/src/qt/qt_softwarerenderer.cpp +++ b/src/qt/qt_softwarerenderer.cpp @@ -76,7 +76,11 @@ void SoftwareRenderer::onPaint(QPaintDevice* device) { QPainter painter(device); painter.setRenderHint(QPainter::SmoothPixmapTransform, video_filter_method > 0 ? true : false); +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) painter.fillRect(0, 0, device->width(), device->height(), QColorConstants::Black); +#else + painter.fillRect(0,0, device->width(), device->height(), Qt::black); +#endif painter.setCompositionMode(QPainter::CompositionMode_Plus); painter.drawImage(destination, *images[cur_image], source); } From 4de19361bfeeb0e310ec152848de61df7ceee220 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Fri, 11 Feb 2022 15:40:07 +0600 Subject: [PATCH 2/3] qt: Properly set saved window size --- src/qt/qt_mainwindow.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 3c6496596..1b4dfe08d 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -468,10 +468,9 @@ void MainWindow::showEvent(QShowEvent *event) { scrnsz_y = fixed_size_y; } else if (window_remember && vid_resize == 1) { - resize(window_w, window_h - + menuBar()->height() - + (hide_status_bar ? 0 : statusBar()->height()) - + (hide_tool_bar ? 0 : ui->toolBar->height()) + 1); + ui->stackedWidget->setFixedSize(window_w, window_h); + adjustSize(); + ui->stackedWidget->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); scrnsz_x = window_w; scrnsz_y = window_h; } From 351e14023ab458c3889701ee8fc2a17acad415fc Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Fri, 11 Feb 2022 16:24:49 +0600 Subject: [PATCH 3/3] qt: Use C (English) locale No translations so far make use of non-standard digits --- src/qt/qt_main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index 78a0fc33f..9ce65411f 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -138,6 +138,7 @@ int main(int argc, char* argv[]) { QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); #endif QApplication app(argc, argv); + QLocale::setDefault(QLocale::C); qt_set_sequence_auto_mnemonic(false); Q_INIT_RESOURCE(qt_resources); Q_INIT_RESOURCE(qt_translations);