Example #1
0
 def on_previewView_linkClicked(self, url):
     """
     Private slot handling the clicking of a link.
     
     @param url url of the clicked link (QUrl)
     """
     e5App().getObject("UserInterface").launchHelpViewer(url.toString())
 def __saOpenProject(self, pfname):
     """
     Private method used to handle the "Open Project" command.
     
     @param pfname filename of the project to be opened (string)
     """
     e5App().getObject("Project").openProject(pfname)
Example #3
0
 def activate(self):
     """
     Public method to activate this plugin.
     
     @return tuple of None and activation status (boolean)
     """
     menu = e5App().getObject("Project").getMenu("Apidoc")
     if menu:
         self.__projectAct = \
             E5Action(
                 self.tr('Generate documentation (eric6_doc)'),
                 self.tr('Generate &documentation (eric6_doc)'), 0, 0,
                 self, 'doc_eric6_doc')
         self.__projectAct.setStatusTip(
             self.tr('Generate API documentation using eric6_doc'))
         self.__projectAct.setWhatsThis(self.tr(
             """<b>Generate documentation</b>"""
             """<p>Generate API documentation using eric6_doc.</p>"""
         ))
         self.__projectAct.triggered.connect(self.__doEricdoc)
         e5App().getObject("Project").addE5Actions([self.__projectAct])
         menu.addAction(self.__projectAct)
     
     e5App().getObject("Project").showMenu.connect(self.__projectShowMenu)
     
     return None, True
 def __saArguments(self, argsStr):
     """
     Private method used to handle the "Arguments" command.
     
     @param argsStr space delimited list of command args(string)
     """
     e5App().getObject("DebugUI").setArgvHistory(argsStr)
Example #5
0
 def __init__(self, ui):
     """
     Constructor
     
     @param ui reference to the user interface object (UI.UserInterface)
     """
     super(VcsMercurialPlugin, self).__init__(ui)
     self.__ui = ui
     
     self.__mercurialDefaults = {
         "StopLogOnCopy": True,  # used in log browser
         "UseLogBrowser": True,
         "LogLimit": 20,
         "CommitMessages": 20,
         "PullUpdate": False,
         "PreferUnbundle": False,
         "ServerPort": 8000,
         "ServerStyle": "",
         "CleanupPatterns": "*.orig *.rej *~",
         "CreateBackup": False,
         "InternalMerge": False,
         "Encoding": "utf-8",
         "EncodingMode": "strict",
         "ConsiderHidden": False,
     }
     
     from VcsPlugins.vcsMercurial.ProjectHelper import HgProjectHelper
     self.__projectHelperObject = HgProjectHelper(None, None)
     try:
         e5App().registerPluginObject(
             pluginTypename, self.__projectHelperObject, pluginType)
     except KeyError:
         pass    # ignore duplicate registration
     readShortcuts(pluginName=pluginTypename)
 def __saOpenFile(self, fname):
     """
     Private method used to handle the "Open File" command.
     
     @param fname filename to be opened (string)
     """
     e5App().getObject("ViewManager").openSourceFile(fname)
Example #7
0
    def __replaceInDirectory(self):
        """
        Private slot to handle the Find&Replace in directory popup menu entry.
        """
        index = self.currentIndex()
        searchDir = self.model().item(index).dirName()

        e5App().getObject("UserInterface").showReplaceFilesDialog(searchDir=searchDir)
Example #8
0
 def prepareUnload(self):
     """
     Public method to prepare for an unload.
     """
     if self.__projectHelperObject:
         self.__projectHelperObject.removeToolbar(
             self.__ui, e5App().getObject("ToolbarManager"))
     e5App().unregisterPluginObject(pluginTypename)
Example #9
0
 def on_editButton_clicked(self):
     """
     Private slot to open the selected file in an editor.
     """
     itm = self.conflictsList.selectedItems()[0]
     filename = itm.data(0, self.FilenameRole)
     if Utilities.MimeTypes.isTextFile(filename):
         e5App().getObject("ViewManager").getEditor(filename)
