stop autoamtic ascii reading if first is cancelled #260

Merged
dominik merged 1 commits from 251-cancel-ascii-read into master 2024-04-02 15:34:42 +00:00
2 changed files with 12 additions and 5 deletions

View File

@ -178,7 +178,7 @@ class QAsciiReader(QtWidgets.QDialog, Ui_ascii_reader):
@QtCore.pyqtSlot()
def accept(self):
if self.apply():
self.close()
super().accept()
def apply(self):
# default row for x is the first row, it will be superseded if an integer number is given.

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from pathlib import Path
import struct
from ..Qt import QtCore
from ..Qt import QtCore, QtWidgets
from .asciireader import QAsciiReader
from .hdfreader import QHdfViewer
from .bdsreader import QBDSReader
@ -26,8 +26,12 @@ class QFileReader(QtCore.QObject):
self.reader = {}
for ext, reader in [
('txt', QAsciiReader), ('dsc', QDSCReader), ('agr', QGraceReader),
('bds', QBDSReader), ('hdf', QHdfViewer), ('nmr', QNMRReader)
('txt', QAsciiReader),
('dsc', QDSCReader),
('agr', QGraceReader),
('bds', QBDSReader),
('hdf', QHdfViewer),
('nmr', QNMRReader),
]:
self.register(ext, reader)
@ -57,7 +61,10 @@ class QFileReader(QtCore.QObject):
try:
# If QAsciiReader.skip = True it accepts automatically and returns None
r(f).exec()
status = r(f).exec()
if status == QtWidgets.QDialog.Rejected and isinstance(r, QAsciiReader):
break
except AttributeError:
pass