Skip to content

Commit 37e4ab2

Browse files
committed
qtvcp -screenoptions: add blur/tint on focus options
1 parent 807dd21 commit 37e4ab2

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

lib/python/qtvcp/widgets/screen_options.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ def __init__(self, parent=None):
108108
self.add_tool_dialog = False
109109
self.add_file_dialog = False
110110
self.add_focus_overlay = False
111+
self.add_focus_effect = False
112+
self.use_focus_tint = False
113+
self.use_focus_blur = False
111114
self.add_keyboard_dialog = False
112115
self.add_versaprobe_dialog = False
113116
self.add_macrotab_dialog = False
@@ -167,6 +170,9 @@ def _hal_init(self):
167170
if self.add_focus_overlay:
168171
self.init_focus_overlay()
169172

173+
if self.add_focus_effect:
174+
self.init_focus_effect()
175+
170176
if self.add_keyboard_dialog:
171177
self.init_keyboard_dialog()
172178

@@ -548,6 +554,10 @@ def init_focus_overlay(self):
548554
w.focusOverlay_.setObjectName('focusOverlay_')
549555
w.focusOverlay_.hal_init(HAL_NAME='')
550556

557+
def init_focus_effect(self):
558+
STATUS.connect('focus-overlay-changed', lambda w, data, text, color:
559+
self.effect(data, text, color))
560+
551561
def init_keyboard_dialog(self):
552562
from qtvcp.widgets.dialog_widget import KeyboardDialog
553563
w = self.QTVCP_INSTANCE_
@@ -690,6 +700,26 @@ def _override_limits(self, n, signal_text):
690700
ACTION.TOGGLE_LIMITS_OVERRIDE()
691701
ACTION.SET_MACHINE_STATE(True)
692702

703+
def effect(self, data, text, color):
704+
if self.use_focus_blur:
705+
ACTION.SET_BLUR(self.QTVCP_INSTANCE_,data)
706+
elif self.use_focus_tint:
707+
ACTION.SET_TINT(self.QTVCP_INSTANCE_, data, color)
708+
709+
#########################################################################
710+
# This is how designer can interact with our widget properties.
711+
# designer will show the pyqtProperty properties in the editor
712+
# it will use the get set and reset calls to do those actions
713+
#
714+
# _toggle_properties makes it so we can only select one option
715+
########################################################################
716+
717+
def _toggle_properties(self, picked):
718+
data = ('focusBlur','focusTint')
719+
for i in data:
720+
if not i == picked:
721+
self[i+'_option'] = False
722+
693723
########################################################################
694724
# This is how designer can interact with our widget properties.
695725
# designer will show the pyqtProperty properties in the editor
@@ -802,6 +832,34 @@ def reset_focusOverlay(self):
802832
self.add_focus_overlay = False
803833
focusOverlay_option = QtCore.pyqtProperty(bool, get_focusOverlay, set_focusOverlay, reset_focusOverlay)
804834

835+
def set_focusEffect(self, data):
836+
self.add_focus_effect = data
837+
def get_focusEffect(self):
838+
return self.add_focus_effect
839+
def reset_focusEffect(self):
840+
self.add_focus_effect = False
841+
focusEffect_option = QtCore.pyqtProperty(bool, get_focusEffect, set_focusEffect, reset_focusEffect)
842+
843+
def set_focusBlur(self, data):
844+
self.use_focus_blur = data
845+
if data:
846+
self._toggle_properties('focusBlur')
847+
def get_focusBlur(self):
848+
return self.use_focus_blur
849+
def reset_focusBlur(self):
850+
self.use_focus_blur = False
851+
focusBlur_option = QtCore.pyqtProperty(bool, get_focusBlur, set_focusBlur, reset_focusBlur)
852+
853+
def set_focusTint(self, data):
854+
self.use_focus_tint = data
855+
if data:
856+
self._toggle_properties('focusTint')
857+
def get_focusTint(self):
858+
return self.use_focus_tint
859+
def reset_focusTint(self):
860+
self.use_focus_tint = False
861+
focusTint_option = QtCore.pyqtProperty(bool, get_focusTint, set_focusTint, reset_focusTint)
862+
805863
# Dialogs ##########################################
806864

807865
def set_messageDialog(self, data):

0 commit comments

Comments
 (0)