142
142
self.dry_run = dry_run
143
143
self._app_runner = app_runner.ApplicationRunner(self.show_error)
144
144
self._custom_modeless_dialogs = {}
145
self._tools_linked_to_wt = False
145
146
# permitted values are None, local, remote
146
147
self.location_category = None
147
148
self.location_views = None
825
826
for prof in self._profiles:
826
827
for entry in prof.tools().root():
827
828
self._add_tool_entry_to_menu(entry, menu)
830
# Disable refresh on working tree visibility
831
if self._tools_linked_to_wt:
832
self._tools_linked_to_wt = False
833
trace.mutter("Disabling refresh on working tree visibility")
834
QtCore.QObject.disconnect(self._wt_browser,
835
QtCore.SIGNAL("visibilityChanged(bool)"),
836
self._refresh_tools_menu)
829
838
# TODO: Add Tools/Options if on Windows
830
839
if self.desktop_env.name() == 'windows':
831
840
footer_actions = [("action", self.ui.action_Preferences)]
833
842
footer_actions = None
834
843
self._refresh_dynamic_menu(self.ui.menu_Tools,
835
844
self._std_tool_menu_items, tool_appender, footer_actions)
836
self._toolbox.refresh()
845
self._toolbox.refresh(self._wt_browser.isVisible())
847
# Enable refresh on working tree visibility if tools linked to it
848
if self._toolbox.linked_to_wt and not self._tools_linked_to_wt:
849
trace.mutter("Enabling refresh on wt visibility - toolbox")
850
self._tools_linked_to_wt = True
851
QtCore.QObject.connect(self._wt_browser,
852
QtCore.SIGNAL("visibilityChanged(bool)"),
853
self._refresh_tools_menu)
838
855
def _add_tool_entry_to_menu(self, entry, menu):
839
856
if isinstance(entry, tools.Tool):
841
self._do_open_tool(entry)
843
action = menu.addAction(entry.title, open_callback)
844
tip = "(%s) %s" % (entry.type, entry.action)
845
action.setStatusTip(tip)
847
icon = kinds.icon_by_resource_path(entry.icon)
849
icon = kinds.icon_for_kind(entry.type)
857
if entry.applies_to_menu():
859
self._do_open_tool(entry)
861
action = menu.addAction(entry.title, open_callback)
862
tip = "(%s) %s" % (entry.type, entry.action)
863
action.setStatusTip(tip)
865
icon = kinds.icon_by_resource_path(entry.icon)
867
icon = kinds.icon_for_kind(entry.type)
851
869
elif isinstance(entry, tools.ToolFolder):
852
submenu = QtGui.QMenu(entry.title, menu)
854
self._add_tool_entry_to_menu(child, submenu)
855
menu.addMenu(submenu)
872
# if toolset depends on working tree then rebuild tools menu
873
# based on visibility of working tree browser
874
if entry.linked_to_wt() and not self._tools_linked_to_wt:
875
trace.mutter("Enabling refresh on wt visibility - menu")
876
self._tools_linked_to_wt = True
877
QtCore.QObject.connect(self._wt_browser,
878
QtCore.SIGNAL("visibilityChanged(bool)"),
879
self._refresh_tools_menu)
881
# build toolset based menu
882
if (not entry.linked_to_wt() or
883
(entry.linked_to_wt() and self._wt_browser.isVisible())) :
884
submenu = QtGui.QMenu(entry.title, menu)
886
self._add_tool_entry_to_menu(child, submenu)
887
menu.addMenu(submenu)
856
888
elif isinstance(entry, tools.ToolSeparator):
857
889
menu.addSeparator()
862
894
self.location_context)
863
895
self.open_web_browser(link)
898
# for wt linked items get items selected in working tree
899
if tool.linked_to_wt() and tool.uses_selected:
901
self._wt_browser._browser._tree_viewer.get_selection_items()
902
if len(selected_items) > 0:
903
paths = [item.path for item in selected_items]
904
self.location_context['selected'] = " ".join(paths)
865
905
args = mod_app_suite.command_to_args(tool.action,
866
906
self.location_context)
867
if tool.type == 'bzr':
907
if (tool.type == 'bzr') or (tool.type == 'bzrexec'):
868
908
# If the command looks like it's a GUI one,
869
909
# run it directly. Otherwise, run it via qrun
870
910
# making sure that we're passing --ui-mode.
871
911
if args[0][0] in ['q', 'g']:
872
912
args = self._get_bzr_executable() + args
913
elif tool.type == 'bzrexec':
914
args = self._get_bzr_executable() + \
915
['qrun', '--ui-mode', '--execute', '--'] + args
874
args = self._get_bzr_executable() + ['qrun', '--ui-mode', '--'] + args
917
args = self._get_bzr_executable() + \
918
['qrun', '--ui-mode', '--'] + args
875
919
self.run_app(args)
877
921
## Show message helpers ##