def __evt_showContextMenu(self, point): _tabbar = self.tabBar() for index in range(_tabbar.count()): rect = _tabbar.tabRect(index) if rect.contains(point): menu = QMenu(self) action = QAction( "close", self, triggered=lambda: self.__evt_close_tab_click(index)) action.setEnabled(self.count() > 1 and index is not 0) menu.addAction(action) action = QAction( "close others", self, triggered=lambda: self.__evt_contextMenuCloseOthers(index)) action.setEnabled(self.count() > 1) menu.addAction(action) action = QAction( "close all", self, triggered=lambda: self.__evt_contextMenuCloseOthers(0)) action.setEnabled(self.count() > 1) menu.addAction(action) menu.exec_(self.mapToGlobal(point))
def contextMenuEvent (self, e): """ right click """ menu = QMenu(self) menu.addAction(self.__editActions["zoomin"]) menu.addAction(self.__editActions["zoomreset"]) menu.addAction(self.__editActions["zoomout"]) menu.addAction(self.__editActions["reload"]) menu.exec_(e.globalPos())
def __evt_contextmenu(self,point): """ show the right menu """ item = self.pluginList.currentItem() if item: menu = QMenu(self) action = QAction(QApplication.translate("default","Install plugins..."),self,triggered=lambda:self.__evt_install_plugin(item)) menu.addAction(action) action = QAction(QApplication.translate("default","Uninstall plugins..."),self) menu.addAction(action) menu.exec_(self.mapToGlobal(self.pluginList.mapTo(self,point)))
def __evt_contextmenu(self, point): """ show the right menu """ item = self.pluginList.currentItem() if item: menu = QMenu(self) action = QAction(QApplication.translate("default", "Install plugins..."), self, triggered=lambda: self.__evt_install_plugin(item)) menu.addAction(action) action = QAction( QApplication.translate("default", "Uninstall plugins..."), self) menu.addAction(action) menu.exec_(self.mapToGlobal(self.pluginList.mapTo(self, point)))
def __evt_showContextMenu(self,point): _tabbar = self.tabBar() for index in range(_tabbar.count()): rect = _tabbar.tabRect(index) if rect.contains(point): menu = QMenu(self) action = QAction("close",self,triggered=lambda:self.__evt_close_tab_click(index)) action.setEnabled(self.count()>1 and index is not 0) menu.addAction(action) action = QAction("close others",self,triggered=lambda:self.__evt_contextMenuCloseOthers(index)) action.setEnabled(self.count()>1) menu.addAction(action) action = QAction("close all",self,triggered=lambda:self.__evt_contextMenuCloseOthers(0)) action.setEnabled(self.count()>1) menu.addAction(action) menu.exec_(self.mapToGlobal(point))
def __evt_contextmenu(self, point): """ show the right menu """ item = self.pluginList.currentItem() if item: menu = QMenu(self) if item.text(4) == "True": action = QAction(QApplication.translate("PluginInfoDialog", "DeActive"),self,\ triggered=lambda re,name=item.text(0):self.__evt_toggle_active(name, False)) #core plugin not allowed disabled action.setEnabled(not PluginAdapter.new().getPluginByName( item.text(0)).packageName == "__core__") else: action = QAction(QApplication.translate("PluginInfoDialog", "Active"),self,\ triggered=lambda re,name=item.text(0):self.__evt_toggle_active(name, True)) menu.addAction(action) menu.exec_(self.mapToGlobal(self.pluginList.mapTo(self, point)))
def __evt_contextmenu(self,point): """ show the right menu """ item = self.pluginList.currentItem() if item: menu = QMenu(self) if item.text(4)=="True": action = QAction(QApplication.translate("PluginInfoDialog", "DeActive"),self,\ triggered=lambda re,name=item.text(0):self.__evt_toggle_active(name, False)) #core plugin not allowed disabled action.setEnabled(not PluginAdapter.new().getPluginByName(item.text(0)).packageName == "__core__") else: action = QAction(QApplication.translate("PluginInfoDialog", "Active"),self,\ triggered=lambda re,name=item.text(0):self.__evt_toggle_active(name, True)) menu.addAction(action) menu.exec_(self.mapToGlobal(self.pluginList.mapTo(self,point)))
def contextMenuEvent(self, e): """ right click . table oprerators etc... """ menu = QMenu(self) tag = self.page().mainFrame().hitTestContent(e.pos()).element() #some table operations if tag and tag.tagName().lower() == "td": hasPre = tag.parent().previousSibling().tagName().lower() == "tr" hasNext = tag.parent().nextSibling().tagName().lower() == "tr" #move up action = QAction(QIcon(getPath('iconDir', 'heditor/row_up.png')), "Move row up", self, triggered=lambda: self._table_tr_moveup(tag)) action.setDisabled(not hasPre) action.setIconVisibleInMenu(True) menu.addAction(action) #move down action = QAction(QIcon(getPath('iconDir', 'heditor/row_down.png')), "Move row down", self, triggered=lambda: self._table_tr_movedown(tag)) action.setDisabled(not hasNext) action.setIconVisibleInMenu(True) menu.addAction(action) menu.addAction( QAction("Copy row to above", self, triggered=lambda: self._table_tr_insert_above(tag))) menu.addAction( QAction("Copy row to below", self, triggered=lambda: self._table_tr_insert_below(tag))) menu.addAction( QAction(QIcon(getPath('iconDir', 'heditor/col_left.png')), "Insert column left", self, triggered=lambda: self._table_column_left(tag))) menu.addAction( QAction(QIcon(getPath('iconDir', 'heditor/col_right.png')), "Insert column right", self, triggered=lambda: self._table_column_right(tag))) action = QAction("Delete row", self, triggered=lambda: self._table_tr_remove(tag)) action.setDisabled(not hasPre and not hasNext) menu.addAction(action) menu.addAction( QAction("Delete column", self, triggered=lambda: self._table_column_remove(tag))) action = QAction("Set Table Style", self, triggered=lambda: self._table_style_change(tag)) menu.addAction(action) action = QAction(QIcon(getPath('iconDir', 'heditor/delete.png')), "Delete table", self, triggered=lambda: self._table_delete(tag)) action.setIconVisibleInMenu(True) menu.addAction(action) menu.addSeparator() #Common content menu menu.addAction(self.__editActions["selectall"]) menu.addAction(self.__editActions["copy"]) menu.addAction(self.__editActions["cut"]) menu.addAction(self.__editActions["paste"]) menu.addSeparator() menuEdit = QMenu("Edit") menuEdit.addAction(self.__editActions["bold"]) menuEdit.addAction(self.__editActions["italic"]) menuEdit.addAction(self.__editActions["underline"]) menuEdit.addAction(self.__editActions["strikethrough"]) menuEdit.addAction(self.__editActions["removeformat"]) menuEdit.addSeparator() menuEdit.addAction(self.__editActions["left"]) menuEdit.addAction(self.__editActions["center"]) menuEdit.addAction(self.__editActions["right"]) menuEdit.addAction(self.__editActions["justify"]) menuEdit.addSeparator() menuEdit.addAction(self.__editActions["indent"]) menuEdit.addAction(self.__editActions["outdent"]) menuEdit.addAction(self.__editActions["subscript"]) menuEdit.addAction(self.__editActions["superscript"]) menu.addMenu(menuEdit) menu.addSeparator() menuInsert = QMenu("Insert") menuInsert.addAction(self.__editActions["image"]) menuInsert.addAction(self.__editActions["table"]) menuInsert.addAction(self.__editActions["linkpage"]) menu.addMenu(menuInsert) menu.exec_(e.globalPos())
def contextMenuEvent (self, e): """ right click . table oprerators etc... """ menu = QMenu(self) tag = self.page().mainFrame().hitTestContent(e.pos()).element() #some table operations if tag and tag.tagName().lower() == "td": hasPre = tag.parent().previousSibling().tagName().lower()=="tr" hasNext = tag.parent().nextSibling().tagName().lower()=="tr" #move up action = QAction(QIcon(getPath('iconDir','heditor/row_up.png')),"Move row up",self,triggered=lambda :self._table_tr_moveup(tag)) action.setDisabled(not hasPre) action.setIconVisibleInMenu(True) menu.addAction(action) #move down action = QAction(QIcon(getPath('iconDir','heditor/row_down.png')),"Move row down",self,triggered=lambda :self._table_tr_movedown(tag)) action.setDisabled(not hasNext) action.setIconVisibleInMenu(True) menu.addAction(action) menu.addAction(QAction("Copy row to above",self,triggered=lambda :self._table_tr_insert_above(tag))) menu.addAction(QAction("Copy row to below",self,triggered=lambda :self._table_tr_insert_below(tag))) menu.addAction(QAction(QIcon(getPath('iconDir','heditor/col_left.png')),"Insert column left",self,triggered=lambda :self._table_column_left(tag))) menu.addAction(QAction(QIcon(getPath('iconDir','heditor/col_right.png')),"Insert column right",self,triggered=lambda :self._table_column_right(tag))) action = QAction("Delete row",self,triggered=lambda :self._table_tr_remove(tag)) action.setDisabled(not hasPre and not hasNext) menu.addAction(action) menu.addAction(QAction("Delete column",self,triggered=lambda :self._table_column_remove(tag))) action = QAction("Set Table Style",self,triggered=lambda :self._table_style_change(tag)) menu.addAction(action) action = QAction(QIcon(getPath('iconDir','heditor/delete.png')),"Delete table",self,triggered=lambda :self._table_delete(tag)) action.setIconVisibleInMenu(True) menu.addAction(action) menu.addSeparator() #Common content menu menu.addAction(self.__editActions["selectall"]) menu.addAction(self.__editActions["copy"]) menu.addAction(self.__editActions["cut"]) menu.addAction(self.__editActions["paste"]) menu.addSeparator() menuEdit = QMenu("Edit") menuEdit.addAction(self.__editActions["bold"]) menuEdit.addAction(self.__editActions["italic"]) menuEdit.addAction(self.__editActions["underline"]) menuEdit.addAction(self.__editActions["strikethrough"]) menuEdit.addAction(self.__editActions["removeformat"]) menuEdit.addSeparator() menuEdit.addAction(self.__editActions["left"]) menuEdit.addAction(self.__editActions["center"]) menuEdit.addAction(self.__editActions["right"]) menuEdit.addAction(self.__editActions["justify"]) menuEdit.addSeparator() menuEdit.addAction(self.__editActions["indent"]) menuEdit.addAction(self.__editActions["outdent"]) menuEdit.addAction(self.__editActions["subscript"]) menuEdit.addAction(self.__editActions["superscript"]) menu.addMenu(menuEdit) menu.addSeparator() menuInsert = QMenu("Insert") menuInsert.addAction(self.__editActions["image"]) menuInsert.addAction(self.__editActions["table"]) menuInsert.addAction(self.__editActions["linkpage"]) menu.addMenu(menuInsert) menu.exec_(e.globalPos())