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:
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()

View File

@ -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: