From 84fcc91023015e4ab19168454522f198df201b22 Mon Sep 17 00:00:00 2001 From: "A. Reit" Date: Thu, 2 Nov 2023 08:09:55 +0100 Subject: [PATCH] spyder: pyside: Fix context menu actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See commit “pyside: Fix preferences modified by checkboxes” for details. --- spyder/plugins/explorer/widgets/explorer.py | 26 ++++++++++----------- spyder/widgets/collectionseditor.py | 2 ++ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/spyder/plugins/explorer/widgets/explorer.py b/spyder/plugins/explorer/widgets/explorer.py index 67243d0c651..a0bad50c0e0 100644 --- a/spyder/plugins/explorer/widgets/explorer.py +++ b/spyder/plugins/explorer/widgets/explorer.py @@ -1020,7 +1020,7 @@ def handle_reset(): @Slot() def open(self, fnames=None): """Open files with the appropriate application""" - if fnames is None: + if fnames is None or isinstance(fnames, bool): fnames = self.get_selected_filenames() for fname in fnames: if osp.isfile(fname) and encoding.is_text_file(fname): @@ -1046,7 +1046,7 @@ def open_association(self, app_path): @Slot() def open_external(self, fnames=None): """Open files with default application""" - if fnames is None: + if fnames is None or isinstance(fnames, bool): fnames = self.get_selected_filenames() for fname in fnames: self.open_outside_spyder([fname]) @@ -1116,7 +1116,7 @@ def delete_file(self, fname, multiple, yes_to_all): @Slot() def delete(self, fnames=None): """Delete files""" - if fnames is None: + if fnames is None or isinstance(fnames, bool): fnames = self.get_selected_filenames() multiple = len(fnames) > 1 yes_to_all = None @@ -1170,14 +1170,14 @@ def rename_file(self, fname): @Slot() def show_in_external_file_explorer(self, fnames=None): """Show file in external file explorer""" - if fnames is None: + if fnames is None or isinstance(fnames, bool): fnames = self.get_selected_filenames() show_in_external_file_explorer(fnames) @Slot() def rename(self, fnames=None): """Rename files""" - if fnames is None: + if fnames is None or isinstance(fnames, bool): fnames = self.get_selected_filenames() if not isinstance(fnames, (tuple, list)): fnames = [fnames] @@ -1261,7 +1261,7 @@ def get_selected_dir(self): def new_folder(self, basedir=None): """New folder.""" - if basedir is None: + if basedir is None or isinstance(basedir, bool): basedir = self.get_selected_dir() title = _('New folder') @@ -1293,7 +1293,7 @@ def create_new_file(self, current_path, title, filters, create_func): def new_file(self, basedir=None): """New file""" - if basedir is None: + if basedir is None or isinstance(basedir, bool): basedir = self.get_selected_dir() title = _("New file") @@ -1313,7 +1313,7 @@ def create_func(fname): @Slot() def run(self, fnames=None): """Run Python scripts""" - if fnames is None: + if fnames is None or isinstance(fnames, bool): fnames = self.get_selected_filenames() for fname in fnames: self.sig_run_requested.emit(fname) @@ -1367,7 +1367,7 @@ def copy_relative_path(self): @Slot() def copy_file_clipboard(self, fnames=None): """Copy file(s)/folders(s) to clipboard.""" - if fnames is None: + if fnames is None or isinstance(fnames, bool): fnames = self.get_selected_filenames() if not isinstance(fnames, (tuple, list)): fnames = [fnames] @@ -1385,7 +1385,7 @@ def copy_file_clipboard(self, fnames=None): @Slot() def save_file_clipboard(self, fnames=None): """Paste file from clipboard into file/project explorer directory.""" - if fnames is None: + if fnames is None or isinstance(fnames, bool): fnames = self.get_selected_filenames() if not isinstance(fnames, (tuple, list)): fnames = [fnames] @@ -1472,7 +1472,7 @@ def save_file_clipboard(self, fnames=None): @Slot() def open_interpreter(self, fnames=None): """Open interpreter""" - if fnames is None: + if fnames is None or isinstance(fnames, bool): fnames = self.get_selected_filenames() for path in sorted(fnames): self.sig_open_interpreter_requested.emit(path) @@ -1709,7 +1709,7 @@ def convert_notebooks(self): def new_package(self, basedir=None): """New package""" - if basedir is None: + if basedir is None or isinstance(basedir, None): basedir = self.get_selected_dir() title = _('New package') @@ -1720,7 +1720,7 @@ def new_package(self, basedir=None): def new_module(self, basedir=None): """New module""" - if basedir is None: + if basedir is None or isinstance(basedir, bool): basedir = self.get_selected_dir() title = _("New module") diff --git a/spyder/widgets/collectionseditor.py b/spyder/widgets/collectionseditor.py index 5d28ce866d5..dc4970fac1e 100644 --- a/spyder/widgets/collectionseditor.py +++ b/spyder/widgets/collectionseditor.py @@ -1081,6 +1081,8 @@ def duplicate_item(self): @Slot() def rename_item(self, new_name=None): """Rename item""" + if isinstance(new_name, bool): + new_name = None self.copy_item(erase_original=True, new_name=new_name) @Slot()