Browse Source

Fix a few compat issues with Qt6, cleanup

Signed-off-by: falkTX <falktx@falktx.com>
pull/1996/head
falkTX 3 months ago
parent
commit
08e60c18eb
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
6 changed files with 38 additions and 27 deletions
  1. +8
    -8
      .github/workflows/pylint.yml
  2. +2
    -2
      data/macos/bundle.py
  3. +2
    -2
      data/windows/app-gui.py
  4. +15
    -7
      source/frontend/widgets/canvaspreviewframe.py
  5. +6
    -6
      source/frontend/widgets/draggablegraphicsview.py
  6. +5
    -2
      source/frontend/widgets/pixmapkeyboard.py

+ 8
- 8
.github/workflows/pylint.yml View File

@@ -21,10 +21,10 @@ jobs:
run: |
virtualenv carla-env
source carla-env/bin/activate
pylint -E source/frontend/carla_app.py
pylint -E source/frontend/carla_backend.py
pylint -E source/frontend/carla_shared.py
pylint -E source/frontend/carla_utils.py
pylint -E --extension-pkg-whitelist=PyQt5 source/frontend/carla_app.py
pylint -E --extension-pkg-whitelist=PyQt5 source/frontend/carla_backend.py
pylint -E --extension-pkg-whitelist=PyQt5 source/frontend/carla_shared.py
pylint -E --extension-pkg-whitelist=PyQt5 source/frontend/carla_utils.py

pyqt6:
runs-on: ubuntu-22.04
@@ -44,7 +44,7 @@ jobs:
run: |
virtualenv carla-env
source carla-env/bin/activate
pylint -E source/frontend/carla_app.py
pylint -E source/frontend/carla_backend.py
pylint -E source/frontend/carla_shared.py
pylint -E source/frontend/carla_utils.py
pylint -E --extension-pkg-whitelist=PyQt6 source/frontend/carla_app.py
pylint -E --extension-pkg-whitelist=PyQt6 source/frontend/carla_backend.py
pylint -E --extension-pkg-whitelist=PyQt6 source/frontend/carla_shared.py
pylint -E --extension-pkg-whitelist=PyQt6 source/frontend/carla_utils.py

+ 2
- 2
data/macos/bundle.py View File

@@ -10,7 +10,7 @@ from os import getenv
# ------------------------------------------------------------------------------------------------------------
# Imports (Custom Stuff)

from carla_host import VERSION
from carla_backend import CARLA_VERSION_STRING

# ------------------------------------------------------------------------------------------------------------

@@ -31,7 +31,7 @@ if SCRIPT_NAME in ("Carla", "Carla-Control"):
boptions["custom_info_plist"] = "./data/macos/%s.plist" % SCRIPT_NAME

setup(name = "Carla",
version = VERSION,
version = CARLA_VERSION_STRING,
description = "Carla Plugin Host",
options = {"build_exe": options, "bdist_mac": boptions},
executables = [Executable("./source/frontend/%s" % SCRIPT_NAME)])


+ 2
- 2
data/windows/app-gui.py View File

@@ -9,7 +9,7 @@ from cx_Freeze import setup, Executable
# ------------------------------------------------------------------------------------------------------------
# Imports (Custom Stuff)

from carla_host import VERSION
from carla_backend import CARLA_VERSION_STRING
from os import getenv

# ------------------------------------------------------------------------------------------------------------
@@ -43,7 +43,7 @@ exe_options = {
}

setup(name = name,
version = VERSION,
version = CARLA_VERSION_STRING,
description = description,
options = {"build_exe": options},
executables = [Executable(**exe_options)])


+ 15
- 7
source/frontend/widgets/canvaspreviewframe.py View File

@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2011-2024 Filipe Coelho <falktx@falktx.com>
# SPDX-FileCopyrightText: 2011-2025 Filipe Coelho <falktx@falktx.com>
# SPDX-License-Identifier: GPL-2.0-or-later

# ---------------------------------------------------------------------------------------------------------------------
@@ -199,7 +199,11 @@ class CanvasPreviewFrame(QFrame):
return
if self.fMouseMode == self._MOUSE_MODE_SCALE:
event.accept()
self._scaleViewRect(event.globalY())
if qt_config == 5:
y = event.globalY()
else:
y = event.globalPosition().y()
self._scaleViewRect(y)
return
QFrame.mouseMoveEvent(self, event)

@@ -384,24 +388,28 @@ class CanvasPreviewFrame(QFrame):
self.setCursor(self.fZoomCursors[self._kCursorZoomIn if dy > 0 else self._kCursorZoomOut])
self.fScene.zoom_wheel(dy)

# FIXME do not rely on this
self.cursor().setPos(self.fMouseInitialZoomPos)

def _updateMouseMode(self, event):
if self.fMouseLeftDown and self.fMouseRightDown:
self.fMouseInitialZoomPos = event.globalPos()
if qt_config == 5:
self.fMouseInitialZoomPos = event.globalPos()
else:
self.fMouseInitialZoomPos = event.globalPosition().toPoint()
self.setCursor(self.fZoomCursors[self._kCursorZoom])
self.fMouseMode = self._MOUSE_MODE_SCALE

elif self.fMouseLeftDown:
self.setCursor(QCursor(Qt.SizeAllCursor))
if self.fMouseMode == self._MOUSE_MODE_NONE:
if QT_VERSION >= 0x60000:
if qt_config == 5:
x = event.x()
y = event.y()
else:
pos = event.position()
x = pos.x()
y = pos.y()
else:
x = event.x()
y = event.y()
self._moveViewRect(x, y)
self.fMouseMode = self._MOUSE_MODE_MOVE



+ 6
- 6
source/frontend/widgets/draggablegraphicsview.py View File

@@ -120,18 +120,18 @@ class DraggableGraphicsView(QGraphicsView):
if timestamp is None:
return

if QT_VERSION >= 0x60000:
event = QMouseEvent(QEvent.MouseButtonPress,
event.position(), event.scenePosition(), event.globalPosition(),
Qt.LeftButton, Qt.LeftButton,
Qt.NoModifier)
else:
if qt_config == 5:
event = QMouseEvent(QEvent.MouseButtonPress,
event.localPos(), event.windowPos(), event.screenPos(),
Qt.LeftButton, Qt.LeftButton,
Qt.NoModifier,
Qt.MouseEventSynthesizedByApplication)
event.setTimestamp(timestamp)
else:
event = QMouseEvent(QEvent.MouseButtonPress,
event.position(), event.scenePosition(), event.globalPosition(),
Qt.LeftButton, Qt.LeftButton,
Qt.NoModifier)

QGraphicsView.mousePressEvent(self, event)



+ 5
- 2
source/frontend/widgets/pixmapkeyboard.py View File

@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2011-2024 Filipe Coelho <falktx@falktx.com>
# SPDX-FileCopyrightText: 2011-2025 Filipe Coelho <falktx@falktx.com>
# SPDX-License-Identifier: GPL-2.0-or-later

# ---------------------------------------------------------------------------------------------------------------------
@@ -408,7 +408,10 @@ class PixmapKeyboard(QWidget):
if self.fPcKeybOffset == 0:
actOctaveDown.setEnabled(False)

actSelected = menu.exec_(event.screenPos().toPoint())
if qt_config == 5:
actSelected = menu.exec_(event.screenPos().toPoint())
else:
actSelected = menu.exec_(event.globalPosition().toPoint())

if not actSelected:
return


Loading…
Cancel
Save