1
0
forked from IPKM/nmreval

added flag to FileDialog for open and save mode; fixes T251

This commit is contained in:
Dominik Demuth 2023-01-10 18:40:57 +01:00
parent e306be3001
commit a98f454942
2 changed files with 3 additions and 2 deletions

View File

@ -529,7 +529,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
if path is None: if path is None:
path = '' path = ''
outfile = None 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() mode = f.exec()
if mode == QtWidgets.QDialog.Accepted: if mode == QtWidgets.QDialog.Accepted:
outfile = f.save_file() outfile = f.save_file()

View File

@ -8,10 +8,11 @@ from ..Qt import QtWidgets, QtCore
class FileDialog(QtWidgets.QFileDialog): class FileDialog(QtWidgets.QFileDialog):
last_path = None 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) super().__init__(parent=parent)
self.setOption(QtWidgets.QFileDialog.DontUseNativeDialog, True) self.setOption(QtWidgets.QFileDialog.DontUseNativeDialog, True)
self.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen if mode == 'open' else QtWidgets.QFileDialog.AcceptSave)
self.setWindowTitle(caption) self.setWindowTitle(caption)
if directory: if directory: