def save_properties(self):
        if self.projectData.name.text().strip() == '':
            QMessageBox.critical(self, self.tr("Properties Invalid"),
                                 self.tr("The Project must have a name."))
            return

        tempName = self._item.name
        self._item.name = self.projectData.name.text()
        self._item.description = self.projectData.description.toPlainText()
        self._item.license = self.projectData.cboLicense.currentText()
        self._item.mainFile = self.projectExecution.path.text()
        self._item.url = self.projectData.url.text()
        self._item.projectType = self.projectData.txtType.text()
        # FIXME
        self._item.pythonPath = self.projectExecution.txtPythonPath.text()
        self._item.PYTHONPATH = self.projectExecution.PYTHONPATH.toPlainText()
        self._item.additional_builtins = filter(
            lambda e: e,  # remove empty names
            self.projectExecution.additional_builtins.text().split(' '))
        self._item.preExecScript = self.projectExecution.txtPreExec.text()
        self._item.postExecScript = self.projectExecution.txtPostExec.text()
        self._item.programParams = self.projectExecution.txtParams.text()
        self._item.venv = self.projectExecution.txtVenvPath.text()
        extensions = self.projectData.txtExtensions.text().split(', ')
        self._item.extensions = tuple(extensions)
        self._item.indentation = self.projectData.spinIndentation.value()
        self._item.useTabs = self.projectData.checkUseTabs.isChecked()
        related = self.projectMetadata.txt_projects.toPlainText()
        related = [path for path in related.split('\n') if path != '']
        self._item.related_projects = related
        #save project properties
        project = {}
        project['name'] = self._item.name
        project['description'] = self._item.description
        project['url'] = self._item.url
        project['license'] = self._item.license
        project['mainFile'] = self._item.mainFile
        project['project-type'] = self._item.projectType
        project['supported-extensions'] = self._item.extensions
        project['indentation'] = self._item.indentation
        project['use-tabs'] = self._item.useTabs
        project['pythonPath'] = self._item.pythonPath  # FIXME
        project['PYTHONPATH'] = self._item.PYTHONPATH
        project['additional_builtins'] = self._item.additional_builtins
        project['preExecScript'] = self._item.preExecScript
        project['postExecScript'] = self._item.postExecScript
        project['venv'] = self._item.venv
        project['programParams'] = self._item.programParams
        project['relatedProjects'] = self._item.related_projects
        if tempName != self._item.name and \
            file_manager.file_exists(self._item.path, tempName + '.nja'):
            file_manager.delete_file(self._item.path, tempName + '.nja')
        json_manager.create_ninja_project(self._item.path, self._item.name,
                                          project)
        self._item.setText(0, self._item.name)
        self._item.setToolTip(0, self._item.name)
        if self._item.extensions != settings.SUPPORTED_EXTENSIONS:
            self._item._parent._refresh_project(self._item)
        self._item.update_paths()
        self.close()
    def save_properties(self):
        if self.projectData.name.text().strip() == '':
            QMessageBox.critical(self, self.tr("Properties Invalid"),
                self.tr("The Project must have a name."))
            return

        tempName = self._item.name
        self._item.name = self.projectData.name.text()
        self._item.description = self.projectData.description.toPlainText()
        self._item.license = self.projectData.cboLicense.currentText()
        self._item.mainFile = self.projectExecution.path.text()
        self._item.url = self.projectData.url.text()
        self._item.projectType = self.projectData.txtType.text()
        # FIXME
        self._item.pythonPath = self.projectExecution.txtPythonPath.text()
        self._item.PYTHONPATH = self.projectExecution.PYTHONPATH.toPlainText()
        self._item.additional_builtins = filter(
                lambda e: e,  # remove empty names
                self.projectExecution.additional_builtins.text().split(' '))
        self._item.preExecScript = self.projectExecution.txtPreExec.text()
        self._item.postExecScript = self.projectExecution.txtPostExec.text()
        self._item.programParams = self.projectExecution.txtParams.text()
        self._item.venv = self.projectExecution.txtVenvPath.text()
        extensions = self.projectData.txtExtensions.text().split(', ')
        self._item.extensions = tuple(extensions)
        self._item.indentation = self.projectData.spinIndentation.value()
        self._item.useTabs = self.projectData.checkUseTabs.isChecked()
        related = self.projectMetadata.txt_projects.toPlainText()
        related = [path for path in related.split('\n') if path != '']
        self._item.related_projects = related
        #save project properties
        project = {}
        project['name'] = self._item.name
        project['description'] = self._item.description
        project['url'] = self._item.url
        project['license'] = self._item.license
        project['mainFile'] = self._item.mainFile
        project['project-type'] = self._item.projectType
        project['supported-extensions'] = self._item.extensions
        project['indentation'] = self._item.indentation
        project['use-tabs'] = self._item.useTabs
        project['pythonPath'] = self._item.pythonPath  # FIXME
        project['PYTHONPATH'] = self._item.PYTHONPATH
        project['additional_builtins'] = self._item.additional_builtins
        project['preExecScript'] = self._item.preExecScript
        project['postExecScript'] = self._item.postExecScript
        project['venv'] = self._item.venv
        project['programParams'] = self._item.programParams
        project['relatedProjects'] = self._item.related_projects
        if tempName != self._item.name and \
            file_manager.file_exists(self._item.path, tempName + '.nja'):
            file_manager.delete_file(self._item.path, tempName + '.nja')
        json_manager.create_ninja_project(
            self._item.path, self._item.name, project)
        self._item.setText(0, self._item.name)
        self._item.setToolTip(0, self._item.name)
        if self._item.extensions != settings.SUPPORTED_EXTENSIONS:
            self._item._parent._refresh_project(self._item)
        self._item.update_paths()
        self.close()
 def open_files(self, files, mainTab=True, notIDEStart=True):
     if mainTab:
         self.actualTab = self._tabMain
     else:
         self.actualTab = self._tabSecondary
     for fileData in files:
         if file_manager.file_exists(unicode(fileData[0])):
             self.open_file(unicode(fileData[0]), fileData[1], notIDEStart)
     self.actualTab = self._tabMain
