Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions preditor/gui/console_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
QTextCursor,
)
from Qt.QtWidgets import QAction, QApplication, QTextEdit, QWidget
from Qt.QtCompat import QMouseEvent

from .. import instance, resourcePath, stream
from ..constants import StreamType
Expand Down Expand Up @@ -136,6 +137,7 @@ def clear(self):
def contextMenuEvent(self, event):
"""Builds a custom right click menu to show."""
# Create the standard menu and allow subclasses to customize it
# The event.pos method for QContextMenuEvent was NOT removed
menu = self.createStandardContextMenu(event.pos())
menu = self.update_context_menu(menu)
if self.controller:
Expand Down Expand Up @@ -432,7 +434,8 @@ def mouseMoveEvent(self, event):
"""Overload of mousePressEvent to change mouse pointer to indicate it is
over a clickable error hyperlink.
"""
if self.anchorAt(event.pos()):
pos = QMouseEvent.position(event).toPoint()
if self.anchorAt(pos):
self.viewport().setCursor(Qt.CursorShape.PointingHandCursor)
else:
self.viewport().unsetCursor()
Expand All @@ -444,8 +447,9 @@ def mousePressEvent(self, event):
select text), we check if user clicked an error hyperlink.
"""
left = event.button() == Qt.MouseButton.LeftButton
anchor = self.anchorAt(event.pos())
self.mousePressPos = event.pos()
pos = QMouseEvent.position(event).toPoint()
anchor = self.anchorAt(pos)
self.mousePressPos = pos

if left and anchor:
event.ignore()
Expand All @@ -457,9 +461,10 @@ def mouseReleaseEvent(self, event):
"""Overload of mouseReleaseEvent to capture if user has left clicked... Check if
click position is the same as release position, if so, call errorHyperlink.
"""
samePos = event.pos() == self.mousePressPos
pos = QMouseEvent.position(event).toPoint()
samePos = pos == self.mousePressPos
left = event.button() == Qt.MouseButton.LeftButton
anchor = self.anchorAt(event.pos())
anchor = self.anchorAt(pos)

if samePos and left and anchor:
self.errorHyperlink(anchor)
Expand Down
10 changes: 7 additions & 3 deletions preditor/gui/drag_tab_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
QSizePolicy,
QTabBar,
)
from Qt.QtCompat import QMouseEvent, QDragMoveEvent

from preditor import osystem

Expand Down Expand Up @@ -236,7 +237,8 @@ def mouseMoveEvent(self, event): # noqa: N802

# Check if the mouse has moved outside of the widget, if not, let
# the QTabBar handle the internal tab movement.
event_pos = event.pos()

event_pos = QMouseEvent.position(event).toPoint()
global_pos = self.mapToGlobal(event_pos)
bar_geo = QRect(self.mapToGlobal(self.pos()), self.size())
inside = bar_geo.contains(global_pos)
Expand Down Expand Up @@ -268,7 +270,8 @@ def mouseMoveEvent(self, event): # noqa: N802

def mousePressEvent(self, event): # noqa: N802
if event.button() == Qt.MouseButton.LeftButton and not self._mime_data:
tab_index = self.tabAt(event.pos())
pos = QMouseEvent.position(event).toPoint()
tab_index = self.tabAt(pos)

# While we don't remove the tab on mouse press, capture its tab image
# and attach it to the mouse. This also stores info needed to handle
Expand Down Expand Up @@ -312,7 +315,8 @@ def dragMoveEvent(self, event): # noqa: N802
# the current tab so users can easily drop inside that tab.
if not event.mimeData().hasFormat(self.mime_type):
event.accept()
tab_index = self.tabAt(event.pos())
pos = QDragMoveEvent().position(event).toPoint()
tab_index = self.tabAt(pos)
if tab_index == -1:
tab_index = self.count() - 1
if self.currentIndex() != tab_index:
Expand Down