Many widgets in the main application window have customizable context menus. Each customizable context menu uses
ContextMenuAction objects that define a unique ID for the action and optional placement using an additional "buddy" action. The menu actions are customized in a
ContextMenu.
Since each context menu may have different actions, debugging support is provided through the message log. Call the ContextMenu::setSettingLogActions() method to enable or disable logging of the actions.
- Warning:
- Context menu logging is provided for debugging purposes only and is therefore only available in debug mode. Enabling the logging will do nothing in a release mode version of the application.
When the user right-clicks on a widget containing a customizable context menu, the following calling sequence is invoked:
- The SessionItem::getContextMenuActions() method is called to get the default list of ContextMenuActions for that session item. This may include actions for additional session items, if the context areas of multiple session items are to be combined.
- The ContextMenu is created.
- If ContextMenu::hasSettingLogActions() and ContextMenu::getSettingLogActions() both return
true, the default actions are recorded in the message log. - The DesktopServices::signalAboutToShowContextMenu() signal is emitted with the ContextMenu value indicating that the menu is about to be displayed. This gives attached objects a chance to add actions to the default list or to remove actions from the list. Custom actions can also be created based on the current state of the session item(s) or the point on which the user clicked to invoke the menu.
- A custom widget signal may be emitted indicating that the user clicked in that particular widget. This provides the capability for objects to attach to a particular session item signal instead of the DesktopServices::signalAboutToShowContextMenu() signal. Available session item signals include the following:
- If the user clicked on a session item in the session explorer, the SessionExplorer::signalAboutToShowSessionItemContextMenu() signal is emitted. The context menu will contain the session item(s) that are currently selected in the session explorer. If only one session item is selected, the menu contains the actions returned by SessionItem::getContextMenuActions() for that item. If multiple session items are selected in the session explorer, the menu initially contains no actions. Objects that are attached to the DesktopServices::signalAboutToShowContextMenu() signal may also need to attach to the SessionExplorer::signalAboutToShowSessionItemContextMenu() signal if they are interested in the selected item(s) in the session explorer.
- After all slot methods connected to each signal are called, if ContextMenu::hasSettingLogActions() and ContextMenu::getSettingLogActions() both return
true, the actions that will be used in the menu is recorded in the message log. These actions are the raw ContextMenuAction object and not the final QAction list that is displayed in the menu so that the placement and removal of the actions is displayed. - A list of QActions that will be displayed in the menu is generated from all ContextMenuAction objects. First, all actions are ordered according to the buddy action in each ContextMenuAction. After all actions have been ordered, actions are removed.
- The context menu is displayed to the user with the generated list of QActions.
Each action that may be added to a default context menu is listed in the sections below according to the class that defines the action. Each action ID is provided for objects to remove them as necessary. The ID values in the tables do not represent the string value to pass into the
ContextMenu methods to add and remove actions, but rather a corresponding
#define that can be used in place of the ID string. All action
#defines are located in the
ContextMenuActions.h file.
Each of the ID names is prefixed with APP_ to prevent collisions with other action IDs defined in plug-ins. When creating context menu actions in a plug-in, be sure to use a similar approach of prefixing the ID string with a namespace identifier to avoid ID collisions with other plug-ins.
In addition to the actions listed below, the context menu for a
CartesianPlot also includes all
PlotView actions.
In addition to the actions listed below, the context menu for a
HistogramPlot also includes all
CartesianPlot actions.
In addition to the actions listed below, the context menu for a
PlotWidget widget also includes all plot view actions for the specific plot view displayed in the plot widget. See the specific plot view documentation for the list of the plot view's actions.
In addition to the actions listed below, the context menu for a
PolarPlot also includes all
PlotView actions.
In addition to the actions listed below, the context menu for a
RasterLayer also includes all
Layer actions.
In addition to the actions listed below, the context menu for the session explorer also includes all
DockWindow actions.
In addition to the actions listed below, the context menu for a
ThresholdLayer also includes all
Layer actions.