# 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
IconSizes
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.
preferencesChanged | Public slot to handle a change of preferences.
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 (UI.UserInterface)
  reference to the user interface object
parent (QObject)
  reference to the parent object

#### EricToolBarManager.__findAction

__findAction(name)

Private method to find an action by name.

name (str)
  name of the action to search for

Return:
  reference to the action

Return Type:
  QAction

#### EricToolBarManager.__findDefaultToolBar

__findDefaultToolBar(name)

Private method to find a default toolbar by name.

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

Return:
  reference to the default toolbar

Return Type:
  QToolBar

#### EricToolBarManager.__toolBarByName

__toolBarByName(name)

Private slot to get a toolbar by its object name.

name (str)
  object name of the toolbar

Return:
  reference to the toolbar

Return Type:
  QToolBar

#### EricToolBarManager.actionById

actionById(aID)

Public method to get an action given its id.

aID (int)
  id of the action object

Return:
  reference to the action

Return Type:
  QAction

#### EricToolBarManager.addAction

addAction(action, category)

Public method to add an action to be managed.

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

#### 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 (QToolBar)
  reference to the toolbar to be managed
category (str)
  category for the toolbar

#### EricToolBarManager.categories

categories()

Public method to get the list of categories.

Return:
  list of categories

Return Type:
  list of str

#### EricToolBarManager.categoryActions

categoryActions(category)

Public method to get the actions belonging to a category.

category (str)
  category for the actions

Return:
  list of actions

Return Type:
  list of QAction

#### EricToolBarManager.createToolBar

createToolBar(title, name="")

Public method to create a custom toolbar.

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

Return:
  reference to the created toolbar

Return Type:
  QToolBar

#### EricToolBarManager.defaultToolBarActions

defaultToolBarActions(tbID)

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

tbID (int)
  id of the default toolbar object

Return:
  list of actions

Return Type:
  list of QAction

#### EricToolBarManager.defaultToolBars

defaultToolBars()

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

Return:
  list of all default toolbars

Return Type:
  list of QToolBar

#### EricToolBarManager.deleteToolBar

deleteToolBar(toolBar)

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

toolBar (QToolBar)
  reference to the toolbar to be managed

#### EricToolBarManager.isDefaultToolBar

isDefaultToolBar(toolBar)

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

toolBar (QToolBar)
  reference to the toolbar to be checked

Return:
  flag indicating an added toolbar

Return Type:
  bool

#### EricToolBarManager.isWidgetAction

isWidgetAction(action)

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

action (QAction)
  reference to the action to be checked

Return:
  flag indicating a widget action

Return Type:
  bool

#### EricToolBarManager.mainWindow

mainWindow()

Public method to get the reference to the main window.

Return:
  reference to the main window

Return Type:
  QMainWindow

#### EricToolBarManager.preferencesChanged

preferencesChanged()

Public slot to handle a change of preferences.

#### EricToolBarManager.removeAction

removeAction(action)

Public method to remove an action from the manager.

action (QAction)
  reference to the action to be removed

#### EricToolBarManager.removeCategoryActions

removeCategoryActions(category)

Public method to remove the actions belonging to a category.

category (str)
  category for the actions

#### EricToolBarManager.removeToolBar

removeToolBar(toolBar)

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

toolBar (QToolBar)
  reference to the toolbar to be removed

#### EricToolBarManager.removeWidgetActions

removeWidgetActions(actions)

Public method to remove widget actions.

actions (dict)
  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 (QToolBar)
  reference to the toolbar to be managed
title (str)
  title to be used for the toolbar

#### 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 (QToolBar)
  reference to the toolbar to configure

#### EricToolBarManager.restoreState

restoreState(state, version=0)

Public method to restore the state of the toolbar manager.

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

Return:
  flag indicating success

Return Type:
  bool

#### EricToolBarManager.saveState

saveState(version=0)

Public method to save the state of the toolbar manager.

version (int)
  version number stored with the data

Return:
  saved state as a byte array

Return Type:
  QByteArray

#### EricToolBarManager.setMainWindow

setMainWindow(mainWindow)

Public method to set the reference to the main window.

mainWindow (QMainWindow)
  reference to the main window

#### EricToolBarManager.setToolBar

setToolBar(toolBar, actions)

Public method to set the actions of a toolbar.

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

#### EricToolBarManager.setToolBars

setToolBars(toolBars)

Public method to set the actions of several toolbars.

toolBars (dict)
  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 (int)
  id of the toolbar object

Return:
  list of actions

Return Type:
  list of QAction

#### EricToolBarManager.toolBarById

toolBarById(tbID)

Public method to get a toolbar given its id.

tbID (int)
  id of the toolbar object

Return:
  reference to the toolbar

Return Type:
  QToolBar

#### EricToolBarManager.toolBarWidgetAction

toolBarWidgetAction(action)

Public method to get the toolbar for a widget action.

action (QAction)
  widget action to check for

Return:
  reference to the toolbar containing action

Return Type:
  QToolBar

#### EricToolBarManager.toolBars

toolBars()

Public method to get all toolbars.

Return:
  list of all toolbars

Return Type:
  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

Return Type:
  dict

Up