From a98f454942706d3d0bb12b3f2723d7d899822362 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Tue, 10 Jan 2023 18:40:57 +0100 Subject: [PATCH] added flag to FileDialog for open and save mode; fixes T251 --- src/gui_qt/graphs/graphwindow.py | 2 +- src/gui_qt/io/filedialog.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui_qt/graphs/graphwindow.py b/src/gui_qt/graphs/graphwindow.py index 65845bb..1ea3c4c 100644 --- a/src/gui_qt/graphs/graphwindow.py +++ b/src/gui_qt/graphs/graphwindow.py @@ -529,7 +529,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): if path is None: path = '' outfile = None - f = FileDialog(caption='Export graphic', directory=str(path), filter=filters) + f = FileDialog(caption='Export graphic', directory=str(path), filter=filters, mode='save') mode = f.exec() if mode == QtWidgets.QDialog.Accepted: outfile = f.save_file() diff --git a/src/gui_qt/io/filedialog.py b/src/gui_qt/io/filedialog.py index 424a542..8340e72 100644 --- a/src/gui_qt/io/filedialog.py +++ b/src/gui_qt/io/filedialog.py @@ -8,10 +8,11 @@ from ..Qt import QtWidgets, QtCore class FileDialog(QtWidgets.QFileDialog): last_path = None - def __init__(self, directory=None, caption=None, filter='', parent=None): + def __init__(self, directory=None, caption=None, filter='', mode='open', parent=None): super().__init__(parent=parent) self.setOption(QtWidgets.QFileDialog.DontUseNativeDialog, True) + self.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen if mode == 'open' else QtWidgets.QFileDialog.AcceptSave) self.setWindowTitle(caption) if directory: