forked from IPKM/nmreval
added flag to FileDialog for open and save mode; fixes T251
This commit is contained in:
parent
e306be3001
commit
a98f454942
@ -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()
|
||||||
|
@ -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:
|
||||||
|
Loading…
Reference in New Issue
Block a user