Example #10
0
 def __configure(self):
     """
     Private method to open the configuration dialog.
     """
     if self.__embeddedBrowser == 1:
         e5App().getObject("UserInterface").showPreferences("debuggerGeneralPage")
     elif self.__embeddedBrowser == 2:
         e5App().getObject("UserInterface").showPreferences("projectBrowserPage")
Example #11
0
 def __compileQRCDone(self, exitCode, exitStatus):
     """
     Private slot to handle the finished signal of the compile process.
     
     @param exitCode exit code of the process (integer)
     @param exitStatus exit status of the process (QProcess.ExitStatus)
     """
     self.compileRunning = False
     e5App().getObject("ViewManager").enableEditorsCheckFocusIn(True)
     ui = e5App().getObject("UserInterface")
     if exitStatus == QProcess.NormalExit and exitCode == 0 and self.buf:
         ofn = os.path.join(self.project.ppath, self.compiledFile)
         try:
             if self.project.useSystemEol():
                 newline = None
             else:
                 newline = self.project.getEolString()
             f = open(ofn, "w", encoding="utf-8", newline=newline)
             for line in self.buf.splitlines():
                 f.write(line + "\n")
             f.close()
             if self.compiledFile not in self.project.pdata["SOURCES"]:
                 self.project.appendFile(ofn)
             if not self.noDialog and not ui.notificationsEnabled():
                 E5MessageBox.information(
                     self,
                     self.tr("Resource Compilation"),
                     self.tr("The compilation of the resource file"
                             " was successful."))
             else:
                 ui.showNotification(
                     UI.PixmapCache.getPixmap("resourcesCompiler48.png"),
                     self.tr("Resource Compilation"),
                     self.tr("The compilation of the resource file"
                             " was successful."))
         except IOError as msg:
             if not self.noDialog:
                 E5MessageBox.information(
                     self,
                     self.tr("Resource Compilation"),
                     self.tr(
                         "<p>The compilation of the resource file"
                         " failed.</p><p>Reason: {0}</p>").format(str(msg)))
     else:
         if not self.noDialog:
             E5MessageBox.information(
                 self,
                 self.tr("Resource Compilation"),
                 self.tr(
                     "The compilation of the resource file failed."))
         else:
             ui.showNotification(
                 UI.PixmapCache.getPixmap("resourcesCompiler48.png"),
                 self.tr("Resource Compilation"),
                 self.tr(
                     "The compilation of the resource file failed."))
     self.compileProc = None
Example #12
0
 def writeXML(self):
     """
     Public method to write the XML to the file.
     """
     XMLStreamWriterBase.writeXML(self)
     
     self.writeDTD('<!DOCTYPE Tasks SYSTEM "Tasks-{0}.dtd">'.format(
         tasksFileFormatVersion))
     
     # add some generation comments
     if self.forProject:
         self.writeComment(
             " eric6 tasks file for project {0} ".format(self.name))
         if Preferences.getProject("XMLTimestamp"):
             self.writeComment(" Saved: {0} ".format(
                 time.strftime('%Y-%m-%d, %H:%M:%S')))
     else:
         self.writeComment(" eric6 tasks file ")
         self.writeComment(
             " Saved: {0} ".format(time.strftime('%Y-%m-%d, %H:%M:%S')))
     
     # add the main tag
     self.writeStartElement("Tasks")
     self.writeAttribute("version", tasksFileFormatVersion)
     
     # write the project scan filter
     if self.forProject:
         self.writeTextElement(
             "ProjectScanFilter",
             e5App().getObject("TaskViewer").projectTasksScanFilter.strip())
     
     # do the tasks
     if self.forProject:
         tasks = e5App().getObject("TaskViewer").getProjectTasks()
     else:
         tasks = e5App().getObject("TaskViewer").getGlobalTasks()
     for task in tasks:
         self.writeStartElement("Task")
         self.writeAttribute("priority", str(task.priority))
         self.writeAttribute("completed", str(task.completed))
         self.writeAttribute("type", str(task.taskType))
         self.writeTextElement("Summary", task.summary.strip())
         self.writeTextElement("Description", task.description.strip())
         self.writeTextElement("Created", time.strftime(
             "%Y-%m-%d, %H:%M:%S", time.localtime(task.created)))
         if task.filename:
             self.writeStartElement("Resource")
             self.writeTextElement(
                 "Filename",
                 Utilities.fromNativeSeparators(task.filename))
             self.writeTextElement("Linenumber", str(task.lineno))
             self.writeEndElement()
         self.writeEndElement()
     
     self.writeEndElement()
     self.writeEndDocument()
