# eric7.EricWidgets.EricToolBarManager

Module implementing a toolbar manager class.

### Global Attributes

None

### Classes

EricToolBarManager | Class implementing a toolbar manager.

### Functions

None

## EricToolBarManager

Class implementing a toolbar manager.

### Derived from

QObject

### Class Attributes

CustomToolBarMarker
ToolBarMarker
VersionMarker

### Class Methods

None

### Methods

EricToolBarManager | Constructor
__findAction | Private method to find an action by name.
__findDefaultToolBar | Private method to find a default toolbar by name.
__toolBarByName | Private slot to get a toolbar by its object name.
actionById | Public method to get an action given its id.
addAction | Public method to add an action to be managed.
addActions | Public method to add actions to be managed.
addToolBar | Public method to add a toolbar to be managed.
categories | Public method to get the list of categories.
categoryActions | Public method to get the actions belonging to a category.
createToolBar | Public method to create a custom toolbar.
defaultToolBarActions | Public method to get a default toolbar's actions given its id.
defaultToolBars | Public method to get all toolbars added with addToolBar().
deleteToolBar | Public method to remove a custom toolbar created with createToolBar().
isDefaultToolBar | Public method to check, if a toolbar was added with addToolBar().
isWidgetAction | Public method to check, if action is a widget action.
mainWindow | Public method to get the reference to the main window.
removeAction | Public method to remove an action from the manager.
removeCategoryActions | Public method to remove the actions belonging to a category.
removeToolBar | Public method to remove a toolbar added with addToolBar().
removeWidgetActions | Public method to remove widget actions.
renameToolBar | Public method to give a toolbar a new title.
resetAllToolBars | Public method to reset all toolbars to their default state.
resetToolBar | Public method to reset a toolbar to its default state.
restoreState | Public method to restore the state of the toolbar manager.
saveState | Public method to save the state of the toolbar manager.
setMainWindow | Public method to set the reference to the main window.
setToolBar | Public method to set the actions of a toolbar.
setToolBars | Public method to set the actions of several toolbars.
toolBarActions | Public method to get a toolbar's actions given its id.
toolBarById | Public method to get a toolbar given its id.
toolBarWidgetAction | Public method to get the toolbar for a widget action.
toolBars | Public method to get all toolbars.
toolBarsActions | Public method to get all toolbars and their actions.

### Static Methods

None

#### EricToolBarManager (Constructor)

EricToolBarManager(ui=None, parent=None)

Constructor

ui
  reference to the user interface object (UI.UserInterface)
parent
  reference to the parent object (QObject)

#### EricToolBarManager.__findAction

__findAction(name)

Private method to find an action by name.

name
  name of the action to search for (string)

Return:
  reference to the action (QAction)

#### EricToolBarManager.__findDefaultToolBar

__findDefaultToolBar(name)

Private method to find a default toolbar by name.

name
  name of the default toolbar to search for (string)

Return:
  reference to the default toolbar (QToolBar)

#### EricToolBarManager.__toolBarByName

__toolBarByName(name)

Private slot to get a toolbar by its object name.

name
  object name of the toolbar (string)

Return:
  reference to the toolbar (QToolBar)

#### EricToolBarManager.actionById

actionById(aID)

Public method to get an action given its id.

aID
  id of the action object (integer)

Return:
  reference to the action (QAction)

#### EricToolBarManager.addAction

addAction(action, category)

Public method to add an action to be managed.

action
  reference to the action to be managed (QAction)
category
  category for the toolbar (string)

#### EricToolBarManager.addActions

addActions(actions, category)

Public method to add actions to be managed.

actions (list of QAction)
  list of actions to be managed
category (str)
  category for the toolbar

#### EricToolBarManager.addToolBar

addToolBar(toolBar, category)

Public method to add a toolbar to be managed.

toolBar
  reference to the toolbar to be managed (QToolBar)
category
  category for the toolbar (string)

#### EricToolBarManager.categories

categories()

Public method to get the list of categories.

Return:
  list of categories (list of string)

#### EricToolBarManager.categoryActions

categoryActions(category)

Public method to get the actions belonging to a category.

category
  category for the actions (string)

Return:
  list of actions (list of QAction)

#### EricToolBarManager.createToolBar

createToolBar(title, name="")

Public method to create a custom toolbar.

title
  title to be used for the toolbar (string)
name
  optional name for the new toolbar (string)

Return:
  reference to the created toolbar (QToolBar)

