Source code for qtpyvcp.widgets.input_widgets.action_slider

import os
import linuxcnc

from PySide6.QtWidgets import QSlider
from PySide6.QtCore import Slot, Property

from qtpyvcp.actions import bindWidget
from qtpyvcp.utilities.logger import getLogger
from qtpyvcp.plugins import getPlugin


LOG = getLogger(__name__)

IN_DESIGNER = os.getenv('DESIGNER', False)
if not IN_DESIGNER:
    STATUS = getPlugin('status')


[docs] class ActionSlider(QSlider): """docstring for ActionSlider.""" def __init__(self, parent=None): super(ActionSlider, self).__init__(parent) self._action_name = '' @Property(str) def actionName(self): """The fully qualified name of the action the slider should trigger. Returns: str : The action name. """ return self._action_name @actionName.setter def actionName(self, action_name): """Sets the name of the action the slider should trigger. Args: action_name (str) : A fully qualified action name. """ self._action_name = action_name bindWidget(self, action_name) def mouseDoubleClickEvent(self, event): # Test for UI LOCK and consume event but do nothing if LOCK in place if STATUS.isLocked(): LOG.debug('Accept mouse Double Click Event') event.accept() return self.setValue(100) def mousePressEvent(self, event): # Test for UI LOCK and consume event but do nothing if LOCK in place if STATUS.isLocked(): LOG.debug('Accept mouse Press Event') event.accept() return super().mousePressEvent(event) def mouseReleaseEvent(self, event): if STATUS.isLocked(): LOG.debug('Accept mouse Release Event') event.accept() return super().mouseReleaseEvent(event) def keyPressEvent(self, event): # Test for UI LOCK and consume event but do nothing if LOCK in place if STATUS.isLocked(): LOG.debug('Accept keyPressEvent Event') event.accept() return super().keyPressEvent(event) def keyReleaseEvent(self, event): # Test for UI LOCK and consume event but do nothing if LOCK in place if STATUS.isLocked(): LOG.debug('Accept keyReleaseEvent Event') event.accept() return super().keyReleaseEvent(event)