Merge pull request #2102 from Cacodemon345/newqt

qt: Compatibility improvements
This commit is contained in:
David Hrdlička
2022-02-11 11:30:03 +01:00
committed by GitHub
6 changed files with 16 additions and 13 deletions

View File

@@ -32,7 +32,7 @@ extern "C" {
void HardwareRenderer::resizeGL(int w, int h) 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 #define PROGRAM_VERTEX_ATTRIBUTE 0
@@ -141,11 +141,11 @@ void HardwareRenderer::paintGL() {
QVector<QVector2D> verts, texcoords; QVector<QVector2D> verts, texcoords;
QMatrix4x4 mat; QMatrix4x4 mat;
mat.setToIdentity(); 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()));
verts.push_back(QVector2D((float)destination.x(), (float)destination.y() + destination.height())); verts.push_back(QVector2D((float)destination.x(), (float)destination.y() + (float)destination.height()));
verts.push_back(QVector2D((float)destination.x() + destination.width(), (float)destination.y() + 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() + destination.width(), (float)destination.y())); 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()) / 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() / 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)); texcoords.push_back(QVector2D((float)(source.x() + source.width()) / 2048.f, (float)(source.y() + source.height()) / 2048.f));

View File

@@ -134,8 +134,11 @@ int main(int argc, char* argv[]) {
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif #endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif
QApplication app(argc, argv); QApplication app(argc, argv);
QLocale::setDefault(QLocale::C);
qt_set_sequence_auto_mnemonic(false); qt_set_sequence_auto_mnemonic(false);
Q_INIT_RESOURCE(qt_resources); Q_INIT_RESOURCE(qt_resources);
Q_INIT_RESOURCE(qt_translations); Q_INIT_RESOURCE(qt_translations);

View File

@@ -468,10 +468,9 @@ void MainWindow::showEvent(QShowEvent *event) {
scrnsz_y = fixed_size_y; scrnsz_y = fixed_size_y;
} }
else if (window_remember && vid_resize == 1) { else if (window_remember && vid_resize == 1) {
resize(window_w, window_h ui->stackedWidget->setFixedSize(window_w, window_h);
+ menuBar()->height() adjustSize();
+ (hide_status_bar ? 0 : statusBar()->height()) ui->stackedWidget->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
+ (hide_tool_bar ? 0 : ui->toolBar->height()) + 1);
scrnsz_x = window_w; scrnsz_x = window_w;
scrnsz_y = window_h; scrnsz_y = window_h;
} }

View File

@@ -7,6 +7,7 @@
#include <vector> #include <vector>
#include <tuple> #include <tuple>
#include <atomic> #include <atomic>
#include <memory>
class QWidget; class QWidget;

View File

@@ -138,10 +138,6 @@ void RendererStack::mousePressEvent(QMouseEvent *event)
{ {
mousedata.mousebuttons |= event->button(); mousedata.mousebuttons |= event->button();
} }
if (main_window->frameGeometry().contains(event->pos()) && !geometry().contains(event->pos()))
{
main_window->windowHandle()->startSystemMove();
}
event->accept(); event->accept();
} }
void RendererStack::wheelEvent(QWheelEvent *event) void RendererStack::wheelEvent(QWheelEvent *event)

View File

@@ -76,7 +76,11 @@ void SoftwareRenderer::onPaint(QPaintDevice* device) {
QPainter painter(device); QPainter painter(device);
painter.setRenderHint(QPainter::SmoothPixmapTransform, video_filter_method > 0 ? true : false); 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); 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.setCompositionMode(QPainter::CompositionMode_Plus);
painter.drawImage(destination, *images[cur_image], source); painter.drawImage(destination, *images[cur_image], source);
} }