Skip to content

Commit

Permalink
Start PyQt6 compatibility update
Browse files Browse the repository at this point in the history
Signed-off-by: falktx@falktx.com <falkTX>
  • Loading branch information
falktx@falktx.com authored and falktx@falktx.com committed Aug 10, 2024
1 parent 104839f commit c5b601b
Show file tree
Hide file tree
Showing 48 changed files with 701 additions and 866 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ qrc_resources.cpp
*.pyc

# Qt files
qt_config.py
*_ui.hpp
*_ui.py
*_rc.cpp
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,8 @@ endif
$(LINK) ../carla_utils.py $(DESTDIR)$(DATADIR)/carla/resources
$(LINK) ../carla_widgets.py $(DESTDIR)$(DATADIR)/carla/resources
$(LINK) ../externalui.py $(DESTDIR)$(DATADIR)/carla/resources
$(LINK) ../qt_compat.py $(DESTDIR)$(DATADIR)/carla/resources
$(LINK) ../qt_config.py $(DESTDIR)$(DATADIR)/carla/resources
$(LINK) ../resources_rc.py $(DESTDIR)$(DATADIR)/carla/resources
$(LINK) ../ui_carla_about.py $(DESTDIR)$(DATADIR)/carla/resources
$(LINK) ../ui_carla_edit.py $(DESTDIR)$(DATADIR)/carla/resources
Expand Down
2 changes: 1 addition & 1 deletion source/Makefile.deps.mk
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ PYRCC ?= $(PYRCC5)
PYUIC ?= $(PYUIC5)
else ifneq ($(PYUIC6),)
PYRCC ?= $(RCC_QT6) -g python
PYUIC ?= $(PYRCC6)
PYUIC ?= $(PYUIC6)
endif

# ---------------------------------------------------------------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions source/frontend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ OBJS = $(CPP_FILES:%=$(OBJDIR)/%.o)
# Resources

RES = \
qt_config.py \
resources_rc.py \
$(BINDIR)/resources/modgui \
$(BINDIR)/resources/patchcanvas \
Expand Down Expand Up @@ -165,6 +166,10 @@ pluginlist/ui_%.h: pluginlist/%.ui
ui_%.py: $(RESDIR)/ui/%.ui
$(PYUIC) $< -o $@

qt_config.py:
echo "#!/usr/bin/env python3" > $@
echo "qt = $(FRONTEND_TYPE)" >> $@

