Leads back to my original question, since I think what I'm doing is not the best...
At the moment I think my implementation is kludgey since I set a flag and check the flag in MySlider.
The following is called after the ui is instantiated:
def addChanStrip(self):
self.max_slider_count = 32
for idx in range(The_Show.mixers.__len__()):
.
.
.
for chn in range(The_Show.mixers[idx].mxrconsole.__len__()):
.
.
.
# Add slider for this channel
sldr = MySlider() # slider with decibel ticks
sldr.setContextMenuPolicy(Qt.CustomContextMenu)
sldr.customContextMenuRequested.connect(self.sldr_action_click)
sldr.sliderMoved.connect(self.slidermove)
sldr.valueChanged.connect(self.slidervalchanged)
sldr.sliderReleased.connect(self.sldrmovedone)
sldr.sliderPressed.connect(self.slder_pressed)
.
.
.
def slidervalchanged(self, val):
sending_slider = self.sender()
logging.info('In slidervalchanged, sending_slider name: {0}'.format(sending_slider.objectName()))
logging.info('SliderDown is : {}'.format(sending_slider.isSliderDown()))
if sending_slider.isSliderDown() or self.slider_keypress:
self.cuehaschanged = True
CE_msg = osc_message_builder.OscMessageBuilder(address='/cue/editstarted')
CE_msg.add_arg(True)
CE_msg = CE_msg.build()
self.CEResponsethread.queue_msg(CE_msg, self.CueAppDev)
.
.
.
if sending_slider.isSliderDown() or self.slider_keypress:
print('In slidervalchanged, sending_slider name: {0}, updating level state'.format(sending_slider.objectName()))
self.updatecuelevelstate()
if self.slider_keypress: self.slider_keypress = False # todo not sure setting flag in MySlider is good...
def addChanStrip(self):
self.max_slider_count = 32
for idx in range(The_Show.mixers.__len__()):
.
.
.
for chn in range(The_Show.mixers[idx].mxrconsole.__len__()):
.
.
.
# Add slider for this channel
sldr = MySlider() # slider with decibel ticks
sldr.setContextMenuPolicy(Qt.CustomContextMenu)
sldr.customContextMenuRequested.connect(self.sldr_action_click)
sldr.sliderMoved.connect(self.slidermove)
sldr.valueChanged.connect(self.slidervalchanged)
sldr.sliderReleased.connect(self.sldrmovedone)
sldr.sliderPressed.connect(self.slder_pressed)
.
.
.
def slidervalchanged(self, val):
sending_slider = self.sender()
logging.info('In slidervalchanged, sending_slider name: {0}'.format(sending_slider.objectName()))
logging.info('SliderDown is : {}'.format(sending_slider.isSliderDown()))
if sending_slider.isSliderDown() or self.slider_keypress:
self.cuehaschanged = True
CE_msg = osc_message_builder.OscMessageBuilder(address='/cue/editstarted')
CE_msg.add_arg(True)
CE_msg = CE_msg.build()
self.CEResponsethread.queue_msg(CE_msg, self.CueAppDev)
.
.
.
if sending_slider.isSliderDown() or self.slider_keypress:
print('In slidervalchanged, sending_slider name: {0}, updating level state'.format(sending_slider.objectName()))
self.updatecuelevelstate()
if self.slider_keypress: self.slider_keypress = False # todo not sure setting flag in MySlider is good...
To copy to clipboard, switch view to plain text mode
def __init__(self, parent=None):
super(MySlider, self).__init__(parent)
.
.
.
def keyPressEvent(self, k_ev):
print('In keyReleaseEvent for slider {}'.format(self.objectName()))
if k_ev.key() in [Qt.Key_Up, Qt.Key_Down, Qt.Key_PageDown, Qt.Key_PageUp]:
self.window().slider_keypress = True
QtWidgets.
QSlider.
keyPressEvent(self, k_ev
).
.
.
class MySlider(QtWidgets.QSlider):
def __init__(self, parent=None):
super(MySlider, self).__init__(parent)
.
.
.
def keyPressEvent(self, k_ev):
print('In keyReleaseEvent for slider {}'.format(self.objectName()))
if k_ev.key() in [Qt.Key_Up, Qt.Key_Down, Qt.Key_PageDown, Qt.Key_PageUp]:
self.window().slider_keypress = True
QtWidgets.QSlider.keyPressEvent(self, k_ev)
.
.
.
To copy to clipboard, switch view to plain text mode
Bookmarks