def __init__(self, switcherState, parent=None): super(OutputsGrid, self).__init__(parent) self.signalMapper = QSignalMapper(self) self.longPressSignalMapper = QSignalMapper(self) layout = QGridLayout() mainMixFrame = MainMixControl() mainMixFrame.cut.connect(self.cut.emit) mainMixFrame.take.connect(self.take.emit) layout.addWidget(mainMixFrame, 0, 0, 1, 2) self.aux_buttons = [] for idx, output in switcherState.outputs.iteritems(): ob = OutputButton(output) layout.addWidget(ob, 1 + (idx / 2), idx % 2) ob.clicked.connect(self.signalMapper.map) self.signalMapper.setMapping(ob, idx) ob.longpress.connect(self.longPressSignalMapper.map) self.longPressSignalMapper.setMapping(ob, idx) self.aux_buttons.append(ob) self.signalMapper.mapped.connect(self.registerClick) self.longPressSignalMapper.mapped.connect(self.longPress) btnAll = ExpandingButton() btnAll.setProperty("class", "mainMix") btnAll.setText("Mix to all") btnAll.clicked.connect(self.mainToAll.emit) layout.addWidget(btnAll, 4, 0) self.btnAll = ExpandingButton() self.btnAll.setText("All") self.btnAll.clicked.connect(self.all.emit) layout.addWidget(self.btnAll, 4, 1) layout.setColumnMinimumWidth(0, 100) layout.setColumnMinimumWidth(1, 100) layout.setColumnStretch(0, 1) layout.setColumnStretch(1, 1) layout.setRowStretch(0, 2) for i in range(1, 5): layout.setRowStretch(i, 1) self.setLayout(layout)
def testOutputButton(self): some_input = Input(VideoSource.INPUT_1, "My input", None) main_mix = Input(VideoSource.ME_1_PROGRAM, "Main mix", None) my_output = Output("Some Output", VideoSource.AUX_1) ob = OutputButton(my_output) ob_state = ob.stateDisplay self.assertEqual('-', ob_state.text()) self.assertFalse(ob_state.property("highlight")) my_output.set_source(some_input) self.assertEqual('My input', ob_state.text()) self.assertTrue(ob_state.property("highlight")) my_output.set_source(main_mix) self.assertEqual('Main mix', ob_state.text()) self.assertFalse(ob_state.property("highlight"))