Changeset 2649
- Timestamp:
- 11/08/16 03:59:05 (7 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/support/mixer-qt4/ffado/widgets/matrixmixer.py
r2546 r2649 22 22 23 23 from PyQt4 import QtGui, QtCore, Qt 24 from PyQt4.QtGui import QColor, QAbstractSlider, QDoubleSpinBox, QWidgetAction 25 from PyQt4.QtGui import QAction, QPainter, QWidget, QGridLayout, QLabel 26 from PyQt4.QtGui import QLayout, QSlider, QLineEdit, QPalette, 27 from PyQt4.QtGui import QVBoxLayout, QHBoxLayout, QTabWidget, QToolBar 28 from PyQt4.QtGui import QComboBox, QScrollArea, QPushButton, QSizePolicy 24 29 import dbus, math, decimal 25 30 … … 80 85 lc = self.colors[low] 81 86 hc = self.colors[high] 82 return Q tGui.QColor(87 return QColor( 83 88 (1-f)*lc.red() + f*hc.red(), 84 89 (1-f)*lc.green() + f*hc.green(), … … 88 93 def __init__(self): 89 94 ColorForNumber.__init__(self) 90 self.addColor( 0.0, Q tGui.QColor( 0, 0, 0))91 self.addColor( 1.0, Q tGui.QColor( 0, 0, 128))92 self.addColor( math.pow(2,6), Q tGui.QColor( 0, 255, 0))93 self.addColor( math.pow(2,14), Q tGui.QColor(255, 255, 0))94 self.addColor(math.pow(2,16)-1, Q tGui.QColor(255, 0, 0))95 self.addColor( 0.0, QColor( 0, 0, 0)) 96 self.addColor( 1.0, QColor( 0, 0, 128)) 97 self.addColor( math.pow(2,6), QColor( 0, 255, 0)) 98 self.addColor( math.pow(2,14), QColor(255, 255, 0)) 99 self.addColor(math.pow(2,16)-1, QColor(255, 0, 0)) 95 100 96 101 def getFrgdColor(self, color): 97 102 if color.valueF() < 0.6: 98 return Q tGui.QColor(255, 255, 255)99 else: 100 return Q tGui.QColor(0, 0, 0)103 return QColor(255, 255, 255) 104 else: 105 return QColor(0, 0, 0) 101 106 102 class MixerNode(Q tGui.QAbstractSlider):107 class MixerNode(QAbstractSlider): 103 108 def __init__(self, input, output, value, max, muted, inverted, parent, matrix_obj): 104 Q tGui.QAbstractSlider.__init__(self, parent)109 QAbstractSlider.__init__(self, parent) 105 110 #log.debug("MixerNode.__init__( %i, %i, %i, %i, %s )" % (input, output, value, max, str(parent)) ) 106 111 … … 129 134 self.connect(self.mapper, QtCore.SIGNAL("mapped(const QString&)"), self.directValues) 130 135 131 self.spinbox = Q tGui.QDoubleSpinBox(self)136 self.spinbox = QDoubleSpinBox(self) 132 137 self.spinbox.setRange(-40, 12) 133 138 self.spinbox.setSuffix(" dB") … … 136 141 137 142 self.connect(self.spinbox, QtCore.SIGNAL("valueChanged(const QString&)"), self.directValues) 138 action = Q tGui.QWidgetAction(self)143 action = QWidgetAction(self) 139 144 action.setDefaultWidget(self.spinbox) 140 145 self.addAction(action) 141 146 142 147 for text in ["3 dB", "0 dB", "-3 dB", "-20 dB", "-inf dB"]: 143 action = Q tGui.QAction(text, self)148 action = QAction(text, self) 144 149 self.connect(action, QtCore.SIGNAL("triggered()"), self.mapper, QtCore.SLOT("map()")) 145 150 self.mapper.setMapping(action, text) … … 149 154 self.mute_action = None 150 155 if (muted != None): 151 action = Q tGui.QAction(text, self)156 action = QAction(text, self) 152 157 action.setSeparator(True) 153 158 self.addAction(action) 154 self.mute_action = Q tGui.QAction("Mute", self)159 self.mute_action = QAction("Mute", self) 155 160 self.mute_action.setCheckable(True) 156 161 self.mute_action.setChecked(muted) … … 163 168 if (inverted != None): 164 169 if (muted == None): 165 action = Q tGui.QAction(text, self)170 action = QAction(text, self) 166 171 action.setSeparator(True) 167 172 self.addAction(action) 168 self.inv_action = Q tGui.QAction("Invert", self)173 self.inv_action = QAction("Invert", self) 169 174 self.inv_action.setCheckable(True) 170 175 self.inv_action.setChecked(inverted) … … 226 231 227 232 def paintEvent(self, ev): 228 p = Q tGui.QPainter(self)233 p = QPainter(self) 229 234 rect = self.rect() 230 235 v = self.value() 231 236 if (self.mute_action!=None and self.mute_action.isChecked()): 232 color = Q tGui.QColor(64, 64, 64)237 color = QColor(64, 64, 64) 233 238 else: 234 239 color = self.bgcolors.getColor(v) … … 270 275 self.update() 271 276 272 class MixerChannel(Q tGui.QWidget):277 class MixerChannel(QWidget): 273 278 def __init__(self, number, parent=None, name="", smallFont=False): 274 Q tGui.QWidget.__init__(self, parent)275 layout = Q tGui.QGridLayout(self)279 QWidget.__init__(self, parent) 280 layout = QGridLayout(self) 276 281 self.number = number 277 282 self.name = name 278 self.lbl = Q tGui.QLabel(self)283 self.lbl = QLabel(self) 279 284 self.lbl.setAlignment(Qt.Qt.AlignCenter) 280 285 if (smallFont): … … 287 292 self.setContextMenuPolicy(Qt.Qt.ActionsContextMenu) 288 293 289 action = Q tGui.QAction("Make this channel small", self)294 action = QAction("Make this channel small", self) 290 295 action.setCheckable(True) 291 296 self.connect(action, QtCore.SIGNAL("triggered(bool)"), self.hideChannel) … … 301 306 302 307 # Matrix view widget 303 class MatrixControlView(Q tGui.QWidget):308 class MatrixControlView(QWidget): 304 309 def __init__(self, servername, basepath, parent=None, sliderMaxValue=-1, mutespath=None, invertspath=None, smallFont=False, shortname=False, shortcolname="Ch", shortrowname="Ch", transpose=False): 305 Q tGui.QWidget.__init__(self, parent)310 QWidget.__init__(self, parent) 306 311 307 312 self.bus = dbus.SessionBus() … … 335 340 self.inverts_interface = dbus.Interface(self.inverts_dev, dbus_interface="org.ffado.Control.Element.MatrixMixer") 336 341 337 layout = Q tGui.QGridLayout(self)338 layout.setSizeConstraint(Q tGui.QLayout.SetNoConstraint);342 layout = QGridLayout(self) 343 layout.setSizeConstraint(QLayout.SetNoConstraint); 339 344 self.setLayout(layout) 340 345 … … 640 645 return True 641 646 642 class VolumeSlider(Q tGui.QSlider):647 class VolumeSlider(QSlider): 643 648 def __init__(self, In, Out, value, parent): 644 Q tGui.QSlider.__init__(self, QtCore.Qt.Vertical, parent)645 646 self.setTickPosition(Q tGui.QSlider.TicksBothSides)649 QSlider.__init__(self, QtCore.Qt.Vertical, parent) 650 651 self.setTickPosition(QSlider.TicksBothSides) 647 652 v_min = 10.0*toDBvalue(0) 648 653 v_max = 10.0*toDBvalue(65536) … … 673 678 674 679 675 class VolumeSliderValueInfo(Q tGui.QLineEdit):680 class VolumeSliderValueInfo(QLineEdit): 676 681 def __init__(self, In, Out, value, parent): 677 Q tGui.QLineEdit.__init__(self, parent)682 QLineEdit.__init__(self, parent) 678 683 679 684 self.setReadOnly(True) … … 695 700 color = self.bgcolors.getColor(value) 696 701 palette = self.palette() 697 palette.setColor(Q tGui.QPalette.Active, QtGui.QPalette.Base, color)698 palette.setColor(Q tGui.QPalette.Active, QtGui.QPalette.Text, self.bgcolors.getFrgdColor(color))702 palette.setColor(QPalette.Active, QPalette.Base, color) 703 palette.setColor(QPalette.Active, QPalette.Text, self.bgcolors.getFrgdColor(color)) 699 704 self.setPalette(palette) 700 705 … … 708 713 self.setText(text) 709 714 710 class BalanceSlider(Q tGui.QSlider):715 class BalanceSlider(QSlider): 711 716 def __init__(self, In, Out, value, parent): 712 Q tGui.QSlider.__init__(self, QtCore.Qt.Horizontal, parent)717 QSlider.__init__(self, QtCore.Qt.Horizontal, parent) 713 718 714 719 v_min = -50 715 720 v_max = 50 716 self.setTickPosition(Q tGui.QSlider.TicksBothSides)721 self.setTickPosition(QSlider.TicksBothSides) 717 722 self.setTickInterval((v_max-v_min)/2) 718 723 self.setMinimum(v_min) … … 738 743 739 744 # Slider view widget 740 class SliderControlView(Q tGui.QWidget):745 class SliderControlView(QWidget): 741 746 def __init__(self, parent, servername, basepath, rule="Columns_are_inputs", shortname=False, shortinname="Ch", shortoutname="Ch", stereochannels = []): 742 Q tGui.QWidget.__init__(self, parent)747 QWidget.__init__(self, parent) 743 748 744 749 self.bus = dbus.SessionBus() … … 760 765 k = 0 761 766 for i in range(self.nbOut): 762 widget = Q tGui.QWidget(parent)763 v_layout = Q tGui.QVBoxLayout(widget)767 widget = QWidget(parent) 768 v_layout = QVBoxLayout(widget) 764 769 v_layout.setAlignment(Qt.Qt.AlignCenter) 765 770 widget.setLayout(v_layout) … … 779 784 # Mixer/Out info label 780 785 if (self.nbOut > 1): 781 lbl = Q tGui.QLabel(widget)786 lbl = QLabel(widget) 782 787 lbl.setText(self.getOutName(i, self.shortname)) 783 788 lbl.setAlignment(Qt.Qt.AlignCenter) … … 785 790 self.out[i].lbl.append(lbl) 786 791 787 h_layout_wid = Q tGui.QWidget(widget)788 h_layout = Q tGui.QHBoxLayout(h_layout_wid)792 h_layout_wid = QWidget(widget) 793 h_layout = QHBoxLayout(h_layout_wid) 789 794 h_layout.setAlignment(Qt.Qt.AlignCenter) 790 795 h_layout_wid.setLayout(h_layout) … … 795 800 796 801 for j in range(self.nbIn): 797 h_v_layout_wid = Q tGui.QWidget(h_layout_wid)798 h_v_layout = Q tGui.QVBoxLayout(h_v_layout_wid)802 h_v_layout_wid = QWidget(h_layout_wid) 803 h_v_layout = QVBoxLayout(h_v_layout_wid) 799 804 h_v_layout.setAlignment(Qt.Qt.AlignCenter) 800 805 h_v_layout_wid.setLayout(h_v_layout) … … 803 808 # Mixer/In info label 804 809 if (self.nbIn > 1): 805 lbl = Q tGui.QLabel(h_v_layout_wid)810 lbl = QLabel(h_v_layout_wid) 806 811 lbl.setText(self.getInName(j, self.shortname)) 807 812 lbl.setAlignment(Qt.Qt.AlignCenter) … … 809 814 self.out[i].lbl.append(lbl) 810 815 811 h_v_h_layout_wid = Q tGui.QWidget(h_v_layout_wid)812 h_v_h_layout = Q tGui.QHBoxLayout(h_v_h_layout_wid)816 h_v_h_layout_wid = QWidget(h_v_layout_wid) 817 h_v_h_layout = QHBoxLayout(h_v_h_layout_wid) 813 818 h_v_h_layout.setAlignment(Qt.Qt.AlignCenter) 814 819 h_v_h_layout_wid.setLayout(h_v_h_layout) … … 1104 1109 from functools import partial 1105 1110 1106 class MatrixMixer(Q tGui.QWidget):1107 def __init__(self, servername, basepath, parent=None, rule="Columns_are_inputs", sliderMaxValue=-1, mutespath=None, invertspath=None, smallFont=False, taborientation=Q tGui.QTabWidget.West, tabshape=QtGui.QTabWidget.Triangular):1108 Q tGui.QWidget.__init__(self, parent)1111 class MatrixMixer(QWidget): 1112 def __init__(self, servername, basepath, parent=None, rule="Columns_are_inputs", sliderMaxValue=-1, mutespath=None, invertspath=None, smallFont=False, taborientation=QTabWidget.West, tabshape=QTabWidget.Triangular): 1113 QWidget.__init__(self, parent) 1109 1114 self.servername = servername 1110 1115 self.basepath = basepath … … 1114 1119 self.smallFont = smallFont 1115 1120 1116 self.layout = Q tGui.QVBoxLayout(self)1121 self.layout = QVBoxLayout(self) 1117 1122 self.setLayout(self.layout) 1118 1123 1119 1124 # Mixer view Tool bar 1120 mxv_set = Q tGui.QToolBar("View settings", self)1125 mxv_set = QToolBar("View settings", self) 1121 1126 1122 1127 # Here is a hack; the first action button appears to behaves strangely, 1123 1128 # possibly a PyQt bug (or an unsufficient fair implementation of it) 1124 1129 # Feel free to remove the next three lines at a time in the future 1125 hack = Q tGui.QAction(" ", mxv_set)1130 hack = QAction(" ", mxv_set) 1126 1131 hack.setDisabled(True) 1127 1132 mxv_set.addAction(hack) 1128 1133 1129 transpose_matrix = Q tGui.QAction("Transpose", mxv_set)1134 transpose_matrix = QAction("Transpose", mxv_set) 1130 1135 self.transpose = False 1131 1136 transpose_matrix.setShortcut('Ctrl+T') … … 1135 1140 mxv_set.addSeparator() 1136 1141 1137 self.hide_matrix = Q tGui.QAction("Hide matrix", mxv_set)1142 self.hide_matrix = QAction("Hide matrix", mxv_set) 1138 1143 self.hide_matrix_bool = False 1139 1144 mxv_set.addAction(self.hide_matrix) … … 1141 1146 mxv_set.addSeparator() 1142 1147 1143 self.hide_per_output = Q tGui.QAction("Hide per Output", mxv_set)1148 self.hide_per_output = QAction("Hide per Output", mxv_set) 1144 1149 self.hide_per_output_bool = False 1145 1150 mxv_set.addAction(self.hide_per_output) … … 1147 1152 mxv_set.addSeparator() 1148 1153 1149 self.use_short_names = Q tGui.QAction("Short names", mxv_set)1154 self.use_short_names = QAction("Short names", mxv_set) 1150 1155 self.short_names_bool = False 1151 1156 mxv_set.addAction(self.use_short_names) … … 1154 1159 mxv_set.addSeparator() 1155 1160 1156 font_switch_lbl = Q tGui.QLabel(mxv_set)1161 font_switch_lbl = QLabel(mxv_set) 1157 1162 font_switch_lbl.setText("Font size ") 1158 1163 mxv_set.addWidget(font_switch_lbl) 1159 font_switch = Q tGui.QComboBox(mxv_set)1164 font_switch = QComboBox(mxv_set) 1160 1165 font_switch.setToolTip("Labels font size") 1161 1166 font = font_switch.font() … … 1172 1177 # First tab is for matrix view 1173 1178 # Next are for "per Out" view 1174 self.tabs = Q tGui.QTabWidget(self)1179 self.tabs = QTabWidget(self) 1175 1180 self.tabs.setTabPosition(taborientation) 1176 1181 self.tabs.setTabShape(tabshape) … … 1187 1192 self.connect(self.matrix, QtCore.SIGNAL("valueChanged"), self.matrixControlChanged) 1188 1193 1189 self.scrollarea_matrix = Q tGui.QScrollArea(self.tabs)1194 self.scrollarea_matrix = QScrollArea(self.tabs) 1190 1195 self.scrollarea_matrix.setWidgetResizable(True) 1191 1196 self.scrollarea_matrix.setWidget(self.matrix) … … 1204 1209 nb_out_mono = self.matrix.cols 1205 1210 1206 stereo_switch_lbl = Q tGui.QLabel(mxv_set)1211 stereo_switch_lbl = QLabel(mxv_set) 1207 1212 stereo_switch_lbl.setText("Stereo: ") 1208 1213 mxv_set.addWidget(stereo_switch_lbl) … … 1212 1217 self.stereo_switch = [] 1213 1218 for i in range(nb_out_mono/2): 1214 stereo_switch = Q tGui.QPushButton("%d+%d" % (2*i+1, 2*i+2), mxv_set)1219 stereo_switch = QPushButton("%d+%d" % (2*i+1, 2*i+2), mxv_set) 1215 1220 stereo_switch.setToolTip("Set these output channels as stereo") 1216 1221 stereo_switch.setCheckable(True) 1217 1222 stereo_switch.clicked.connect(partial(self.switchStereoChannel, i)) 1218 1223 stereo_switch.setMinimumSize(stereo_switch_lbl.fontMetrics().boundingRect("%d+%d" % (nb_out_mono, nb_out_mono)).size()*1.05) 1219 stereo_switch.setSizePolicy(Q tGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum))1224 stereo_switch.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)) 1220 1225 stereo_switch.is_stereo = False 1221 1226 mxv_set.addWidget(stereo_switch) … … 1227 1232 self.connect(self.perOut, QtCore.SIGNAL("valueChanged"), self.sliderControlChanged) 1228 1233 for i in range(self.perOut.nbOut): 1229 self.perOut.out[i].scrollarea = Q tGui.QScrollArea(self.tabs)1234 self.perOut.out[i].scrollarea = QScrollArea(self.tabs) 1230 1235 self.perOut.out[i].scrollarea.setWidgetResizable(True) 1231 1236 self.perOut.out[i].scrollarea.setWidget(self.perOut.out[i]) … … 1242 1247 self.connect(self.matrix, QtCore.SIGNAL("valueChanged"), self.matrixControlChanged) 1243 1248 1244 self.scrollarea_matrix = Q tGui.QScrollArea(self.tabs)1249 self.scrollarea_matrix = QScrollArea(self.tabs) 1245 1250 self.scrollarea_matrix.setWidgetResizable(True) 1246 1251 self.scrollarea_matrix.setWidget(self.matrix) … … 1383 1388 current = 0 1384 1389 for i in range(self.perOut.nbOut): 1385 self.perOut.out[i].scrollarea = Q tGui.QScrollArea(self.tabs)1390 self.perOut.out[i].scrollarea = QScrollArea(self.tabs) 1386 1391 self.perOut.out[i].scrollarea.setWidgetResizable(True) 1387 1392 self.perOut.out[i].scrollarea.setWidget(self.perOut.out[i])