Example #13
0
 def shutdown(self):
     """
     Public method to shut down the object.
     
     This method does some preparations so the object can be deleted
     properly. It disconnects from the focusChanged signal in order to
     avoid trouble later on.
     """
     e5App().focusChanged[QWidget, QWidget].disconnect(
         self.__appFocusChanged)
Example #14
0
 def deactivate(self):
     """
     Public method to deactivate this plugin.
     """
     e5App().getObject("Project").showMenu.disconnect(
         self.__projectShowMenu)
     e5App().getObject("ProjectBrowser").getProjectBrowser("sources")\
         .showMenu.disconnect(self.__projectBrowserShowMenu)
     e5App().getObject("ViewManager").editorOpenedEd.disconnect(
         self.__editorOpened)
     e5App().getObject("ViewManager").editorClosedEd.disconnect(
         self.__editorClosed)
     
     menu = e5App().getObject("Project").getMenu("Checks")
     if menu:
         menu.removeAction(self.__projectAct)
     
     if self.__projectBrowserMenu:
         if self.__projectBrowserAct:
             self.__projectBrowserMenu.removeAction(
                 self.__projectBrowserAct)
     
     for editor in self.__editors:
         editor.showMenu.disconnect(self.__editorShowMenu)
         menu = editor.getMenu("Checks")
         if menu is not None:
             menu.removeAction(self.__editorAct)
     
     self.__initialize()
Example #15
0
    def deactivate(self):
        """
        Public method to deactivate this plugin.
        """
        e5App().getObject("Project").showMenu.disconnect(self.__projectShowMenu)

        menu = e5App().getObject("Project").getMenu("Apidoc")
        if menu:
            menu.removeAction(self.__projectAct)
            e5App().getObject("Project").removeE5Actions([self.__projectAct])
        self.__initialize()
Example #16
0
 def __init__(self, device, projectName):
     """
     Constructor
     
     @param device reference to the I/O device to write to (QIODevice)
     @param projectName name of the project (string)
     """
     XMLStreamWriterBase.__init__(self, device)
     
     self.pudata = e5App().getObject("Project").pudata
     self.pdata = e5App().getObject("Project").pdata
     self.name = projectName
Example #17
0
 def on_resultList_itemActivated(self, itm, col):
     """
     Private slot to handle the activation of an item.
     
     @param itm reference to the activated item (QTreeWidgetItem)
     @param col column the item was activated in (integer)
     """
     if self.noResults:
         return
     
     fn = Utilities.normabspath(itm.data(0, self.filenameRole))
     lineno = int(itm.text(1))
     
     e5App().getObject("ViewManager").openSourceFile(fn, lineno)
Example #18
0
 def __init__(self, ui):
     """
     Constructor
     
     @param ui reference to the user interface object (UI.UserInterface)
     """
     super(CodeStyleCheckerPlugin, self).__init__(ui)
     self.__ui = ui
     self.__initialize()
     
     self.backgroundService = e5App().getObject("BackgroundService")
     
     path = os.path.join(
         os.path.dirname(__file__), 'CheckerPlugins', 'CodeStyleChecker')
     self.backgroundService.serviceConnect(
         'style', 'Python2', path, 'CodeStyleChecker',
         self.__translateStyleCheck,
         onErrorCallback=self.serviceErrorPy2,
         onBatchDone=self.batchJobDone)
     self.backgroundService.serviceConnect(
         'style', 'Python3', path, 'CodeStyleChecker',
         self.__translateStyleCheck,
         onErrorCallback=self.serviceErrorPy3,
         onBatchDone=self.batchJobDone)
     
     self.queuedBatches = []
     self.batchesFinished = True