Exemple #4
0
 def open_files(self, files, mainTab=True, notIDEStart=True):
     if mainTab:
         self.actualTab = self._tabMain
     else:
         self.actualTab = self._tabSecondary
     for fileData in files:
         if file_manager.file_exists(unicode(fileData[0])):
             self.open_file(unicode(fileData[0]),
                 fileData[1], notIDEStart)
     self.actualTab = self._tabMain
    def open_files(self, files, mainTab=True, notIDEStart=True):
        if mainTab:
            self.actualTab = self._tabMain
        else:
            self.actualTab = self._tabSecondary
            if files:
                self._tabSecondary.show()

        for fileData in files:
            if file_manager.file_exists(unicode(fileData[0])):
                self.open_file(unicode(fileData[0]), fileData[1], notStart=notIDEStart, positionIsLineNumber=True)
        self.actualTab = self._tabMain
    def save_properties(self):
        if unicode(self.projectData.name.text()).strip() == '':
            QMessageBox.critical(self, self.tr("Properties Invalid"),
                self.tr("The Project must have a name."))
            return

        tempName = self._item.name
        self._item.name = unicode(self.projectData.name.text())
        self._item.description = unicode(
            self.projectData.description.toPlainText())
        self._item.license = unicode(self.projectData.cboLicense.currentText())
        self._item.mainFile = unicode(self.projectExecution.path.text())
        self._item.url = unicode(self.projectData.url.text())
        self._item.projectType = unicode(self.projectData.txtType.text())
        self._item.pythonPath = unicode(
            self.projectExecution.txtPythonPath.text())  # FIXME
        self._item.PYTHONPATH = unicode(
            self.projectExecution.PYTHONPATH.toPlainText())
        self._item.preExecScript = unicode(
            self.projectExecution.txtPreExec.text())
        self._item.postExecScript = unicode(
            self.projectExecution.txtPostExec.text())
        self._item.programParams = unicode(
            self.projectExecution.txtParams.text())
        self._item.venv = unicode(self.projectExecution.txtVenvPath.text())
        extensions = unicode(self.projectData.txtExtensions.text()).split(', ')
        self._item.extensions = tuple(extensions)
        #save project properties
        project = {}
        project['name'] = self._item.name
        project['description'] = self._item.description
        project['url'] = self._item.url
        project['license'] = self._item.license
        project['mainFile'] = self._item.mainFile
        project['project-type'] = self._item.projectType
        project['supported-extensions'] = self._item.extensions
        project['pythonPath'] = self._item.pythonPath  # FIXME
        project['PYTHONPATH'] = self._item.PYTHONPATH
        project['preExecScript'] = self._item.preExecScript
        project['postExecScript'] = self._item.postExecScript
        project['venv'] = self._item.venv
        project['programParams'] = self._item.programParams
        if tempName != self._item.name and \
            file_manager.file_exists(self._item.path, tempName + '.nja'):
            file_manager.delete_file(self._item.path, tempName + '.nja')
        json_manager.create_ninja_project(
            self._item.path, self._item.name, project)
        self._item.setText(0, self._item.name)
        self._item.setToolTip(0, self._item.name)
        if self._item.extensions != settings.SUPPORTED_EXTENSIONS:
            self._item._parent._refresh_project(self._item)
        self.close()
