Disable Snapshot and Record push buttons in SequenceBrowserPlayWidget while recordning

Hello,

I work on an application in which we use SequenceBrowserPlayWidget to browse sequences. We would like to disable Snapshot (pushButton_Snapshot) and Record (pushButton_VcrRecord) push buttons as we do not use them.
However, in Modules/Loadable/Sequences/Widgets/qMRMLSequenceBrowserPlayWidget.cxx, these buttons are automatically set visible when a node is recording (L. 150-153).

Would it be possible to add a member variable (and the function to set it) to disable this behaviour ?

Thank you !

The record&snapshot buttons are automatically shown if recording is allowed for any of the sequence nodes. To disable recording for all sequences, you can call sequenceBrowserNode.SetRecording(None, False).

Hello Andras,

Thank you very much Andras for your quick response !
This command is, indeed, quite useful to disable recording for all sequences.

The point is, we are recording images, but the recording is not controlled through the SequenceBrowserPlayWidget. So, we need to have recording enabled for some sequences, but we would like not to show the recording and snapshot buttons meanwhile.

Yes, you could add an extra property to the widget (recordingEnabled) that would be required to be set to true to make the record buttons visible (in addition to having recordable sequences). This flag would not be saved into MRML, applied to other widgets, just used by that single widget. If you need any help with getting started with this then let us know. If you send us a pull request then we’ll integrate your changes and maintain it in Slicer core.

Thank you ! I will try to make the corresponding changes; let you know if I need some help and send the pull request.

1 Like

An option would be to add a member boolean variable to the class, initially set to true to allow enabling the buttons, with two methods to set and get the value.

if (m_activateButtons)
  {
    d->pushButton_VcrRecord->setVisible(recordingAllowed);
    d->pushButton_VcrRecord->setEnabled(!playbackActive);
    d->pushButton_Snapshot->setVisible(recordingAllowed);
    d->pushButton_Snapshot->setEnabled(!playbackActive && !recordingActive);
  }

This member variable would be set in qMRMLSequenceBrowserPlayWidget.h.

What do you think about it ?

Sounds good. A few tips:

  • The member variable name has to be recordingControlsVisible (since there is already setRecordingEnabled method).
  • Make it a Qt property (by adding Q_PROPERTY(bool recordingControlsVisible READ recordingControlsVisible WRITE setRecordingControlsVisible)) so that you can enable/disable this property in Qt Designer.
  • Whenever the value is changed then make sure the buttons are immediately shown/hidden as applicable (by calling updateWidgetFromMRML())
  • Change the logic in updateWidgetFromMRML() to make record&snapshot buttons visible if recordingAllowed && d->recordingControlsVisible

Thanks in advance, looking forward to getting your pull request.

Thank you very much Andras for your tips, they were very useful !