def show_context_menu(self, point): idx = self.currentIndex() if idx and idx.isValid() and not idx.data(Qt.UserRole).toPyObject(): m = QMenu() m.addAction(QIcon(I('view.png')), _('View this cover at full size'), self.show_cover) m.exec_(QCursor.pos())
def contextMenuEvent(self, event): #pos): popup_menu = self.textEdit.createStandardContextMenu() #pos) # Select the word under the cursor. cursor = self.textEdit.textCursor() cursor.select(QTextCursor.WordUnderCursor) self.textEdit.setTextCursor(cursor) # Check if the selected word is misspelled and offer spelling # suggestions if it is. if self.textEdit.textCursor().hasSelection(): text = unicode(self.textEdit.textCursor().selectedText()) if not self.dict.check(text): #print "o0mad to0 dict :D" spell_menu = QMenu(u'شاید منظورتان این بوده:') #print spell_menu for word in self.dict.suggest(text): action = SpellAction(word, spell_menu) action.correct.connect(self.correctWord) spell_menu.addAction(action) #print word # Only add the spelling suggests to the menu if there are # suggestions. print len(spell_menu.actions()) #print spell_menu.actions() if len(spell_menu.actions()) != 0: popup_menu.insertSeparator(popup_menu.actions()[0]) popup_menu.insertMenu(popup_menu.actions()[0], spell_menu) popup_menu.exec_(QCursor.pos( )) #self.textEdit.mapToGlobal(QPoint(0, 0)))#.globalPos())
def show_context_menu(self, point): idx = self.currentIndex() if idx and idx.isValid() and not idx.data(Qt.UserRole).toPyObject(): m = QMenu() m.addAction(QIcon(I('view.png')), _('View this cover at full size'), self.show_cover) m.addAction(QIcon(I('edit-copy.png')), _('Copy this cover to clipboard'), self.copy_cover) m.exec_(QCursor.pos())
def contextMenuEvent(self, event):#pos): popup_menu = self.textEdit.createStandardContextMenu()#pos) # Select the word under the cursor. cursor = self.textEdit.textCursor() cursor.select(QTextCursor.WordUnderCursor) self.textEdit.setTextCursor(cursor) # Check if the selected word is misspelled and offer spelling # suggestions if it is. if self.textEdit.textCursor().hasSelection(): text = unicode(self.textEdit.textCursor().selectedText()) if not self.dict.check(text): #print "o0mad to0 dict :D" spell_menu = QMenu(u'شاید منظورتان این بوده:') #print spell_menu for word in self.dict.suggest(text): action = SpellAction(word, spell_menu) action.correct.connect(self.correctWord) spell_menu.addAction(action) #print word # Only add the spelling suggests to the menu if there are # suggestions. print len(spell_menu.actions()) #print spell_menu.actions() if len(spell_menu.actions()) != 0: popup_menu.insertSeparator(popup_menu.actions()[0]) popup_menu.insertMenu(popup_menu.actions()[0], spell_menu) popup_menu.exec_(QCursor.pos())#self.textEdit.mapToGlobal(QPoint(0, 0)))#.globalPos())
def showOrdContextMenu(self): menu = QMenu(self.segOrdListBox) if len(self.segOrdListBox.selectedItems())==0: return item = self.segOrdListBox.currentItem() deleteOrdMenuItem = menu.addAction("Delete Ordering") action = menu.exec_(QCursor.pos()) if action == deleteOrdMenuItem: self.deleteOrdItem(item)
def showSegContextMenu(self): menu = QMenu(self.segDefTableView) if len(self.segDefTableView.selectedIndexes())==0: return row = self.segDefTableView.selectedIndexes()[0].row() deleteSegMenuItem = menu.addAction("Delete Segment") action = menu.exec_(QCursor.pos()) if action == deleteSegMenuItem: self.deleteSegRow(row)
def show_context_menu(self, point): item = self.currentItem() def key(k): sc = unicode( QKeySequence(k | Qt.CTRL).toString(QKeySequence.NativeText)) return ' [%s]' % sc if item is not None: m = QMenu() ci = unicode(item.data(0, Qt.DisplayRole).toString()) p = item.parent() or self.invisibleRootItem() idx = p.indexOfChild(item) if idx > 0: m.addAction(QIcon(I('arrow-up.png')), (_('Move "%s" up') % ci) + key(Qt.Key_Up), self.move_up) if idx + 1 < p.childCount(): m.addAction(QIcon(I('arrow-down.png')), (_('Move "%s" down') % ci) + key(Qt.Key_Down), self.move_down) m.addAction(QIcon(I('trash.png')), _('Remove all selected items'), self.del_items) if item.parent() is not None: m.addAction(QIcon(I('back.png')), (_('Unindent "%s"') % ci) + key(Qt.Key_Left), self.move_left) if idx > 0: m.addAction(QIcon(I('forward.png')), (_('Indent "%s"') % ci) + key(Qt.Key_Right), self.move_right) m.addAction(QIcon(I('edit_input.png')), _('Change the location this entry points to'), self.edit_item) m.addAction(_('Change all selected items to title case'), self.title_case) m.addAction(QIcon(I('modified.png')), _('Bulk rename all selected items'), self.bulk_rename) m.exec_(QCursor.pos())
def show_context_menu(self, point): item = self.currentItem() def key(k): sc = unicode(QKeySequence(k | Qt.CTRL).toString(QKeySequence.NativeText)) return ' [%s]'%sc if item is not None: m = QMenu() ci = unicode(item.data(0, Qt.DisplayRole).toString()) p = item.parent() or self.invisibleRootItem() idx = p.indexOfChild(item) if idx > 0: m.addAction(QIcon(I('arrow-up.png')), (_('Move "%s" up')%ci)+key(Qt.Key_Up), self.move_up) if idx + 1 < p.childCount(): m.addAction(QIcon(I('arrow-down.png')), (_('Move "%s" down')%ci)+key(Qt.Key_Down), self.move_down) m.addAction(QIcon(I('trash.png')), _('Remove all selected items'), self.del_items) if item.parent() is not None: m.addAction(QIcon(I('back.png')), (_('Unindent "%s"')%ci)+key(Qt.Key_Left), self.move_left) if idx > 0: m.addAction(QIcon(I('forward.png')), (_('Indent "%s"')%ci)+key(Qt.Key_Right), self.move_right) m.addAction(QIcon(I('edit_input.png')), _('Change the location this entry points to'), self.edit_item) m.addAction(_('Change all selected items to title case'), self.title_case) m.exec_(QCursor.pos())
def collapse_menu_hovered(self, action): tip = action.toolTip() if tip == '*': tip = '' QToolTip.showText(QCursor.pos(), tip)