Exemple #7
0
    def open_files(self, files, mainTab=True, notIDEStart=True):
        if mainTab:
            self.actualTab = self._tabMain
        else:
            self.actualTab = self._tabSecondary
            if files:
                self._tabSecondary.show()
                self.splitted = True

        for fileData in files:
            if file_manager.file_exists(fileData[0]):
                self.open_file(fileData[0], fileData[1], notStart=notIDEStart)
        self.actualTab = self._tabMain
Exemple #8
0
    def open_files(self, files, mainTab=True, notIDEStart=True):
        if mainTab:
            self.actualTab = self._tabMain
        else:
            self.actualTab = self._tabSecondary
            if files:
                self._tabSecondary.show()
                self.splitted = True

        for fileData in files:
            if file_manager.file_exists(fileData[0]):
                self.open_file(fileData[0], fileData[1], notStart=notIDEStart)
        self.actualTab = self._tabMain
Exemple #9
0
 def save_properties(self):
     if unicode(self.projectData.name.text()).strip() == '':
         QMessageBox.critical(self, self.tr("Properties Invalid"),
                              self.tr("The Project must have a name."))
         return
     tempName = self._item.name
     self._item.name = unicode(self.projectData.name.text())
     self._item.description = unicode(
         self.projectData.description.toPlainText())
     self._item.license = unicode(self.projectData.cboLicense.currentText())
     self._item.mainFile = unicode(self.projectExecution.path.text())
     self._item.url = unicode(self.projectData.url.text())
     self._item.projectType = unicode(self.projectData.txtType.text())
     self._item.pythonPath = unicode(
         self.projectExecution.txtPythonPath.text())
     self._item.preExecScript = unicode(
         self.projectExecution.txtPreExec.text())
     self._item.postExecScript = unicode(
         self.projectExecution.txtPostExec.text())
     self._item.programParams = unicode(
         self.projectExecution.txtParams.text())
     self._item.venv = unicode(self.projectExecution.txtVenvPath.text())
     extensions = unicode(self.projectData.txtExtensions.text()).split(', ')
     self._item.extensions = tuple(extensions)
     #save project properties
     project = {}
     project['name'] = self._item.name
     project['description'] = self._item.description
     project['url'] = self._item.url
     project['license'] = self._item.license
     project['mainFile'] = self._item.mainFile
     project['project-type'] = self._item.projectType
     project['supported-extensions'] = self._item.extensions
     project['pythonPath'] = self._item.pythonPath
     project['preExecScript'] = self._item.preExecScript
     project['postExecScript'] = self._item.postExecScript
     project['venv'] = self._item.venv
     project['programParams'] = self._item.programParams
     if tempName != self._item.name and \
         file_manager.file_exists(self._item.path, tempName + '.nja'):
         file_manager.delete_file(self._item.path, tempName + '.nja')
     json_manager.create_ninja_project(self._item.path, self._item.name,
                                       project)
     self._item.setText(0, self._item.name)
     self._item.setToolTip(0, self._item.name)
     if self._item.extensions != settings.SUPPORTED_EXTENSIONS:
         self._item._parent._refresh_project(self._item)
     self.close()
