Changeset 2694

Show
Ignore:
Timestamp:
06/03/17 01:25:01 (3 years ago)
Author:
jwoithe
Message:

ffado-mixer: Centralise imports of PyQt? modules and make compatible with PyQt?5.

In Xavier Forestier's patch set submitted to ffado-devel in November 2016,
changes were required to every PyQt? import statement if PyQt?5 were to to be
used instead. Since the current intent is to retain compatiblity to both
PyQt?4 and PyQt?5 a slightly different approach was needed.

All PyQt? module imports are now handled by the newly added import_pyqt
module. This transparently loads PyQt?4 or PyQt?5 modules depending on what
is found on the system at runtime. Presently PyQt?4 is tried first with a
fallback to PyQt?5 if PyQt?4 is not found, but this could change in future.
The result is that the ffado-mixer code should now be very close to being
compatible with PyQt?5 without additional patches. Having said that, some
build system changes are still needed to make PyQt?5 an option, along with
some other minor fixes.

This is perhaps not the neatest way of achieving the desired result, but it
seems to work. It avoids the need to patch every ffado-mixer source file
depending on the PyQt? version in use, and allows ffado-mixer to adapt to the
PyQt? version found at runtime.

The import_pyqt module also sets two global version variables:
ffado_pyqt_version (the version of PyQt? in use) and ffado_python3 (true if
python3 is in use). These may be of use when addressing remaining
PtQt?4/PyQt5 and Python 2/3 issues.