#### EricToolBarManager.defaultToolBarActions

defaultToolBarActions(tbID)

Public method to get a default toolbar's actions given its id.

tbID
  id of the default toolbar object (integer)

Return:
  list of actions (list of QAction)

#### EricToolBarManager.defaultToolBars

defaultToolBars()

Public method to get all toolbars added with addToolBar().

Return:
  list of all default toolbars (list of QToolBar)

#### EricToolBarManager.deleteToolBar

deleteToolBar(toolBar)

Public method to remove a custom toolbar created with createToolBar().

toolBar
  reference to the toolbar to be managed (QToolBar)

#### EricToolBarManager.isDefaultToolBar

isDefaultToolBar(toolBar)

Public method to check, if a toolbar was added with addToolBar().

toolBar
  reference to the toolbar to be checked (QToolBar)

Return:
  flag indicating an added toolbar (boolean)

#### EricToolBarManager.isWidgetAction

isWidgetAction(action)

Public method to check, if action is a widget action.

action
  reference to the action to be checked (QAction)

Return:
  flag indicating a widget action (boolean)

#### EricToolBarManager.mainWindow

mainWindow()

Public method to get the reference to the main window.

Return:
  reference to the main window (QMainWindow)

#### EricToolBarManager.removeAction

removeAction(action)

Public method to remove an action from the manager.

action
  reference to the action to be removed (QAction)

#### EricToolBarManager.removeCategoryActions

removeCategoryActions(category)

Public method to remove the actions belonging to a category.

category
  category for the actions (string)

#### EricToolBarManager.removeToolBar

removeToolBar(toolBar)

Public method to remove a toolbar added with addToolBar().

toolBar
  reference to the toolbar to be removed (QToolBar)

#### EricToolBarManager.removeWidgetActions

removeWidgetActions(actions)

Public method to remove widget actions.

actions
  dictionary with toolbar id as key and a list of widget actions as value

#### EricToolBarManager.renameToolBar

renameToolBar(toolBar, title)

Public method to give a toolbar a new title.

toolBar
  reference to the toolbar to be managed (QToolBar)
title
  title to be used for the toolbar (string)

#### EricToolBarManager.resetAllToolBars

resetAllToolBars()

Public method to reset all toolbars to their default state.

#### EricToolBarManager.resetToolBar

resetToolBar(toolBar)

Public method to reset a toolbar to its default state.

toolBar
  reference to the toolbar to configure (QToolBar)

#### EricToolBarManager.restoreState

restoreState(state, version=0)

Public method to restore the state of the toolbar manager.

state
  byte array containing the saved state (QByteArray)
version
  version number stored with the data (integer)

Return:
  flag indicating success (boolean)

#### EricToolBarManager.saveState

saveState(version=0)

Public method to save the state of the toolbar manager.

version
  version number stored with the data (integer)

Return:
  saved state as a byte array (QByteArray)

#### EricToolBarManager.setMainWindow

setMainWindow(mainWindow)

Public method to set the reference to the main window.

mainWindow
  reference to the main window (QMainWindow)

#### EricToolBarManager.setToolBar

setToolBar(toolBar, actions)

Public method to set the actions of a toolbar.

toolBar
  reference to the toolbar to configure (QToolBar)
actions
  list of actions to be set (list of QAction)

#### EricToolBarManager.setToolBars

setToolBars(toolBars)

Public method to set the actions of several toolbars.

toolBars
  dictionary with toolbar id as key and a list of actions as value

#### EricToolBarManager.toolBarActions

toolBarActions(tbID)

Public method to get a toolbar's actions given its id.

tbID
  id of the toolbar object (integer)

Return:
  list of actions (list of QAction)

#### EricToolBarManager.toolBarById

toolBarById(tbID)

Public method to get a toolbar given its id.

tbID
  id of the toolbar object (integer)

Return:
  reference to the toolbar (QToolBar)

#### EricToolBarManager.toolBarWidgetAction

toolBarWidgetAction(action)

Public method to get the toolbar for a widget action.

action
  widget action to check for (QAction)

Return:
  reference to the toolbar containing action (QToolBar)

#### EricToolBarManager.toolBars

toolBars()

Public method to get all toolbars.

Return:
  list of all toolbars (list of QToolBar)

#### EricToolBarManager.toolBarsActions

toolBarsActions()

Public method to get all toolbars and their actions.

Return:
  reference to dictionary of toolbar IDs as key and list of actions as values

Up