Exemple #10
0
 def _navigate_bookmarks(self, val):
     """Navigate between the bookmarks."""
     bookList = list(settings.BOOKMARKS.keys())
     bookList.sort()
     if not bookList:
         return
     if self.__bookmarksFile not in bookList:
         self.__bookmarksFile = bookList[0]
     index = bookList.index(self.__bookmarksFile)
     bookms = settings.BOOKMARKS.get(self.__bookmarksFile, [])
     lineNumber = 0
     #val == True: forward
     if val:
         if (len(bookms) - 1) > self.__bookmarksPos:
             self.__bookmarksPos += 1
             lineNumber = bookms[self.__bookmarksPos]
         elif len(bookms) > 0:
             if index < (len(bookList) - 1):
                 self.__bookmarksFile = bookList[index + 1]
             else:
                 self.__bookmarksFile = bookList[0]
             self.__bookmarksPos = 0
             bookms = settings.BOOKMARKS[self.__bookmarksFile]
             lineNumber = bookms[0]
     else:
         if self.__bookmarksPos > 0:
             self.__bookmarksPos -= 1
             lineNumber = bookms[self.__bookmarksPos]
         elif len(bookms) > 0:
             self.__bookmarksFile = bookList[index - 1]
             bookms = settings.BOOKMARKS[self.__bookmarksFile]
             self.__bookmarksPos = len(bookms) - 1
             lineNumber = bookms[self.__bookmarksPos]
     if file_manager.file_exists(self.__bookmarksFile):
         self.ide.mainContainer.open_file(self.__bookmarksFile,
             lineNumber, None, True)
     else:
         settings.BOOKMARKS.pop(self.__bookmarksFile)
Exemple #11
0
 def _navigate_bookmarks(self, val):
     """Navigate between the bookmarks."""
     bookList = settings.BOOKMARKS.keys()
     bookList.sort()
     if not bookList:
         return
     if self.__bookmarksFile not in bookList:
         self.__bookmarksFile = bookList[0]
     index = bookList.index(self.__bookmarksFile)
     bookms = settings.BOOKMARKS.get(self.__bookmarksFile, [])
     lineNumber = 0
     #val == True: forward
     if val:
         if (len(bookms) - 1) > self.__bookmarksPos:
             self.__bookmarksPos += 1
             lineNumber = bookms[self.__bookmarksPos]
         elif len(bookms) > 0:
             if index < (len(bookList) - 1):
                 self.__bookmarksFile = bookList[index + 1]
             else:
                 self.__bookmarksFile = bookList[0]
             self.__bookmarksPos = 0
             bookms = settings.BOOKMARKS[self.__bookmarksFile]
             lineNumber = bookms[0]
     else:
         if self.__bookmarksPos > 0:
             self.__bookmarksPos -= 1
             lineNumber = bookms[self.__bookmarksPos]
         elif len(bookms) > 0:
             self.__bookmarksFile = bookList[index - 1]
             bookms = settings.BOOKMARKS[self.__bookmarksFile]
             self.__bookmarksPos = len(bookms) - 1
             lineNumber = bookms[self.__bookmarksPos]
     if file_manager.file_exists(self.__bookmarksFile):
         self.ide.mainContainer.open_file(self.__bookmarksFile, lineNumber,
                                          None, True)
     else:
         settings.BOOKMARKS.pop(self.__bookmarksFile)
