Changeset 2699

Show
Ignore:
Timestamp:
06/03/17 04:29:20 (7 years ago)
Author:
jwoithe
Message:

matrixmixer.py: attempt to deal with UTF8 string changes in python3.

PyQt?5 under python3 does not implement QString and instead relies on the
native python UTF string type. Attempt to deal with this when drawing mixer
elements which make use of UTF characters. This has not yet been tested under
python3 due to the author not having access to a system with python3, so
testing may yet prove that the approach taken in this commit is
insufficient.

This commit is based on the suggestion from Xavier Forestier in his patch
set from November 2016 submitted via the ffado-devel mailing list.

Files:

Legend:

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

    r2694 r2699  
    258258            symb_inf = u"\u221E" 
    259259            text = "-" + symb_inf + " dB" 
    260         p.drawText(rect, Qt.AlignCenter, QtCore.QString.fromUtf8(text)) 
     260        if ffado_python3: 
     261            # Python3 uses native python UTF strings rather than QString. 
     262            # This therefore appears to be the correct way to display this 
     263            # UTF8 string, but testing may prove otherwise. 
     264            p.drawText(rect, Qt.AlignCenter, text) 
     265        else: 
     266            p.drawText(rect, Qt.AlignCenter, QtCore.QString.fromUtf8(text)) 
    261267        if (self.inv_action!=None and self.inv_action.isChecked()): 
    262             p.drawText(rect, Qt.AlignLeft|Qt.AlignTop, QtCore.QString.fromUtf8(" ϕ")) 
     268            if ffado_python3: 
     269                # Refer to the comment about about Python UTF8 strings. 
     270                p.drawText(rect, Qt.AlignLeft|Qt.AlignTop, " ϕ") 
     271            else: 
     272                p.drawText(rect, Qt.AlignLeft|Qt.AlignTop, QtCore.QString.fromUtf8(" ϕ")) 
    263273 
    264274    def internalValueChanged(self, value):