def initContextMenu(self): """ Context menu initialization @return: @rtype: QMenu """ menu = QMenu() # menu.actionReset = QAction('Reset To Default', None) # menu.actionLoadImage = QAction('Load New Image', None) # multiple selections menu.actionMerge = QAction('Merge Lower', None) # merge only adjustment layer with image layer menu.actionRepositionLayer = QAction('Reposition Layer(s)', None) menu.actionColorMaskEnable = QAction('Color', None) menu.actionOpacityMaskEnable = QAction('Opacity', None) menu.actionClippingMaskEnable = QAction('Clipping', None) menu.actionMaskDisable = QAction('Disabled', None) menu.actionMaskUndo = QAction('Undo Mask', None) menu.actionMaskRedo = QAction('Redo Mask', None) menu.actionMaskInvert = QAction('Invert Mask', None) menu.actionMaskReset_UM = QAction('Unmask All', None) menu.actionMaskReset_M = QAction('Mask All', None) menu.actionMaskCopy = QAction('Copy Mask to Clipboard', None) menu.actionImageCopy = QAction('Copy Image to Clipboard', None) menu.actionMaskPaste = QAction('Paste Mask', None) menu.actionImagePaste = QAction('Paste Image', None) menu.actionMaskDilate = QAction('Dilate Mask', None) menu.actionMaskErode = QAction('Erode Mask', None) menu.actionMaskSmooth = QAction('Smooth Mask', None) menu.actionMaskBright1 = QAction('Bright 1 Mask', None) menu.actionMaskBright2 = QAction('Bright 2 Mask', None) menu.actionMaskBright3 = QAction('Bright 3 Mask', None) menu.actionMaskDark1 = QAction('Dark 1 Mask', None) menu.actionMaskDark2 = QAction('Dark 2 Mask', None) menu.actionMaskDark3 = QAction('Dark 3 Mask', None) menu.actionMaskMid1 = QAction('Mid 1 Mask', None) menu.actionMaskMid2 = QAction('Mid 2 Mask', None) menu.actionMaskMid3 = QAction('Mid 3 Mask', None) menu.actionMergingFlag = QAction('Merged Layer', None) menu.actionMergingFlag.setCheckable(True) menu.actionColorMaskEnable.setCheckable(True) menu.actionOpacityMaskEnable.setCheckable(True) menu.actionClippingMaskEnable.setCheckable(True) menu.actionMaskDisable.setCheckable(True) #################### # Build menu ################### menu.addAction(menu.actionRepositionLayer) menu.addSeparator() # layer menu.addAction(menu.actionImageCopy) menu.addAction(menu.actionImagePaste) menu.addAction(menu.actionMergingFlag) menu.addSeparator() # mask menu.subMenuEnable = menu.addMenu('Mask...') menu.subMenuEnable.addAction(menu.actionColorMaskEnable) menu.subMenuEnable.addAction(menu.actionOpacityMaskEnable) menu.subMenuEnable.addAction(menu.actionClippingMaskEnable) menu.subMenuEnable.addAction(menu.actionMaskDisable) menu.addAction(menu.actionMaskUndo) menu.addAction(menu.actionMaskRedo) menu.addAction(menu.actionMaskInvert) menu.subMenuLum = menu.addMenu('Luminosity Mask...') for a in [ menu.actionMaskBright1, menu.actionMaskBright2, menu.actionMaskBright3, menu.actionMaskDark1, menu.actionMaskDark2, menu.actionMaskDark3, menu.actionMaskMid1, menu.actionMaskMid2, menu.actionMaskMid3 ]: menu.subMenuLum.addAction(a) menu.addAction(menu.actionMaskReset_UM) menu.addAction(menu.actionMaskReset_M) menu.addAction(menu.actionMaskCopy) menu.addAction(menu.actionMaskPaste) menu.addAction(menu.actionMaskDilate) menu.addAction(menu.actionMaskErode) menu.addAction(menu.actionMaskSmooth) menu.addSeparator() # miscellaneous # menu.addAction(menu.actionLoadImage) # to link actionDup with a shortcut, # it must be set in __init__ menu.addAction(self.actionDup) menu.addAction(menu.actionMerge) # menu.addAction(menu.actionReset) return menu
def initContextMenu(self): """ return the context menu @return: @rtype: QMenu """ menu = QMenu() menu.actionReset = QAction('Reset To Default', None) menu.actionLoadImage = QAction('Load New Image', None) menu.actionGroupSelection = QAction('Group Selection', None) menu.actionAdd2Group = QAction('Add to Group', None) # Active layer is not in a group or right clicked layer is in a group menu.actionUnGroup = QAction('Ungroup', None) # multiple selections menu.actionMerge = QAction('Merge Lower', None) # merge only adjustment layer with image layer # don't dup adjustment layers menu.actionUnselect = QAction('Unselect All', None) menu.actionRepositionLayer = QAction('Reposition Layer(s)', None) menu.actionColorMaskEnable = QAction('Color Mask', None) menu.actionOpacityMaskEnable = QAction('Opacity Mask', None) menu.actionClippingMaskEnable = QAction('Clipping Mask', None) menu.actionMaskDisable = QAction('Disable Mask', None) menu.actionMaskInvert = QAction('Invert Mask', None) menu.actionMaskReset = QAction('Clear Mask', None) menu.actionMaskCopy = QAction('Copy Mask to Clipboard', None) menu.actionImageCopy = QAction('Copy Image to Clipboard', None) menu.actionMaskPaste = QAction('Paste Mask', None) menu.actionImagePaste = QAction('Paste Image', None) menu.actionMaskDilate = QAction('Dilate Mask', None) menu.actionMaskErode = QAction('Erode Mask', None) menu.actionColorMaskEnable.setCheckable(True) menu.actionOpacityMaskEnable.setCheckable(True) menu.actionClippingMaskEnable.setCheckable(True) menu.actionMaskDisable.setCheckable(True) #################### # Build menu ################### # group/ungroup menu.addAction(menu.actionAdd2Group) menu.addAction(menu.actionGroupSelection) menu.addAction(menu.actionUnGroup) menu.addSeparator() menu.addAction(menu.actionUnselect) menu.addSeparator() menu.addAction(menu.actionRepositionLayer) menu.addSeparator() # layer menu.addAction(menu.actionImageCopy) menu.addAction(menu.actionImagePaste) menu.addSeparator() # mask menu.subMenuEnable = menu.addMenu('Mask...') menu.subMenuEnable.addAction(menu.actionColorMaskEnable) menu.subMenuEnable.addAction(menu.actionOpacityMaskEnable) menu.subMenuEnable.addAction(menu.actionClippingMaskEnable) menu.subMenuEnable.addAction(menu.actionMaskDisable) menu.addAction(menu.actionMaskInvert) menu.addAction(menu.actionMaskReset) menu.addAction(menu.actionMaskCopy) menu.addAction(menu.actionMaskPaste) menu.addAction(menu.actionMaskDilate) menu.addAction(menu.actionMaskErode) menu.addSeparator() # miscellaneous menu.addAction(menu.actionLoadImage) # to link actionDup with a shortcut, # it must be set in __init__ menu.addAction(self.actionDup) menu.addAction(menu.actionMerge) menu.addAction(menu.actionReset) return menu