forked from IPKM/nmreval
crude updater added; write_state uses plain text, not pickle; disallow invalid characters; T246
This commit is contained in:
@ -5,10 +5,9 @@ import re
|
||||
from pathlib import Path
|
||||
|
||||
from numpy import geomspace, linspace
|
||||
from pyqtgraph import ViewBox, PlotDataItem
|
||||
from pyqtgraph import ViewBox
|
||||
|
||||
from nmreval.configs import *
|
||||
from nmreval.lib.utils import open_bug_report
|
||||
|
||||
from .management import UpperManagement
|
||||
from ..Qt import QtCore, QtGui, QtPrintSupport, QtWidgets
|
||||
@ -28,6 +27,7 @@ from ..math.smooth import QSmooth
|
||||
from ..nmr.coupling_calc import QCoupCalcDialog
|
||||
from ..nmr.t1_from_tau import QRelaxCalc
|
||||
from .._py.basewindow import Ui_BaseWindow
|
||||
from ..lib.utils import UpdateDialog, open_bug_report
|
||||
|
||||
|
||||
class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
@ -218,13 +218,13 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
@QtCore.pyqtSlot(name='on_action_open_triggered')
|
||||
def open(self):
|
||||
filedialog = OpenFileDialog(directory=self.path, caption='Open files',
|
||||
filters='All files (*.*);;'
|
||||
'Program session (*.nmr);;'
|
||||
'HDF files (*.h5);;'
|
||||
'Text files (*.txt *.dat);;'
|
||||
'Novocontrol Alpha (*.EPS);;'
|
||||
'TecMag files (*.tnt);;'
|
||||
'Grace files (*.agr)')
|
||||
filter='All files (*.*);;'
|
||||
'Program session (*.nmr);;'
|
||||
'HDF files (*.h5);;'
|
||||
'Text files (*.txt *.dat);;'
|
||||
'Novocontrol Alpha (*.EPS);;'
|
||||
'TecMag files (*.tnt);;'
|
||||
'Grace files (*.agr)')
|
||||
|
||||
filedialog.set_graphs(self.management.graphs.list())
|
||||
|
||||
@ -250,9 +250,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
@QtCore.pyqtSlot(name='on_actionExportData_triggered')
|
||||
@QtCore.pyqtSlot(name='on_actionSave_triggered')
|
||||
def save(self):
|
||||
save_dialog = SaveDirectoryDialog(
|
||||
directory=str(self.path), parent=self,
|
||||
)
|
||||
save_dialog = SaveDirectoryDialog(directory=str(self.path), parent=self)
|
||||
|
||||
mode = save_dialog.exec()
|
||||
if mode == QtWidgets.QDialog.Accepted:
|
||||
@ -274,12 +272,14 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
@QtCore.pyqtSlot()
|
||||
@QtCore.pyqtSlot(list)
|
||||
def save_fit_parameter(self, fit_sets: list[str] = None):
|
||||
fname, _ = QtWidgets.QFileDialog.getSaveFileName(self, 'Save fit parameter', directory=str(self.path),
|
||||
filter='All files(*, *);;Text files(*.dat *.txt)',
|
||||
options=QtWidgets.QFileDialog.DontConfirmOverwrite)
|
||||
save_dialog = SaveDirectoryDialog(parent=self, caption='Save fit parameter', directory=str(self.path),
|
||||
filter='All files(*, *);;Text files(*.dat *.txt)')
|
||||
|
||||
if fname:
|
||||
self.management.save_fit_parameter(fname, fit_sets=fit_sets)
|
||||
mode = save_dialog.exec()
|
||||
if mode == QtWidgets.QDialog.Accepted:
|
||||
savefile = save_dialog.save_file()
|
||||
if savefile:
|
||||
self.management.save_fit_parameter(savefile, fit_sets=fit_sets)
|
||||
|
||||
@QtCore.pyqtSlot(name='on_actionExportGraphic_triggered')
|
||||
def export_graphic(self):
|
||||
@ -988,14 +988,19 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
dialog.show()
|
||||
|
||||
def close(self):
|
||||
write_state({'recent_path': str(self.path)})
|
||||
write_state({'History': {'recent path': str(self.path)}})
|
||||
|
||||
super().close()
|
||||
|
||||
def read_state(self):
|
||||
opts = read_state()
|
||||
self.path = pathlib.Path(opts.get('recent_path', Path.home()))
|
||||
self.path = pathlib.Path(opts['History'].get('recent path', Path.home()))
|
||||
|
||||
@QtCore.pyqtSlot(name='on_actionBugs_triggered')
|
||||
def report_bug(self):
|
||||
open_bug_report()
|
||||
|
||||
@QtCore.pyqtSlot(name='on_actionUpdate_triggered')
|
||||
def look_for_update(self):
|
||||
w = UpdateDialog(parent=self)
|
||||
w.show()
|
||||
|
Reference in New Issue
Block a user