libffado-2.4.0-py3-pyqt5-fixes.patch 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. ------------------------------------------------------------------------
  2. r2726 | jwoithe | 2018-01-05 18:56:40 +0900 (Fri, 05 Jan 2018) | 13 lines
  3. Further Python3/PyQt5 compatibility fixes, enhance "About" dialog box.
  4. This patch was prepared by Orcan Ogetbil on Fedora and tested on that
  5. distribution with PyQt4-4.12.1 and PyQt5-5.9.1. It is primarily concerned
  6. with additional compatibility between Python2/3 and PyQt4/5. It has also
  7. been tested under python 2 with pyqt 4.11.4. Further testing under
  8. different python/pyqt environments would be welcomed.
  9. An enhancement to the "About" dialog is also included which adds version
  10. strings and updates the copyright year range.
  11. The patch was submitted to the ffado-devel mailing list.
  12. Index: support/mixer-qt4/ffado/ffadowindow.py
  13. ===================================================================
  14. --- a/support/mixer-qt4/ffado/ffadowindow.py (revision 2725)
  15. +++ b/support/mixer-qt4/ffado/ffadowindow.py (revision 2726)
  16. @@ -22,6 +22,8 @@
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. +import ctypes
  20. +import datetime
  21. import os
  22. from ffado.config import *
  23. @@ -92,7 +94,8 @@
  24. self.menuTheme[theme].setCheckable(True)
  25. if (ffado_python3 and (self.style().objectName().lower() == theme.lower()) or
  26. - not(ffado_python3) and (self.style().objectName().toLower() == theme.toLower())):
  27. + not(ffado_python3) and (self.style().objectName().toLower() == theme.toLower() if ffado_pyqt_version == 4 else
  28. + self.style().objectName().lower() == theme.lower())):
  29. self.menuTheme[theme].setDisabled(True)
  30. self.menuTheme[theme].setChecked(True)
  31. self.menuTheme[theme].triggered.connect(self.switchTheme )
  32. @@ -174,9 +177,11 @@
  33. QMessageBox.about( self, "About FFADO", """
  34. <h1>ffado.org</h1>
  35. +<p>{ffado_version}</p>
  36. +
  37. <p>FFADO is the new approach to have firewire audio on linux.</p>
  38. -<p>&copy; 2006-2014 by the FFADO developers<br />ffado is licensed under the GPLv3, for the full license text see <a href="http://www.gnu.org/licenses/">www.gnu.org/licenses</a> or the LICENSE.* files shipped with ffado.</p>
  39. + <p>&copy; 2006-2018 by the FFADO developers<br />ffado is licensed under the GPLv3, for the full license text see <a href="http://www.gnu.org/licenses/">www.gnu.org/licenses</a> or the LICENSE.* files shipped with ffado.</p>
  40. <p>FFADO developers are:<ul>
  41. <li>Pieter Palmers
  42. @@ -191,8 +196,17 @@
  43. <li>Stefan Richter
  44. <li>Jano Svitok
  45. </ul>
  46. -""" )
  47. + """.format(ffado_version=get_ffado_version(), thisyear=datetime.datetime.now().year))
  48. +def get_ffado_version():
  49. + try:
  50. + # call the C function ffado_get_version() to figure out the version
  51. + lib = ctypes.cdll.LoadLibrary('libffado.so')
  52. + func = ctypes.CFUNCTYPE(ctypes.c_char_p)
  53. + ffado_get_version = func(('ffado_get_version', lib))
  54. + return ffado_get_version()
  55. + except:
  56. + return "libffado"
  57. def get_lock(process_name):
  58. import socket
  59. @@ -252,6 +266,7 @@
  60. logging.getLogger('global').setLevel(debug_level)
  61. log = logging.getLogger('main')
  62. + log.debug("Using %s with Qt: %s PyQt: %s" % (get_ffado_version(), QtCore.QT_VERSION_STR, QtCore.PYQT_VERSION_STR))
  63. app = QApplication(args)
  64. app.setWindowIcon( QIcon( SHAREDIR + "/icons/hi64-apps-ffado.png" ) )
  65. Index: support/mixer-qt4/ffado/logginghandler.py
  66. ===================================================================
  67. --- a/support/mixer-qt4/ffado/logginghandler.py (revision 2725)
  68. +++ b/support/mixer-qt4/ffado/logginghandler.py (revision 2726)
  69. @@ -28,7 +28,7 @@
  70. log = logging.getLogger('logginghandler')
  71. class QStatusLogger( QObject, logging.Handler ):
  72. - log = pyqtSignal(QString, int, name='log')
  73. + log = pyqtSignal(QString if ffado_pyqt_version == 4 else str, int, name='log')
  74. def __init__( self, parent, statusbar, level=logging.NOTSET ):
  75. QObject.__init__( self, parent )
  76. logging.Handler.__init__( self, level )
  77. Index: support/mixer-qt4/ffado/panelmanager.py
  78. ===================================================================
  79. --- a/support/mixer-qt4/ffado/panelmanager.py (revision 2725)
  80. +++ b/support/mixer-qt4/ffado/panelmanager.py (revision 2726)
  81. @@ -378,7 +378,7 @@
  82. action = self.sender()
  83. # Extract the action data and store as a dbus.String type so
  84. # it is usable as a key into self.panels[].
  85. - panel_key = dbus.String(action.data().toString())
  86. + panel_key = dbus.String(action.data().toString() if ffado_pyqt_version == 4 else action.data())
  87. self.tabs.setCurrentIndex(self.tabs.indexOf(self.panels[panel_key]))
  88. def displayPanels(self):
  89. @@ -515,6 +515,8 @@
  90. saveString.append('</device>\n')
  91. # file saving
  92. savefilename = QFileDialog.getSaveFileName(self, 'Save File', os.getenv('HOME'))
  93. + if isinstance(savefilename, tuple): # newer PyQt5
  94. + savefilename = savefilename[0]
  95. try:
  96. f = open(savefilename, 'w')
  97. except IOError:
  98. @@ -526,6 +528,8 @@
  99. def readSettings(self):
  100. readfilename = QFileDialog.getOpenFileName(self, 'Open File', os.getenv('HOME'))
  101. + if isinstance(readfilename, tuple): # newer PyQt5
  102. + readfilename = readfilename[0]
  103. try:
  104. f = open(readfilename, 'r')
  105. except IOError:
  106. Index: support/mixer-qt4/ffado/widgets/crossbarrouter.py
  107. ===================================================================
  108. --- a/support/mixer-qt4/ffado/widgets/crossbarrouter.py (revision 2725)
  109. +++ b/support/mixer-qt4/ffado/widgets/crossbarrouter.py (revision 2726)
  110. @@ -168,7 +168,10 @@
  111. self.timer.setInterval(200)
  112. self.timer.timeout.connect(self.updateLevels)
  113. - self.vubtn.setChecked(self.settings.value("crossbarrouter/runvu", False).toBool())
  114. + if ffado_pyqt_version == 4:
  115. + self.vubtn.setChecked(self.settings.value("crossbarrouter/runvu", False).toBool())
  116. + else:
  117. + self.vubtn.setChecked(self.settings.value("crossbarrouter/runvu", False) == u'true')
  118. def __del__(self):
  119. print( "CrossbarRouter.__del__()" )
  120. Index: support/mixer-qt4/ffado/widgets/matrixmixer.py
  121. ===================================================================
  122. --- a/support/mixer-qt4/ffado/widgets/matrixmixer.py (revision 2725)
  123. +++ b/support/mixer-qt4/ffado/widgets/matrixmixer.py (revision 2726)
  124. @@ -200,7 +200,7 @@
  125. def mousePressEvent(self, ev):
  126. if ev.buttons() & Qt.LeftButton:
  127. - self.pos = ev.posF()
  128. + self.pos = ev.posF() if ffado_pyqt_version == 4 else ev.localPos()
  129. self.tmpvalue = self.value()
  130. ev.accept()
  131. #log.debug("MixerNode.mousePressEvent() %s" % str(self.pos))
  132. @@ -207,7 +207,7 @@
  133. def mouseMoveEvent(self, ev):
  134. if hasattr(self, "tmpvalue") and self.pos is not QtCore.QPointF(0, 0):
  135. - newpos = ev.posF()
  136. + newpos = ev.posF() if ffado_pyqt_version == 4 else ev.localPos()
  137. change = newpos.y() - self.pos.y()
  138. #log.debug("MixerNode.mouseReleaseEvent() change %s" % (str(change)))
  139. self.setValue( self.tmpvalue - math.copysign(pow(abs(change), 2), change) )
  140. @@ -215,7 +215,7 @@
  141. def mouseReleaseEvent(self, ev):
  142. if hasattr(self, "tmpvalue") and self.pos is not QtCore.QPointF(0, 0):
  143. - newpos = ev.posF()
  144. + newpos = ev.posF() if ffado_pyqt_version == 4 else ev.localPos()
  145. change = newpos.y() - self.pos.y()
  146. #log.debug("MixerNode.mouseReleaseEvent() change %s" % (str(change)))
  147. self.setValue( self.tmpvalue - math.copysign(pow(abs(change), 2), change) )
  148. @@ -257,19 +257,19 @@
  149. if v == 0:
  150. symb_inf = u"\u221E"
  151. text = "-" + symb_inf + " dB"
  152. - if ffado_python3:
  153. + if ffado_python3 or ffado_pyqt_version == 5:
  154. # Python3 uses native python UTF strings rather than QString.
  155. # This therefore appears to be the correct way to display this
  156. # UTF8 string, but testing may prove otherwise.
  157. p.drawText(rect, Qt.AlignCenter, text)
  158. else:
  159. - p.drawText(rect, Qt.AlignCenter, QtCore.QString.fromUtf8(text))
  160. + p.drawText(rect, Qt.AlignCenter, QString.fromUtf8(text))
  161. if (self.inv_action!=None and self.inv_action.isChecked()):
  162. - if ffado_python3:
  163. + if ffado_python3 or ffado_pyqt_version == 5:
  164. # Refer to the comment about about Python UTF8 strings.
  165. p.drawText(rect, Qt.AlignLeft|Qt.AlignTop, " ϕ")
  166. else:
  167. - p.drawText(rect, Qt.AlignLeft|Qt.AlignTop, QtCore.QString.fromUtf8(" ϕ"))
  168. + p.drawText(rect, Qt.AlignLeft|Qt.AlignTop, QString.fromUtf8(" ϕ"))
  169. def internalValueChanged(self, value):
  170. #log.debug("MixerNode.internalValueChanged( %i )" % value)
  171. ------------------------------------------------------------------------