mirror of
https://github.com/fergalmoran/picard.git
synced 2026-02-14 11:43:59 +00:00
QFileDialog: use keyword arguments
Note: I dropped caption="" in most places, because that's the default, though I think we should set one in most cases, this will need further work.
This commit is contained in:
@@ -222,7 +222,12 @@ class ScriptSerializer():
|
||||
|
||||
dialog_title = _("Export Script File")
|
||||
dialog_file_types = self._get_dialog_filetypes()
|
||||
filename, file_type = QtWidgets.QFileDialog.getSaveFileName(parent, dialog_title, default_path, dialog_file_types)
|
||||
filename, file_type = QtWidgets.QFileDialog.getSaveFileName(
|
||||
parent=parent,
|
||||
caption=dialog_title,
|
||||
directory=default_path,
|
||||
filter=dialog_file_types,
|
||||
)
|
||||
if not filename:
|
||||
return False
|
||||
# Fix issue where Qt may set the extension twice
|
||||
@@ -259,7 +264,12 @@ class ScriptSerializer():
|
||||
dialog_title = _("Import Script File")
|
||||
dialog_file_types = cls._get_dialog_filetypes()
|
||||
default_script_directory = os.path.normpath(QtCore.QStandardPaths.writableLocation(QtCore.QStandardPaths.StandardLocation.DocumentsLocation))
|
||||
filename, file_type = QtWidgets.QFileDialog.getOpenFileName(parent, dialog_title, default_script_directory, dialog_file_types)
|
||||
filename, file_type = QtWidgets.QFileDialog.getOpenFileName(
|
||||
parent=parent,
|
||||
caption=dialog_title,
|
||||
directory=default_script_directory,
|
||||
filter=dialog_file_types,
|
||||
)
|
||||
if not filename:
|
||||
return None
|
||||
log.debug("Importing script file: %s", filename)
|
||||
|
||||
@@ -1201,7 +1201,7 @@ class Tagger(QtWidgets.QApplication):
|
||||
traceback=self._debug)
|
||||
|
||||
def lookup_discid_from_logfile(self):
|
||||
file_chooser = QtWidgets.QFileDialog(self.window)
|
||||
file_chooser = QtWidgets.QFileDialog(parent=self.window)
|
||||
file_chooser.setNameFilters([
|
||||
_("All supported log files") + " (*.log *.txt)",
|
||||
_("EAC / XLD / Whipper / fre:ac log files") + " (*.log)",
|
||||
|
||||
@@ -607,7 +607,7 @@ class CoverArtBox(QtWidgets.QGroupBox):
|
||||
return coverartimage
|
||||
|
||||
def choose_local_file(self):
|
||||
file_chooser = QtWidgets.QFileDialog(self)
|
||||
file_chooser = QtWidgets.QFileDialog(parent=self)
|
||||
extensions = ['*' + ext for ext in imageinfo.get_supported_extensions()]
|
||||
extensions.sort()
|
||||
file_chooser.setNameFilters([
|
||||
|
||||
@@ -276,9 +276,9 @@ class LogView(LogViewCommon):
|
||||
|
||||
def _save_log_as_do(self):
|
||||
path, ok = QtWidgets.QFileDialog.getSaveFileName(
|
||||
self,
|
||||
parent=self,
|
||||
caption=_("Save Log View to File"),
|
||||
options=QtWidgets.QFileDialog.Option.DontConfirmOverwrite
|
||||
options=QtWidgets.QFileDialog.Option.DontConfirmOverwrite,
|
||||
)
|
||||
if ok and path:
|
||||
if os.path.isfile(path):
|
||||
|
||||
@@ -847,7 +847,11 @@ class MainWindow(QtWidgets.QMainWindow, PreserveGeometry):
|
||||
extensions.sort()
|
||||
formats.insert(0, _("All supported formats") + " (%s)" % " ".join(extensions))
|
||||
formats.insert(1, _("All files") + " (*)")
|
||||
files, _filter = QtWidgets.QFileDialog.getOpenFileNames(self, "", current_directory, ";;".join(formats))
|
||||
files, _filter = QtWidgets.QFileDialog.getOpenFileNames(
|
||||
parent=self,
|
||||
directory=current_directory,
|
||||
filter=";;".join(formats),
|
||||
)
|
||||
if files:
|
||||
config = get_config()
|
||||
config.persist['current_directory'] = os.path.dirname(files[0])
|
||||
@@ -860,11 +864,17 @@ class MainWindow(QtWidgets.QMainWindow, PreserveGeometry):
|
||||
dir_list = []
|
||||
config = get_config()
|
||||
if not config.setting['allow_multi_dirs_selection']:
|
||||
directory = QtWidgets.QFileDialog.getExistingDirectory(self, "", current_directory)
|
||||
directory = QtWidgets.QFileDialog.getExistingDirectory(
|
||||
parent=self,
|
||||
directory=current_directory,
|
||||
)
|
||||
if directory:
|
||||
dir_list.append(directory)
|
||||
else:
|
||||
file_dialog = MultiDirsSelectDialog(parent=self, caption="", directory=current_directory)
|
||||
file_dialog = MultiDirsSelectDialog(
|
||||
parent=self,
|
||||
directory=current_directory,
|
||||
)
|
||||
if file_dialog.exec() == QtWidgets.QDialog.DialogCode.Accepted:
|
||||
dir_list = file_dialog.selectedFiles()
|
||||
|
||||
|
||||
@@ -120,7 +120,10 @@ class FingerprintingOptionsPage(OptionsPage):
|
||||
self._acoustid_fpcalc_check()
|
||||
|
||||
def acoustid_fpcalc_browse(self):
|
||||
path, _filter = QtWidgets.QFileDialog.getOpenFileName(self, "", self.ui.acoustid_fpcalc.text())
|
||||
path, _filter = QtWidgets.QFileDialog.getOpenFileName(
|
||||
parent=self,
|
||||
directory=self.ui.acoustid_fpcalc.text(),
|
||||
)
|
||||
if path:
|
||||
path = os.path.normpath(path)
|
||||
self.ui.acoustid_fpcalc.setText(path)
|
||||
|
||||
@@ -197,7 +197,10 @@ class InterfaceOptionsPage(OptionsPage):
|
||||
|
||||
def starting_directory_browse(self):
|
||||
item = self.ui.starting_directory_path
|
||||
path = QtWidgets.QFileDialog.getExistingDirectory(self, "", item.text())
|
||||
path = QtWidgets.QFileDialog.getExistingDirectory(
|
||||
parent=self,
|
||||
directory=item.text(),
|
||||
)
|
||||
if path:
|
||||
path = os.path.normpath(path)
|
||||
item.setText(path)
|
||||
|
||||
@@ -162,7 +162,10 @@ class InterfaceToolbarOptionsPage(OptionsPage):
|
||||
|
||||
def starting_directory_browse(self):
|
||||
item = self.ui.starting_directory_path
|
||||
path = QtWidgets.QFileDialog.getExistingDirectory(self, "", item.text())
|
||||
path = QtWidgets.QFileDialog.getExistingDirectory(
|
||||
parent=self,
|
||||
directory=item.text(),
|
||||
)
|
||||
if path:
|
||||
path = os.path.normpath(path)
|
||||
item.setText(path)
|
||||
|
||||
@@ -141,7 +141,10 @@ class MaintenanceOptionsPage(OptionsPage):
|
||||
dialog.exec()
|
||||
|
||||
def _dialog_autobackup_dir_browse(self):
|
||||
path = QtWidgets.QFileDialog.getExistingDirectory(self, "", self.get_current_autobackup_dir())
|
||||
path = QtWidgets.QFileDialog.getExistingDirectory(
|
||||
parent=self,
|
||||
directory=self.get_current_autobackup_dir(),
|
||||
)
|
||||
if path:
|
||||
self.set_current_autobackup_dir(path)
|
||||
|
||||
|
||||
@@ -660,10 +660,9 @@ class PluginsOptionsPage(OptionsPage):
|
||||
|
||||
def open_plugins(self):
|
||||
files, _filter = QtWidgets.QFileDialog.getOpenFileNames(
|
||||
self,
|
||||
"",
|
||||
QtCore.QDir.homePath(),
|
||||
"Picard plugin (*.py *.pyc *.zip)"
|
||||
parent=self,
|
||||
directory=QtCore.QDir.homePath(),
|
||||
filter="Picard plugin (*.py *.pyc *.zip)",
|
||||
)
|
||||
if files:
|
||||
for path in files:
|
||||
|
||||
@@ -280,7 +280,10 @@ class RenamingOptionsPage(OptionsPage):
|
||||
super().display_error(error)
|
||||
|
||||
def move_files_to_browse(self):
|
||||
path = QtWidgets.QFileDialog.getExistingDirectory(self, "", self.ui.move_files_to.text())
|
||||
path = QtWidgets.QFileDialog.getExistingDirectory(
|
||||
parent=self,
|
||||
directory=self.ui.move_files_to.text(),
|
||||
)
|
||||
if path:
|
||||
path = os.path.normpath(path)
|
||||
self.ui.move_files_to.setText(path)
|
||||
|
||||
Reference in New Issue
Block a user