Skip to content

Commit d359903

Browse files
committed
qtvcp -baseclass: register dialogs for later checks
like if you want to send responses to the current showing dialog
1 parent f5cff62 commit d359903

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

lib/python/qtvcp/qt_makegui.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def __init__(self, halcomp=None, path=None):
9595
self.originalCloseEvent_ = self.closeEvent
9696
self._halWidgetList = []
9797
self._VCPWindowList = []
98+
self._DialogList = []
9899
self.settings = QtCore.QSettings('QtVcp', path.BASENAME)
99100
log.info('Qsettings file path: yellow<{}>'.format(self.settings.fileName()))
100101
# make an instance with embedded variables so they
@@ -107,6 +108,12 @@ def registerHalWidget(self, widget):
107108
def getRegisteredHalWidgetList(self):
108109
return self._halWidgetList
109110

111+
def registerDialog(self, widget):
112+
self._DialogList.append(widget)
113+
114+
def getRegisteredDialogList(self):
115+
return self._DialogList
116+
110117
# These catch events if using a plain VCP panel and there is no handler file
111118
def keyPressEvent(self, e):
112119
self.keyPressTrap(e)

lib/python/qtvcp/widgets/widget_baseclass.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import hal
2020
from PyQt5.QtCore import pyqtProperty
21+
from PyQt5.QtWidgets import QDialog
22+
2123
from qtvcp import logger
2224

2325
# Instantiate the libraries with global reference
@@ -52,6 +54,7 @@ def __init__(self,comp=None,path=None,window=None):
5254
# INSTANCE_NAME is the embedded panel name
5355
def hal_init(self, HAL_NAME=None,INSTANCE_NAME = None):
5456
self.__class__.QTVCP_INSTANCE_.registerHalWidget(self)
57+
5558
if INSTANCE_NAME is not None:
5659
self.__class__.THIS_INSTANCE_ = self.__class__.QTVCP_INSTANCE_[INSTANCE_NAME]
5760
else:
@@ -67,6 +70,13 @@ def hal_init(self, HAL_NAME=None,INSTANCE_NAME = None):
6770
self.PREFS_ = self.QTVCP_INSTANCE_.PREFS_
6871
except:
6972
self.PREFS_ = None
73+
74+
# register avaliable dialogs (for external controls)
75+
if isinstance(self, QDialog):
76+
idname = self.objectName()
77+
LOG.verbose('green<Registered Dialog:> {}'.format(idname))
78+
self.__class__.QTVCP_INSTANCE_.registerDialog(self)
79+
7080
LOG.verbose("HAL_init: ObjectName:'{}'\n SELF:{}\n HAL NAME:{}\n PREFS:{}\n INSTANMCE:{}".format(self.objectName(),self,self.HAL_NAME_,self.PREFS_ ,self.__class__.THIS_INSTANCE_))
7181
self._hal_init()
7282

0 commit comments

Comments
 (0)