My element/device button to trigger a resync of alarms, on press the element sends a message to the device to start the resync and the device sends all the alarms as traps.
What is the best way to limit this button press to e.g. once every 5s? I am thinking of something similar to OTP or 2FA button requests where after a press, the button gets grayed out and may even show a countdown till it can be pressed again.
Hi,
The most easy thing to do is adding a QAction that gets triggered by the button. This QAction is an "instance" QAction (not a static one) that keeps a UTC DateTime as field variable. When the QAction gets triggered, compare the current time with the previous one, if the time > 5s then allow further execution and adapt the DateTime, else exit the QAction and add a log line why it was exited.
A countdown could be handy for the end user, but makes it more complex as then a timer needs to constantly run in the background to adapt how much time is left.
Regards,