def _open_file(self, item, val): if item.childCount() == 0 and not item.isFolder: fileName = os.path.join(item.path, str(item.text(val))) if (manage_files.get_file_extension(fileName)) in ('.jpg', '.png'): self._main.open_image(fileName) elif (manage_files.get_file_extension(fileName)).endswith('.ui'): self.w = uic.loadUi(fileName) self.w.show() else: item = self._get_project_root() self._main.open_document(fileName, self.projects[item])
def _show_follow_mode(self): if type(self._tabs.obtain_editor()) is not Editor: return if self._tabs2.isVisible() and not self._follow_mode: self.show_split(self.orientation()) if self._follow_mode: self._follow_mode = False self._tabs2._close_tab(0) self._tabs2.hide() self._tabs2.setTabsClosable(True) self._tabs._follow_mode = False self._tabs2._follow_mode = False else: #check if is instance of Editor self._follow_mode = True self.setOrientation(Qt.Horizontal) editor = self._tabs.obtain_editor() name = str(self._tabs.tabText(self._tabs.currentIndex())) editor2 = factory_editor( manage_files.get_file_extension(name)[1:], self._tabs2) editor2.setPlainText(editor.get_text()) editor2.setReadOnly(True) self._tabs2.add_tab(editor2, name) if editor.textModified: self._tabs2.mark_as_changed(True) self._tabs._follow_mode = True self._tabs2._follow_mode = True self._tabs2.show() editor2.verticalScrollBar().setRange( editor.sidebarWidget.highest_line - 2, 0) self._tabs2.setTabsClosable(False) self.setSizes([1, 1])
def _show_follow_mode(self): if type(self._tabs.obtain_editor()) is not Editor: return if self._tabs2.isVisible() and not self._follow_mode: self.show_split(self.orientation()) if self._follow_mode: self._follow_mode = False self._tabs2._close_tab(0) self._tabs2.hide() self._tabs2.setTabsClosable(True) self._tabs._follow_mode = False self._tabs2._follow_mode = False else: #check if is instance of Editor self._follow_mode = True self.setOrientation(Qt.Horizontal) editor = self._tabs.obtain_editor() name = str(self._tabs.tabText(self._tabs.currentIndex())) editor2 = factory_editor( manage_files.get_file_extension(name)[1:], self._tabs2) editor2.setPlainText(editor.get_text()) editor2.setReadOnly(True) self._tabs2.add_tab(editor2, name) if editor.textModified: self._tabs2.mark_as_changed(True) self._tabs._follow_mode = True self._tabs2._follow_mode = True self._tabs2.show() editor2.verticalScrollBar().setRange(editor.sidebarWidget.highest_line - 2, 0) self._tabs2.setTabsClosable(False) self.setSizes([1, 1])
def _refresh_symbols(self): editor = self._central.obtain_editor() if editor: #we only show symbols for Python! if manage_files.get_file_extension(editor.path) == ".py" and \ editor.get_project_folder() is not None: path = os.path.dirname(editor.path) fileName = os.path.basename(editor.path) self._properties._treeSymbols.refresh(path, fileName)
def get_file_extension(self, fileName): return manage_files.get_file_extension(fileName)[1:]
def lang(self): if self.mainFile != '': return manage_files.get_file_extension(self.mainFile)[1:]
def obtain_icon(self, fileName): return QIcon(self.images.get(manage_files.get_file_extension(fileName), resources.images['tree-generic']))