diff -r 7b8a21fd2d58 -r e1e1d6e317c7 src/eric7/EricWidgets/EricFileDialog.py --- a/src/eric7/EricWidgets/EricFileDialog.py Sun Nov 03 17:50:34 2024 +0100 +++ b/src/eric7/EricWidgets/EricFileDialog.py Sun Nov 03 18:12:28 2024 +0100 @@ -9,6 +9,7 @@ import pathlib +from PyQt6.QtCore import QCoreApplication from PyQt6.QtWidgets import QFileDialog from eric7.SystemUtilities import OSUtilities @@ -72,6 +73,9 @@ @return name of file to be opened @rtype str """ + if parent is None: + parent = QCoreApplication.instance().getMainWindow() + return getOpenFileNameAndFilter( parent, caption, directory, filterStr, initialFilter, options )[0] @@ -99,6 +103,9 @@ @return name of file to be opened and selected filter @rtype tuple of (str, str) """ + if parent is None: + parent = QCoreApplication.instance().getMainWindow() + if options is None: options = QFileDialog.Option(0) newfilter = __reorderFilter(filterStr, initialFilter) @@ -128,6 +135,9 @@ @return list of file names to be opened @rtype list of str """ + if parent is None: + parent = QCoreApplication.instance().getMainWindow() + return getOpenFileNamesAndFilter( parent, caption, directory, filterStr, initialFilter, options )[0] @@ -155,6 +165,9 @@ @return list of file names to be opened and selected filter @rtype tuple of (list of str, str) """ + if parent is None: + parent = QCoreApplication.instance().getMainWindow() + if options is None: options = QFileDialog.Option(0) newfilter = __reorderFilter(filterStr, initialFilter) @@ -184,6 +197,9 @@ """ from .EricDirFileDialog import EricDirFileDialog + if parent is None: + parent = QCoreApplication.instance().getMainWindow() + return EricDirFileDialog.getOpenFileAndDirNames( parent, caption, directory, filterStr, options ) @@ -210,6 +226,9 @@ @return name of file to be saved @rtype str """ + if parent is None: + parent = QCoreApplication.instance().getMainWindow() + return getSaveFileNameAndFilter( parent, caption, directory, filterStr, initialFilter, options )[0] @@ -237,6 +256,9 @@ @return name of file to be saved and selected filte @rtype tuple of (str, str) """ + if parent is None: + parent = QCoreApplication.instance().getMainWindow() + if options is None: options = QFileDialog.Option(0) newfilter = __reorderFilter(filterStr, initialFilter) @@ -263,6 +285,9 @@ @return name of selected directory @rtype str """ + if parent is None: + parent = QCoreApplication.instance().getMainWindow() + if options is None: options = QFileDialog.Option(0) return QFileDialog.getExistingDirectory(parent, caption, directory, options) @@ -294,6 +319,9 @@ @return path of file to be opened @rtype pathlib.Path """ + if parent is None: + parent = QCoreApplication.instance().getMainWindow() + return getOpenFilePathAndFilter( parent, caption, directory, filterStr, initialFilter, options )[0] @@ -321,6 +349,9 @@ @return path of file to be opened and selected filter @rtype tuple of (pathlib.Path, str) """ + if parent is None: + parent = QCoreApplication.instance().getMainWindow() + if options is None: options = QFileDialog.Option(0) newfilter = __reorderFilter(filterStr, initialFilter) @@ -351,6 +382,9 @@ @return list of file paths to be opened @rtype list of pathlib.Path """ + if parent is None: + parent = QCoreApplication.instance().getMainWindow() + return getOpenFilPathsAndFilter( parent, caption, directory, filterStr, initialFilter, options )[0] @@ -378,6 +412,9 @@ @return list of file paths to be opened and selected filter @rtype tuple of (list of pathlib.Path, str) """ + if parent is None: + parent = QCoreApplication.instance().getMainWindow() + if options is None: options = QFileDialog.Option(0) newfilter = __reorderFilter(filterStr, initialFilter) @@ -408,6 +445,9 @@ """ from .EricDirFileDialog import EricDirFileDialog + if parent is None: + parent = QCoreApplication.instance().getMainWindow() + return EricDirFileDialog.getOpenFileAndDirPaths( parent, caption, directory, filterStr, options ) @@ -434,6 +474,9 @@ @return path of file to be saved @rtype pathlib.Path """ + if parent is None: + parent = QCoreApplication.instance().getMainWindow() + return getSaveFilePathAndFilter( parent, caption, str(directory), filterStr, initialFilter, options )[0] @@ -461,6 +504,9 @@ @return path of file to be saved and selected filte @rtype tuple of (pathlib.Path, str) """ + if parent is None: + parent = QCoreApplication.instance().getMainWindow() + if options is None: options = QFileDialog.Option(0) newfilter = __reorderFilter(filterStr, initialFilter) @@ -488,6 +534,9 @@ @return path of selected directory @rtype pathlib.Path """ + if parent is None: + parent = QCoreApplication.instance().getMainWindow() + if options is None: options = QFileDialog.Option(0) dirname = QFileDialog.getExistingDirectory(parent, caption, str(directory), options)