From 56ecde0c7cf10ebdd55ab7d76ee890c1d5339dec Mon Sep 17 00:00:00 2001 From: goszpeti Date: Sun, 6 Oct 2024 12:11:51 +0200 Subject: [PATCH] Fix edit file and add applink not showing up for files --- .../package_explorer/package_explorer.py | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/conan_explorer/ui/views/package_explorer/package_explorer.py b/src/conan_explorer/ui/views/package_explorer/package_explorer.py index 2da06a24..72ab5cf4 100644 --- a/src/conan_explorer/ui/views/package_explorer/package_explorer.py +++ b/src/conan_explorer/ui/views/package_explorer/package_explorer.py @@ -409,37 +409,39 @@ def on_file_context_menu_requested(self, position): """Disable some context menu items depending on context""" if not self._file_cntx_menu: return - self._add_link_action.setVisible(True) - self._edit_file_action.setVisible(True) - self._rename_action.setVisible(True) + + # enable all, then disable based on conditions + self._enable_all_variable_file_context_menu_entries() tab_idx = self._ui.package_tab_widget.currentIndex() # Add Link only works on actual packages pkg_type = self._pkg_tabs_ctrl[tab_idx].get_conan_pkg_type() if pkg_type == PkgSelectionType.export: self._add_link_action.setVisible(False) - else: - self._add_link_action.setVisible(True) # multiselect options paths = self._pkg_tabs_ctrl[tab_idx].get_selected_pkg_paths() - if len(paths) > 1: # no multiselect + if len(paths) > 1: # multiselect self._add_link_action.setVisible(False) self._edit_file_action.setVisible(False) self._rename_action.setVisible(False) self._open_fm_action.setVisible(False) self._copy_as_path_action.setVisible(False) self._open_terminal_action.setVisible(False) - elif os.path.exists(paths[0]): + elif os.path.isdir(paths[0]): # disable unappropriate actions for folders self._add_link_action.setVisible(False) self._edit_file_action.setVisible(False) - self._rename_action.setVisible(True) - self._open_fm_action.setVisible(True) - self._copy_as_path_action.setVisible(True) - self._open_terminal_action.setVisible(True) self._file_cntx_menu.exec(self._ui.package_file_view.mapToGlobal(position)) + def _enable_all_variable_file_context_menu_entries(self): + self._add_link_action.setVisible(True) + self._edit_file_action.setVisible(True) + self._rename_action.setVisible(True) + self._open_fm_action.setVisible(True) + self._copy_as_path_action.setVisible(True) + self._open_terminal_action.setVisible(True) + def select_local_package_from_ref(self, conan_ref: str): return self._pkg_sel_ctrl.select_local_package_from_ref(conan_ref)