digiKam
|
A helper class to add actions and special menus to the context menu. More...
Classes | |
class | Private |
Public Types | |
typedef const QList< qlonglong > | imageIds |
Signals | |
void | signalAddNewTagFromABCMenu (const QString &) |
void | signalAddToExistingQueue (int) |
void | signalAssignColorLabel (int) |
void | signalAssignPickLabel (int) |
void | signalAssignRating (int) |
void | signalAssignTag (int) |
void | signalCreateGroup () |
void | signalCreateGroupByFilename () |
void | signalCreateGroupByTime () |
void | signalCreateGroupByTimelapse () |
void | signalGotoAlbum (const ItemInfo &) |
void | signalGotoDate (const ItemInfo &) |
void | signalGotoTag (int) |
void | signalPopupTagsView () |
void | signalRemoveFromGroup () |
void | signalRemoveTag (int) |
void | signalSetThumbnail (const ItemInfo &) |
void | signalUngroup () |
Public Member Functions | |
void | addAction (const QString &name, bool addDisabled=false) |
void | addAction (QAction *const action, bool addDisabled=false) |
void | addAction (QAction *const action, QObject *const recv, const char *const slot, bool addDisabled=false) |
void | addActionDeleteAlbum (AlbumModificationHelper *const helper, PAlbum *const album) |
void | addActionDeleteFaceTag (TagModificationHelper *const helper, TAlbum *const tag) |
void | addActionDeleteFaceTags (TagModificationHelper *const helper, const QList< TAlbum * > &tags) |
void | addActionDeleteTag (TagModificationHelper *const helper, TAlbum *const tag) |
void | addActionDeleteTags (TagModificationHelper *const helper, const QList< TAlbum * > &tags) |
void | addActionEditAlbum (AlbumModificationHelper *const helper, PAlbum *const album) |
void | addActionEditTag (TagModificationHelper *const helper, TAlbum *const tag) |
void | addActionNewAlbum (AlbumModificationHelper *const helper, PAlbum *const parentAlbum=nullptr) |
void | addActionNewTag (TagModificationHelper *const helper, TAlbum *const parentTag=nullptr) |
void | addActionRenameAlbum (AlbumModificationHelper *const helper, PAlbum *const album) |
void | addActionResetAlbumIcon (AlbumModificationHelper *const helper, PAlbum *const album) |
void | addActionTagsToFaceTags (TagModificationHelper *const helper, const QList< TAlbum * > &tags) |
void | addActionTagToFaceTag (TagModificationHelper *const helper, TAlbum *const tag) |
void | addAlbumCheckUncheckActions (Album *const album) |
void | addAssignTagsMenu (const imageIds &ids) |
void | addCreateTagFromAddressbookMenu () |
void | addExportMenu () |
void | addGotoMenu (const imageIds &ids) |
void | addGroupActions (const imageIds &ids) |
void | addGroupMenu (const imageIds &ids, const QList< QAction * > &extraMenuItems=QList< QAction * >()) |
void | addImportMenu () |
void | addIQSAction (QObject *const recv, const char *const slot) |
void | addLabelsAction () |
void | addOpenAndNavigateActions (const imageIds &ids, bool lightTable=false) |
void | addQueueManagerMenu () |
void | addRemoveTagsMenu (const imageIds &ids) |
void | addSeparator () |
void | addServicesMenu (const QList< QUrl > &selectedItems) |
void | addStandardActionCopy (QObject *const recv, const char *const slot) |
void | addStandardActionCut (QObject *const recv, const char *const slot) |
void | addStandardActionItemDelete (QObject *const recv, const char *const slot, int quantity=1) |
void | addStandardActionLightTable () |
void | addStandardActionPaste (QObject *const recv, const char *const slot) |
void | addStandardActionThumbnail (const imageIds &ids, Album *const album) |
void | addSubMenu (QMenu *subMenu) |
ContextMenuHelper (QMenu *const parent) | |
QAction * | exec (const QPoint &pos, QAction *const at=nullptr) |
void | setAlbumModel (AbstractCheckableAlbumModel *const model) |
void | setItemFilterModel (ItemFilterModel *const model) |
~ContextMenuHelper () override | |
A helper class to add actions and special menus to the context menu.
The ContextMenuHelper class helps adding commonly used actions and menus. Use this class to add
All addAction() methods take a special parameter 'addDisabled'. This parameter controls if disabled actions are added to the menu. Normally adding disabled actions is turned off, to clean up the menu and make it more readable.
If the ContextMenuHelper class is used, you need to call its own exec() method, instead the one from the parent menu. This way signals from special menus can be emitted and connected to the appropriate slots.
typedef const QList<qlonglong> Digikam::ContextMenuHelper::imageIds |
|
explicit |
Constructs the helper class.
parent | the menu the helper class is linked to |
References Digikam::DigikamApp::instance(), Digikam::ContextMenuHelper::Private::parent, and Digikam::ContextMenuHelper::Private::stdActionCollection.
|
override |
void Digikam::ContextMenuHelper::addAction | ( | const QString & | name, |
bool | addDisabled = false |
||
) |
Add an action from the actionCollection.
This method adds actions from the actionCollection. The actionCollection can be set in the constructor of the ContextMenuHelper class.
name | the name of the action in the actionCollection |
addDisabled | if set, disabled actions are added to the menu |
References Digikam::ContextMenuHelper::Private::stdActionCollection.
Referenced by addAction(), addActionDeleteAlbum(), addActionDeleteFaceTag(), addActionDeleteFaceTags(), addActionDeleteTag(), addActionDeleteTags(), addActionEditAlbum(), addActionEditTag(), addActionNewAlbum(), addActionNewTag(), addActionRenameAlbum(), addActionResetAlbumIcon(), addActionTagsToFaceTags(), addActionTagToFaceTag(), Digikam::TagFilterView::addCustomContextMenuActions(), Digikam::AlbumSelectTreeView::addCustomContextMenuActions(), Digikam::TagCheckView::addCustomContextMenuActions(), Digikam::TagFolderView::addCustomContextMenuActions(), Digikam::EditableSearchTreeView::addCustomContextMenuActions(), Digikam::NormalSearchTreeView::addCustomContextMenuActions(), addGotoMenu(), addIQSAction(), addOpenAndNavigateActions(), addServicesMenu(), addStandardActionCopy(), addStandardActionCut(), addStandardActionItemDelete(), addStandardActionLightTable(), addStandardActionPaste(), addStandardActionThumbnail(), Digikam::TagMngrListView::contextMenuEvent(), Digikam::TagFolderView::setContexMenuItems(), and Digikam::TagMngrTreeView::setContexMenuItems().
void Digikam::ContextMenuHelper::addAction | ( | QAction *const | action, |
bool | addDisabled = false |
||
) |
Add a temporary action.
Sometimes it is necessary to define actions that only exist in the current context menu content. Use this method to add such an action.
action | the action to add |
addDisabled | if set, disabled actions are added to the menu |
References Digikam::ContextMenuHelper::Private::parent.
void Digikam::ContextMenuHelper::addAction | ( | QAction *const | action, |
QObject *const | recv, | ||
const char *const | slot, | ||
bool | addDisabled = false |
||
) |
Add a temporary action and assign it to a custom slot.
Use this method if you want to add a temporary action and immediately connect it to the receiving slot.
action | the action to add |
recv | the receiver of the triggered action |
slot | the slot to connect the triggered action to |
addDisabled | if set, disabled actions are added to the menu |
References addAction().
void Digikam::ContextMenuHelper::addActionDeleteAlbum | ( | AlbumModificationHelper *const | helper, |
PAlbum *const | album | ||
) |
void Digikam::ContextMenuHelper::addActionDeleteFaceTag | ( | TagModificationHelper *const | helper, |
TAlbum *const | tag | ||
) |
Add action to delete tags from people sidebar.
References addAction(), and Digikam::TagModificationHelper::bindTag().
Referenced by Digikam::TagFolderView::addCustomContextMenuActions().
void Digikam::ContextMenuHelper::addActionDeleteFaceTags | ( | TagModificationHelper *const | helper, |
const QList< TAlbum * > & | tags | ||
) |
References addAction(), and Digikam::TagModificationHelper::bindMultipleTags().
Referenced by Digikam::TagFolderView::setContexMenuItems().
void Digikam::ContextMenuHelper::addActionDeleteTag | ( | TagModificationHelper *const | helper, |
TAlbum *const | tag | ||
) |
References addAction(), and Digikam::TagModificationHelper::bindTag().
Referenced by Digikam::TagFolderView::addCustomContextMenuActions().
void Digikam::ContextMenuHelper::addActionDeleteTags | ( | TagModificationHelper *const | helper, |
const QList< TAlbum * > & | tags | ||
) |
References addAction(), and Digikam::TagModificationHelper::bindMultipleTags().
Referenced by Digikam::TagFolderView::setContexMenuItems(), and Digikam::TagMngrTreeView::setContexMenuItems().
void Digikam::ContextMenuHelper::addActionEditAlbum | ( | AlbumModificationHelper *const | helper, |
PAlbum *const | album | ||
) |
void Digikam::ContextMenuHelper::addActionEditTag | ( | TagModificationHelper *const | helper, |
TAlbum *const | tag | ||
) |
References addAction(), and Digikam::TagModificationHelper::bindTag().
Referenced by Digikam::TagFolderView::addCustomContextMenuActions().
void Digikam::ContextMenuHelper::addActionNewAlbum | ( | AlbumModificationHelper *const | helper, |
PAlbum *const | parentAlbum = nullptr |
||
) |
Add actions to add, remove or edit a tag. The tag modification helper is used to execute the action. You must set the parent tag to use on modification helper.
References addAction(), Digikam::AlbumModificationHelper::bindAlbum(), and Digikam::ContextMenuHelper::Private::copyFromMainCollection().
void Digikam::ContextMenuHelper::addActionNewTag | ( | TagModificationHelper *const | helper, |
TAlbum *const | parentTag = nullptr |
||
) |
Add actions to add, remove or edit a tag. The tag modification helper is used to execute the action. You must set the parent tag to use on modification helper.
References addAction(), and Digikam::TagModificationHelper::bindTag().
Referenced by Digikam::TagFolderView::addCustomContextMenuActions(), and Digikam::TagMngrTreeView::setContexMenuItems().
void Digikam::ContextMenuHelper::addActionRenameAlbum | ( | AlbumModificationHelper *const | helper, |
PAlbum *const | album | ||
) |
void Digikam::ContextMenuHelper::addActionResetAlbumIcon | ( | AlbumModificationHelper *const | helper, |
PAlbum *const | album | ||
) |
References addAction(), Digikam::AlbumModificationHelper::bindAlbum(), and Digikam::Album::isRoot().
void Digikam::ContextMenuHelper::addActionTagsToFaceTags | ( | TagModificationHelper *const | helper, |
const QList< TAlbum * > & | tags | ||
) |
References addAction(), and Digikam::TagModificationHelper::bindMultipleTags().
void Digikam::ContextMenuHelper::addActionTagToFaceTag | ( | TagModificationHelper *const | helper, |
TAlbum *const | tag | ||
) |
Add action to set tags as face tags.
References addAction(), and Digikam::TagModificationHelper::bindTag().
Referenced by Digikam::TagFolderView::addCustomContextMenuActions(), and Digikam::TagFolderView::setContexMenuItems().
void Digikam::ContextMenuHelper::addAlbumCheckUncheckActions | ( | Album *const | album | ) |
Add a Select and Deselect menu to check and uncheck albums. Note: Call setAlbumModel before, or this will have no effect.
References addSubMenu(), Digikam::ContextMenuHelper::Private::albumModel, Digikam::ContextMenuHelper::Private::parent, Digikam::Album::TAG, and Digikam::Album::type().
Referenced by Digikam::TagCheckView::addCustomContextMenuActions().
void Digikam::ContextMenuHelper::addAssignTagsMenu | ( | const imageIds & | ids | ) |
Add "Assign Tags" menu.
This menu will provide a list of all tags available so that they can be assigned to the current selected items.
To make this menu work, you need to run exec() from this class, otherwise the signals are not emitted and you will not be able to react on triggered actions from this menu. Make sure to connect the signals to the appropriate slots in the context menu handling method.
ids | the selected items |
References Digikam::ContextMenuHelper::Private::parent, Digikam::TagsPopupMenu::RECENTLYASSIGNED, signalAssignTag(), and signalPopupTagsView().
void Digikam::ContextMenuHelper::addCreateTagFromAddressbookMenu | ( | ) |
Add a menu to create new tags from adressbook entries.
References Digikam::ContextMenuHelper::Private::parent, and signalAddNewTagFromABCMenu().
Referenced by Digikam::TagFolderView::addCustomContextMenuActions().
void Digikam::ContextMenuHelper::addExportMenu | ( | ) |
Add Export Webservices actions menu.
References Digikam::DPluginAction::GenericExport, Digikam::DPluginLoader::instance(), Digikam::ContextMenuHelper::Private::parent, Digikam::DPluginLoader::pluginsActions(), and Digikam::ContextMenuHelper::Private::stdActionCollection.
Referenced by Digikam::TagFolderView::addCustomContextMenuActions(), and Digikam::TagFolderView::setContexMenuItems().
void Digikam::ContextMenuHelper::addGotoMenu | ( | const imageIds & | ids | ) |
Add the Goto menu.
This menu will provide the following actions for the given item:
imageIds | the list of selected items |
TODO:tags to be ported to multiple selection
References addAction(), Digikam::ItemInfo::albumId(), Digikam::AlbumManager::currentAlbums(), Digikam::Album::DATE, Digikam::TagsPopupMenu::DISPLAY, Digikam::ContextMenuHelper::Private::gotoAlbumAction, Digikam::ContextMenuHelper::Private::gotoDateAction, Digikam::Album::id(), Digikam::AlbumManager::instance(), Digikam::ItemInfo::isNull(), Digikam::ContextMenuHelper::Private::parent, Digikam::Album::PHYSICAL, Digikam::ContextMenuHelper::Private::selectedIds, signalGotoTag(), and Digikam::Album::type().
Referenced by addOpenAndNavigateActions().
void Digikam::ContextMenuHelper::addGroupActions | ( | const imageIds & | ids | ) |
References Digikam::ContextMenuHelper::Private::parent.
void Digikam::ContextMenuHelper::addGroupMenu | ( | const imageIds & | ids, |
const QList< QAction * > & | extraMenuItems = QList<QAction*>() |
||
) |
Add a "Group" menu. This menu will provide actions open, close, add to, remove from, or split a group.
addGroupActions will add the actions as a flat list, not in a submenu. Note: Call setItemFilterModel before to have Open/Close group actions.
References Digikam::ContextMenuHelper::Private::parent.
void Digikam::ContextMenuHelper::addImportMenu | ( | ) |
Add Import Webservices actions menu.
References Digikam::DPluginAction::GenericImport, Digikam::DPluginLoader::instance(), Digikam::ContextMenuHelper::Private::parent, Digikam::DPluginLoader::pluginsActions(), and Digikam::ContextMenuHelper::Private::stdActionCollection.
void Digikam::ContextMenuHelper::addIQSAction | ( | QObject *const | recv, |
const char *const | slot | ||
) |
Add the standard Image Quality Sorter action and connect it to the appropriate slot
recv | the receiver of the triggered action |
slot | the slot to connect the triggered action to |
References addAction(), and Digikam::ContextMenuHelper::Private::parent.
void Digikam::ContextMenuHelper::addLabelsAction | ( | ) |
Add "Pick/Color/Rating Labels" action.
This action will provide methods to assign pick/color/rating labels to the currently selected items.
To make this menu work, you need to run exec() from this class, otherwise the signals are not emitted and you will not be able to react on triggered actions from this menu. Make sure to connect the signals to the appropriate slots in the context menu handling method.
References addSubMenu(), Digikam::ContextMenuHelper::Private::parent, signalAssignColorLabel(), signalAssignPickLabel(), and signalAssignRating().
void Digikam::ContextMenuHelper::addOpenAndNavigateActions | ( | const imageIds & | ids, |
bool | lightTable = false |
||
) |
Add section for main views for opening and moving/going to albums.
This is a convenience function to ensure consistent menus and reduce code duplication.
imageIds | the list of selected items |
lightTable | for the light table |
References addAction(), addGotoMenu(), addServicesMenu(), and Digikam::ContextMenuHelper::Private::selectedItems.
void Digikam::ContextMenuHelper::addQueueManagerMenu | ( | ) |
Add Queue Manager actions menu.
References Digikam::ContextMenuHelper::Private::parent, Digikam::ContextMenuHelper::Private::queueActions, Digikam::QueueMgrWindow::queueManagerWindow(), Digikam::QueueMgrWindow::queueManagerWindowCreated(), Digikam::QueueMgrWindow::queuesMap(), and Digikam::ContextMenuHelper::Private::stdActionCollection.
void Digikam::ContextMenuHelper::addRemoveTagsMenu | ( | const imageIds & | ids | ) |
Add "Remove Tags" menu.
This menu will provide a list of all tags assigned to the current items. Actions triggered in here will remove the selected tag from the items.
To make this menu work, you need to run exec() from this class, otherwise the signals are not emitted and you will not be able to react on triggered actions from this menu. Make sure to connect the signals to the appropriate slots in the context menu handling method.
ids | the selected items |
References Digikam::CoreDbAccess::db(), Digikam::CoreDB::getItemCommonTagIDs(), Digikam::TagsCache::instance(), Digikam::ContextMenuHelper::Private::parent, Digikam::TagsPopupMenu::REMOVE, and signalRemoveTag().
void Digikam::ContextMenuHelper::addSeparator | ( | ) |
Add a separator to the context menu
References Digikam::ContextMenuHelper::Private::parent.
Referenced by Digikam::TagCheckView::addCustomContextMenuActions(), Digikam::TagFolderView::addCustomContextMenuActions(), Digikam::NormalSearchTreeView::addCustomContextMenuActions(), Digikam::TagFolderView::setContexMenuItems(), and Digikam::TagMngrTreeView::setContexMenuItems().
void Digikam::ContextMenuHelper::addServicesMenu | ( | const QList< QUrl > & | selectedItems | ) |
Add the services menu to the menu.
The services menu is used to open the selected items in a different application. It will query the item for registered services and provide them in a submenu. The menu will be titled "Open With...".
selectedItems | the list of selected items |
References addAction(), Digikam::ContextMenuHelper::Private::parent, Digikam::DServiceMenu::servicesForOpenWith(), and Digikam::ContextMenuHelper::Private::servicesMap.
Referenced by addOpenAndNavigateActions().
void Digikam::ContextMenuHelper::addStandardActionCopy | ( | QObject *const | recv, |
const char *const | slot | ||
) |
Add the standard copy action and connect it to the appropriate slot
recv | the receiver of the triggered action |
slot | the slot to connect the triggered action to |
References addAction(), Digikam::DXmlGuiWindow::buildStdAction(), Digikam::ContextMenuHelper::Private::parent, and Digikam::StdCopyAction.
void Digikam::ContextMenuHelper::addStandardActionCut | ( | QObject *const | recv, |
const char *const | slot | ||
) |
Add the standard cut action and connect it to the appropriate slot
recv | the receiver of the triggered action |
slot | the slot to connect the triggered action to |
References addAction(), Digikam::DXmlGuiWindow::buildStdAction(), Digikam::ContextMenuHelper::Private::parent, and Digikam::StdCutAction.
void Digikam::ContextMenuHelper::addStandardActionItemDelete | ( | QObject *const | recv, |
const char *const | slot, | ||
int | quantity = 1 |
||
) |
Add the standard delete action and connect it to the appropriate slot
recv | the receiver of the triggered action |
slot | the slot to connect the triggered action to |
quantity | the number of the files that should be deleted. This parameter is used for the action name and is normally used when deleting more then one item. |
References addAction(), and Digikam::ContextMenuHelper::Private::parent.
void Digikam::ContextMenuHelper::addStandardActionLightTable | ( | ) |
Add the lighttable action to the menu.
Do not use addAction() to add the lighttable action, because we need to handle special cases here. Depending on whether the lighttable window has already been created and filled with items, we set different actions.
References addAction(), Digikam::LightTableWindow::lightTableWindow(), Digikam::LightTableWindow::lightTableWindowCreated(), and Digikam::ContextMenuHelper::Private::stdActionCollection.
void Digikam::ContextMenuHelper::addStandardActionPaste | ( | QObject *const | recv, |
const char *const | slot | ||
) |
Add the standard paste action and connect it to the appropriate slot
recv | the receiver of the triggered action |
slot | the slot to connect the triggered action to |
References addAction(), Digikam::DXmlGuiWindow::buildStdAction(), Digikam::ContextMenuHelper::Private::parent, and Digikam::StdPasteAction.
void Digikam::ContextMenuHelper::addStandardActionThumbnail | ( | const imageIds & | ids, |
Album *const | album | ||
) |
Add the thumbnail action to the menu.
Do not use addAction() to add the thumbnail action, because we need to handle special cases here. Depending on whether the current view is album or icon view, we set different actions.
ids | the selected items in the current view |
album | the current album the AlbumIconView is displaying |
References addAction(), Digikam::ContextMenuHelper::Private::parent, Digikam::Album::PHYSICAL, Digikam::ContextMenuHelper::Private::setThumbnailAction, Digikam::Album::TAG, and Digikam::Album::type().
void Digikam::ContextMenuHelper::addSubMenu | ( | QMenu * | subMenu | ) |
Add a submenu to the parent context menu.
subMenu | the submenu to be added |
References Digikam::ContextMenuHelper::Private::parent.
Referenced by addAlbumCheckUncheckActions(), and addLabelsAction().
QAction * Digikam::ContextMenuHelper::exec | ( | const QPoint & | pos, |
QAction *const | at = nullptr |
||
) |
Execute the registered parent menu and evaluate the triggered actions.
Always use this method instead the one from the parent menu. It will ensure that the signals are emitted and special cases are handled.
pos | position of the triggered action in the registered menu |
at | the action that should be at the position pos |
References Digikam::ContextMenuHelper::Private::gotoAlbumAction, Digikam::ContextMenuHelper::Private::gotoDateAction, Digikam::ContextMenuHelper::Private::parent, Digikam::ContextMenuHelper::Private::queueActions, Digikam::ContextMenuHelper::Private::selectedIds, Digikam::ContextMenuHelper::Private::setThumbnailAction, signalAddToExistingQueue(), signalGotoAlbum(), signalGotoDate(), and signalSetThumbnail().
Referenced by Digikam::TagMngrListView::contextMenuEvent(), Digikam::TagMngrTreeView::contextMenuEvent(), and Digikam::TagFolderView::contextMenuEvent().
void Digikam::ContextMenuHelper::setAlbumModel | ( | AbstractCheckableAlbumModel *const | model | ) |
Set an album model. The check/uncheck actions will operate directly on the model.
References Digikam::ContextMenuHelper::Private::albumModel.
Referenced by Digikam::TagCheckView::addCustomContextMenuActions().
void Digikam::ContextMenuHelper::setItemFilterModel | ( | ItemFilterModel *const | model | ) |
Set a filter model. Some of the group actions will operate directly on the model.
References Digikam::ContextMenuHelper::Private::imageFilterModel.
|
signal |
Referenced by addCreateTagFromAddressbookMenu().
|
signal |
Referenced by exec().
|
signal |
Referenced by addLabelsAction().
|
signal |
Referenced by addLabelsAction().
|
signal |
Referenced by addLabelsAction().
|
signal |
Referenced by addAssignTagsMenu().
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
Referenced by addGotoMenu().
|
signal |
Referenced by addAssignTagsMenu().
|
signal |
|
signal |
Referenced by addRemoveTagsMenu().
|
signal |
Referenced by exec().
|
signal |