Skip to content

Commit

Permalink
Fix edit file and add applink not showing up for files
Browse files Browse the repository at this point in the history
  • Loading branch information
goszpeti committed Oct 6, 2024
1 parent d711e34 commit 56ecde0
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/conan_explorer/ui/views/package_explorer/package_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 56ecde0

Please sign in to comment.