Workspace 6.21.5
Signals | Public Member Functions | List of all members
WidgetWindow Class Reference

Provides a floating window which keeps its title synchronized with its source. More...

#include <Workspace/Widgets/widgetwindow.h>

Inherits QWidget.

Signals

void shortcutPressed (CSIRO::Widgets::WidgetWindow *toggleWidget)
 

Public Member Functions

 WidgetWindow (DataExecution::IOBase &iobase, QWidget *parent=nullptr)
 
 ~WidgetWindow () override
 
void focusInEvent (QFocusEvent *event) override
 
DataExecution::IOBasegetIOBase ()
 
QWidget * getWidget ()
 
void keyPressEvent (QKeyEvent *event) override
 
bool loadWidgetProperties (const DataExecution::SerializedItem &item)
 
void recreateWidget ()
 
bool saveWidgetProperties (DataExecution::SerializedItem &item) const
 
void setAdaptType (QString adaptType)
 
void setWidget (QWidget *w)
 
QWidget * takeWidget ()
 

Detailed Description

The widget is meant to be used as a wrapper around a widget that is attached to an input or output in the workspace. It takes care of keeping the widget in sync with the input/output, ensuring that the window title is updated if the name of the input/output changes and recreating the widget if the input/output changes data type.

Because these widgets tend to be used as floating windows, they have their Qt::WA_DeleteOnClose attribute set by default.

Constructor & Destructor Documentation

◆ WidgetWindow()

WidgetWindow ( DataExecution::IOBase iobase,
QWidget *  parent = nullptr 
)
Parameters
iobaseThe input/output this window will be displaying. The title of the window will be updated whenever the name of this input/output changes
parentThe parent widget of this window. This will normally be null, since widget windows are usually top level windows. It is for this reason that WidgetWindow is created with its Qt::WA_DeleteOnClose attribute set.

◆ ~WidgetWindow()

~WidgetWindow ( )
override

Member Function Documentation

◆ focusInEvent()

void focusInEvent ( QFocusEvent *  event)
override

◆ getIOBase()

DataExecution::IOBase & getIOBase ( )
Returns
The input/output this widget window is associated with.

◆ getWidget()

QWidget * getWidget ( )
Returns
The currently held child widget or a null pointer if there was no child widget.
See also
setWidget(), takeWidget()

◆ keyPressEvent()

void keyPressEvent ( QKeyEvent *  event)
override

◆ loadWidgetProperties()

bool loadWidgetProperties ( const DataExecution::SerializedItem item)
Parameters
itemThe parent item from which we are loading widget properties.
Returns
true if the properties were able to be deserialized, false otherwise.

Loads custom properties into the contained widget. This can be used to load widget properties from a Workspace file.

◆ recreateWidget()

void recreateWidget ( )

This function forces the widget currently held by this widget window to be deleted and a new one created in its place. This is most useful after the data type of the input/output the widget window is associated with is changed, such as for a polymorphic operation whose inputs and outputs change data type to match. It will create the input/output's preferred widget type if one is set.

See also
setWidget(), getWidget()

◆ saveWidgetProperties()

bool saveWidgetProperties ( DataExecution::SerializedItem item) const
Parameters
itemThe parent item under which we are saving widget properties.
Returns
true if the properties were able to be serialized, false otherwise.

Saves the custom properties of the contained widget into a SerializedItem. This can then be used to save widget properties with a Workspace file.

◆ setAdaptType()

void setAdaptType ( QString  adaptType)

◆ setWidget()

void setWidget ( QWidget *  w)
Parameters
wThe new child widget, or a null pointer if the window should hold no widget (this would normally be a transitional state before eventually setting the widget to something).

When this function is called, it deletes the currently held widget (if set) and also the current layout. It will then create a new layout and add w to it.

Note
This function takes ownership of w.
See also
getWidget(), takeWidget(), recreateWidget()

◆ shortcutPressed

void shortcutPressed ( CSIRO::Widgets::WidgetWindow toggleWidget)
signal

◆ takeWidget()

QWidget * takeWidget ( )

Takes back ownership of the currently held widget. The WidgetWindow will no longer try to delete the child widget when the window object is deleted.

Returns
The child widget that was held, or a null pointer if there was no child widget.
See also
setWidget(), getWidget()