resources_rc.py: $(RESDIR)/resources.qrc $(RESDIR)/*/*.png $(RESDIR)/*/*.svg $(RESDIR)/*/*.svgz
$(PYRCC) $< -o $@

Expand Down
25 changes: 8 additions & 17 deletions source/frontend/bigmeter-ui
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Carla Native Plugins
# Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# For a full copy of the GNU General Public License see the doc/GPL.txt file.
# SPDX-FileCopyrightText: 2011-2024 Filipe Coelho <falktx@falktx.com>
# SPDX-License-Identifier: GPL-2.0-or-later

# ------------------------------------------------------------------------------------------------------------
# Imports (Global)

from PyQt5.QtCore import Qt
from qt_compat import qt_config

if qt_config == 5:
from PyQt5.QtCore import Qt
elif qt_config == 6:
from PyQt6.QtCore import Qt

# -----------------------------------------------------------------------
# Imports (Custom)
Expand Down
28 changes: 10 additions & 18 deletions source/frontend/carla-plugin
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Carla plugin host (plugin UI)
# Copyright (C) 2013-2020 Filipe Coelho <falktx@falktx.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# For a full copy of the GNU General Public License see the GPL.txt file
# SPDX-FileCopyrightText: 2011-2024 Filipe Coelho <falktx@falktx.com>
# SPDX-License-Identifier: GPL-2.0-or-later

# ------------------------------------------------------------------------------------------------------------
# Imports (Global)

from PyQt5.QtGui import QKeySequence, QMouseEvent
from PyQt5.QtWidgets import QFrame, QSplitter
from qt_compat import qt_config

if qt_config == 5:
from PyQt5.QtGui import QKeySequence, QMouseEvent
from PyQt5.QtWidgets import QFrame, QSplitter
elif qt_config == 6:
from PyQt6.QtGui import QKeySequence, QMouseEvent
from PyQt6.QtWidgets import QFrame, QSplitter

# ------------------------------------------------------------------------------------------------------------
# Imports (Custom Stuff)
Expand Down
43 changes: 18 additions & 25 deletions source/frontend/carla_app.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Carla application
# Copyright (C) 2013-2020 Filipe Coelho <falktx@falktx.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# For a full copy of the GNU General Public License see the doc/GPL.txt file.
# SPDX-FileCopyrightText: 2011-2024 Filipe Coelho <falktx@falktx.com>
# SPDX-License-Identifier: GPL-2.0-or-later

# ------------------------------------------------------------------------------------------------------------
# Imports (Global)
Expand All @@ -28,11 +14,18 @@
from ctypes import CDLL, RTLD_GLOBAL

# ------------------------------------------------------------------------------------------------------------
# Imports (PyQt5)
# Imports (PyQt)

from PyQt5.QtCore import QT_VERSION, Qt, QCoreApplication, QLibraryInfo, QLocale, QTranslator
from PyQt5.QtGui import QColor, QIcon, QPalette
from PyQt5.QtWidgets import QApplication
from qt_compat import qt_config

if qt_config == 5:
from PyQt5.QtCore import QT_VERSION, Qt, QCoreApplication, QLibraryInfo, QLocale, QTranslator
from PyQt5.QtGui import QColor, QIcon, QPalette
from PyQt5.QtWidgets import QApplication
elif qt_config == 6:
from PyQt6.QtCore import QT_VERSION, Qt, QCoreApplication, QLibraryInfo, QLocale, QTranslator
from PyQt6.QtGui import QColor, QIcon, QPalette
from PyQt6.QtWidgets import QApplication

# ------------------------------------------------------------------------------------------------------------
# Imports (Custom)
Expand Down Expand Up @@ -137,21 +130,21 @@ def __init__(self, appName = "Carla2", libPrefix = None):
self.createPaletteBlue()

def createApp(self, appName):
if LINUX:
if qt_config == 5 and LINUX:
# AA_X11InitThreads is not available on old PyQt versions
try:
attr = Qt.AA_X11InitThreads
except:
attr = 10
QApplication.setAttribute(attr)

if QT_VERSION >= 0x50600:
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)

if MACOS:
QApplication.setAttribute(Qt.AA_DontShowIconsInMenus)

if QT_VERSION >= 0x50600:
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)

args = sys.argv[:]

if WINDOWS:
Expand Down
25 changes: 8 additions & 17 deletions source/frontend/carla_backend_qt.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Carla Backend code (Qt stuff)
# Copyright (C) 2011-2020 Filipe Coelho <falktx@falktx.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# For a full copy of the GNU General Public License see the doc/GPL.txt file.
# SPDX-FileCopyrightText: 2011-2024 Filipe Coelho <falktx@falktx.com>
# SPDX-License-Identifier: GPL-2.0-or-later

# ------------------------------------------------------------------------------------------------------------
# Imports (Global)

from PyQt5.QtCore import pyqtSignal, QObject
from qt_compat import qt_config

if qt_config == 5:
from PyQt5.QtCore import pyqtSignal, QObject
elif qt_config == 6:
from PyQt6.QtCore import pyqtSignal, QObject

# ------------------------------------------------------------------------------------------------------------
# Imports (Custom)
Expand Down
24 changes: 7 additions & 17 deletions source/frontend/carla_frontend.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Carla Backend utils
# Copyright (C) 2011-2024 Filipe Coelho <falktx@falktx.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# For a full copy of the GNU General Public License see the doc/GPL.txt file.
# SPDX-FileCopyrightText: 2011-2024 Filipe Coelho <falktx@falktx.com>
# SPDX-License-Identifier: GPL-2.0-or-later

# ------------------------------------------------------------------------------------------------------------
# Imports (Global)
Expand All @@ -28,7 +14,11 @@
POINTER
)

from sip import unwrapinstance
try:
from sip import unwrapinstance
except ImportError:
def unwrapinstance(_):
return None

# ------------------------------------------------------------------------------------------------------------
# Imports (Custom)
Expand Down
105 changes: 73 additions & 32 deletions source/frontend/carla_host.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Carla host code
# Copyright (C) 2011-2022 Filipe Coelho <falktx@falktx.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# For a full copy of the GNU General Public License see the doc/GPL.txt file.
# SPDX-FileCopyrightText: 2011-2024 Filipe Coelho <falktx@falktx.com>
# SPDX-License-Identifier: GPL-2.0-or-later

# ------------------------------------------------------------------------------------------------------------
# Imports (Global)
Expand All @@ -29,23 +15,78 @@
)

# ------------------------------------------------------------------------------------------------------------
# Imports (PyQt5)
# Imports (PyQt)

# This fails in some configurations, assume >= 5.6.0 in that case
try:
from PyQt5.Qt import PYQT_VERSION
except ImportError:
PYQT_VERSION = 0x50600
from qt_compat import qt_config

from PyQt5.QtCore import (
QT_VERSION, qCritical, QBuffer, QEventLoop, QFileInfo, QIODevice, QMimeData, QModelIndex, QPointF, QTimer, QEvent
)
from PyQt5.QtGui import (
QImage, QImageWriter, QPainter, QPalette, QBrush
)
from PyQt5.QtWidgets import (
QAction, QApplication, QInputDialog, QFileSystemModel, QListWidgetItem, QGraphicsView, QMainWindow
)
if qt_config == 5:
# This fails in some configurations, assume >= 5.6.0 in that case
try:
from PyQt5.Qt import PYQT_VERSION
except ImportError:
PYQT_VERSION = 0x50600

from PyQt5.QtCore import (
QT_VERSION,
qCritical,
QBuffer,
QEvent,
QEventLoop,
QFileInfo,
QIODevice,
QMimeData,
QModelIndex,
QPointF,
QTimer,
)
from PyQt5.QtGui import (
QBrush,
QImage,
QImageWriter,
QPainter,
QPalette,
)
from PyQt5.QtWidgets import (
QAction,
QApplication,
QInputDialog,
QFileSystemModel,
QListWidgetItem,
QGraphicsView,
QMainWindow,
)

elif qt_config == 6:
from PyQt6.QtCore import (
PYQT_VERSION,
QT_VERSION,
qCritical,
QBuffer,
QEvent,
QEventLoop,
QFileInfo,
QIODevice,
QMimeData,
QModelIndex,
QPointF,
QTimer,
)
from PyQt6.QtGui import (
QAction,
QBrush,
QFileSystemModel,
QImage,
QImageWriter,
QPainter,
QPalette,
)
from PyQt6.QtWidgets import (
QApplication,
QInputDialog,
QListWidgetItem,
QGraphicsView,
QMainWindow,
)

# ------------------------------------------------------------------------------------------------------------
# Imports (Custom)
Expand Down Expand Up @@ -1595,7 +1636,7 @@ def setupCanvas(self):
self.ui.graphicsView.setRenderHint(QPainter.SmoothPixmapTransform, fullAA)
self.ui.graphicsView.setRenderHint(QPainter.TextAntialiasing, fullAA)

if self.fSavedSettings[CARLA_KEY_CANVAS_USE_OPENGL] and hasGL:
if self.fSavedSettings[CARLA_KEY_CANVAS_USE_OPENGL] and hasGL and QPainter.HighQualityAntialiasing is not None:
self.ui.graphicsView.setRenderHint(QPainter.HighQualityAntialiasing, self.fSavedSettings[CARLA_KEY_CANVAS_HQ_ANTIALIASING])

else:
Expand Down
Loading

0 comments on commit c5b601b

Please sign in to comment.