コード例 #1
0
ファイル: planning_grid.py プロジェクト: bebert64/planning
 def contextMenuEvent(self, event: QtGui.QContextMenuEvent) -> None:
     column = self.currentColumn()
     if column % 3 != 2:
         row = self.currentRow()
         menu = CellMenu(self, row, column)
         menu_position = event.pos()
         self._open_context_menu(menu, menu_position)
コード例 #2
0
    def contextMenuEvent(self, event: QtGui.QContextMenuEvent):

        index = self.indexAt(
            event.pos()
        )  # fixme: DeprecationWarning: Function: 'pos() const' is marked as deprecated, please check the documentation for more information.

        model = index.model()

        if model:  # click on item
            menu = QtWidgets.QMenu(self)
            if model.isDir(index):
                menu.addAction(self.action_open)
                menu.addAction(self.action_open_new)
            else:
                menu.addAction(self.action_open_default)
            menu.exec(event.globalPos())
        else:  # click on empty space
            pass
コード例 #3
0
 def contextMenuEvent(self, event: QContextMenuEvent):
     """Override Qt method to pop up a list of statuses and change visible of
     status.
     """
     menu = AMenu(self)
     for text, is_checked in self._checked_dict.items():
         action = create_action(
             parent=self,
             text=text,
             is_checkable=True,
             is_checked=is_checked,
         )
         menu.addAction(action)  # type: ignore
     # Display popup menu on places of right-clicked.
     selected_action = menu.exec_(self.mapToGlobal(
         event.pos()))  # type: ignore
     if selected_action is not None:
         action_text = selected_action.text()
         is_check = self._checked_dict[action_text]
         self._checked_dict[action_text] = not is_check
         if is_check:
             self._status_dict[action_text].hide()
         else:
             self._status_dict[action_text].show()
コード例 #4
0
ファイル: hex_area.py プロジェクト: octorock/the-little-hat
 def contextMenuEvent(self, event: QContextMenuEvent) -> None:
     self.signal_context_menu_shown.emit(event.globalPos())
コード例 #5
0
    def contextMenuEvent(self, event: QtGui.QContextMenuEvent) -> None:
        local_pos = QPointF(self.mapFromGlobal(event.globalPos()))
        local_pos -= self.get_area_canvas_offset()
        self._next_node_location = self.qt_local_to_game_loc(local_pos)

        menu = QtWidgets.QMenu(self)
        if self.state is None:
            menu.addAction(self._show_all_connections_action)
        if self.edit_mode:
            menu.addAction(self._create_node_action)
            menu.addAction(self._move_node_action)
            self._move_node_action.setEnabled(
                self.highlighted_node is not None)
            if self.highlighted_node is not None:
                self._move_node_action.setText(
                    f"Move {self.highlighted_node.name} here")

        # Areas Menu
        menu.addSeparator()
        areas_at_mouse = self._other_areas_at_position(local_pos)

        for area in areas_at_mouse:
            sub_menu = QtWidgets.QMenu(f"Area: {area.name}", self)
            sub_menu.addAction("View area").triggered.connect(
                functools.partial(self.SelectAreaRequest.emit, area))
            if self.edit_mode:
                sub_menu.addAction(
                    "Create dock here to this area").triggered.connect(
                        functools.partial(self.CreateDockRequest.emit,
                                          self._next_node_location, area))
            menu.addMenu(sub_menu)

        if not areas_at_mouse:
            sub_menu = QtGui.QAction("No areas here", self)
            sub_menu.setEnabled(False)
            menu.addAction(sub_menu)

        # Nodes Menu
        menu.addSeparator()
        nodes_at_mouse = self._nodes_at_position(local_pos)
        if self.highlighted_node in nodes_at_mouse:
            nodes_at_mouse.remove(self.highlighted_node)

        for node in nodes_at_mouse:
            if len(nodes_at_mouse) == 1:
                menu.addAction(node.name).setEnabled(False)
                sub_menu = menu
            else:
                sub_menu = QtWidgets.QMenu(node.name, self)

            sub_menu.addAction("Highlight this").triggered.connect(
                functools.partial(self.SelectNodeRequest.emit, node))
            view_connections = sub_menu.addAction("View connections to this")
            view_connections.setEnabled(
                (self.edit_mode and self.highlighted_node != node) or
                (node in self.area.connections.get(self.highlighted_node, {})))
            view_connections.triggered.connect(
                functools.partial(self.SelectConnectionsRequest.emit, node))

            if self.edit_mode:
                sub_menu.addSeparator()
                sub_menu.addAction(
                    "Replace connection with Trivial").triggered.connect(
                        functools.partial(
                            self.ReplaceConnectionsRequest.emit,
                            node,
                            Requirement.trivial(),
                        ))
                sub_menu.addAction("Remove connection").triggered.connect(
                    functools.partial(
                        self.ReplaceConnectionsRequest.emit,
                        node,
                        Requirement.impossible(),
                    ))
                if areas_at_mouse:
                    move_menu = QtWidgets.QMenu("Move to...", self)
                    for area in areas_at_mouse:
                        move_menu.addAction(area.name).triggered.connect(
                            functools.partial(
                                self.MoveNodeToAreaRequest.emit,
                                node,
                                area,
                            ))
                    sub_menu.addMenu(move_menu)

            if sub_menu != menu:
                menu.addMenu(sub_menu)

        if not nodes_at_mouse:
            sub_menu = QtGui.QAction("No other nodes here", self)
            sub_menu.setEnabled(False)
            menu.addAction(sub_menu)

        # Done

        menu.exec_(event.globalPos())
コード例 #6
0
ファイル: __init__.py プロジェクト: stefs/evelyn-reminder
 def contextMenuEvent(
         self,
         event: QContextMenuEvent
 ) -> None:
     self.context_menu.exec_(event.globalPos())