From 34ebaf34bd8732afdadf3e4fe1c23478bbdcbd9d Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Thu, 12 Jan 2023 20:11:20 +0100 Subject: [PATCH] No overwrite confirm for saving fit parameter needed --- src/gui_qt/io/filedialog.py | 12 ++++++------ src/gui_qt/main/mainwindow.py | 8 +++++--- src/gui_qt/main/management.py | 9 ++++----- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/gui_qt/io/filedialog.py b/src/gui_qt/io/filedialog.py index 8340e72..6134d00 100644 --- a/src/gui_qt/io/filedialog.py +++ b/src/gui_qt/io/filedialog.py @@ -50,12 +50,12 @@ class FileDialog(QtWidgets.QFileDialog): def is_valid(filename: str): return True - bad_character = r'/*<>\|:"' - for c in bad_character: - if c in filename: - return False - - return True + # bad_character = r'/*<>\|:"' + # for c in bad_character: + # if c in filename: + # return False + # + # return True def close(self): FileDialog.last_path = self.directory() diff --git a/src/gui_qt/main/mainwindow.py b/src/gui_qt/main/mainwindow.py index 19877d5..a4fa995 100644 --- a/src/gui_qt/main/mainwindow.py +++ b/src/gui_qt/main/mainwindow.py @@ -18,7 +18,7 @@ from ..fit.result import QFitResult from ..graphs.graphwindow import QGraphWindow from ..graphs.movedialog import QMover from ..io.fcbatchreader import QFCReader -from ..io.filedialog import OpenFileDialog, SaveDirectoryDialog +from ..io.filedialog import * from ..lib import get_icon, make_action_icons from ..lib.pg_objects import RegionItem from ..math.evaluation import QEvalDialog @@ -277,8 +277,10 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): @QtCore.pyqtSlot() @QtCore.pyqtSlot(list) def save_fit_parameter(self, fit_sets: list[str] = None): - save_dialog = SaveDirectoryDialog(parent=self, caption='Save fit parameter', directory=str(self.path), - filter='All files(*, *);;Text files(*.dat *.txt)') + save_dialog = FileDialog(parent=self, caption='Save fit parameter', directory=str(self.path), + filter='All files(*, *);;Text files(*.dat *.txt)') + save_dialog.setAcceptMode(FileDialog.AcceptSave) + save_dialog.setOption(QtWidgets.QFileDialog.DontConfirmOverwrite, True) mode = save_dialog.exec() if mode == QtWidgets.QDialog.Accepted: diff --git a/src/gui_qt/main/management.py b/src/gui_qt/main/management.py index 8c4c8b5..94657b9 100644 --- a/src/gui_qt/main/management.py +++ b/src/gui_qt/main/management.py @@ -3,7 +3,6 @@ from __future__ import annotations import pathlib import re import uuid -from typing import List from nmreval.fit import data as fit_d from nmreval.fit.model import Model @@ -154,7 +153,7 @@ class UpperManagement(QtCore.QObject): return _id - def load_files(self, fname: List[str], new_plot: str = None): + def load_files(self, fname: list[str], new_plot: str = None): if self._filereader is None: self._filereader = QFileReader(manager=self) ret_dic = self._filereader.readfiles(fname) @@ -546,7 +545,7 @@ class UpperManagement(QtCore.QObject): self.newData.emit(f_id_list, gid) - def make_fit_parameter(self, fit_sets: List[str | FitResult], graph_id: str = None): + def make_fit_parameter(self, fit_sets: list[str | FitResult], graph_id: str = None): fit_dict = self._collect_fit_parameter(fit_sets) if fit_dict: @@ -560,7 +559,7 @@ class UpperManagement(QtCore.QObject): self.newData.emit(p_id_list, graph_id) - def save_fit_parameter(self, fname: str | pathlib.Path, fit_sets: List[str] = None): + def save_fit_parameter(self, fname: str | pathlib.Path, fit_sets: list[str] = None): if fit_sets is None: fit_sets = [s for (s, _) in self.active_sets] @@ -571,7 +570,7 @@ class UpperManagement(QtCore.QObject): data.data.save_parameter(fname) - def _collect_fit_parameter(self, fit_sets: List[str | FitResult]) -> dict: + def _collect_fit_parameter(self, fit_sets: list[str | FitResult]) -> dict: fit_dict = {} for set_id in fit_sets: