From cc7572fe145aecd00d609a99de6ff4737d0c03d2 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Wed, 15 May 2024 17:15:09 +0200 Subject: [PATCH] retain settings in FC reader dialog --- src/gui_qt/io/fcbatchreader.py | 8 ++++++++ src/gui_qt/main/mainwindow.py | 16 +++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/gui_qt/io/fcbatchreader.py b/src/gui_qt/io/fcbatchreader.py index c4bb80b..a4444e6 100644 --- a/src/gui_qt/io/fcbatchreader.py +++ b/src/gui_qt/io/fcbatchreader.py @@ -28,6 +28,12 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog): self.listWidget.installEventFilter(self) + def __call__(self, path=None): + if path is None: + path = pathlib.Path().home() + self.path = path + self.listWidget.clear() + def eventFilter(self, src: QtCore.QObject, evt: QtCore.QEvent) -> bool: # intercept key press in listwidget to allow deletion with Del if evt.type() == QtCore.QEvent.Type.KeyPress: @@ -82,6 +88,7 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog): def accept(self): items = [self.listWidget.item(i).text() for i in range(self.listWidget.count())] + print(items) if items: with busy_cursor(): self.read(items) @@ -116,6 +123,7 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog): ret_vals = [] ret_vals.extend(fc_eval.get_parameter(path=self.label.text(), kind='temp', parameter=save_variables)) + print(ret_vals) grp = '' if not self.graph_checkbox.isChecked(): diff --git a/src/gui_qt/main/mainwindow.py b/src/gui_qt/main/mainwindow.py index 7f6123b..5143964 100644 --- a/src/gui_qt/main/mainwindow.py +++ b/src/gui_qt/main/mainwindow.py @@ -62,6 +62,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): self.fitresult_dialog = None self.eval = None self.editor = None + self.fc_reader = None self.logtext = QTextHandler(self) logger.addHandler(self.logtext) @@ -264,14 +265,15 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): @QtCore.pyqtSlot(name='on_actionOpen_FC_triggered') def read_fc(self): - reader = QFCReader(path=self.path, parent=self) - reader.add_graphs(self.management.graphs.list()) - reader.data_read.connect(self.management.add_new_data) - reader.exec() + if self.fc_reader is None: + self.fc_reader = QFCReader(path=self.path, parent=self) + self.fc_reader.data_read.connect(self.management.add_new_data) + else: + self.fc_reader(path=self.path) + self.fc_reader.add_graphs(self.management.graphs.list()) + self.fc_reader.exec() - self.path = reader.path - - del reader + self.path = self.fc_reader.path @QtCore.pyqtSlot(name='on_actionPrint_triggered') def print(self):