Exemple #12
0
 def _navigate_breakpoints(self, val):
     """Navigate between the breakpoints."""
     breakList = list(settings.BREAKPOINTS.keys())
     breakList.sort()
     if not breakList:
         return
     if self.__breakpointsFile not in breakList:
         self.__breakpointsFile = breakList[0]
     index = breakList.index(self.__breakpointsFile)
     breaks = settings.BREAKPOINTS.get(self.__breakpointsFile, [])
     lineNumber = 0
     #val == True: forward
     if val:
         if (len(breaks) - 1) > self.__breakpointsPos:
             self.__breakpointsPos += 1
             lineNumber = breaks[self.__breakpointsPos]
         elif len(breaks) > 0:
             if index < (len(breakList) - 1):
                 self.__breakpointsFile = breakList[index + 1]
             else:
                 self.__breakpointsFile = breakList[0]
             self.__breakpointsPos = 0
             breaks = settings.BREAKPOINTS[self.__breakpointsFile]
             lineNumber = breaks[0]
     else:
         if self.__breakpointsPos > 0:
             self.__breakpointsPos -= 1
             lineNumber = breaks[self.__breakpointsPos]
         elif len(breaks) > 0:
             self.__breakpointsFile = breakList[index - 1]
             breaks = settings.BREAKPOINTS[self.__breakpointsFile]
             self.__breakpointsPos = len(breaks) - 1
             lineNumber = breaks[self.__breakpointsPos]
     if file_manager.file_exists(self.__breakpointsFile):
         self.ide.mainContainer.open_file(self.__breakpointsFile,
                                          lineNumber, None, True)
     else:
         settings.BREAKPOINTS.pop(self.__breakpointsFile)
Exemple #13
0
 def _navigate_breakpoints(self, val):
     """Navigate between the breakpoints."""
     breakList = settings.BREAKPOINTS.keys()
     breakList.sort()
     if not breakList:
         return
     if self.__breakpointsFile not in breakList:
         self.__breakpointsFile = breakList[0]
     index = breakList.index(self.__breakpointsFile)
     breaks = settings.BREAKPOINTS.get(self.__breakpointsFile, [])
     lineNumber = 0
     #val == True: forward
     if val:
         if (len(breaks) - 1) > self.__breakpointsPos:
             self.__breakpointsPos += 1
             lineNumber = breaks[self.__breakpointsPos]
         elif len(breaks) > 0:
             if index < (len(breakList) - 1):
                 self.__breakpointsFile = breakList[index + 1]
             else:
                 self.__breakpointsFile = breakList[0]
             self.__breakpointsPos = 0
             breaks = settings.BREAKPOINTS[self.__breakpointsFile]
             lineNumber = breaks[0]
     else:
         if self.__breakpointsPos > 0:
             self.__breakpointsPos -= 1
             lineNumber = breaks[self.__breakpointsPos]
         elif len(breaks) > 0:
             self.__breakpointsFile = breakList[index - 1]
             breaks = settings.BREAKPOINTS[self.__breakpointsFile]
             self.__breakpointsPos = len(breaks) - 1
             lineNumber = breaks[self.__breakpointsPos]
     if file_manager.file_exists(self.__breakpointsFile):
         self.ide.mainContainer.open_file(self.__breakpointsFile,
             lineNumber, None, True)
     else:
         settings.BREAKPOINTS.pop(self.__breakpointsFile)
Exemple #14
0
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_())
Exemple #15
0
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_())
Exemple #16
0
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_())
Exemple #17
0
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_())
Exemple #18
0
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_())