Developer Documentation

View Mode Interface

This Interface can be used to configure visible widgets and menus in the viewer. A given view mode contains a list of toolbars, toolboxes and context menus which should be visible if the mode is active. Therefore you can define a subset of the full interface for special tasks.

# Example using custom view modes

OpenFlipper comes along with a lot of plugins each offering a wide variety of GUI elements such as toolboxes and toolbars. In order to constrain OpenFlipper's interface to a certain number of toolboxes and/or toolbar elements, the ViewModeInterface offers means to filter these elements.

So, for example, if we only wanted the toolboxes of the Data Control and the Selection plugin to be visible, we have to emit signal ViewModeInterface::defineViewModeToolboxes(QString, QStringList) in order to hide out everything else:

// In your plugin initialization, define the view modes:
void ExamplePlugin::pluginsInitialized() {
// Generate the list of toolboxes to use:
QStringList toolBoxes = QString("Data Control,Selection").split(",");
// Define the view mode.
emit defineViewModeToolboxes("My Custom View Mode", toolBoxes);
//define the viewMode Toolbars
QStringList toolBars;
toolBars.push_back( "Selection" );
emit defineViewModeToolbars("My Custom View Mode", toolBars);
}

When the user selects "My Custom View Mode" out of the view modes menu, all toolboxes except for Data Control and Selection will disappear. This works analogously for toolbar elements via the signal ViewModeInterface::defineViewModeToolbars(QString, QStringList).

# Defaults

The Main Toolbar and the Viewer Toolbar will always be included in the list of toolbars and will be the default when you define a View Mode with only toolboxes and context menus. If you do not define context menus for your View Mode, they will default to all.

# Icons

Additionally, if we wanted the "My Custom View Mode" entry in the view modes menu to appear with a fancy icon, we just have to call ViewModeInterface::defineViewModeIcon(QString, QString):

emit defineViewModeIcon("My Custom View Mode", "myIconFile.png");

# Usage

To use the ViewModeInterface:

- include ViewModeInterface.hh in your plugins header file
- derive your plugin from the class ViewModeInterface
- add Q_INTERFACES(ViewModeInterface) to your plugin class
- And add the signals you want to use to your plugin class