From 24c12d6adbab8b64adb65d56fc89fcf28a4a59c8 Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 26 Mar 2019 15:21:09 +0100 Subject: [PATCH] Fix compatibility with Qt < 5.6 Signed-off-by: falkTX --- resources/ui/carla_about.ui | 21 ++++++++++++++++++--- source/frontend/carla_host.py | 5 +++-- source/frontend/patchcanvas/scene.py | 5 ++++- source/theme/CarlaStyle.cpp | 5 +++-- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/resources/ui/carla_about.ui b/resources/ui/carla_about.ui index 46cf12a03..d97a88365 100644 --- a/resources/ui/carla_about.ui +++ b/resources/ui/carla_about.ui @@ -371,7 +371,10 @@ Qt::PlainText - :/48x48/folder.png + :/scalable/folder.svgz + + + true @@ -396,7 +399,10 @@ Qt::PlainText - :/48x48/warning.png + :/scalable/warning.svgz + + + true @@ -421,7 +427,10 @@ Qt::PlainText - :/48x48/wine.png + :/scalable/wine.svgz + + + true @@ -498,6 +507,9 @@ :/scalable/carla.svg + + true + @@ -523,6 +535,9 @@ :/scalable/carla-control.svg + + true + diff --git a/source/frontend/carla_host.py b/source/frontend/carla_host.py index 2e22ed474..1c1e307b2 100644 --- a/source/frontend/carla_host.py +++ b/source/frontend/carla_host.py @@ -22,7 +22,7 @@ import json from PyQt5.Qt import PYQT_VERSION -from PyQt5.QtCore import qCritical, QEventLoop, QFileInfo, QModelIndex, QPointF, QTimer, QEvent +from PyQt5.QtCore import QT_VERSION, qCritical, QEventLoop, QFileInfo, QModelIndex, QPointF, QTimer, QEvent from PyQt5.QtGui import QImage, QPalette, QBrush from PyQt5.QtWidgets import QAction, QApplication, QInputDialog, QFileSystemModel, QListWidgetItem, QGraphicsView, QMainWindow @@ -2329,7 +2329,8 @@ class HostWindow(QMainWindow): self.refreshTransport(True) QMainWindow.showEvent(self, event) - self.host.set_engine_option(ENGINE_OPTION_FRONTEND_UI_SCALE, int(self.devicePixelRatioF() * 1000), "") + if QT_VERSION >= 0x50600: + self.host.set_engine_option(ENGINE_OPTION_FRONTEND_UI_SCALE, int(self.devicePixelRatioF() * 1000), "") # set our gui as parent for all plugins UIs if self.host.manageUIs and not (self.host.isControl or self.host.isPlugin): diff --git a/source/frontend/patchcanvas/scene.py b/source/frontend/patchcanvas/scene.py index 88e480213..938b9b4b7 100644 --- a/source/frontend/patchcanvas/scene.py +++ b/source/frontend/patchcanvas/scene.py @@ -21,7 +21,7 @@ from math import floor -from PyQt5.QtCore import pyqtSignal, pyqtSlot, qFatal, Qt, QPointF, QRectF +from PyQt5.QtCore import QT_VERSION, pyqtSignal, pyqtSlot, qFatal, Qt, QPointF, QRectF from PyQt5.QtGui import QCursor, QPixmap, QPolygonF from PyQt5.QtWidgets import QGraphicsRectItem, QGraphicsScene @@ -86,6 +86,9 @@ class PatchScene(QGraphicsScene): self.selectionChanged.connect(self.slot_selectionChanged) def getDevicePixelRatioF(self): + if QT_VERSION < 0x50600: + return 1.0 + return self.m_view.devicePixelRatioF() def getScaleFactor(self): diff --git a/source/theme/CarlaStyle.cpp b/source/theme/CarlaStyle.cpp index c3ae30e4f..7af740b55 100644 --- a/source/theme/CarlaStyle.cpp +++ b/source/theme/CarlaStyle.cpp @@ -1934,8 +1934,8 @@ void CarlaStyle::drawControl(ControlElement element, const QStyleOption *option, pixmap = menuItem->icon.pixmap(iconSize, mode); #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) - const qreal pixw = static_cast(pixmap.width()) / pixmap.devicePixelRatioF(); - const qreal pixh = static_cast(pixmap.height()) / pixmap.devicePixelRatioF(); + const int pixw = pixmap.width() / pixmap.devicePixelRatioF(); + const int pixh = pixmap.height() / pixmap.devicePixelRatioF(); #else const int pixw = pixmap.width(); const int pixh = pixmap.height(); @@ -2086,6 +2086,7 @@ void CarlaStyle::drawControl(ControlElement element, const QStyleOption *option, #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) w = pixmap.width() / pixmap.devicePixelRatio(); #else + w = pixmap.width(); #endif if (button->direction == Qt::RightToLeft)