Example #19
0
    def __init__(self, ui):
        """
        Constructor
        
        @param ui reference to the user interface object (UI.UserInterface)
        """
        super(TabnannyPlugin, self).__init__(ui)
        self.__ui = ui
        self.__initialize()

        self.backgroundService = e5App().getObject("BackgroundService")

        path = os.path.join(os.path.dirname(__file__), "CheckerPlugins", "Tabnanny")
        self.backgroundService.serviceConnect(
            "indent",
            "Python2",
            path,
            "Tabnanny",
            lambda *args: self.indentChecked.emit(*args),
            onErrorCallback=self.serviceErrorPy2,
        )
        self.backgroundService.serviceConnect(
            "indent",
            "Python3",
            path,
            "Tabnanny",
            lambda *args: self.indentChecked.emit(*args),
            onErrorCallback=self.serviceErrorPy3,
        )
Example #20
0
 def __projectBrowserShowMenu(self, menuName, menu):
     """
     Private slot called, when the the project browser menu or a submenu is
     about to be shown.
     
     @param menuName name of the menu to be shown (string)
     @param menu reference to the menu (QMenu)
     """
     if menuName == "Checks" and \
        e5App().getObject("Project").getProjectLanguage() in \
             ["Python3", "Python2", "Python"]:
         self.__projectBrowserMenu = menu
         if self.__projectBrowserAct is None:
             self.__projectBrowserAct = E5Action(
                 self.tr('Check Code Style'),
                 self.tr('&Code Style...'), 0, 0,
                 self, "")
             self.__projectBrowserAct.setWhatsThis(self.tr(
                 """<b>Check Code Style...</b>"""
                 """<p>This checks Python files for compliance to the"""
                 """ code style conventions given in various PEPs.</p>"""
             ))
             self.__projectBrowserAct.triggered.connect(
                 self.__projectBrowserCodeStyleCheck)
         if self.__projectBrowserAct not in menu.actions():
             menu.addAction(self.__projectBrowserAct)
Example #21
0
 def __projectBrowserCodeStyleCheck(self):
     """
     Private method to handle the code style check context menu action of
     the project sources browser.
     """
     browser = e5App().getObject("ProjectBrowser")\
         .getProjectBrowser("sources")
     if browser.getSelectedItemsCount([ProjectBrowserFileItem]) > 1:
         fn = []
         for itm in browser.getSelectedItems([ProjectBrowserFileItem]):
             fn.append(itm.fileName())
         isDir = False
     else:
         itm = browser.model().item(browser.currentIndex())
         try:
             fn = itm.fileName()
             isDir = False
         except AttributeError:
             fn = itm.dirName()
             isDir = True
     
     from CheckerPlugins.CodeStyleChecker.CodeStyleCheckerDialog import \
         CodeStyleCheckerDialog
     self.__projectBrowserCodeStyleCheckerDialog = CodeStyleCheckerDialog(
         self)
     self.__projectBrowserCodeStyleCheckerDialog.show()
     if isDir:
         self.__projectBrowserCodeStyleCheckerDialog.start(
             fn, save=True)
     else:
         self.__projectBrowserCodeStyleCheckerDialog.start(
             fn, save=True, repeat=True)
Example #22
0
 def on_newConnection(self):
     """
     Private slot for new incomming connections from the clients.
     """
     connection = self.nextPendingConnection()
     if not connection.waitForReadyRead(1000):
         return
     lang = connection.read(64)
     if sys.version_info[0] == 3:
         lang = lang.decode('utf-8')
     # Avoid hanging of eric on shutdown
     if self.connections.get(lang):
         self.connections[lang].close()
     if self.isWorking == lang:
         self.isWorking = None
     self.connections[lang] = connection
     connection.readyRead.connect(
         lambda x=lang: self.__receive(x))
     connection.disconnected.connect(
         lambda x=lang: self.on_disconnectSocket(x))
         
     for (fx, lng), args in self.services.items():
         if lng == lang:
             # Register service with modulepath and module
             self.enqueueRequest('INIT', lng, fx, args[:2])
     
     # Syntax check the open editors again
     try:
         vm = e5App().getObject("ViewManager")
     except KeyError:
         return
     for editor in vm.getOpenEditors():
         if editor.getLanguage() == lang:
             QTimer.singleShot(0, editor.checkSyntax)
