bugfixes (#188)
All checks were successful
Build AppImage / Explore-Gitea-Actions (push) Successful in 1m58s
All checks were successful
Build AppImage / Explore-Gitea-Actions (push) Successful in 1m58s
Bugfixes for several issues: closes #163, closes #151, closes #176, closes #138, closes #104 Co-authored-by: Dominik Demuth <dominik.demuth@physik.tu-darmstadt.de> Reviewed-on: #188
This commit is contained in:
@ -27,6 +27,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
||||
mouseDoubleClicked = QtCore.pyqtSignal()
|
||||
positionClicked = QtCore.pyqtSignal(tuple, bool)
|
||||
aboutToClose = QtCore.pyqtSignal(list)
|
||||
newData = QtCore.pyqtSignal(list, str)
|
||||
|
||||
counter = itertools.count()
|
||||
|
||||
@ -87,6 +88,9 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
||||
|
||||
self.bwbutton.toggled.connect(self.change_background)
|
||||
|
||||
self.setAcceptDrops(True)
|
||||
self.graphic.installEventFilter(self)
|
||||
|
||||
def _init_gui(self):
|
||||
self.setWindowTitle('Graph ' + str(next(QGraphWindow.counter)))
|
||||
|
||||
@ -119,6 +123,34 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
||||
for lineedit in [self.xmin_lineedit, self.xmax_lineedit, self.ymin_lineedit, self.ymax_lineedit]:
|
||||
lineedit.setValidator(QtGui.QDoubleValidator())
|
||||
|
||||
def eventFilter(self, obj: QtCore.QObject, evt: QtCore.QEvent):
|
||||
"""
|
||||
Catch drag and Drop to prevent anything inside self.graphic to accept the events.
|
||||
Without event filter, we cannot process it here and start file reading
|
||||
"""
|
||||
if evt.type() == QtCore.QEvent.Type.DragEnter:
|
||||
evt.accept()
|
||||
return True
|
||||
|
||||
elif evt.type() == QtCore.QEvent.Type.Drop:
|
||||
return self._handle_drop(evt)
|
||||
|
||||
else:
|
||||
return False
|
||||
|
||||
def dropEvent(self, evt: QtGui.QDropEvent):
|
||||
return self._handle_drop(evt)
|
||||
|
||||
def _handle_drop(self, evt: QtGui.QDropEvent):
|
||||
if evt.mimeData().hasUrls():
|
||||
files = [str(url.toLocalFile()) for url in evt.mimeData().urls()]
|
||||
self.newData.emit(files, self.id)
|
||||
|
||||
evt.accept()
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def __contains__(self, item: str):
|
||||
return item in self.sets
|
||||
|
||||
@ -304,6 +336,8 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
||||
if item in self.graphic.items():
|
||||
self.graphic.removeItem(item)
|
||||
|
||||
self.show_legend()
|
||||
|
||||
@QtCore.pyqtSlot(bool, name='on_imag_button_toggled')
|
||||
@QtCore.pyqtSlot(bool, name='on_real_button_toggled')
|
||||
def set_imag_visible(self, visible: bool):
|
||||
|
Reference in New Issue
Block a user