def apply_preferences(self): new_patterns = ';'.join(utils.get_ignored_patterns()) if self._last_ignore_patterns != new_patterns: self._last_ignore_patterns = new_patterns self.view.clear_ignore_patterns() self.view.add_ignore_patterns(self.get_ignored_patterns()) self.view.set_root_path(api.project.get_current_project()) self.view.context_menu.update_show_in_explorer_action() self._tab_bar_action_show_in_explorer.setText( _('Show in %s') % FileSystemContextMenu.get_file_explorer_name()) self._update_workspaces_menu() self.action_goto_anything.setShortcut(shortcuts.get( 'Goto anything', _('Goto anything'), 'Ctrl+P')) self.action_goto_symbol.setShortcut(shortcuts.get( 'Goto symbol', _('Goto symbol'), 'Ctrl+R')) self.action_goto_symbol_in_project.setShortcut(shortcuts.get( 'Goto symbol in project', _('Goto symbol in project'), 'Ctrl+Shift+R')) self.action_goto_line.setShortcut(shortcuts.get( 'Goto line', _('Goto line'), 'Ctrl+G')) self._update_templates_menu() menu = api.window.get_menu(_('&Goto')) for action in menu.actions(): action.setEnabled(settings.indexing_enabled()) tab = api.editor.get_current_editor() self.action_goto_line.setEnabled(tab is not None) if self.main_window.app.flg_force_indexing: self._reindex_all_projects() if not settings.indexing_enabled(): for indexor in self._indexors: indexor.cancel()
def apply_preferences(self): new_patterns = ';'.join(utils.get_ignored_patterns()) if self._last_ignore_patterns != new_patterns: self._last_ignore_patterns = new_patterns self.view.clear_ignore_patterns() self.view.add_ignore_patterns(self.get_ignored_patterns()) self.view.set_root_path(api.project.get_current_project()) self.view.context_menu.update_show_in_explorer_action() self._tab_bar_action_show_in_explorer.setText( _('Show in %s') % FileSystemContextMenu.get_file_explorer_name()) self._update_workspaces_menu() self.action_goto_file.setShortcut( shortcuts.get('Goto file', _('Goto file'), 'Ctrl+T')) self.action_goto_symbol.setShortcut( shortcuts.get('Goto symbol', _('Goto symbol'), 'Ctrl+R')) self.action_goto_symbol_in_project.setShortcut( shortcuts.get('Goto symbol in project', _('Goto symbol in project'), 'Ctrl+Shift+R')) self.action_goto_line.setShortcut( shortcuts.get('Goto line', _('Goto line'), 'Ctrl+G')) self._update_templates_menu() menu = api.window.get_menu(_('&Goto')) for action in menu.actions(): action.setEnabled(settings.indexing_enabled()) tab = api.editor.get_current_editor() self.action_goto_line.setEnabled(tab is not None) if self.main_window.app.flg_force_indexing: self._reindex_all_projects() if not settings.indexing_enabled(): for indexor in self._indexors: indexor.cancel()
def _setup_filesystem_treeview(self): self.view = FileSystemTreeView(self._widget) self.view.setMinimumWidth(200) self._last_ignore_patterns = ';'.join(utils.get_ignored_patterns()) self.view.add_ignore_patterns(self.get_ignored_patterns()) self.view.file_created.connect(self._on_file_created) self.view.files_deleted.connect(self._on_files_deleted) self.view.files_renamed.connect(self._on_files_renamed) self.main_window.document_saved.connect(self._on_file_saved) self.view.set_icon_provider(FileIconProvider()) context_menu = FileSystemContextMenu() self.view.set_context_menu(context_menu) self.templates_menu = context_menu.menu_new.addSeparator() self.templates_menu = context_menu.menu_new.addMenu(_('Templates')) self.templates_menu.menuAction().setIcon( QtGui.QIcon.fromTheme('folder-templates')) self._update_templates_menu() self.view.activated.connect(self._on_file_activated) self.action_mark_as_ignored = QtWidgets.QAction( _('Mark as ignored'), self.view) self.action_mark_as_ignored.triggered.connect(self._on_mark_as_ignored) self.action_mark_as_ignored.setIcon( QtGui.QIcon.fromTheme('emblem-unreadable')) self.view.context_menu.insertAction( self.view.context_menu.action_show_in_explorer, self.action_mark_as_ignored) self.view.context_menu.insertSeparator( self.view.context_menu.action_show_in_explorer) self.action_show_in_terminal = QtWidgets.QAction( QtGui.QIcon.fromTheme('utilities-terminal'), _('Open in terminal'), self.view) self.action_show_in_terminal.triggered.connect( self._on_show_in_terminal_triggered) self.view.context_menu.addAction(self.action_show_in_terminal) self.action_open_in_browser = QtWidgets.QAction( QtGui.QIcon.fromTheme('applications-internet'), _('Open in web browser'), self.view) self.action_open_in_browser.triggered.connect( self._on_action_open_in_browser_triggered) self.view.context_menu.addAction(self.action_open_in_browser) insert_pt = self.view.context_menu.menu_new.menuAction() action = QtWidgets.QAction(_('Execute file'), self.main_window) action.setToolTip(_('Run executable')) action.setIcon(api.special_icons.run_icon()) action.triggered.connect(self._execute_file) self.action_exec_file = action self.view.context_menu.insertAction(insert_pt, action) action = QtWidgets.QAction(self.main_window) action.setSeparator(True) self.view.context_menu.insertAction(insert_pt, action) self.view.about_to_show_context_menu.connect( self._on_about_to_show_context_menu)
def _setup_tab_bar_context_menu(self, window): text = _('Show in %s') % FileSystemContextMenu.get_file_explorer_name() action = QtWidgets.QAction(text, window) action.setToolTip(text) action.setIcon(QtGui.QIcon.fromTheme('system-file-manager')) action.triggered.connect(self._on_show_in_explorer_triggered) api.window.add_tab_widget_context_menu_action(action) self._tab_bar_action_show_in_explorer = action
def test_fs_treeview(): tv = FileSystemTreeView() tv.set_context_menu(FileSystemContextMenu()) tv.set_root_path(__file__) tv.show() QTest.qWait(500) tv.close() del tv
def apply_preferences(self): """ Apply preferences on all open windows """ if settings.dark_theme(): self._qapp.setStyleSheet(load_stylesheet_pyqt5()) else: self._qapp.setStyleSheet('') if self._args.dev: self._qapp.setStyleSheet( self._qapp.styleSheet() + '\nQToolBar{background-color: #80AA80;color: white;}') self.tray_icon.setVisible(settings.show_tray_icon()) mime_types.load() icons.init() FileSystemContextMenu.set_file_explorer_command( settings.file_manager_cmd()) for w in self.editor_windows: w.apply_preferences() self.flg_force_indexing = False
def apply_preferences(self): """ Apply preferences on all open windows """ if settings.dark_theme(): self._qapp.setStyleSheet(load_stylesheet_pyqt5()) else: self._qapp.setStyleSheet('') if os.environ.get('HACKEDIT_DEV_MODE') is not None: self._qapp.setStyleSheet( self._qapp.styleSheet() + '\nQToolBar{background-color: #AAAA80;color: white;}') self.tray_icon.setVisible(settings.show_tray_icon()) mime_types.load() icons.init() FileSystemContextMenu.set_file_explorer_command( settings.file_manager_cmd()) for w in self.editor_windows: w.apply_preferences() self.flg_force_indexing = False
def __init__(self, parent, ide, path, dock_widget): super(FolderBrowser, self).__init__(parent) self.main_window = parent self._path = path self._ide = ide self._dock_widget = dock_widget self.clear_ignore_patterns() self.add_ignore_patterns(ide.ignore_patterns) self.set_root_path(os.path.normpath(path)) self.set_context_menu(FileSystemContextMenu()) self._watcher = QFileSystemWatcher() self._watcher.addPath(path) self._watcher.fileChanged.connect(self._index_files) self._watcher.directoryChanged.connect(self._index_files) self._indexing = False self._file_list = [] self._index_files()
def __init__(self, parent, ide, path, dock_widget): super(FolderBrowser, self).__init__(parent) self.main_window = parent self._path = path self._ide = ide self._dock_widget = dock_widget self._dock_widget._gitignore_checkbox.stateChanged.connect( self._toggle_gitignore) self._set_ignore_patterns() self.set_root_path(os.path.normpath(path)) self.set_context_menu(FileSystemContextMenu(self.main_window)) self._watcher = QFileSystemWatcher() self._watcher.addPath(path) self._watcher.fileChanged.connect(self._on_file_changed) self._watcher.directoryChanged.connect(self._on_folder_changed) self._indexing = False self._file_list = [] self._active = True self._timer = None self._index_files()
def restore_defaults(self): # user interface settings.set_widescreen_layout(False) settings.set_dark_theme(False) settings.set_use_system_icons(True if system.LINUX else False) settings.set_toolbar_icon_size(22) settings.set_icon_theme(icons.ORIGINAL_THEME_NAME if not system.LINUX else 'default') # system tools FileSystemContextMenu._command = FileSystemContextMenu._explorer = None settings.set_file_manager_cmd( FileSystemContextMenu.get_file_explorer_command()) settings.set_cmd_open_folder_in_terminal( system.get_cmd_open_folder_in_terminal()) settings.set_cmd_run_command_in_terminal( system.get_cmd_run_command_in_terminal()) settings.set_use_default_browser(True) settings.set_custom_browser_command('') settings.set_show_tray_icon(True) gettext.set_locale('default') # environment variables environ.restore()
""" This example show you how to use the FileSystemTreeView (we show the content of test_dir). """ import logging import os import sys from pyqode.core.widgets import FileSystemTreeView, FileSystemContextMenu from pyqode.qt import QtWidgets logging.basicConfig(level=logging.DEBUG) if __name__ == '__main__': def _on_tv_activated(index): print(tv.filePath(index)) print(tv.fileInfo(index)) app = QtWidgets.QApplication(sys.argv) tv = FileSystemTreeView() tv.set_context_menu(FileSystemContextMenu()) tv.activated.connect(_on_tv_activated) path = os.path.join(os.getcwd(), 'test_dir') print('watching: %s' % path) tv.set_root_path(path) tv.show() app.exec_()
def file_manager_cmd(): try: default = FileSystemContextMenu.get_file_explorer_command() except Exception: default = '' return _SETTINGS.value('env/file_manager_command', default)
def _on_show_in_explorer_triggered(): path = api.window.get_tab_under_context_menu().file.path FileSystemContextMenu.show_in_explorer( path, api.window.get_main_window())
def _on_show_in_explorer_triggered(): path = api.window.get_tab_under_context_menu().file.path FileSystemContextMenu.show_in_explorer(path, api.window.get_main_window())