Example #23
0
 def __init__(self):
     """
     Constructor
     """
     super(ProjectBrowserPage, self).__init__()
     self.setupUi(self)
     self.setObjectName("ProjectBrowserPage")
     
     self.__currentProjectTypeIndex = 0
     
     # set initial values
     self.projectTypeCombo.addItem('', '')
     self.__projectBrowserFlags = {'': 0}
     try:
         projectTypes = e5App().getObject("Project").getProjectTypes()
         for projectType in sorted(projectTypes.keys()):
             self.projectTypeCombo.addItem(projectTypes[projectType],
                                           projectType)
             self.__projectBrowserFlags[projectType] = \
                 Preferences.getProjectBrowserFlags(projectType)
     except KeyError:
         self.pbGroup.setEnabled(False)
     
     self.initColour(
         "Highlighted", self.pbHighlightedButton,
         Preferences.getProjectBrowserColour)
     
     self.followEditorCheckBox.setChecked(
         Preferences.getProject("FollowEditor"))
     self.followCursorLineCheckBox.setChecked(
         Preferences.getProject("FollowCursorLine"))
     self.autoPopulateCheckBox.setChecked(
         Preferences.getProject("AutoPopulateItems"))
     self.hideGeneratedCheckBox.setChecked(
         Preferences.getProject("HideGeneratedForms"))
Example #24
0
 def __init__(self, ui):
     """
     Constructor
     
     @param ui reference to the user interface object (UI.UserInterface)
     """
     super(TabnannyPlugin, self).__init__(ui)
     self.__ui = ui
     self.__initialize()
     
     self.backgroundService = e5App().getObject("BackgroundService")
     
     path = os.path.join(
         os.path.dirname(__file__), 'CheckerPlugins', 'Tabnanny')
     self.backgroundService.serviceConnect(
         'indent', 'Python2', path, 'Tabnanny',
         lambda *args: self.indentChecked.emit(*args),
         onErrorCallback=self.serviceErrorPy2,
         onBatchDone=self.batchJobDone)
     self.backgroundService.serviceConnect(
         'indent', 'Python3', path, 'Tabnanny',
         lambda *args: self.indentChecked.emit(*args),
         onErrorCallback=self.serviceErrorPy3,
         onBatchDone=self.batchJobDone)
     
     self.queuedBatches = []
     self.batchesFinished = True
Example #25
0
 def __projectBrowserShowMenu(self, menuName, menu):
     """
     Private slot called, when the the project browser context menu or a
     submenu is about to be shown.
     
     @param menuName name of the menu to be shown (string)
     @param menu reference to the menu (QMenu)
     """
     if menuName == "Checks" and \
        e5App().getObject("Project").getProjectLanguage() in \
             ["Python3", "Python2", "Python"]:
         self.__projectBrowserMenu = menu
         if self.__projectBrowserAct is None:
             self.__projectBrowserAct = E5Action(
                 self.tr('Check Indentations'),
                 self.tr('&Indentations...'), 0, 0,
                 self, "")
             self.__projectBrowserAct.setWhatsThis(self.tr(
                 """<b>Check Indentations...</b>"""
                 """<p>This checks Python files"""
                 """ for bad indentations using tabnanny.</p>"""
             ))
             self.__projectBrowserAct.triggered.connect(
                 self.__projectBrowserTabnanny)
         if self.__projectBrowserAct not in menu.actions():
             menu.addAction(self.__projectBrowserAct)
