|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
from PyQt5.QtCore import Qt, QPoint |
|
|
|
|
from PyQt5.QtGui import QCursor |
|
|
|
|
from PyQt6.QtCore import Qt, QPoint |
|
|
|
|
from PyQt6.QtGui import QCursor |
|
|
|
|
|
|
|
|
|
from PyQt5.QtWidgets import ( |
|
|
|
|
from PyQt6.QtWidgets import ( |
|
|
|
|
QWidget, |
|
|
|
|
QScrollArea, QFrame, QApplication, QAction, |
|
|
|
|
QScrollArea, QFrame, QApplication |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
from .region_label_collection import RegionLabelCollection |
|
|
|
@ -41,8 +41,8 @@ class WorldRegionsWidget(QScrollArea):
|
|
|
|
|
region_label_collection_wrapper_widget = QWidget() |
|
|
|
|
region_label_collection_wrapper_widget.setLayout(self.region_label_collection) |
|
|
|
|
|
|
|
|
|
self.setAlignment(Qt.AlignCenter) |
|
|
|
|
self.setFrameShape(QFrame.NoFrame) |
|
|
|
|
self.setAlignment(Qt.Alignment.AlignCenter) |
|
|
|
|
self.setFrameShape(QFrame.Shape.NoFrame) |
|
|
|
|
self.setWidget(region_label_collection_wrapper_widget) |
|
|
|
|
|
|
|
|
|
def get_zoom_adjusted_label_size(self): |
|
|
|
@ -71,30 +71,36 @@ class WorldRegionsWidget(QScrollArea):
|
|
|
|
|
""" altering class functions """ |
|
|
|
|
def mousePressEvent(self, event): |
|
|
|
|
modifiers = QApplication.keyboardModifiers() |
|
|
|
|
if modifiers == Qt.ControlModifier and event.button() == Qt.LeftButton: |
|
|
|
|
if modifiers == Qt.KeyboardModifiers.ControlModifier and event.button() == Qt.MouseButtons.LeftButton: |
|
|
|
|
self.drag_in_progress = True |
|
|
|
|
self.drag_start.setX(event.x()) |
|
|
|
|
self.drag_start.setY(event.y()) |
|
|
|
|
self.drag_start.setX(event.position().x()) |
|
|
|
|
self.drag_start.setY(event.position().y()) |
|
|
|
|
|
|
|
|
|
super().mousePressEvent(event) |
|
|
|
|
|
|
|
|
|
def mouseReleaseEvent(self, event): |
|
|
|
|
if event.button() == Qt.LeftButton: |
|
|
|
|
if event.button() == Qt.MouseButtons.LeftButton: |
|
|
|
|
self.drag_in_progress = False |
|
|
|
|
|
|
|
|
|
super().mouseReleaseEvent(event) |
|
|
|
|
|
|
|
|
|
def mouseMoveEvent(self, event): |
|
|
|
|
if self.drag_in_progress: |
|
|
|
|
self.verticalScrollBar().setValue(self.verticalScrollBar().value() - (event.y() - self.drag_start.y())) |
|
|
|
|
self.horizontalScrollBar().setValue(self.horizontalScrollBar().value() - (event.x() - self.drag_start.x())) |
|
|
|
|
self.drag_start = QPoint(event.x(), event.y()) |
|
|
|
|
self.verticalScrollBar().setValue( |
|
|
|
|
self.verticalScrollBar().value() - (event.position().y() - self.drag_start.y()) |
|
|
|
|
) |
|
|
|
|
self.horizontalScrollBar().setValue( |
|
|
|
|
self.horizontalScrollBar().value() - (event.position().x() - self.drag_start.x()) |
|
|
|
|
) |
|
|
|
|
self.drag_start = QPoint( |
|
|
|
|
event.position().x(), event.position().y() |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
super().mouseMoveEvent(event) |
|
|
|
|
|
|
|
|
|
def wheelEvent(self, event): |
|
|
|
|
modifiers = QApplication.keyboardModifiers() |
|
|
|
|
if modifiers == Qt.ControlModifier: |
|
|
|
|
if modifiers == Qt.KeyboardModifiers.ControlModifier: |
|
|
|
|
if event.angleDelta().y() > 0: |
|
|
|
|
self.action_zoom_in() |
|
|
|
|
else: |
|
|
|
@ -106,12 +112,12 @@ class WorldRegionsWidget(QScrollArea):
|
|
|
|
|
|
|
|
|
|
def keyPressEvent(self, event): |
|
|
|
|
if event.key() in (16777249, 16777250): |
|
|
|
|
self.setCursor(QCursor(Qt.SizeAllCursor)) |
|
|
|
|
self.setCursor(QCursor(Qt.CursorShape.SizeAllCursor)) |
|
|
|
|
|
|
|
|
|
super().keyPressEvent(event) |
|
|
|
|
|
|
|
|
|
def keyReleaseEvent(self, event): |
|
|
|
|
if event.key() in (16777249, 16777250): |
|
|
|
|
self.setCursor(QCursor(Qt.ArrowCursor)) |
|
|
|
|
self.setCursor(QCursor(Qt.CursorShape.ArrowCursor)) |
|
|
|
|
|
|
|
|
|
super().keyReleaseEvent(event) |
|
|
|
|