contextmenu#

The base context menu implementation used across Bookmarks.

All context menus derive from the BaseContextMenu. The class contains the definitions of all menu options. See BaseContextMenu.setup() for menu overrides and definitions.

Classes:

BaseContextMenu(index[, parent])

Base class containing the context menu definitions.

Functions:

key()

Utility method used to generate a hexadecimal uuid string.

resize_event_override(cls, event)

Private utility method used to implement rounded corners.

show_event_override(cls, event)

Private utility method for manually calculating the width of :class:.`BaseContextMenu`.

class bookmarks.contextmenu.BaseContextMenu(index, parent=None)[source]#

Bases: QMenu

Base class containing the context menu definitions.

The internal menu structure is defined in BaseContextMenu.menu, a collections.OrderedDict instance. This data is populated by the *_menu methods and expanded into a UI layout by BaseContextMenu.create_menu(). The menu is principally designed to work with index-based views and as a result the default constructor takes a QModelIndex, stored in BaseContextMenu.index.

The internal BaseContextMenu.menu dict object assumes the following form:

 1self.menu = collections.OrderedDict({
 2    'uuid1': {
 3        'text': 'My Menu Item',
 4        'icon': get_icon('my_menu_icon'),   # QIcon
 5        'shortcut: QtGui.QShortcut('Ctrl+M'), # QtGui.QShortcut
 6        'disabled': False,
 7        'action': my_menu_function1,         # a method to execute
 8    },
 9    'uuid2': {
10        'text': 'My Menu Item2',
11        'icon': get_icon('my_menu_icon'),
12        'shortcut: QtGui.QShortcut('Ctrl+N'),
13        'disabled': True,
14        'action': my_menu_function2,
15    }
16})
Properties:

index (QModelIndex): The index the context menu is associated with.

Methods:

add_asset_to_bookmark_menu()

Add asset to bookmark item actions.

add_file_menu()

Add file actions.

add_file_to_asset_menu()

Add file to asset actions.

asset_url_menu()

Asset item URL actions.

bookmark_editor_menu()

Bookmark item properties editor.

bookmark_url_menu()

Bookmark item URL actions.

collapse_sequence_menu()

File item collapse toggle actions.

control_favourites_menu()

Favourite item actions.

convert_menu()

FFMpeg convert menu.

copy_menu()

List item path copy actions.

create_menu(menu[, parent])

Expands the internal BaseContextMenu.menu dict data.

delete_selected_files_menu()

Delete file item menu actions.

edit_active_asset_menu()

Selected asset item property menu.

edit_active_bookmark_menu()

Active bookmark item property menu.

edit_selected_asset_menu()

Selected asset item property menu.

edit_selected_bookmark_menu()

Bookmark item properties editor actions.

edit_selected_file_menu()

Selected file item property menu.

import_export_menu()

Export property

launcher_menu()

Application launcher menu actions.

list_filter_menu()

List item filter actions.

notes_menu()

Note editor actions.

preferences_menu()

Application preferences actions.

publish_menu()

Publish file item menu actions.

quit_menu()

Application shutdown options.

refresh_menu()

List item reload/refresh options.

remove_favourite_menu()

List item favourite actions.

resizeEvent(self, event)

reveal_item_menu()

List item file reveal options.

row_size_menu()

List item row size actions.

separator([menu])

Adds a menu separator item.

setup()

Creates the context menu.

sg_link_asset_menu()

ShotGrid asset linker menu actions.

sg_link_assets_menu()

ShotGrid batch asset linker menu actions.

sg_link_bookmark_menu()

ShotGrid bookmark item menu actions.

sg_publish_menu()

ShotGrid publish menu actions.

sg_rv_menu()

ShotGrid RV menu actions.

sg_thumbnail_menu()

ShotGrid thumbnail image menu actions.

sg_url_menu()

ShotGrid URL menu actions.

showEvent(event)

Show event handler.

show_add_asset_menu()

Add asset menu actions.

sort_menu()

List item sorting options.

task_folder_toggle_menu()

File item task folder picker menu.

thumbnail_menu()

Thumbnail image specific actions.

toggle_item_flags_menu()

List item filter flag toggle actions.

window_menu()

General application window specific actions.

add_asset_to_bookmark_menu()[source]#

Add asset to bookmark item actions.

add_file_menu()[source]#

Add file actions.

add_file_to_asset_menu()[source]#

Add file to asset actions.

asset_url_menu()[source]#

Asset item URL actions.

bookmark_editor_menu()[source]#

Bookmark item properties editor.

bookmark_url_menu()[source]#

Bookmark item URL actions.

collapse_sequence_menu()[source]#

File item collapse toggle actions.

control_favourites_menu()[source]#

Favourite item actions.

convert_menu()[source]#

FFMpeg convert menu.

copy_menu()[source]#

List item path copy actions.

create_menu(menu, parent=None)[source]#

Expands the internal BaseContextMenu.menu dict data.

delete_selected_files_menu()[source]#

Delete file item menu actions.

edit_active_asset_menu()[source]#

Selected asset item property menu.

edit_active_bookmark_menu()[source]#

Active bookmark item property menu.

edit_selected_asset_menu()[source]#

Selected asset item property menu.

edit_selected_bookmark_menu()[source]#

Bookmark item properties editor actions.

edit_selected_file_menu()[source]#

Selected file item property menu.

import_export_menu()[source]#

Export property

launcher_menu()[source]#

Application launcher menu actions.

list_filter_menu()[source]#

List item filter actions.

notes_menu()[source]#

Note editor actions.

preferences_menu()[source]#

Application preferences actions.

publish_menu()[source]#

Publish file item menu actions.

quit_menu()[source]#

Application shutdown options.

refresh_menu()[source]#

List item reload/refresh options.

remove_favourite_menu()[source]#

List item favourite actions.

resizeEvent(self, event: PySide2.QtGui.QResizeEvent) None[source]#
reveal_item_menu()[source]#

List item file reveal options.

row_size_menu()[source]#

List item row size actions.

separator(menu=None)[source]#

Adds a menu separator item.

Parameters

menu (str) – Specify menu key.

setup()[source]#

Creates the context menu.

ShotGrid asset linker menu actions.

ShotGrid batch asset linker menu actions.

ShotGrid bookmark item menu actions.

sg_publish_menu()[source]#

ShotGrid publish menu actions.

sg_rv_menu()[source]#

ShotGrid RV menu actions.

sg_thumbnail_menu()[source]#

ShotGrid thumbnail image menu actions.

sg_url_menu()[source]#

ShotGrid URL menu actions.

showEvent(event)[source]#

Show event handler.

show_add_asset_menu()[source]#

Add asset menu actions.

sort_menu()[source]#

List item sorting options.

task_folder_toggle_menu()[source]#

File item task folder picker menu.

thumbnail_menu()[source]#

Thumbnail image specific actions.

toggle_item_flags_menu()[source]#

List item filter flag toggle actions.

window_menu()[source]#

General application window specific actions.

bookmarks.contextmenu.key()[source]#

Utility method used to generate a hexadecimal uuid string.

bookmarks.contextmenu.resize_event_override(cls, event)[source]#

Private utility method used to implement rounded corners.

bookmarks.contextmenu.show_event_override(cls, event)[source]#

Private utility method for manually calculating the width of :class:.`BaseContextMenu`.

I might be misunderstanding how styling menus effect appearance and resulting size. What is certain, that QT doesn’t seem to be able to display the menus with a correct width, and hence we’ll calculate width manually here.