This patch has been tested with PyQt?4 under Python 2.7.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/support/mixer-qt4/ffado/config.py.in

    r2670 r2694  
    3131 
    3232import os.path 
    33 from PyQt4 import uic 
     33 
     34# from PyQt4 import uic 
     35from ffado.import_pyqt import * 
     36 
    3437def uicLoad(file, object): 
    3538    if not file.endswith(".ui"): 
  • trunk/libffado/support/mixer-qt4/ffado/ffadowindow.py

    r2684 r2694  
    2929import subprocess 
    3030 
    31 from PyQt4.QtCore import QObject, QTimer, Qt 
    32 from PyQt4.QtGui import * 
     31# from PyQt4.QtCore import QObject, QTimer, Qt 
     32# from PyQt4.QtGui import * 
     33from ffado.import_pyqt import * 
    3334 
    3435from ffado.dbus_util import * 
  • trunk/libffado/support/mixer-qt4/ffado/logginghandler.py

    r2653 r2694  
    2121# 
    2222 
    23 from PyQt4.QtGui import QTextEdit, QAbstractSlider, QColor 
    24 from PyQt4.QtCore import QObject, pyqtSignal, QString 
     23# from PyQt4.QtGui import QTextEdit, QAbstractSlider, QColor 
     24# from PyQt4.QtCore import QObject, pyqtSignal, QString 
     25from ffado.import_pyqt import * 
    2526 
    2627import logging 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/audiofire.py

    r2659 r2694  
    2121# 
    2222 
    23 from PyQt4.QtCore import Qt, QTimer 
    24 from PyQt4.QtGui import QWidget, QHBoxLayout, QVBoxLayout, \ 
    25                         QGroupBox, QTabWidget, QLabel, \ 
    26                         QPushButton, QToolButton, QSpacerItem, QSizePolicy 
     23# from PyQt4.QtCore import Qt, QTimer 
     24# from PyQt4.QtGui import QWidget, QHBoxLayout, QVBoxLayout 
     25# from PyQt4.QtGui import QGroupBox, QTabWidget, QLabel 
     26# from PyQt4.QtGui import QPushButton, QToolButton, QSpacerItem, QSizePolicy 
     27from ffado.import_pyqt import * 
     28 
    2729from ffado.config import * 
    2830import logging 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/bcoaudio5control.py

    r2658 r2694  
    2121# 
    2222 
    23 from PyQt4.QtGui import QWidget 
     23# from PyQt4.QtGui import QWidget 
     24from ffado.import_pyqt import * 
     25 
    2426from ffado.config import * 
    2527import logging 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/dummy.py

    r2653 r2694  
    2121# 
    2222 
    23 from PyQt4.QtGui import QWidget 
     23# from PyQt4.QtGui import QWidget 
     24from ffado.import_pyqt import * 
     25 
    2426from ffado.config import * 
    2527 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/edirolfa101control.py

    r2653 r2694  
    2121# 
    2222 
    23 from PyQt4.QtGui import QWidget 
     23# from PyQt4.QtGui import QWidget 
     24from ffado.import_pyqt import * 
     25 
    2426from ffado.config import * 
    2527 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/edirolfa66control.py

    r2658 r2694  
    2121# 
    2222 
    23 from PyQt4.QtGui import QWidget 
     23# from PyQt4.QtGui import QWidget 
     24from ffado.import_pyqt import * 
     25 
    2426from ffado.config import * 
    2527 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/generic_dice_eap.py

    r2680 r2694  
    2020# 
    2121 
    22 from PyQt4 import QtGui, QtCore, Qt 
    23 from PyQt4.QtGui import QWidget, QGridLayout, QTabWidget, QScrollArea 
     22# from PyQt4 import QtGui, QtCore, Qt 
     23# from PyQt4.QtGui import QWidget, QGridLayout, QTabWidget, QScrollArea 
     24from ffado.import_pyqt import * 
     25 
    2426import dbus 
    2527 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/globalmixer.py

    r2680 r2694  
    2222# 
    2323 
    24 from PyQt4.QtCore import QObject, pyqtSlot 
    25 from PyQt4.QtGui import QWidget, QMessageBox 
     24# from PyQt4.QtCore import QObject, pyqtSlot 
     25# from PyQt4.QtGui import QWidget, QMessageBox 
     26from ffado.import_pyqt import * 
     27 
    2628from ffado.config import * 
    2729 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/mackie_onyxmixer.py

    r2653 r2694  
    2121# 
    2222 
    23 from PyQt4.QtGui import QWidget 
     23# from PyQt4.QtGui import QWidget 
     24from ffado.import_pyqt import * 
     25 
    2426from ffado.config import * 
    2527 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/maudio_bebob.py

    r2653 r2694  
    1 from PyQt4.QtCore import Qt 
    2 from PyQt4.QtGui import QSizePolicy, QHBoxLayout, QVBoxLayout, QGroupBox 
    3 from PyQt4.QtGui import QWidget, QTabWidget, QLabel, QSlider, QToolButton 
     1# from PyQt4.QtCore import Qt 
     2# from PyQt4.QtGui import QSizePolicy, QHBoxLayout, QVBoxLayout, QGroupBox 
     3# from PyQt4.QtGui import QWidget, QTabWidget, QLabel, QSlider, QToolButton 
     4from ffado.import_pyqt import * 
     5 
    46from math import log10 
    57from ffado.config import * 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/motu.py

    r2658 r2694  
    2222# 
    2323 
    24 from PyQt4.QtCore import Qt 
    25 from PyQt4.QtGui import QWidget, QApplication 
     24# from PyQt4.QtCore import Qt 
     25# from PyQt4.QtGui import QWidget, QApplication 
     26from ffado.import_pyqt import * 
     27 
    2628from ffado.config import * 
    2729 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/motu_mark3.py

    r2653 r2694  
    2222# 
    2323 
    24 from PyQt4.QtGui import QWidget, QApplication 
     24# from PyQt4.QtGui import QWidget, QApplication 
     25from ffado.import_pyqt import * 
     26 
    2527from ffado.config import * 
    2628 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/nodevice.py

    r1934 r2694  
    2222# 
    2323 
    24 from PyQt4.QtGui import QWidget 
     24# from PyQt4.QtGui import QWidget 
     25from ffado.import_pyqt import * 
     26 
    2527from mixer_nodeviceui import Ui_NoDeviceMixerUI 
    2628 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/phase24control.py

    r2658 r2694  
    2121# 
    2222 
    23 from PyQt4.QtGui import QWidget 
     23# from PyQt4.QtGui import QWidget 
     24from ffado.import_pyqt import * 
     25 
    2426from ffado.config import * 
    2527 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/phase88control.py

    r2658 r2694  
    2323# 
    2424 
    25 from PyQt4.QtGui import QWidget 
     25# from PyQt4.QtGui import QWidget 
     26from ffado.import_pyqt import * 
     27 
    2628from math import log10 
    2729from ffado.config import * 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/presonus_firebox.py

    r2653 r2694  
    2020# 
    2121 
    22 from PyQt4 import QtGui, QtCore 
    23 from PyQt4.QtCore import Qt 
    24 from PyQt4.QtGui import QHBoxLayout, QVBoxLayout, QGridLayout 
    25 from PyQt4.QtGui import QWidget, QTabWidget, QGroupBox, QLabel, QSizePolicy, QToolButton, QSlider, QComboBox, QSpacerItem, QDial 
     22# from PyQt4 import QtGui, QtCore 
     23# from PyQt4.QtCore import Qt 
     24# from PyQt4.QtGui import QHBoxLayout, QVBoxLayout, QGridLayout 
     25# from PyQt4.QtGui import QWidget, QTabWidget, QGroupBox, QLabel, QSizePolicy, QToolButton, QSlider, QComboBox, QSpacerItem, QDial 
     26from ffado.import_pyqt import * 
     27 
    2628from math import log10 
    2729from ffado.config import * 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/presonus_fp10.py

    r2653 r2694  
    2020# 
    2121 
    22 from PyQt4 import QtGui, QtCore 
    23 from PyQt4.QtCore import Qt 
    24 from PyQt4.QtGui import QGridLayout 
    25 from PyQt4.QtGui import QWidget, QLabel, QSizePolicy, QToolButton, QSlider, QDial 
     22# from PyQt4 import QtGui, QtCore 
     23# from PyQt4.QtCore import Qt 
     24# from PyQt4.QtGui import QGridLayout 
     25# from PyQt4.QtGui import QWidget, QLabel, QSizePolicy, QToolButton, QSlider, QDial 
     26from ffado.import_pyqt import * 
     27 
    2628from math import log10 
    2729from ffado.config import * 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/presonus_inspire1394.py

    r2653 r2694  
    2020# 
    2121 
    22 from PyQt4 import QtGui, QtCore 
    23 from PyQt4.QtCore import QObject, Qt 
    24 from PyQt4.QtGui import QWidget, QHBoxLayout, QVBoxLayout, QGridLayout 
    25 from PyQt4.QtGui import QGroupBox, QLabel, QSizePolicy, QSlider, QDial, QComboBox, QToolButton 
     22# from PyQt4 import QtGui, QtCore 
     23# from PyQt4.QtCore import QObject, Qt 
     24# from PyQt4.QtGui import QWidget, QHBoxLayout, QVBoxLayout, QGridLayout 
     25# from PyQt4.QtGui import QGroupBox, QLabel, QSizePolicy, QSlider, QDial, QComboBox, QToolButton 
     26from ffado.import_pyqt import * 
     27 
    2628from math import log10 
    2729from ffado.config import * 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/profire2626.py

    r2680 r2694  
    1919# 
    2020 
    21 from PyQt4 import QtGui, QtCore, Qt 
    22 from PyQt4.QtGui import QWidget, QScrollArea 
     21# from PyQt4 import QtGui, QtCore, Qt 
     22# from PyQt4.QtGui import QWidget, QScrollArea 
     23from ffado.import_pyqt import * 
     24 
    2325import dbus 
    2426 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/quatafire.py

    r2658 r2694  
    2121# 
    2222 
    23 from PyQt4.QtGui import QWidget 
     23# from PyQt4.QtGui import QWidget 
     24from ffado.import_pyqt import * 
     25 
    2426from ffado.config import * 
    2527 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/rme.py

    r2680 r2694  
    2121# 
    2222 
    23 from PyQt4 import QtGui 
    24  
    25 from PyQt4.QtCore import QObject, Qt, QTimer 
    26 from PyQt4.QtGui import QWidget, QApplication, QVBoxLayout 
     23# from PyQt4 import QtGui 
     24# from PyQt4.QtCore import QObject, Qt, QTimer 
     25# from PyQt4.QtGui import QWidget, QApplication, QVBoxLayout 
     26from ffado.import_pyqt import * 
     27 
    2728from ffado.config import * 
    2829 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/saffire.py

    r2667 r2694  
    2121# 
    2222 
    23 from PyQt4.QtGui import QWidget, QHBoxLayout 
     23# from PyQt4.QtGui import QWidget, QHBoxLayout 
     24from ffado.import_pyqt import * 
     25 
    2426from ffado.config import * 
    2527from ffado.mixer.saffire_base import SaffireMixerBase 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/saffirepro.py

    r1691 r2694  
    2121# 
    2222 
    23 from PyQt4.QtGui import QWidget, QHBoxLayout, QMessageBox 
     23# from PyQt4.QtGui import QWidget, QHBoxLayout, QMessageBox 
     24from ffado.import_pyqt import * 
     25 
    2426from ffado.config import * 
    2527from ffado.mixer.saffire_base import SaffireMixerBase 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/saffire_dice.py

    r2680 r2694  
    1919# 
    2020 
    21 from PyQt4 import QtGui, QtCore, Qt 
    22 from PyQt4.QtGui import QWidget, QScrollArea 
     21# from PyQt4 import QtGui, QtCore, Qt 
     22# from PyQt4.QtGui import QWidget, QScrollArea 
     23from ffado.import_pyqt import * 
     24 
    2325import dbus 
    2426 
  • trunk/libffado/support/mixer-qt4/ffado/mixer/yamahago.py

    r2653 r2694  
    2222# 
    2323 
    24 from PyQt4.QtGui import QWidget 
     24# from PyQt4.QtGui import QWidget 
     25from ffado.import_pyqt import * 
     26 
    2527from math import log10 
    2628from ffado.config import * 
  • trunk/libffado/support/mixer-qt4/ffado/panelmanager.py

    r2680 r2694  
    2525from ffado.config import * #FFADO_VERSION, FFADO_DBUS_SERVER, FFADO_DBUS_BASEPATH 
    2626 
    27 from PyQt4.QtGui import QFrame, QWidget, QTabWidget, QVBoxLayout, QMainWindow, QIcon, QAction, qApp, QStyleOptionTabWidgetFrame, QFileDialog 
    28 from PyQt4.QtCore import QTimer, pyqtSignal 
     27# from PyQt4.QtGui import QFrame, QWidget, QTabWidget, QVBoxLayout, QMainWindow, QIcon, QAction, qApp, QStyleOptionTabWidgetFrame, QFileDialog 
     28# from PyQt4.QtCore import QTimer, pyqtSignal 
     29from ffado.import_pyqt import * 
    2930 
    3031from ffado.dbus_util import * 
  • trunk/libffado/support/mixer-qt4/ffado/regdialog.py

    r2653 r2694  
    2222# 
    2323 
    24 from PyQt4.QtGui import QDialog 
     24# from PyQt4.QtGui import QDialog 
     25from ffado.import_pyqt import * 
     26 
    2527from ffado.config import * 
    2628 
  • trunk/libffado/support/mixer-qt4/ffado/registration.py

    r2690 r2694  
    4444 
    4545from ffado.config import REGISTER_URL, INI_FILE_PATH, FFADO_CONFIG_DIR 
    46 from PyQt4.QtGui import QMessageBox 
    47 from PyQt4.QtCore import QByteArray 
     46 
     47# from PyQt4.QtGui import QMessageBox 
     48# from PyQt4.QtCore import QByteArray 
     49from ffado.import_pyqt import * 
    4850 
    4951from ffado.regdialog import * 
  • trunk/libffado/support/mixer-qt4/ffado/widgets/crossbarrouter.py

    r2680 r2694  
    2020# 
    2121 
    22 from PyQt4 import QtGui, QtCore 
    23 from PyQt4.QtCore import pyqtSignal 
    24 from PyQt4.QtGui import QFrame, QPainter, QGridLayout, QLabel, QComboBox 
    25 from PyQt4.QtGui import QWidget, QVBoxLayout, QHBoxLayout, QPushButton 
     22# from PyQt4 import QtGui, QtCore 
     23# from PyQt4.QtCore import pyqtSignal 
     24# from PyQt4.QtGui import QFrame, QPainter, QGridLayout, QLabel, QComboBox 
     25# from PyQt4.QtGui import QWidget, QVBoxLayout, QHBoxLayout, QPushButton 
     26from ffado.import_pyqt import * 
     27 
    2628import dbus, math 
    2729 
  • trunk/libffado/support/mixer-qt4/ffado/widgets/matrixmixer.py

    r2680 r2694  
    2121# 
    2222 
    23 from PyQt4 import QtGui, QtCore, Qt 
    24 from PyQt4.QtCore import pyqtSignal 
    25 from PyQt4.QtGui import QColor, QAbstractSlider, QDoubleSpinBox, QWidgetAction 
    26 from PyQt4.QtGui import QAction, QPainter, QWidget, QGridLayout, QLabel 
    27 from PyQt4.QtGui import QLayout, QSlider, QLineEdit, QPalette 
    28 from PyQt4.QtGui import QVBoxLayout, QHBoxLayout, QTabWidget, QToolBar 
    29 from PyQt4.QtGui import QComboBox, QScrollArea, QPushButton, QSizePolicy 
     23# from PyQt4 import QtGui, QtCore, Qt 
     24# from PyQt4.QtCore import pyqtSignal 
     25# from PyQt4.QtGui import QColor, QAbstractSlider, QDoubleSpinBox, QWidgetAction 
     26# from PyQt4.QtGui import QAction, QPainter, QWidget, QGridLayout, QLabel 
     27# from PyQt4.QtGui import QLayout, QSlider, QLineEdit, QPalette 
     28# from PyQt4.QtGui import QVBoxLayout, QHBoxLayout, QTabWidget, QToolBar 
     29# from PyQt4.QtGui import QComboBox, QScrollArea, QPushButton, QSizePolicy 
     30from ffado.import_pyqt import * 
     31 
    3032import dbus, math, decimal 
    3133 
     
    122124        self.input = input 
    123125        self.output = output 
    124         self.setOrientation(Qt.Qt.Vertical) 
     126        self.setOrientation(Qt.Vertical) 
    125127        if max == -1: 
    126128            max = pow(2, 16)-1 
     
    133135        self.bgcolors = BckgrdColorForNumber() 
    134136 
    135         self.setContextMenuPolicy(Qt.Qt.ActionsContextMenu) 
     137        self.setContextMenuPolicy(Qt.ActionsContextMenu) 
    136138        self.mapper = QtCore.QSignalMapper(self) 
    137139        self.mapper.mapped['QString'].connect(self.directValues) 
     
    198200 
    199201    def mousePressEvent(self, ev): 
    200         if ev.buttons() & Qt.Qt.LeftButton: 
     202        if ev.buttons() & Qt.LeftButton: 
    201203            self.pos = ev.posF() 
    202204            self.tmpvalue = self.value() 
     
    225227    #   Additionnaly press Control key for wheel controling the values 
    226228    def wheelEvent (self, ev): 
    227         if (ev.modifiers() & Qt.Qt.ControlModifier): 
     229        if (ev.modifiers() & Qt.ControlModifier): 
    228230            tmpvalue = self.value() 
    229231            change = ev.delta()/8 
     
    256258            symb_inf = u"\u221E" 
    257259            text = "-" + symb_inf + " dB" 
    258         p.drawText(rect, Qt.Qt.AlignCenter, QtCore.QString.fromUtf8(text)) 
     260        p.drawText(rect, Qt.AlignCenter, QtCore.QString.fromUtf8(text)) 
    259261        if (self.inv_action!=None and self.inv_action.isChecked()): 
    260             p.drawText(rect, Qt.Qt.AlignLeft|Qt.Qt.AlignTop, QtCore.QString.fromUtf8(" ϕ")) 
     262            p.drawText(rect, Qt.AlignLeft|Qt.AlignTop, QtCore.QString.fromUtf8(" ϕ")) 
    261263 
    262264    def internalValueChanged(self, value): 
     
    286288        self.name = name 
    287289        self.lbl = QLabel(self) 
    288         self.lbl.setAlignment(Qt.Qt.AlignCenter) 
     290        self.lbl.setAlignment(Qt.AlignCenter) 
    289291        if (smallFont): 
    290292            font = self.lbl.font() 
     
    294296        self.hideChannel(False) 
    295297 
    296         self.setContextMenuPolicy(Qt.Qt.ActionsContextMenu) 
     298        self.setContextMenuPolicy(Qt.ActionsContextMenu) 
    297299 
    298300        action = QAction("Make this channel small", self) 
     
    713715 
    714716        self.setReadOnly(True) 
    715         self.setAlignment(Qt.Qt.AlignCenter) 
     717        self.setAlignment(Qt.AlignCenter) 
    716718        self.setAutoFillBackground(True) 
    717719        self.setFrame(False) 
     
    800802            widget = QWidget(parent) 
    801803            v_layout = QVBoxLayout(widget) 
    802             v_layout.setAlignment(Qt.Qt.AlignCenter) 
     804            v_layout.setAlignment(Qt.AlignCenter) 
    803805            widget.setLayout(v_layout) 
    804806            self.out.append(widget) 
     
    819821                lbl = QLabel(widget) 
    820822                lbl.setText(self.getOutName(i, self.shortname)) 
    821                 lbl.setAlignment(Qt.Qt.AlignCenter) 
     823                lbl.setAlignment(Qt.AlignCenter) 
    822824                v_layout.addWidget(lbl) 
    823825                self.out[i].lbl.append(lbl) 
     
    825827            h_layout_wid = QWidget(widget) 
    826828            h_layout = QHBoxLayout(h_layout_wid) 
    827             h_layout.setAlignment(Qt.Qt.AlignCenter) 
     829            h_layout.setAlignment(Qt.AlignCenter) 
    828830            h_layout_wid.setLayout(h_layout) 
    829831            v_layout.addWidget(h_layout_wid) 
     
    835837                h_v_layout_wid = QWidget(h_layout_wid) 
    836838                h_v_layout = QVBoxLayout(h_v_layout_wid) 
    837                 h_v_layout.setAlignment(Qt.Qt.AlignCenter) 
     839                h_v_layout.setAlignment(Qt.AlignCenter) 
    838840                h_v_layout_wid.setLayout(h_v_layout) 
    839841                h_layout.addWidget(h_v_layout_wid) 
     
    843845                    lbl = QLabel(h_v_layout_wid) 
    844846                    lbl.setText(self.getInName(j, self.shortname)) 
    845                     lbl.setAlignment(Qt.Qt.AlignCenter) 
     847                    lbl.setAlignment(Qt.AlignCenter) 
    846848                    h_v_layout.addWidget(lbl) 
    847849                    self.out[i].lbl.append(lbl) 
     
    849851                h_v_h_layout_wid = QWidget(h_v_layout_wid) 
    850852                h_v_h_layout = QHBoxLayout(h_v_h_layout_wid) 
    851                 h_v_h_layout.setAlignment(Qt.Qt.AlignCenter) 
     853                h_v_h_layout.setAlignment(Qt.AlignCenter) 
    852854                h_v_h_layout_wid.setLayout(h_v_h_layout) 
    853855                h_v_layout.addWidget(h_v_h_layout_wid)