Skip to content

Commit

Permalink
Merge pull request #15 from nodedge/fix/comment-widget-right-click
Browse files Browse the repository at this point in the history
Fix comment widget right click.
  • Loading branch information
nodedge committed Nov 7, 2022
2 parents d4f5539 + 2a03060 commit d677f2b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
1 change: 0 additions & 1 deletion nodedge/elements/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from nodedge.elements.graphics_element import GraphicsElement
from nodedge.logger import logger
from nodedge.serializable import Serializable

# from nodedge.types import Pos
from nodedge.utils import dumpException

Expand Down
29 changes: 24 additions & 5 deletions nodedge/graphics_text_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
from PySide6.QtCore import Qt, Signal
from PySide6.QtGui import QFocusEvent
from PySide6.QtWidgets import (
QColorDialog,
QFontDialog,
QGraphicsItem,
QGraphicsSceneMouseEvent,
QGraphicsTextItem,
QMenu,
)

from nodedge.logger import logger


class GraphicsTextItem(QGraphicsTextItem):
textChanged = Signal(str)
Expand Down Expand Up @@ -54,8 +58,23 @@ def mouseReleaseEvent(self, event: QGraphicsSceneMouseEvent) -> None:
super().mouseReleaseEvent(event)

if event.button() == Qt.RightButton:
ok, font = QFontDialog.getFont()
if not ok:
return
print(font)
self.setFont(font)
contextMenu = QMenu()
bezierAct = contextMenu.addAction("Change font")
directAct = contextMenu.addAction("Change color")
action = contextMenu.exec_(event.screenPos())
print(action)

if action.text() == "Change font":
ok, font = QFontDialog.getFont()
if not ok:
return
logger.debug(font)
self.setFont(font)
event.accept()
elif action.text() == "Change color":
color = QColorDialog.getColor()
if color is None:
return
logger.debug(color)
self.setDefaultTextColor(color)
event.accept()
4 changes: 3 additions & 1 deletion nodedge/mdi_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
QMouseEvent,
QPixmap,
)
from PySide6.QtWidgets import QGraphicsProxyWidget, QMenu
from PySide6.QtWidgets import QGraphicsProxyWidget, QGraphicsTextItem, QMenu

from nodedge.blocks.block import Block
from nodedge.blocks.block_config import BLOCKS, getClassFromOperationCode
Expand Down Expand Up @@ -222,6 +222,8 @@ def contextMenuEvent(self, event: QContextMenuEvent):
elif hasattr(item, "edge"):
self.handleEdgeContextMenu(event)
# elif item is None:
elif isinstance(item, QGraphicsTextItem):
self.__contextLogger.debug("Right click on a comment.")
else:
self.handleNewNodeContextMenu(event)

Expand Down
1 change: 0 additions & 1 deletion nodedge/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from nodedge.graphics_node_content import GraphicsNodeContent
from nodedge.serializable import Serializable
from nodedge.socket_type import SocketType

# from nodedge.types import Pos
from nodedge.utils import dumpException

Expand Down

0 comments on commit d677f2b

Please sign in to comment.