Browse Source

Fix compatibility with Qt < 5.6

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.1-rc1
falkTX 5 years ago
parent
commit
24c12d6adb
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 28 additions and 8 deletions
  1. +18
    -3
      resources/ui/carla_about.ui
  2. +3
    -2
      source/frontend/carla_host.py
  3. +4
    -1
      source/frontend/patchcanvas/scene.py
  4. +3
    -2
      source/theme/CarlaStyle.cpp

+ 18
- 3
resources/ui/carla_about.ui View File

@@ -371,7 +371,10 @@
<enum>Qt::PlainText</enum>
</property>
<property name="pixmap">
<pixmap resource="../resources.qrc">:/48x48/folder.png</pixmap>
<pixmap resource="../resources.qrc">:/scalable/folder.svgz</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
@@ -396,7 +399,10 @@
<enum>Qt::PlainText</enum>
</property>
<property name="pixmap">
<pixmap resource="../resources.qrc">:/48x48/warning.png</pixmap>
<pixmap resource="../resources.qrc">:/scalable/warning.svgz</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
@@ -421,7 +427,10 @@
<enum>Qt::PlainText</enum>
</property>
<property name="pixmap">
<pixmap resource="../resources.qrc">:/48x48/wine.png</pixmap>
<pixmap resource="../resources.qrc">:/scalable/wine.svgz</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
@@ -498,6 +507,9 @@
<property name="pixmap">
<pixmap resource="../resources.qrc">:/scalable/carla.svg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
@@ -523,6 +535,9 @@
<property name="pixmap">
<pixmap resource="../resources.qrc">:/scalable/carla-control.svg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>


+ 3
- 2
source/frontend/carla_host.py View File

@@ -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):


+ 4
- 1
source/frontend/patchcanvas/scene.py View File

@@ -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):


+ 3
- 2
source/theme/CarlaStyle.cpp View File

@@ -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<qreal>(pixmap.width()) / pixmap.devicePixelRatioF();
const qreal pixh = static_cast<qreal>(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)


Loading…
Cancel
Save