def expand_tab_name(self, title): """Expand the tab title to differentiate files with the same name. The way it is currently implemented, it will only change the first conflicting title passed in, because it only searches until the new title isn't in the tab titles. """ if title == 'New Document': return elif title not in self.titles: self.titles.append(title) return indexes = [i for i in range(self.count()) if type(self.widget(i)) is editor.Editor and self.tabText(i) == title and self.widget(i).ID] # self.widget.ID returns the basename self.dontLoopInExpandTitle = True for i in indexes: newName = file_manager.create_path( file_manager.get_basename( file_manager.get_folder(self.widget(i).ID)), title) while newName in self.titles: # Keep prepending the folder name onto the title until it # does not conflict. path = self.widget(i).ID tempDir = path[:path.rfind(newName)] newName = file_manager.create_path( file_manager.get_basename( file_manager.get_folder(tempDir)), '..', title) self.titles.append(newName) self.setTabText(i, newName) self.dontLoopInExpandTitle = False
def expand_tab_name(self, title): title = unicode(title) if title == 'New Document': return elif title not in self.titles: self.titles.append(title) return indexes = [i for i in xrange(self.count()) if type(self.widget(i)) is editor.Editor and \ self.tabText(i) == title and \ self.widget(i).ID] self.dontLoopInExpandTitle = True for i in indexes: newName = file_manager.create_path( file_manager.get_basename( file_manager.get_folder(self.widget(i).ID)), title) while newName in self.titles: path = self.widget(i).ID tempDir = path[:path.rfind(newName)] newName = file_manager.create_path( file_manager.get_basename( file_manager.get_folder(tempDir)), '..', title) self.titles.append(newName) self.setTabText(i, newName) self.dontLoopInExpandTitle = False
def on_wizard_finish(self, wizard): global PROJECT_TYPE ids = wizard.pageIds() # Manipulate default data for NINJA-IDE projects page = wizard.page(ids[2]) place = str(page.txtPlace.text()) if place == '': QMessageBox.critical(self, 'Incorrect Location', 'The project couldn\'t be create') return folder = str(page.txtFolder.text()) path = file_manager.create_path(place, folder) if not file_manager.folder_exists(path): file_manager.create_folder(path) project = {} name = unicode(page.txtName.text()) project['name'] = name project['project-type'] = PROJECT_TYPE project['description'] = unicode(page.txtDescription.toPlainText()) project['license'] = unicode(page.cboLicense.currentText()) project['venv'] = unicode(page.vtxtPlace.text()) # Manipulate plugin project data page = wizard.page(ids[1]) json_manager.create_ninja_project(path, name, project) plugin_dict = self.create_descriptor(page, path) self.create_plugin_class(page, path, plugin_dict) # Load the project! wizard._load_project(path)
def _add_file_to_project(self, path): pathProject = [self.ide.explorer.get_actual_project()] addToProject = ui_tools.AddToProject(pathProject, self.ide) addToProject.exec_() if not addToProject.pathSelected: return editorWidget = self.ide.mainContainer.get_actual_editor() if not editorWidget.ID: name = unicode(QInputDialog.getText(None, self.tr("Add File To Project"), self.tr("File Name:"))[0]) if not name: QMessageBox.information(self, self.tr("Invalid Name"), self.tr("The file name is empty, please enter a name")) return else: name = file_manager.get_basename(editorWidget.ID) path = file_manager.create_path( unicode(addToProject.pathSelected), name) try: path = file_manager.store_file_content( path, editorWidget.get_text(), newFile=True) editorWidget.ID = path self.ide.explorer.add_existing_file(path) self.ide.change_window_title(path) name = file_manager.get_basename(path) self.ide.mainContainer.actualTab.setTabText( self.ide.mainContainer.actualTab.currentIndex(), name) editorWidget._file_saved() except file_manager.NinjaFileExistsException, ex: QMessageBox.information(self, self.tr("File Already Exists"), self.tr("Invalid Path: the file '%s' already exists." % \ ex.filename))
def _add_file_to_project(self, path): """Add the file for 'path' in the project the user choose here.""" pathProject = [self.ide.explorer.get_actual_project()] addToProject = ui_tools.AddToProject(pathProject, self.ide) addToProject.exec_() if not addToProject.pathSelected: return editorWidget = self.ide.mainContainer.get_actual_editor() if not editorWidget.ID: name = unicode(QInputDialog.getText(None, self.tr("Add File To Project"), self.tr("File Name:"))[0]) if not name: QMessageBox.information(self, self.tr("Invalid Name"), self.tr("The file name is empty, please enter a name")) return else: name = file_manager.get_basename(editorWidget.ID) path = file_manager.create_path( unicode(addToProject.pathSelected), name) try: path = file_manager.store_file_content( path, editorWidget.get_text(), newFile=True) editorWidget.ID = path self.ide.explorer.add_existing_file(path) self.ide.change_window_title(path) name = file_manager.get_basename(path) self.ide.mainContainer.actualTab.setTabText( self.ide.mainContainer.actualTab.currentIndex(), name) editorWidget._file_saved() except file_manager.NinjaFileExistsException, ex: QMessageBox.information(self, self.tr("File Already Exists"), self.tr("Invalid Path: the file '%s' already exists." % \ ex.filename))
def _copy_file(self): #get the selected QTreeWidgetItem item = self.currentItem() if item.parent() is None: pathForFile = item.path else: pathForFile = os.path.join(item.path, item.text(0)) pathProjects = [p.path for p in self.get_open_projects()] addToProject = ui_tools.AddToProject(pathProjects, self) addToProject.setWindowTitle(self.tr("Copy File to")) addToProject.exec_() if not addToProject.pathSelected: return name = QInputDialog.getText(self, self.tr("Copy File"), self.tr("File Name:"), text=item.text(0))[0] if not name: QMessageBox.information(self, self.tr("Invalid Name"), self.tr("The file name is empty, please enter a name")) return path = file_manager.create_path(addToProject.pathSelected, name) try: content = file_manager.read_file_content(pathForFile) path = file_manager.store_file_content(path, content, newFile=True) self.add_existing_file(path) except file_manager.NinjaFileExistsException as ex: QMessageBox.information(self, self.tr("File Already Exists"), self.tr("Invalid Path: the file '%s' already exists." % ex.filename))
def _replace_results(self): result = QMessageBox.question( self, self.tr("Replace Files Contents"), self.tr("Are you sure you want to replace the content in " "this files?\n(The change is not reversible)"), buttons=QMessageBox.Yes | QMessageBox.No) if result == QMessageBox.Yes: for index in range(self._result_widget.topLevelItemCount()): parent = self._result_widget.topLevelItem(index) root_dir_name = parent.dir_name_root file_name = parent.text(0) file_path = file_manager.create_path(root_dir_name, file_name) file_object = QFile(file_path) if not file_object.open(QFile.ReadOnly): return stream = QTextStream(file_object) content = stream.readAll() file_object.close() pattern = self._find_widget.pattern_line_edit.text() case_sensitive = self._find_widget.case_checkbox.isChecked() type_ = QRegExp.RegExp if \ self._find_widget.type_checkbox.isChecked() else \ QRegExp.FixedString target = QRegExp(pattern, case_sensitive, type_) content.replace(target, self._find_widget.replace_line.text()) file_manager.store_file_content(file_path, content, False)
def _move_file(self): item = self.currentItem() if item.parent() is None: pathForFile = item.path else: pathForFile = os.path.join(item.path, item.text(0)) pathProjects = [p.path for p in self.get_open_projects()] addToProject = ui_tools.AddToProject(pathProjects, self) addToProject.setWindowTitle(self.tr("Copy File to")) addToProject.exec_() if not addToProject.pathSelected: return name = file_manager.get_basename(pathForFile) path = file_manager.create_path(addToProject.pathSelected, name) try: content = file_manager.read_file_content(pathForFile) path = file_manager.store_file_content(path, content, newFile=True) file_manager.delete_file(pathForFile) index = item.parent().indexOfChild(item) item.parent().takeChild(index) self.add_existing_file(path) except file_manager.NinjaFileExistsException as ex: QMessageBox.information( self, self.tr("File Already Exists"), self.tr("Invalid Path: the file '%s' already exists." % ex.filename))
def _copy_file(self): #get the selected QTreeWidgetItem item = self.currentItem() if item.parent() is None: pathForFile = item.path else: pathForFile = os.path.join(item.path, item.text(0)) pathProjects = [p.path for p in self.get_open_projects()] addToProject = ui_tools.AddToProject(pathProjects, self) addToProject.setWindowTitle(self.tr("Copy File to")) addToProject.exec_() if not addToProject.pathSelected: return name = QInputDialog.getText(self, self.tr("Copy File"), self.tr("File Name:"), text=item.text(0))[0] if not name: QMessageBox.information( self, self.tr("Invalid Name"), self.tr("The file name is empty, please enter a name")) return path = file_manager.create_path(addToProject.pathSelected, name) try: content = file_manager.read_file_content(pathForFile) path = file_manager.store_file_content(path, content, newFile=True) self.add_existing_file(path) except file_manager.NinjaFileExistsException as ex: QMessageBox.information( self, self.tr("File Already Exists"), self.tr("Invalid Path: the file '%s' already exists." % ex.filename))
def execute_project(self): """Execute the project marked as Main Project.""" mainFile = self.ide.explorer.get_project_main_file() if not mainFile and self.ide.explorer._treeProjects and \ self.ide.explorer._treeProjects._actualProject: self.ide.explorer._treeProjects.open_project_properties() elif mainFile: self.save_project() path = self.ide.explorer.get_actual_project() #emit a signal for plugin! self.emit(SIGNAL("projectExecuted(QString)"), path) # load our jutsus! project = json_manager.read_ninja_project(path) python_exec = project.get('venv', False) if not python_exec: python_exec = project.get('pythonPath', 'python') PYTHONPATH = project.get('PYTHONPATH', None) params = project.get('programParams', '') preExec = project.get('preExecScript', '') postExec = project.get('postExecScript', '') mainFile = file_manager.create_path(path, mainFile) self.ide.misc.run_application(mainFile, pythonPath=python_exec, PYTHONPATH=PYTHONPATH, programParams=params, preExec=preExec, postExec=postExec)
def _replace_results(self): result = QMessageBox.question(self, self.tr("Replace Files Contents"), self.tr("Are you sure you want to replace the content in " "this files?\n(The change is not reversible)"), buttons=QMessageBox.Yes | QMessageBox.No) if result == QMessageBox.Yes: for index in range(self._result_widget.topLevelItemCount()): parent = self._result_widget.topLevelItem(index) root_dir_name = parent.dir_name_root file_name = parent.text(0) file_path = file_manager.create_path(root_dir_name, file_name) try: content = file_manager.read_file_content(file_path) pattern = self._find_widget.pattern_line_edit.text() flags = 0 if not self._find_widget.case_checkbox.isChecked(): flags |= re.IGNORECASE if self._find_widget.type_checkbox.isChecked(): pattern = r'\b%s\b' % pattern new_content = re.sub(pattern, self._find_widget.replace_line.text(), content, flags=flags) file_manager.store_file_content(file_path, new_content, False) except: print('File: %s content, could not be replaced' % file_path)
def _move_file(self): item = self.currentItem() if item.parent() is None: pathForFile = item.path else: pathForFile = os.path.join(item.path, item.text(0)) pathProjects = [p.path for p in self.get_open_projects()] addToProject = ui_tools.AddToProject(pathProjects, self) addToProject.setWindowTitle(self.tr("Copy File to")) addToProject.exec_() if not addToProject.pathSelected: return name = file_manager.get_basename(pathForFile) path = file_manager.create_path(addToProject.pathSelected, name) try: content = file_manager.read_file_content(pathForFile) path = file_manager.store_file_content(path, content, newFile=True) file_manager.delete_file(pathForFile) index = item.parent().indexOfChild(item) item.parent().takeChild(index) self.add_existing_file(path) except file_manager.NinjaFileExistsException as ex: QMessageBox.information(self, self.tr("File Already Exists"), self.tr("Invalid Path: the file '%s' already exists." % ex.filename))
def _replace_results(self): result = QMessageBox.question(self, self.tr("Replace Files Contents"), self.tr("Are you sure you want to replace the content in " "this files?\n(The change is not reversible)"), buttons=QMessageBox.Yes | QMessageBox.No) if result == QMessageBox.Yes: for index in xrange(self._result_widget.topLevelItemCount()): parent = self._result_widget.topLevelItem(index) root_dir_name = unicode(parent.dir_name_root) file_name = unicode(parent.text(0)) file_path = file_manager.create_path(root_dir_name, file_name) file_object = QFile(file_path) if not file_object.open(QFile.ReadOnly): return stream = QTextStream(file_object) content = stream.readAll() file_object.close() pattern = self._find_widget.pattern_line_edit.text() case_sensitive = self._find_widget.case_checkbox.isChecked() type_ = QRegExp.RegExp if \ self._find_widget.type_checkbox.isChecked() else \ QRegExp.FixedString target = QRegExp(pattern, case_sensitive, type_) content.replace(target, self._find_widget.replace_line.text()) file_manager.store_file_content(file_path, content, False)
def _replace_results(self): result = QMessageBox.question( self, self.tr("Replace Files Contents"), self.tr("Are you sure you want to replace the content in " "this files?\n(The change is not reversible)"), buttons=QMessageBox.Yes | QMessageBox.No) if result == QMessageBox.Yes: for index in range(self._result_widget.topLevelItemCount()): parent = self._result_widget.topLevelItem(index) root_dir_name = parent.dir_name_root file_name = parent.text(0) file_path = file_manager.create_path(root_dir_name, file_name) try: content = file_manager.read_file_content(file_path) pattern = self._find_widget.pattern_line_edit.text() flags = 0 if not self._find_widget.case_checkbox.isChecked(): flags |= re.IGNORECASE if self._find_widget.type_checkbox.isChecked(): pattern = r'\b%s\b' % pattern new_content = re.sub(pattern, self._find_widget.replace_line.text(), content, flags=flags) file_manager.store_file_content(file_path, new_content, False) except: print('File: %s content, could not be replaced' % file_path)
def _copy_file(self): item = self.currentItem() if item.parent() is None: pathForFile = item.path else: pathForFile = os.path.join(item.path, unicode(item.text(0))) pathProject = self.get_selected_project_path() addToProject = ui_tools.AddToProject(pathProject, self) addToProject.setWindowTitle(self.tr("Copy File to")) addToProject.exec_() if not addToProject.pathSelected: return name = unicode(QInputDialog.getText(None, self.tr("Copy File"), self.tr("File Name:"))[0]) if not name: QMessageBox.information(self, self.tr("Indalid Name"), self.tr("The file name is empty, please enter a name")) return path = file_manager.create_path( unicode(addToProject.pathSelected), name) try: content = file_manager.read_file_content(pathForFile) path = file_manager.store_file_content(path, content, newFile=True) self.add_existing_file(path) except file_manager.NinjaFileExistsException, ex: QMessageBox.information(self, self.tr("File Already Exists"), self.tr("Invalid Path: the file '%s' already exists." % \ ex.filename))
def _move_file(self): item = self.currentItem() if item.parent() is None: pathForFile = item.path else: pathForFile = os.path.join(item.path, item.text(0)) pathProjects = [p.path for p in self.get_open_projects()] addToProject = ui_tools.AddToProject(pathProjects, self) addToProject.setWindowTitle(_translate("TreeProjectsWidget", "Copy File to")) addToProject.exec_() if not addToProject.pathSelected: return name = file_manager.get_basename(pathForFile) path = file_manager.create_path(addToProject.pathSelected, name) try: content = file_manager.read_file_content(pathForFile) path = file_manager.store_file_content(path, content, newFile=True) file_manager.delete_file(pathForFile) index = item.parent().indexOfChild(item) item.parent().takeChild(index) self.add_existing_file(path) # Update path of opened file main = main_container.MainContainer() if main.is_open(pathForFile): widget = main.get_widget_for_path(pathForFile) if widget: widget.ID = path except file_manager.NinjaFileExistsException as ex: QMessageBox.information(self, _translate("TreeProjectsWidget", "File Already Exists"), (_translate("TreeProjectsWidget", "Invalid Path: the file '%s' already exists.") % ex.filename))
def _go_to(self, item, val): if item.text(1): parent = item.parent() file_name = parent.text(0) lineno = item.text(1) root_dir_name = parent.dir_name_root file_path = file_manager.create_path(root_dir_name, file_name) #open the file and jump_to_line self._main_container.open_file(file_path) self._main_container.editor_jump_to_line(lineno=int(lineno) - 1)
def _delete_file(self): item = self.currentItem() val = QMessageBox.question(self, self.tr("Delete File"), self.tr("Do you want to delete the following file: ") \ + os.path.join(item.path, unicode(item.text(0))), QMessageBox.Yes, QMessageBox.No) if val == QMessageBox.Yes: path = file_manager.create_path(item.path, unicode(item.text(0))) file_manager.delete_file(item.path, unicode(item.text(0))) self.removeItemWidget(item, 0) mainContainer = main_container.MainContainer() if mainContainer.is_open(path): mainContainer.close_deleted_file(path)
def _delete_file(self): item = self.currentItem() val = QMessageBox.question(self, self.tr("Delete File"), self.tr("Do you want to delete the following file: ") + os.path.join(item.path, item.text(0)), QMessageBox.Yes, QMessageBox.No) if val == QMessageBox.Yes: path = file_manager.create_path(item.path, item.text(0)) file_manager.delete_file(item.path, item.text(0)) index = item.parent().indexOfChild(item) item.parent().takeChild(index) mainContainer = main_container.MainContainer() if mainContainer.is_open(path): mainContainer.close_deleted_file(path)
def execute_project(self): mainFile = self.ide.explorer.get_project_main_file() if not mainFile and self.ide.explorer._treeProjects and \ self.ide.explorer._treeProjects._actualProject: self.ide.explorer._treeProjects.open_project_properties() elif mainFile: self.save_project() #emit a signal for plugin! self.emit(SIGNAL("projectExecuted(QString)"), mainFile) path = self.ide.explorer.get_actual_project() project = json_manager.read_ninja_project(path) venv = project.get('venv', False) params = project.get('programParams', '') mainFile = file_manager.create_path(path, mainFile) self.ide.misc.run_application(mainFile, pythonPath=venv, programParams=params)
def execute_project(self): mainFile = self.ide.explorer.get_project_main_file() if not mainFile and self.ide.explorer._treeProjects and \ self.ide.explorer._treeProjects._actualProject: self.ide.explorer._treeProjects.open_project_properties() elif mainFile: self.save_project() path = self.ide.explorer.get_actual_project() #emit a signal for plugin! self.emit(SIGNAL("projectExecuted(QString)"), path) project = json_manager.read_ninja_project(path) venv = project.get('venv', False) params = project.get('programParams', '') mainFile = file_manager.create_path(path, mainFile) self.ide.misc.run_application(mainFile, pythonPath=venv, programParams=params)
def _refresh_project(self, item=None): if item is None: item = self.currentItem() parentItem = self._get_project_root(item) if parentItem is None: return if item.parent() is None: path = item.path else: path = file_manager.create_path(item.path, item.text(0)) thread = ui_tools.ThreadProjectExplore() self._thread_execution[path] = thread thread.folderDataRefreshed.connect(self._callback_refresh_project) thread.finished.connect(self._clean_threads) thread.refresh_project(path, item, parentItem.extensions)
def _refresh_project(self, item=None): if item is None: item = self.currentItem() parentItem = self._get_project_root(item) if parentItem is None: return if item.parent() is None: path = item.path else: path = file_manager.create_path(item.path, unicode(item.text(0))) thread = ui_tools.ThreadExecution( self._thread_refresh_project, args=[path, item, parentItem]) self._thread_execution[path] = thread self.connect(thread, SIGNAL("executionFinished(PyQt_PyObject)"), self._callback_refresh_project) thread.start()
def _refresh_project(self, item=None): if item is None: item = self.currentItem() parentItem = self._get_project_root(item) if parentItem is None: return if item.parent() is None: path = item.path else: path = file_manager.create_path(item.path, item.text(0)) thread = ui_tools.ThreadProjectExplore() self._thread_execution[path] = thread self.connect(thread, SIGNAL("folderDataRefreshed(PyQt_PyObject)"), self._callback_refresh_project) self.connect(thread, SIGNAL("finished()"), self._clean_threads) thread.refresh_project(path, item, parentItem.extensions)
def _refresh_project(self, item=None): if item is None: item = self.currentItem() parentItem = self._get_project_root(item) if parentItem is None: return if item.parent() is None: path = item.path else: path = file_manager.create_path(item.path, unicode(item.text(0))) thread = ui_tools.ThreadExecution(self._thread_refresh_project, args=[path, item, parentItem]) self._thread_execution[path] = thread self.connect(thread, SIGNAL("executionFinished(PyQt_PyObject)"), self._callback_refresh_project) thread.start()
def _add_file_to_project(self, path): """Add the file for 'path' in the project the user choose here.""" pathProject = [self.ide.explorer.get_actual_project()] addToProject = ui_tools.AddToProject(pathProject, self.ide) addToProject.exec_() if not addToProject.pathSelected: return editorWidget = self.ide.mainContainer.get_actual_editor() if not editorWidget.ID: name = QInputDialog.getText(None, self.tr("Add File To Project"), self.tr("File Name:"))[0] if not name: QMessageBox.information( self, self.tr("Invalid Name"), self.tr("The file name is empty, please enter a name")) return else: name = file_manager.get_basename(editorWidget.ID) path = file_manager.create_path(addToProject.pathSelected, name) try: path = file_manager.store_file_content(path, editorWidget.get_text(), newFile=True) self.ide.mainContainer._file_watcher.allow_kill = False if path != editorWidget.ID: self.ide.mainContainer.remove_standalone_watcher( editorWidget.ID) editorWidget.ID = path self.ide.mainContainer.add_standalone_watcher(path) self.ide.mainContainer._file_watcher.allow_kill = True self.ide.explorer.add_existing_file(path) self.ide.change_window_title(path) name = file_manager.get_basename(path) self.ide.mainContainer.actualTab.setTabText( self.ide.mainContainer.actualTab.currentIndex(), name) editorWidget._file_saved() except file_manager.NinjaFileExistsException as ex: QMessageBox.information( self, self.tr("File Already Exists"), (self.tr("Invalid Path: the file '%s' already exists.") % ex.filename))
def _refresh_project(self, item=None): if item is None: item = self.currentItem() parentItem = self._get_project_root(item) if parentItem is None: return if item.parent() is None: path = item.path else: path = file_manager.create_path(item.path, unicode(item.text(0))) if parentItem.extensions != settings.SUPPORTED_EXTENSIONS: folderStructure = file_manager.open_project_with_extensions( path, parentItem.extensions) else: folderStructure = file_manager.open_project(path) if folderStructure.get(path, [None, None])[1] is not None: folderStructure[path][1].sort() else: return item.takeChildren() self._load_folder(folderStructure, path, item) item.setExpanded(True)
def _add_file_to_project(self, path): """Add the file for 'path' in the project the user choose here.""" pathProject = [self.ide.explorer.get_actual_project()] addToProject = ui_tools.AddToProject(pathProject, self.ide) addToProject.exec_() if not addToProject.pathSelected: return editorWidget = self.ide.mainContainer.get_actual_editor() if not editorWidget.ID: name = QInputDialog.getText(None, _translate("_s_Actions", "Add File To Project"), _translate("_s_Actions", "File Name:"))[0] if not name: QMessageBox.information(None, _translate("_s_Actions", "Invalid Name"), _translate("_s_Actions", "The file name is empty, please enter a name")) return else: name = file_manager.get_basename(editorWidget.ID) path = file_manager.create_path(addToProject.pathSelected, name) try: path = file_manager.store_file_content( path, editorWidget.get_text(), newFile=True) self.ide.mainContainer._file_watcher.allow_kill = False if path != editorWidget.ID: self.ide.mainContainer.remove_standalone_watcher( editorWidget.ID) editorWidget.ID = path self.ide.mainContainer.add_standalone_watcher(path) self.ide.mainContainer._file_watcher.allow_kill = True self.ide.explorer.add_existing_file(path) self.ide.change_window_title(path) name = file_manager.get_basename(path) self.ide.mainContainer.actualTab.setTabText( self.ide.mainContainer.actualTab.currentIndex(), name) editorWidget._file_saved() except file_manager.NinjaFileExistsException as ex: QMessageBox.information(None, _translate("_s_Actions", "File Already Exists"), (_translate("_s_Actions", "Invalid Path: the file '%s' already exists.") % ex.filename))
def start(filenames=None, projects_path=None, extra_plugins=None, linenos=None): app = QApplication(sys.argv) QCoreApplication.setOrganizationName("NINJA-IDE") QCoreApplication.setOrganizationDomain("NINJA-IDE") QCoreApplication.setApplicationName("NINJA-IDE") app.setWindowIcon(QIcon(resources.IMAGES["icon"])) # Check if there is another session of ninja-ide opened # and in that case send the filenames and projects to that session running = ipc.is_running() start_server = not running[0] if running[0] and (filenames or projects_path): sended = ipc.send_data(running[1], filenames, projects_path, linenos) running[1].close() if sended: sys.exit() else: running[1].close() # Create and display the splash screen splash_pix = QPixmap(resources.IMAGES["splash"]) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking global cursor_flash_time cursor_flash_time = app.cursorFlashTime() app.setCursorFlashTime(0) # Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName("utf-8")) # Translator qsettings = QSettings() language = QLocale.system().language() lang = unicode(qsettings.value("preferences/interface/language", language).toString()) + ".qm" lang_path = file_manager.create_path(resources.LANGS, unicode(lang)) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path elif file_manager.file_exists(file_manager.create_path(resources.LANGS_DOWNLOAD, unicode(lang))): settings.LANGUAGE = file_manager.create_path(resources.LANGS_DOWNLOAD, unicode(lang)) translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) # Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() # Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) settings.load_settings() # Set Stylesheet if settings.USE_STYLESHEET: with open(resources.NINJA_THEME) as f: qss = f.read() app.setStyleSheet(qss) # Loading Themes splash.showMessage("Loading Themes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = unicode(qsettings.value("preferences/editor/scheme", "default").toString()) if scheme != "default": scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + ".color") if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) # Loading Shortcuts resources.load_shortcuts() # Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ide = IDE(start_server) # Showing GUI ide.show() # Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) # Files in Main Tab mainFiles = qsettings.value("openFiles/mainTab", []).toList() tempFiles = [] for file_ in mainFiles: fileData = file_.toList() tempFiles.append((unicode(fileData[0].toString()), fileData[1].toInt()[0])) mainFiles = tempFiles # Files in Secondary Tab secondaryFiles = qsettings.value("openFiles/secondaryTab", []).toList() tempFiles = [] for file_ in secondaryFiles: fileData = file_.toList() tempFiles.append((unicode(fileData[0].toString()), fileData[1].toInt()[0])) secondaryFiles = tempFiles # Current File current_file = unicode(qsettings.value("openFiles/currentFile", "").toString()) # Projects projects = qsettings.value("openFiles/projects", []).toList() projects = [unicode(project.toString()) for project in projects] # Include files received from console args file_with_nro = map(lambda f: (f[0], f[1] - 1), zip(filenames, linenos)) file_without_nro = map(lambda f: (f, 0), filenames[len(linenos) :]) mainFiles += file_with_nro + file_without_nro # Include projects received from console args if projects_path: projects += projects_path mainFiles.reverse() secondaryFiles.reverse() ide.load_session_files_projects(mainFiles, secondaryFiles, projects, current_file) # Load external plugins if extra_plugins: ide.load_external_plugins(extra_plugins) splash.finish(ide) ide.notify_plugin_errors() sys.exit(app.exec_())
def start(filenames=None, projects_path=None, extra_plugins=None, linenos=None): app = QApplication(sys.argv) QCoreApplication.setOrganizationName('NINJA-IDE') QCoreApplication.setOrganizationDomain('NINJA-IDE') QCoreApplication.setApplicationName('NINJA-IDE') app.setWindowIcon(QIcon(resources.IMAGES['icon'])) # Check if there is another session of ninja-ide opened # and in that case send the filenames and projects to that session running = ipc.is_running() start_server = not running[0] if running[0] and (filenames or projects_path): sended = ipc.send_data(running[1], filenames, projects_path, linenos) running[1].close() if sended: sys.exit() else: running[1].close() # Create and display the splash screen splash_pix = QPixmap(resources.IMAGES['splash']) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking global cursor_flash_time cursor_flash_time = app.cursorFlashTime() app.setCursorFlashTime(0) #Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8')) #Translator qsettings = QSettings() language = QLocale.system().name() lang = qsettings.value('preferences/interface/language', language) + '.qm' lang_path = file_manager.create_path(resources.LANGS, lang) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path elif file_manager.file_exists( file_manager.create_path(resources.LANGS_DOWNLOAD, lang)): settings.LANGUAGE = file_manager.create_path(resources.LANGS_DOWNLOAD, lang) translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) #Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() #Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) settings.load_settings() #Set Stylesheet style_applied = False if settings.NINJA_SKIN not in ('Default', 'Classic Theme'): file_name = ("%s.qss" % settings.NINJA_SKIN) qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD, file_name) if file_manager.file_exists(qss_file): with open(qss_file) as f: qss = f.read() app.setStyleSheet(qss) style_applied = True if not style_applied: if settings.NINJA_SKIN == 'Default': with open(resources.NINJA_THEME) as f: qss = f.read() else: with open(resources.NINJA__THEME_CLASSIC) as f: qss = f.read() app.setStyleSheet(qss) #Loading Schemes splash.showMessage("Loading Schemes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = qsettings.value('preferences/editor/scheme', "default") if scheme != 'default': scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + '.color') if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) #Loading Shortcuts resources.load_shortcuts() #Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ide = IDE(start_server) #Showing GUI ide.show() #Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) #Files in Main Tab main_files = qsettings.value('openFiles/mainTab', []) if main_files is not None: mainFiles = list(main_files) else: mainFiles = list() tempFiles = [] for file_ in mainFiles: fileData = list(file_) tempFiles.append((fileData[0], int(fileData[1]))) mainFiles = tempFiles #Files in Secondary Tab sec_files = qsettings.value('openFiles/secondaryTab', []) if sec_files is not None: secondaryFiles = list(sec_files) else: secondaryFiles = list() tempFiles = [] for file_ in secondaryFiles: fileData = list(file_) tempFiles.append((fileData[0], int(fileData[1]))) secondaryFiles = tempFiles # Recent Files recent = qsettings.value('openFiles/recentFiles', []) if recent is not None: recent_files = list(recent) else: recent_files = list() recent_files = [file_ for file_ in recent_files] #Current File current_file = qsettings.value('openFiles/currentFile', '') #Projects projects_list = qsettings.value('openFiles/projects', []) if projects_list is not None: projects = list(projects_list) else: projects = list() projects = [project for project in projects] #Include files received from console args file_with_nro = list( map(lambda f: (f[0], f[1] - 1), zip(filenames, linenos))) file_without_nro = list(map(lambda f: (f, 0), filenames[len(linenos):])) mainFiles += file_with_nro + file_without_nro #Include projects received from console args if projects_path: projects += projects_path ide.load_session_files_projects(mainFiles, secondaryFiles, projects, current_file, recent_files) #Load external plugins if extra_plugins: ide.load_external_plugins(extra_plugins) splash.finish(ide) ide.notify_plugin_errors() sys.exit(app.exec_())
def start(listener, filenames=None, projects_path=None, extra_plugins=None): app = QApplication(sys.argv) QCoreApplication.setOrganizationName('NINJA-IDE') QCoreApplication.setOrganizationDomain('NINJA-IDE') QCoreApplication.setApplicationName('NINJA-IDE') app.setWindowIcon(QIcon(resources.IMAGES['icon'])) # Create and display the splash screen splash_pix = QPixmap(resources.IMAGES['splash']) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking app.setCursorFlashTime(0) #Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8')) #Translator qsettings = QSettings() language = QLocale.system().language() lang = unicode(qsettings.value( 'preferences/interface/language', language).toString()) + '.qm' lang_path = file_manager.create_path(resources.LANGS, unicode(lang)) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path elif file_manager.file_exists(file_manager.create_path( resources.LANGS_DOWNLOAD, unicode(lang))): settings.LANGUAGE = file_manager.create_path( resources.LANGS_DOWNLOAD, unicode(lang)) translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) #Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() #Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) settings.load_settings() #Loading Themes splash.showMessage("Loading Themes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = unicode(qsettings.value('preferences/editor/scheme', "default").toString()) if scheme != 'default': scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + '.color') if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) #Loading Shortcuts resources.load_shortcuts() #Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ide = IDE() #Showing GUI ide.show() #Connect listener signals ide.connect(listener, SIGNAL("fileOpenRequested(QString)"), ide.open_file) ide.connect(listener, SIGNAL("projectOpenRequested(QString)"), ide.open_project) #Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) #Files in Main Tab mainFiles = qsettings.value('openFiles/mainTab', []).toList() tempFiles = [] for file_ in mainFiles: fileData = file_.toList() tempFiles.append((unicode(fileData[0].toString()), fileData[1].toInt()[0])) mainFiles = tempFiles #Files in Secondary Tab secondaryFiles = qsettings.value('openFiles/secondaryTab', []).toList() tempFiles = [] for file_ in secondaryFiles: fileData = file_.toList() tempFiles.append((unicode(fileData[0].toString()), fileData[1].toInt()[0])) secondaryFiles = tempFiles #Projects projects = qsettings.value('openFiles/projects', []).toList() projects = [unicode(project.toString()) for project in projects] #Include files received from console args if filenames: mainFiles += [(f, 0) for f in filenames] #Include projects received from console args if projects_path: projects += projects_path ide.load_session_files_projects(mainFiles, secondaryFiles, projects) #Load external plugins if extra_plugins: ide.load_external_plugins(extra_plugins) splash.finish(ide) ide.notify_plugin_errors() sys.exit(app.exec_())
def start(listener, filenames=None, projects_path=None, extra_plugins=None): app = QApplication(sys.argv) QCoreApplication.setOrganizationName('NINJA-IDE') QCoreApplication.setOrganizationDomain('NINJA-IDE') QCoreApplication.setApplicationName('NINJA-IDE') app.setWindowIcon(QIcon(resources.IMAGES['icon'])) # Create and display the splash screen splash_pix = QPixmap(resources.IMAGES['splash']) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking app.setCursorFlashTime(0) #Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8')) #Translator qsettings = QSettings() language = QLocale.system().language() lang = unicode( qsettings.value('preferences/interface/language', language).toString()) + '.qm' lang_path = file_manager.create_path(resources.LANGS, unicode(lang)) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path elif file_manager.file_exists( file_manager.create_path(resources.LANGS_DOWNLOAD, unicode(lang))): settings.LANGUAGE = file_manager.create_path(resources.LANGS_DOWNLOAD, unicode(lang)) translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) #Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() #Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) settings.load_settings() #Loading Themes splash.showMessage("Loading Themes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = unicode( qsettings.value('preferences/editor/scheme', "default").toString()) if scheme != 'default': scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + '.color') if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) #Loading Shortcuts resources.load_shortcuts() #Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ide = IDE() #Showing GUI ide.show() #Connect listener signals ide.connect(listener, SIGNAL("fileOpenRequested(QString)"), ide.open_file) ide.connect(listener, SIGNAL("projectOpenRequested(QString)"), ide.open_project) #Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) #Files in Main Tab mainFiles = qsettings.value('openFiles/mainTab', []).toList() tempFiles = [] for file_ in mainFiles: fileData = file_.toList() tempFiles.append( (unicode(fileData[0].toString()), fileData[1].toInt()[0])) mainFiles = tempFiles #Files in Secondary Tab secondaryFiles = qsettings.value('openFiles/secondaryTab', []).toList() tempFiles = [] for file_ in secondaryFiles: fileData = file_.toList() tempFiles.append( (unicode(fileData[0].toString()), fileData[1].toInt()[0])) secondaryFiles = tempFiles #Projects projects = qsettings.value('openFiles/projects', []).toList() projects = [unicode(project.toString()) for project in projects] #Include files received from console args if filenames: mainFiles += [(f, 0) for f in filenames] #Include projects received from console args if projects_path: projects += projects_path ide.load_session_files_projects(mainFiles, secondaryFiles, projects) #Load external plugins if extra_plugins: ide.load_external_plugins(extra_plugins) splash.finish(ide) ide.notify_plugin_errors() sys.exit(app.exec_())
def start(filenames=None, projects_path=None, extra_plugins=None, linenos=None): app = QApplication(sys.argv) QCoreApplication.setOrganizationName('NINJA-IDE') QCoreApplication.setOrganizationDomain('NINJA-IDE') QCoreApplication.setApplicationName('NINJA-IDE') app.setWindowIcon(QIcon(resources.IMAGES['icon'])) # Check if there is another session of ninja-ide opened # and in that case send the filenames and projects to that session running = ipc.is_running() start_server = not running[0] if running[0] and (filenames or projects_path): sended = ipc.send_data(running[1], filenames, projects_path, linenos) running[1].close() if sended: sys.exit() else: running[1].close() # Create and display the splash screen splash_pix = QPixmap(resources.IMAGES['splash']) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking global cursor_flash_time cursor_flash_time = app.cursorFlashTime() app.setCursorFlashTime(0) #Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8')) #Translator qsettings = QSettings() language = QLocale.system().name() lang = qsettings.value('preferences/interface/language', language) + '.qm' lang_path = file_manager.create_path(resources.LANGS, lang) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path elif file_manager.file_exists(file_manager.create_path( resources.LANGS_DOWNLOAD, lang)): settings.LANGUAGE = file_manager.create_path( resources.LANGS_DOWNLOAD, lang) translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) #Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() #Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) settings.load_settings() #Set Stylesheet style_applied = False if settings.NINJA_SKIN not in ('Default', 'Classic Theme'): file_name = ("%s.qss" % settings.NINJA_SKIN) qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD, file_name) if file_manager.file_exists(qss_file): with open(qss_file) as f: qss = f.read() app.setStyleSheet(qss) style_applied = True if not style_applied: if settings.NINJA_SKIN == 'Default': with open(resources.NINJA_THEME) as f: qss = f.read() else: with open(resources.NINJA__THEME_CLASSIC) as f: qss = f.read() app.setStyleSheet(qss) #Loading Schemes splash.showMessage("Loading Schemes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = qsettings.value('preferences/editor/scheme', "default") if scheme != 'default': scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + '.color') if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) #Loading Shortcuts resources.load_shortcuts() #Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ide = IDE(start_server) #Showing GUI ide.show() #Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) #Files in Main Tab main_files = qsettings.value('openFiles/mainTab', []) if main_files is not None: mainFiles = list(main_files) else: mainFiles = list() tempFiles = [] for file_ in mainFiles: fileData = list(file_) tempFiles.append((fileData[0], int(fileData[1]))) mainFiles = tempFiles #Files in Secondary Tab sec_files = qsettings.value('openFiles/secondaryTab', []) if sec_files is not None: secondaryFiles = list(sec_files) else: secondaryFiles = list() tempFiles = [] for file_ in secondaryFiles: fileData = list(file_) tempFiles.append((fileData[0], int(fileData[1]))) secondaryFiles = tempFiles # Recent Files recent = qsettings.value('openFiles/recentFiles', []) if recent is not None: recent_files = list(recent) else: recent_files = list() recent_files = [file_ for file_ in recent_files] #Current File current_file = qsettings.value('openFiles/currentFile', '') #Projects projects_list = qsettings.value('openFiles/projects', []) if projects_list is not None: projects = list(projects_list) else: projects = list() projects = [project for project in projects] #Include files received from console args file_with_nro = list(map(lambda f: (f[0], f[1] - 1), zip(filenames, linenos))) file_without_nro = list(map(lambda f: (f, 0), filenames[len(linenos):])) mainFiles += file_with_nro + file_without_nro #Include projects received from console args if projects_path: projects += projects_path ide.load_session_files_projects(mainFiles, secondaryFiles, projects, current_file, recent_files) #Load external plugins if extra_plugins: ide.load_external_plugins(extra_plugins) splash.finish(ide) ide.notify_plugin_errors() sys.exit(app.exec_())