Ejemplo n.º 1
0
 def contextMenuEvent(self, event):
     """A simple context menu for managing images."""
     context_menu = QMenu(self) # Create menu instance
     context_menu.addAction(self.parent.sort_ascend_act)
     context_menu.addAction(self.parent.sort_descend_act)
     context_menu.addSeparator()
     context_menu.addAction(self.parent.delete_act)
     context_menu.exec(self.mapToGlobal(event.pos()))       
Ejemplo n.º 2
0
 def show_context_menu(self, pos):
     item = self.itemAt(pos)
     if not item:
         return
     m = QMenu(self)
     m.addAction(_('Close tabs to the bottom'),
                 partial(self.close_tabs_to_bottom, item))
     m.addAction(_('Close other tabs'), partial(self.close_other_tabs,
                                                item))
     m.addAction(_('Close this tree'), partial(self.close_tree, item))
     m.exec(self.mapToGlobal(pos))
Ejemplo n.º 3
0
    def contextMenuEvent(self, event):

        cmenu = QMenu(self)

        newAct = cmenu.addAction("New")
        openAct = cmenu.addAction("Open")
        quitAct = cmenu.addAction("Quit")
        action = cmenu.exec(self.mapToGlobal(event.pos()))

        if action == quitAct:
            QApplication.instance().quit()
Ejemplo n.º 4
0
 def eventFilter(self, source, event):
     if event.type(
     ) == QEvent.Type.ContextMenu and source is self.mock_env_list:
         menu = QMenu()
         _copy = menu.addAction(
             QIcon(full_path("assets/images/icons/export.ico")), "Export")
         _remove = menu.addAction(
             QIcon(full_path("assets/images/icons/trash-can.ico")),
             "Remove")
         if source.itemAt(event.pos()):
             action = menu.exec(event.globalPos())
             _item = source.itemAt(event.pos())
             _id = _item.whatsThis()
             if action == _remove:
                 delete_confirmation(self, _id, self.delete)
         return True
     return super().eventFilter(source, event)
Ejemplo n.º 5
0
    def contextMenuEvent(self, event):
        """Add actions to right click menu, dependent on currently active table
        """
        child = self.childAt(event.pos())

        menu = QMenu(self)
        # menu.setToolTipsVisible(True)

        table_widget = self.active_table_widget()
        for section in table_widget.context_actions.values():
            for action in section:
                name_action = f'act_{action}'
                try:
                    menu.addAction(getattr(self, name_action))
                except Exception as e:
                    try:
                        menu.addAction(getattr(table_widget, name_action))
                    except Exception as e:
                        log.warning(
                            f'Couldn\'t add action to context menu: {action}')

            menu.addSeparator()

        action = menu.exec(self.mapToGlobal(event.pos()))
Ejemplo n.º 6
0
    def eventFilter(self, source, event):
        if event.type(
        ) == QEvent.Type.ContextMenu and source is self.mock_endpoints:
            menu = QMenu()
            _copy = menu.addAction(
                QIcon(full_path("assets/images/icons/copy.ico")), "Copy")
            _toggle = menu.addAction(
                QIcon(full_path("assets/images/icons/toggle.ico")), "Toggle")
            _remove = menu.addAction(
                QIcon(full_path("assets/images/icons/trash-can.ico")),
                "Remove")

            if source.itemAt(event.pos()):
                action = menu.exec(event.globalPos())
                _item = source.itemAt(event.pos())
                _id = _item.whatsThis()
                if action == _copy:
                    copy_endpoint(endpoint_ids=[_id])
                elif action == _toggle:
                    self.toggle_endpoint(_id)
                elif action == _remove:
                    delete_confirmation(self, _id, self.delete)
            return True
        return super().eventFilter(source, event)
Ejemplo n.º 7
0
Archivo: demo.py Proyecto: clpi/isutils
 def contextMenuEvent(self, e: QContextMenuEvent) -> None:
     menu = QMenu(self)
     if e.isInputEvent():
         menu.addActions(iter(self.actions()))
         return super().contextMenuEvent(e)
     menu.exec(e.globalPos())