Example #26
0
 def _VCSCommit(self):
     """
     Protected slot called by the context menu to commit the changes to the
     VCS repository.
     """
     if self.isTranslationsBrowser:
         names = [itm.dirName()
                  for itm in self.browser.getSelectedItems(
                      [ProjectBrowserSimpleDirectoryItem])]
         if not names:
             names = [itm.fileName()
                      for itm in self.browser.getSelectedItems(
                          [ProjectBrowserFileItem])]
     else:
         names = []
         for itm in self.browser.getSelectedItems():
             try:
                 name = itm.fileName()
             except AttributeError:
                 name = itm.dirName()
             names.append(name)
     if Preferences.getVCS("AutoSaveFiles"):
         vm = e5App().getObject("ViewManager")
         for name in names:
             vm.saveEditor(name)
     self.vcs.vcsCommit(names, '')
Example #27
0
def exportShortcuts(fn):
    """
    Module function to export the keyboard shortcuts for the defined QActions.
    
    @param fn filename of the export file (string)
    """
    # let the plugin manager create on demand plugin objects
    pm = e5App().getObject("PluginManager")
    pm.initOnDemandPlugins()
    
    f = QFile(fn)
    if f.open(QIODevice.WriteOnly):
        from E5XML.ShortcutsWriter import ShortcutsWriter
        ShortcutsWriter(f).writeXML()
        f.close()
    else:
        E5MessageBox.critical(
            None,
            QCoreApplication.translate(
                "Shortcuts", "Export Keyboard Shortcuts"),
            QCoreApplication.translate(
                "Shortcuts",
                "<p>The keyboard shortcuts could not be written to file"
                " <b>{0}</b>.</p>")
            .format(fn))
Example #28
0
def importShortcuts(fn):
    """
    Module function to import the keyboard shortcuts for the defined E5Actions.
    
    @param fn filename of the import file (string)
    """
    # let the plugin manager create on demand plugin objects
    pm = e5App().getObject("PluginManager")
    pm.initOnDemandPlugins()
    
    f = QFile(fn)
    if f.open(QIODevice.ReadOnly):
        from E5XML.ShortcutsReader import ShortcutsReader
        reader = ShortcutsReader(f)
        reader.readXML()
        f.close()
        if not reader.hasError():
            shortcuts = reader.getShortcuts()
            setActions(shortcuts)
            saveShortcuts()
            syncPreferences()
    else:
        E5MessageBox.critical(
            None,
            QCoreApplication.translate(
                "Shortcuts", "Import Keyboard Shortcuts"),
            QCoreApplication.translate(
                "Shortcuts",
                "<p>The keyboard shortcuts could not be read from file"
                " <b>{0}</b>.</p>")
            .format(fn))
        return
Example #29
0
 def __projectBrowserShowMenu(self, menuName, menu):
     """
     Private slot called, when the the project browser menu or a submenu is
     about to be shown.
     
     @param menuName name of the menu to be shown (string)
     @param menu reference to the menu (QMenu)
     """
     if menuName == "Checks" and \
        e5App().getObject("Project").getProjectLanguage() in \
             self.syntaxCheckService.getLanguages():
         self.__projectBrowserMenu = menu
         if self.__projectBrowserAct is None:
             self.__projectBrowserAct = E5Action(
                 self.tr('Check Syntax'),
                 self.tr('&Syntax...'), 0, 0,
                 self, "")
             self.__projectBrowserAct.setWhatsThis(self.tr(
                 """<b>Check Syntax...</b>"""
                 """<p>This checks Python files for syntax errors.</p>"""
             ))
             self.__projectBrowserAct.triggered.connect(
                 self.__projectBrowserSyntaxCheck)
         if self.__projectBrowserAct not in menu.actions():
             menu.addAction(self.__projectBrowserAct)
Example #30
0
def prepareUninstall():
    """
    Module function to prepare for an uninstallation.
    """
    if not e5App().getObject("PluginManager").isPluginLoaded(
            "PluginVcsMercurial"):
        Preferences.Prefs.settings.remove("Mercurial")