def on_vcsUrlButton_clicked(self):
        """
        Private slot to display a selection dialog.
        """
        if self.protocolCombo.currentText() == "file://":
            directory = E5FileDialog.getExistingDirectory(
                self, self.tr("Select Repository-Directory"),
                self.vcsUrlEdit.text(),
                E5FileDialog.Options(E5FileDialog.ShowDirsOnly))

            if directory:
                self.vcsUrlEdit.setText(
                    Utilities.toNativeSeparators(directory))
        else:
            from .SvnRepoBrowserDialog import SvnRepoBrowserDialog
            dlg = SvnRepoBrowserDialog(self.vcs, mode="select", parent=self)
            dlg.start(self.protocolCombo.currentText() +
                      self.vcsUrlEdit.text())
            if dlg.exec_() == QDialog.Accepted:
                url = dlg.getSelectedUrl()
                if url:
                    protocol = url.split("://")[0]
                    path = url.split("://")[1]
                    self.protocolCombo.setCurrentIndex(
                        self.protocolCombo.findText(protocol + "://"))
                    self.vcsUrlEdit.setText(path)
示例#2
0
    def on_archiveButton_clicked(self):
        """
        Private slot to select the archive name via a file selection dialog.
        """
        type_ = self.typeComboBox.itemData(self.typeComboBox.currentIndex())

        archive = Utilities.fromNativeSeparators(self.archiveEdit.text())
        if not archive:
            archive = self.__projectPath

        if type_ == "files":
            archive = E5FileDialog.getExistingDirectory(
                self, self.tr("Select Archive Directory"), archive,
                E5FileDialog.Options(E5FileDialog.ShowDirsOnly))
        else:
            archive, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
                self, self.tr("Select Archive File"), archive,
                self.__fileFilters, None,
                E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
            if archive:
                ext = QFileInfo(archive).suffix()
                if not ext:
                    ex = selectedFilter.split("(*")[1].split(")")[0]
                    if ex:
                        archive += ex

        if archive:
            self.archiveEdit.setText(Utilities.toNativeSeparators(archive))
示例#3
0
    def __exportStyles(self, lexers):
        """
        Private method to export the styles of the given lexers.
        
        @param lexers list of lexer objects for which to export the styles
        """
        fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
            self, self.tr("Export Highlighting Styles"), "",
            self.tr("Highlighting styles file (*.e4h)"), "",
            E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))

        if not fn:
            return

        ext = QFileInfo(fn).suffix()
        if not ext:
            ex = selectedFilter.split("(*")[1].split(")")[0]
            if ex:
                fn += ex

        f = QFile(fn)
        if f.open(QIODevice.WriteOnly):
            from E5XML.HighlightingStylesWriter import HighlightingStylesWriter
            HighlightingStylesWriter(f, lexers).writeXML()
            f.close()
        else:
            E5MessageBox.critical(
                self, self.tr("Export Highlighting Styles"),
                self.tr(
                    """<p>The highlighting styles could not be exported"""
                    """ to file <b>{0}</b>.</p><p>Reason: {1}</p>""").format(
                        fn, f.errorString()))
示例#4
0
    def on_saveButton_clicked(self):
        """
        Private slot to save the snapshot.
        """
        if not self.__snapshot.isNull():
            while os.path.exists(self.__filename):
                self.__autoIncFilename()

            fileName, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
                self, self.tr("Save Snapshot"), self.__filename,
                self.__outputFilter, self.__defaultFilter,
                E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
            if not fileName:
                return

            ext = QFileInfo(fileName).suffix()
            if not ext:
                ex = selectedFilter.split("(*")[1].split(")")[0]
                if ex:
                    fileName += ex

            if self.__saveImage(fileName):
                self.__modified = False
                self.__filename = fileName
                self.__autoIncFilename()
                self.__updateCaption()
示例#5
0
 def on_archiveButton_clicked(self):
     """
     Private slot to select the archive name via a file selection dialog.
     """
     type_ = self.typeComboBox.itemData(self.typeComboBox.currentIndex())
     
     archive = Utilities.fromNativeSeparators(self.archiveEdit.text())
     if not archive:
         archive = self.__projectPath
     
     if type_ == "files":
         archive = E5FileDialog.getExistingDirectory(
             self,
             self.tr("Select Archive Directory"),
             archive,
             E5FileDialog.Options(E5FileDialog.ShowDirsOnly))
     else:
         archive, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
             self,
             self.tr("Select Archive File"),
             archive,
             self.__fileFilters,
             None,
             E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
         if archive:
             ext = QFileInfo(archive).suffix()
             if not ext:
                 ex = selectedFilter.split("(*")[1].split(")")[0]
                 if ex:
                     archive += ex
     
     if archive:
         self.archiveEdit.setText(Utilities.toNativeSeparators(archive))
示例#6
0
 def __installPip(self):
     """
     Private slot to install pip.
     """
     python = E5FileDialog.getOpenFileName(
         None, self.tr("Select Python Executable"))
     if python:
         python = QDir.toNativeSeparators(python)
         dia = PipDialog(self.tr('Install PIP'))
         res = dia.startProcesses([
             (python, ["-m", "ensurepip"]),
             (python, ["-m", "pip", "install", "--upgrade", "pip"]),
         ])
         if res:
             dia.exec_()
             pip = E5FileDialog.getOpenFileName(
                 None, self.tr("Select PIP Executable"),
                 os.path.dirname(python))
             if pip:
                 pip = QDir.toNativeSeparators(pip)
                 pipExecutables = \
                     self.__plugin.getPreferences("PipExecutables")
                 if pip not in pipExecutables:
                     pipExecutables.append(pip)
                     self.__plugin.setPreferences("PipExecutables",
                                                  pipExecutables)
示例#7
0
    def _getFileName(self, filter):
        """
        Protected method to get the file name of the export file from the user.
        
        @param filter the filter string to be used (string). The filter for
            "All Files (*)" is appended by this method.
        @return file name entered by the user (string)
        """
        filter_ = filter
        filter_ += ";;"
        filter_ += QCoreApplication.translate('Exporter', "All Files (*)")
        fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
            self.editor, self.tr("Export source"), "", filter_, "",
            E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))

        if fn:
            ext = QFileInfo(fn).suffix()
            if not ext:
                ex = selectedFilter.split("(*")[1].split(")")[0]
                if ex:
                    fn += ex
            if QFileInfo(fn).exists():
                res = E5MessageBox.yesNo(
                    self.editor,
                    self.tr("Export source"),
                    self.tr("<p>The file <b>{0}</b> already exists."
                            " Overwrite it?</p>").format(fn),
                    icon=E5MessageBox.Warning)
                if not res:
                    return ""

            fn = Utilities.toNativeSeparators(fn)

        return fn
示例#8
0
    def saveImage(self):
        """
        Public method to handle the save context menu entry.
        """
        fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
            self, self.tr("Save Diagram"), "",
            self.tr("Portable Network Graphics (*.png);;"
                    "Scalable Vector Graphics (*.svg)"), "",
            E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
        if fname:
            ext = QFileInfo(fname).suffix()
            if not ext:
                ex = selectedFilter.split("(*")[1].split(")")[0]
                if ex:
                    fname += ex
            if QFileInfo(fname).exists():
                res = E5MessageBox.yesNo(
                    self,
                    self.tr("Save Diagram"),
                    self.tr("<p>The file <b>{0}</b> already exists."
                            " Overwrite it?</p>").format(fname),
                    icon=E5MessageBox.Warning)
                if not res:
                    return

            success = super(UMLGraphicsView,
                            self).saveImage(fname,
                                            QFileInfo(fname).suffix().upper())
            if not success:
                E5MessageBox.critical(
                    self, self.tr("Save Diagram"),
                    self.tr(
                        """<p>The file <b>{0}</b> could not be saved.</p>""").
                    format(fname))
示例#9
0
 def on_saveButton_clicked(self):
     """
     Private slot to handle the Save button press.
     
     It saves the diff shown in the dialog to a file in the local
     filesystem.
     """
     if isinstance(self.__filename, list):
         if len(self.__filename) > 1:
             fname = self.vcs.splitPathList(self.__filename)[0]
         else:
             dname, fname = self.vcs.splitPath(self.__filename[0])
             if fname != '.':
                 fname = "{0}.diff".format(self.__filename[0])
             else:
                 fname = dname
     else:
         fname = self.vcs.splitPath(self.__filename)[0]
     
     fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
         self,
         self.tr("Save Diff"),
         fname,
         self.tr("Patch Files (*.diff)"),
         None,
         E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
     
     if not fname:
         return  # user aborted
     
     ext = QFileInfo(fname).suffix()
     if not ext:
         ex = selectedFilter.split("(*")[1].split(")")[0]
         if ex:
             fname += ex
     if QFileInfo(fname).exists():
         res = E5MessageBox.yesNo(
             self,
             self.tr("Save Diff"),
             self.tr("<p>The patch file <b>{0}</b> already exists."
                     " Overwrite it?</p>").format(fname),
             icon=E5MessageBox.Warning)
         if not res:
             return
     fname = Utilities.toNativeSeparators(fname)
     
     eol = e5App().getObject("Project").getEolString()
     try:
         f = open(fname, "w", encoding="utf-8", newline="")
         f.write(eol.join(self.contents2.toPlainText().splitlines()))
         f.write(eol)
         f.close()
     except IOError as why:
         E5MessageBox.critical(
             self, self.tr('Save Diff'),
             self.tr(
                 '<p>The patch file <b>{0}</b> could not be saved.'
                 '<br>Reason: {1}</p>')
             .format(fname, str(why)))
示例#10
0
 def __saveAs(self, filename=""):
     """
     Private slot to save the diagram.
     
     @param filename name of the file to write to (string)
     """
     if not filename:
         fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
             self,
             self.tr("Save Diagram"),
             "",
             self.tr("Eric Graphics File (*.e5g);;All Files (*)"),
             "",
             E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
         if not fname:
             return
         ext = QFileInfo(fname).suffix()
         if not ext:
             ex = selectedFilter.split("(*")[1].split(")")[0]
             if ex:
                 fname += ex
         if QFileInfo(fname).exists():
             res = E5MessageBox.yesNo(
                 self,
                 self.tr("Save Diagram"),
                 self.tr("<p>The file <b>{0}</b> already exists."
                         " Overwrite it?</p>").format(fname),
                 icon=E5MessageBox.Warning)
             if not res:
                 return
         filename = fname
     
     lines = [
         "version: 1.0",
         "diagram_type: {0} ({1})".format(
             self.__diagramType, self.__diagramTypeString()),
         "scene_size: {0};{1}".format(self.scene.width(),
                                      self.scene.height()),
     ]
     persistenceData = self.builder.getPersistenceData()
     if persistenceData:
         lines.append("builder_data: {0}".format(persistenceData))
     lines.extend(self.umlView.getPersistenceData())
     
     try:
         f = open(filename, "w", encoding="utf-8")
         f.write("\n".join(lines))
         f.close()
     except (IOError, OSError) as err:
         E5MessageBox.critical(
             self,
             self.tr("Save Diagram"),
             self.tr(
                 """<p>The file <b>{0}</b> could not be saved.</p>"""
                 """<p>Reason: {1}</p>""").format(filename, str(err)))
         return
     
     self.__fileName = filename
示例#11
0
 def on_exceptDirButton_clicked(self):
     """
     Private slot to select a file to exempt from translation.
     """
     texcept = E5FileDialog.getExistingDirectory(
         self,
         self.tr("Exempt directory from translation"), self.project.ppath,
         E5FileDialog.Options(E5FileDialog.ShowDirsOnly))
     if texcept:
         self.exceptionEdit.setText(Utilities.toNativeSeparators(texcept))
示例#12
0
    def on_dirSelectButton_clicked(self):
        """
        Private slot to display a directory selection dialog.
        """
        directory = E5FileDialog.getExistingDirectory(
            self, self.tr("Select directory"), self.dirCombo.currentText(),
            E5FileDialog.Options(E5FileDialog.ShowDirsOnly))

        if directory:
            self.dirCombo.setEditText(Utilities.toNativeSeparators(directory))
示例#13
0
    def on_iconDirectoryButton_clicked(self):
        """
        Private slot to select an icon directory.
        """
        dir = E5FileDialog.getExistingDirectory(
            None, self.tr("Select icon directory"), "",
            E5FileDialog.Options(E5FileDialog.ShowDirsOnly))

        if dir:
            self.iconDirectoryEdit.setText(Utilities.toNativeSeparators(dir))
示例#14
0
    def on_directoryButton_clicked(self):
        """
        Private slot called by pressing the export directory selection button.
        """
        dn = E5FileDialog.getExistingDirectory(
            self, self.tr("Export Patches"), self.directoryEdit.text(),
            E5FileDialog.Options(E5FileDialog.Option(0)))

        if dn:
            self.directoryEdit.setText(Utilities.toNativeSeparators(dn))
    def __newUiForm(self, path):
        """
        Private slot to handle the New Form menu action for Qt-related
        projects.
        
        @param path full directory path for the new form file (string)
        """
        selectedForm, ok = QInputDialog.getItem(None, self.tr("New Form"),
                                                self.tr("Select a form type:"),
                                                self.templateTypes4, 0, False)
        if not ok or not selectedForm:
            # user pressed cancel
            return

        templateIndex = self.templateTypes4.index(selectedForm)
        templateFile = os.path.join(getConfig('ericTemplatesDir'),
                                    self.templates4[templateIndex])

        fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
            self, self.tr("New Form"), path,
            self.tr("Qt User-Interface Files (*.ui);;All Files (*)"), "",
            E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))

        if not fname:
            # user aborted or didn't enter a filename
            return

        ext = QFileInfo(fname).suffix()
        if not ext:
            ex = selectedFilter.split("(*")[1].split(")")[0]
            if ex:
                fname += ex

        if os.path.exists(fname):
            res = E5MessageBox.yesNo(
                self,
                self.tr("New Form"),
                self.tr("The file already exists! Overwrite it?"),
                icon=E5MessageBox.Warning)
            if not res:
                # user selected to not overwrite
                return

        try:
            shutil.copy(templateFile, fname)
        except IOError as e:
            E5MessageBox.critical(
                self, self.tr("New Form"),
                self.tr(
                    "<p>The new form file <b>{0}</b> could not be created.<br>"
                    "Problem: {1}</p>").format(fname, str(e)))
            return

        self.project.appendFile(fname)
        self.designerFile.emit(fname)
示例#16
0
    def on_dirButton_clicked(self):
        """
        Private method used to open a directory selection dialog.
        """
        cwd = self.ui.workdirCombo.currentText()
        d = E5FileDialog.getExistingDirectory(
            self, self.tr("Working directory"), cwd,
            E5FileDialog.Options(E5FileDialog.ShowDirsOnly))

        if d:
            self.ui.workdirCombo.setEditText(Utilities.toNativeSeparators(d))
    def on_flashDataPathButton_clicked(self):
        """
        Private slot to handle the flash data path selection.
        """
        path = E5FileDialog.getExistingDirectory(
            self, self.tr("Select Flash Cookies Data Path"),
            self.flashDataPathEdit.text(),
            E5FileDialog.Options(E5FileDialog.ShowDirsOnly))

        if path:
            self.flashDataPathEdit.setText(Utilities.toNativeSeparators(path))
    def on_directoryButton_clicked(self):
        """
        Private slot to select the shared directory via a directory selection
        dialog.
        """
        directory = E5FileDialog.getExistingDirectory(
            self, self.tr("Shared Directory"), self.directoryEdit.text(),
            E5FileDialog.Options(E5FileDialog.Option(0)))

        if directory:
            self.directoryEdit.setText(Utilities.toNativeSeparators(directory))
示例#19
0
    def on_qt4TransButton_clicked(self):
        """
        Private slot to handle the Qt4 translations directory selection.
        """
        dir = E5FileDialog.getExistingDirectory(
            self, self.tr("Select Qt4 Translations Directory"),
            self.qt4TransEdit.text(),
            E5FileDialog.Options(E5FileDialog.ShowDirsOnly))

        if dir:
            self.qt4TransEdit.setText(Utilities.toNativeSeparators(dir))
示例#20
0
 def __newToplevelDir(self):
     """
     Private slot to handle the New toplevel directory popup menu entry.
     """
     dname = E5FileDialog.getExistingDirectory(
         None,
         QCoreApplication.translate('Browser', "New toplevel directory"),
         "", E5FileDialog.Options(E5FileDialog.ShowDirsOnly))
     if dname:
         dname = os.path.abspath(Utilities.toNativeSeparators(dname))
         self.__model.addTopLevelDir(dname)
示例#21
0
    def on_qtToolsDirButton_clicked(self):
        """
        Private slot to handle the Qt tools directory selection.
        """
        dir = E5FileDialog.getExistingDirectory(
            self, self.tr("Select Qt Tools Directory"),
            self.qtToolsDirEdit.text(),
            E5FileDialog.Options(E5FileDialog.DontUseNativeDialog))

        if dir:
            self.qtToolsDirEdit.setText(Utilities.toNativeSeparators(dir))
示例#22
0
 def on_saveButton_clicked(self):
     """
     Private slot to handle the Save button press.
     
     It saves the diff shown in the dialog to a file in the local
     filesystem.
     """
     dname, fname = Utilities.splitPath(self.filename2)
     if fname != '.':
         fname = "{0}.diff".format(self.filename2)
     else:
         fname = dname
         
     fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
         self,
         self.tr("Save Diff"),
         fname,
         self.tr("Patch Files (*.diff)"),
         None,
         E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
     
     if not fname:
         return
     
     ext = QFileInfo(fname).suffix()
     if not ext:
         ex = selectedFilter.split("(*")[1].split(")")[0]
         if ex:
             fname += ex
     if QFileInfo(fname).exists():
         res = E5MessageBox.yesNo(
             self,
             self.tr("Save Diff"),
             self.tr("<p>The patch file <b>{0}</b> already exists."
                     " Overwrite it?</p>").format(fname),
             icon=E5MessageBox.Warning)
         if not res:
             return
     fname = Utilities.toNativeSeparators(fname)
     
     try:
         f = open(fname, "w", encoding="utf-8")
         txt = self.contents.toPlainText()
         try:
             f.write(txt)
         except UnicodeError:
             pass
         f.close()
     except IOError as why:
         E5MessageBox.critical(
             self, self.tr('Save Diff'),
             self.tr(
                 '<p>The patch file <b>{0}</b> could not be saved.<br />'
                 'Reason: {1}</p>').format(fname, str(why)))
 def on_newProjectButton_clicked(self):
     """
     Private slot to select the new project directory name via a directory
     selection dialog.
     """
     directory = Utilities.fromNativeSeparators(self.newProjectEdit.text())
     directory = E5FileDialog.getExistingDirectory(
         self, self.tr("New Project Directory"), directory,
         E5FileDialog.Options(E5FileDialog.ShowDirsOnly))
     if directory:
         self.newProjectEdit.setText(
             Utilities.toNativeSeparators(directory))
示例#24
0
    def on_projectDirButton_clicked(self):
        """
        Private slot to display a directory selection dialog.
        """
        directory = E5FileDialog.getExistingDirectory(
            self, self.tr("Select Project Directory"),
            self.vcsProjectDirEdit.text(),
            E5FileDialog.Options(E5FileDialog.ShowDirsOnly))

        if directory:
            self.vcsProjectDirEdit.setText(
                Utilities.toNativeSeparators(directory))
示例#25
0
 def __saveMessages(self):
     """
     Private slot to save the contents of the messages display.
     """
     hasText = not self.messages.document().isEmpty()
     if hasText:
         if Utilities.isWindowsPlatform():
             htmlExtension = "htm"
         else:
             htmlExtension = "html"
         fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
             self,
             self.tr("Save Messages"),
             "",
             self.tr(
                 "HTML Files (*.{0});;Text Files (*.txt);;All Files (*)")
             .format(htmlExtension),
             None,
             E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
         if fname:
             ext = QFileInfo(fname).suffix()
             if not ext:
                 ex = selectedFilter.split("(*")[1].split(")")[0]
                 if ex:
                     fname += ex
                 ext = QFileInfo(fname).suffix()
             if QFileInfo(fname).exists():
                 res = E5MessageBox.yesNo(
                     self,
                     self.tr("Save Messages"),
                     self.tr("<p>The file <b>{0}</b> already exists."
                             " Overwrite it?</p>").format(fname),
                     icon=E5MessageBox.Warning)
                 if not res:
                     return
                 fname = Utilities.toNativeSeparators(fname)
             
             try:
                 if ext.lower() in ["htm", "html"]:
                     txt = self.messages.toHtml()
                 else:
                     txt = self.messages.toPlainText()
                 f = open(fname, "w", encoding="utf-8")
                 f.write(txt)
                 f.close()
             except IOError as err:
                 E5MessageBox.critical(
                     self,
                     self.tr("Error saving Messages"),
                     self.tr(
                         """<p>The messages contents could not be written"""
                         """ to <b>{0}</b></p><p>Reason: {1}</p>""")
                     .format(fname, str(err)))
    def on_searchDirButton_clicked(self):
        """
        Private slot to handle the clicked signal of the search directory
        selection button.
        """
        searchDir = E5FileDialog.getExistingDirectory(
            None, self.tr("Select search directory"),
            self.searchDirEdit.text(),
            E5FileDialog.Options(E5FileDialog.ShowDirsOnly))

        if searchDir:
            self.searchDirEdit.setText(Utilities.toNativeSeparators(searchDir))
示例#27
0
 def __saveImage(self):
     """
     Private slot to save the selected image to disk.
     """
     act = self.sender()
     index = act.data()
     itm = self.imagesTree.topLevelItem(index)
     if itm is None:
         return
     
     imageUrl = QUrl(itm.text(1))
     if not imageUrl.host():
         imageUrl.setHost(QUrl(self.siteAddressLabel.text()).host())
         imageUrl.setScheme(QUrl(self.siteAddressLabel.text()).scheme())
     
     import Helpviewer.HelpWindow
     cache = Helpviewer.HelpWindow.HelpWindow.networkAccessManager().cache()
     if cache:
         cacheData = cache.data(imageUrl)
     else:
         cacheData = None
     if not cacheData:
         E5MessageBox.critical(
             self,
             self.tr("Save Image"),
             self.tr("""This image is not available."""))
         return
     
     downloadDirectory = Helpviewer.HelpWindow.HelpWindow\
         .downloadManager().downloadDirectory()
     fn = os.path.join(downloadDirectory, os.path.basename(itm.text(1)))
     filename = E5FileDialog.getSaveFileName(
         self,
         self.tr("Save Image"),
         fn,
         self.tr("All Files (*)"),
         E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
     
     if not filename:
         return
     
     f = QFile(filename)
     if not f.open(QFile.WriteOnly):
         E5MessageBox.critical(
             self,
             self.tr("Save Image"),
             self.tr(
                 """<p>Cannot write to file <b>{0}</b>.</p>""")
             .format(filename))
         return
     f.write(cacheData.readAll())
     f.close()
示例#28
0
 def on_sourceDirectoryButton_clicked(self):
     """
     Private slot to select the packages root directory via a
     directory selection dialog.
     """
     startDir = self.sourceDirectoryEdit.text() or self.__getStartDir()
     sourceDirectory = E5FileDialog.getExistingDirectory(
         self, self.tr("Source Directory"),
         Utilities.fromNativeSeparators(startDir),
         E5FileDialog.Options(E5FileDialog.ShowDirsOnly))
     if sourceDirectory:
         self.sourceDirectoryEdit.setText(
             Utilities.toNativeSeparators(sourceDirectory))
示例#29
0
    def on_workspaceButton_clicked(self):
        """
        Private slot to display a directory selection dialog.
        """
        default = self.workspaceEdit.text()
        if default == "":
            default = Utilities.getHomeDir()
        directory = E5FileDialog.getExistingDirectory(
            self, self.tr("Select Workspace Directory"), default,
            E5FileDialog.Options(0))

        if directory:
            self.workspaceEdit.setText(Utilities.toNativeSeparators(directory))
示例#30
0
    def on_vcsUrlButton_clicked(self):
        """
        Private slot to display a selection dialog.
        """
        if self.protocolCombo.currentText() == "file://":
            directory = E5FileDialog.getExistingDirectory(
                self, self.tr("Select Repository-Directory"),
                self.vcsUrlEdit.text(),
                E5FileDialog.Options(E5FileDialog.ShowDirsOnly))

            if directory:
                self.vcsUrlEdit.setText(
                    Utilities.toNativeSeparators(directory))
示例#31
0
    def on_downloadDirButton_clicked(self):
        """
        Private slot to handle the directory selection via dialog.
        """
        directory = E5FileDialog.getExistingDirectory(
            self, self.tr("Select plugins download directory"),
            self.downloadDirEdit.text(),
            E5FileDialog.Options(E5FileDialog.ShowDirsOnly))

        if directory:
            dn = Utilities.toNativeSeparators(directory)
            while dn.endswith(os.sep):
                dn = dn[:-1]
            self.downloadDirEdit.setText(dn)
示例#32
0
 def on_loadButton_clicked(self):
     """
     Private slot to load a regexp from a file.
     """
     fname = E5FileDialog.getOpenFileName(
         self,
         self.tr("Load regular expression"),
         "",
         self.tr("RegExp Files (*.rx);;All Files (*)"))
     if fname:
         try:
             f = open(
                 Utilities.toNativeSeparators(fname), "r", encoding="utf-8")
             regexp = f.read()
             f.close()
             if regexp.startswith("syntax="):
                 lines = regexp.splitlines()
                 syntax = int(lines[0].replace("syntax=", ""))
                 index = self.syntaxCombo.findData(syntax)
                 self.syntaxCombo.setCurrentIndex(index)
                 regexp = lines[1]
             self.regexpLineEdit.setText(regexp)
         except IOError as err:
             E5MessageBox.information(
                 self,
                 self.tr("Save regular expression"),
                 self.tr("""<p>The regular expression could not"""
                         """ be saved.</p><p>Reason: {0}</p>""")
                 .format(str(err)))
示例#33
0
    def __importCertificate(self):
        """
        Private method to read a certificate.
        
        @return certificates read (list of QSslCertificate)
        """
        fname = E5FileDialog.getOpenFileName(
            self,
            self.tr("Import Certificate"),
            "",
            self.tr("Certificate Files (*.pem *.crt *.der *.cer *.ca);;" "All Files (*)"),
        )

        if fname:
            f = QFile(fname)
            if not f.open(QIODevice.ReadOnly):
                E5MessageBox.critical(
                    self,
                    self.tr("Export Certificate"),
                    self.tr(
                        """<p>The certificate could not be read from file""" """ <b>{0}</b></p><p>Error: {1}</p>"""
                    ).format(fname, f.errorString()),
                )
                return []

            crt = f.readAll()
            f.close()
            cert = QSslCertificate.fromData(crt, QSsl.Pem)
            if not cert:
                cert = QSslCertificate.fromData(crt, QSsl.Der)

            return cert

        return []
示例#34
0
 def on_fileDialogButton_clicked(self):
     """
     Private slot to open a file dialog.
     """
     if self.dbs:
         py2Extensions = \
             ' '.join(["*{0}".format(ext)
                       for ext in self.dbs.getExtensions('Python2')])
         py3Extensions = \
             ' '.join(["*{0}".format(ext)
                       for ext in self.dbs.getExtensions('Python3')])
         filter = self.tr(
             "Python3 Files ({1});;Python2 Files ({0});;All Files (*)")\
             .format(py2Extensions, py3Extensions)
     else:
         filter = self.tr("Python Files (*.py);;All Files (*)")
     prog = E5FileDialog.getOpenFileName(
         self,
         "",
         self.testsuiteComboBox.currentText(),
         filter)
     
     if not prog:
         return
     
     self.insertProg(Utilities.toNativeSeparators(prog))
示例#35
0
 def on_saveButton_clicked(self):
     """
     Private slot to save the snapshot.
     """
     if not self.__snapshot.isNull():
         while os.path.exists(self.__filename):
             self.__autoIncFilename()
         
         fileName, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
             self,
             self.tr("Save Snapshot"),
             self.__filename,
             self.__outputFilter,
             self.__defaultFilter,
             E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
         if not fileName:
             return
         
         ext = QFileInfo(fileName).suffix()
         if not ext:
             ex = selectedFilter.split("(*")[1].split(")")[0]
             if ex:
                 fileName += ex
         
         if self.__saveImage(fileName):
             self.__modified = False
             self.__filename = fileName
             self.__autoIncFilename()
             self.__updateCaption()
示例#36
0
 def on_mainscriptButton_clicked(self):
     """
     Private slot to display a file selection dialog.
     """
     dir = self.dirEdit.text()
     if not dir:
         dir = QDir.currentPath()
     patterns = []
     for pattern, filetype in list(self.project.pdata["FILETYPES"].items()):
         if filetype == "SOURCES":
             patterns.append(pattern)
     filters = self.tr("Source Files ({0});;All Files (*)")\
         .format(" ".join(patterns))
     fn = E5FileDialog.getOpenFileName(
         self,
         self.tr("Select main script file"),
         dir,
         filters)
     
     if fn:
         ppath = self.dirEdit.text()
         if ppath:
             ppath = QDir(ppath).absolutePath() + QDir.separator()
             fn = fn.replace(ppath, "")
         self.mainscriptEdit.setText(Utilities.toNativeSeparators(fn))
示例#37
0
 def on_vcsUrlButton_clicked(self):
     """
     Private slot to display a selection dialog.
     """
     if self.protocolCombo.currentText() == "file://":
         directory = E5FileDialog.getExistingDirectory(
             self,
             self.tr("Select Repository-Directory"),
             self.vcsUrlEdit.text(),
             E5FileDialog.Options(E5FileDialog.ShowDirsOnly))
         
         if directory:
             self.vcsUrlEdit.setText(
                 Utilities.toNativeSeparators(directory))
     else:
         from .SvnRepoBrowserDialog import SvnRepoBrowserDialog
         dlg = SvnRepoBrowserDialog(self.vcs, mode="select", parent=self)
         dlg.start(
             self.protocolCombo.currentText() + self.vcsUrlEdit.text())
         if dlg.exec_() == QDialog.Accepted:
             url = dlg.getSelectedUrl()
             if url:
                 protocol = url.split("://")[0]
                 path = url.split("://")[1]
                 self.protocolCombo.setCurrentIndex(
                     self.protocolCombo.findText(protocol + "://"))
                 self.vcsUrlEdit.setText(path)
示例#38
0
    def on_saveButton_clicked(self):
        """
        Private slot to handle the Save button press.
        
        It saves the diff shown in the dialog to a file in the local
        filesystem.
        """
        if isinstance(self.filename, list):
            if len(self.filename) > 1:
                fname = self.vcs.splitPathList(self.filename)[0]
            else:
                dname, fname = self.vcs.splitPath(self.filename[0])
                if fname != ".":
                    fname = "{0}.diff".format(self.filename[0])
                else:
                    fname = dname
        else:
            fname = self.vcs.splitPath(self.filename)[0]

        fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
            self,
            self.tr("Save Diff"),
            fname,
            self.tr("Patch Files (*.diff)"),
            None,
            E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite),
        )

        if not fname:
            return  # user aborted

        ext = QFileInfo(fname).suffix()
        if not ext:
            ex = selectedFilter.split("(*")[1].split(")")[0]
            if ex:
                fname += ex
        if QFileInfo(fname).exists():
            res = E5MessageBox.yesNo(
                self,
                self.tr("Save Diff"),
                self.tr("<p>The patch file <b>{0}</b> already exists." " Overwrite it?</p>").format(fname),
                icon=E5MessageBox.Warning,
            )
            if not res:
                return
        fname = Utilities.toNativeSeparators(fname)

        eol = e5App().getObject("Project").getEolString()
        try:
            f = open(fname, "w", encoding="utf-8", newline="")
            f.write(eol.join(self.contents.toPlainText().splitlines()))
            f.close()
        except IOError as why:
            E5MessageBox.critical(
                self,
                self.tr("Save Diff"),
                self.tr("<p>The patch file <b>{0}</b> could not be saved." "<br>Reason: {1}</p>").format(
                    fname, str(why)
                ),
            )
示例#39
0
 def exportBookmarks(self):
     """
     Public method to export the bookmarks.
     """
     fileName, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
         None,
         self.tr("Export Bookmarks"),
         "eric6_bookmarks.xbel",
         self.tr("XBEL bookmarks (*.xbel);;"
                 "XBEL bookmarks (*.xml);;"
                 "HTML Bookmarks (*.html)"))
     if not fileName:
         return
     
     ext = QFileInfo(fileName).suffix()
     if not ext:
         ex = selectedFilter.split("(*")[1].split(")")[0]
         if ex:
             fileName += ex
     
     ext = QFileInfo(fileName).suffix()
     if ext == "html":
         from .NsHtmlWriter import NsHtmlWriter
         writer = NsHtmlWriter()
     else:
         from .XbelWriter import XbelWriter
         writer = XbelWriter()
     if not writer.write(fileName, self.__bookmarkRootNode):
         E5MessageBox.critical(
             None,
             self.tr("Exporting Bookmarks"),
             self.tr("""Error exporting bookmarks to <b>{0}</b>.""")
             .format(fileName))
示例#40
0
    def on_styleSheetButton_clicked(self):
        """
        Private slot to handle the user style sheet selection.
        """
        file = E5FileDialog.getOpenFileName(self, self.tr("Select Style Sheet"), self.styleSheetEdit.text(), "")

        if file:
            self.styleSheetEdit.setText(Utilities.toNativeSeparators(file))
示例#41
0
    def on_fileButton_clicked(self):
        """
        Private slot called by pressing the file selection button.
        """
        fn = E5FileDialog.getOpenFileName(self, self.tr("Select file for property"), self.propFileEdit.text(), "")

        if fn:
            self.propFileEdit.setText(Utilities.toNativeSeparators(fn))
 def on_fileButton_clicked(self):
     """
     Private slot to handle the file selection via a file selection dialog.
     """
     bookmark = E5FileDialog.getOpenFileName()
     if bookmark:
         bookmark = Utilities.toNativeSeparators(bookmark)
         self.fileEdit.setText(bookmark)
示例#43
0
    def on_databaseFileButton_clicked(self):
        """
        Private slot to open a database file via a file selection dialog.
        """
        startdir = self.databaseEdit.text()
        dbFile = E5FileDialog.getOpenFileName(self, self.tr("Select Database File"), startdir, self.tr("All Files (*)"))

        if dbFile:
            self.databaseEdit.setText(Utilities.toNativeSeparators(dbFile))
 def on_pathButton_clicked(self):
     """
     Private slot called to open a directory selection dialog.
     """
     path = E5FileDialog.getExistingDirectory(
         self, self.tr("Select source directory"), QDir.fromNativeSeparators(self.pathnameEdit.text())
     )
     if path:
         self.pathnameEdit.setText(QDir.toNativeSeparators(path))
示例#45
0
 def on_addButton_clicked(self):
     """
     Private slot to handle the Add... button.
     """
     fname = E5FileDialog.getOpenFileName(
         self,
         self.tr("Attach file"))
     if fname:
         self.attachFile(fname, False)
示例#46
0
 def on_iconButton_clicked(self):
     """
     Private slot to handle the icon selection via a file selection dialog.
     """
     icon = E5FileDialog.getOpenFileName(
         self, self.tr("Select icon file"), self.iconEdit.text(), self.tr("Icon files (*.png)")
     )
     if icon:
         self.iconEdit.setText(icon)
 def on_exceptDirButton_clicked(self):
     """
     Private slot to select a file to exempt from translation.
     """
     texcept = E5FileDialog.getExistingDirectory(
         self,
         self.tr("Exempt directory from translation"),
         self.project.ppath,
         E5FileDialog.Options(E5FileDialog.ShowDirsOnly))
     if texcept:
         self.exceptionEdit.setText(Utilities.toNativeSeparators(texcept))
 def on_exceptFileButton_clicked(self):
     """
     Private slot to select a file to exempt from translation.
     """
     texcept = E5FileDialog.getOpenFileName(
         self,
         self.tr("Exempt file from translation"),
         self.project.ppath,
         self.filters)
     if texcept:
         self.exceptionEdit.setText(Utilities.toNativeSeparators(texcept))
示例#49
0
 def __openFile(self):
     """
     Private slot to load a new file.
     """
     fn = E5FileDialog.getOpenFileName(
         self,
         self.tr("Select UI file"),
         self.currentFile,
         self.tr("Qt User-Interface Files (*.ui)"))
     if fn:
         self.__loadFile(fn)
示例#50
0
 def on_saveButton_clicked(self):
     """
     Private slot to handle the Save button press.
     
     It saves the diff shown in the dialog to a file in the local
     filesystem.
     """
     dname, fname = Utilities.splitPath(self.filename2)
     if fname != '.':
         fname = "{0}.diff".format(self.filename2)
     else:
         fname = dname
         
     fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
         self,
         self.tr("Save Diff"),
         fname,
         self.tr("Patch Files (*.diff)"),
         None,
         E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
     
     if not fname:
         return
     
     ext = QFileInfo(fname).suffix()
     if not ext:
         ex = selectedFilter.split("(*")[1].split(")")[0]
         if ex:
             fname += ex
     if QFileInfo(fname).exists():
         res = E5MessageBox.yesNo(
             self,
             self.tr("Save Diff"),
             self.tr("<p>The patch file <b>{0}</b> already exists."
                     " Overwrite it?</p>").format(fname),
             icon=E5MessageBox.Warning)
         if not res:
             return
     fname = Utilities.toNativeSeparators(fname)
     
     try:
         f = open(fname, "w", encoding="utf-8")
         txt = self.contents.toPlainText()
         try:
             f.write(txt)
         except UnicodeError:
             pass
         f.close()
     except IOError as why:
         E5MessageBox.critical(
             self, self.tr('Save Diff'),
             self.tr(
                 '<p>The patch file <b>{0}</b> could not be saved.<br />'
                 'Reason: {1}</p>').format(fname, str(why)))
示例#51
0
 def __saveMessages(self):
     """
     Private slot to save the contents of the messages display.
     """
     hasText = not self.messages.document().isEmpty()
     if hasText:
         if Utilities.isWindowsPlatform():
             htmlExtension = "htm"
         else:
             htmlExtension = "html"
         fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
             self,
             self.tr("Save Messages"),
             "",
             self.tr(
                 "HTML Files (*.{0});;Text Files (*.txt);;All Files (*)")
             .format(htmlExtension),
             None,
             E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
         if fname:
             ext = QFileInfo(fname).suffix()
             if not ext:
                 ex = selectedFilter.split("(*")[1].split(")")[0]
                 if ex:
                     fname += ex
                 ext = QFileInfo(fname).suffix()
             if QFileInfo(fname).exists():
                 res = E5MessageBox.yesNo(
                     self,
                     self.tr("Save Messages"),
                     self.tr("<p>The file <b>{0}</b> already exists."
                             " Overwrite it?</p>").format(fname),
                     icon=E5MessageBox.Warning)
                 if not res:
                     return
                 fname = Utilities.toNativeSeparators(fname)
             
             try:
                 if ext.lower() in ["htm", "html"]:
                     txt = self.messages.toHtml()
                 else:
                     txt = self.messages.toPlainText()
                 f = open(fname, "w", encoding="utf-8")
                 f.write(txt)
                 f.close()
             except IOError as err:
                 E5MessageBox.critical(
                     self,
                     self.tr("Error saving Messages"),
                     self.tr(
                         """<p>The messages contents could not be written"""
                         """ to <b>{0}</b></p><p>Reason: {1}</p>""")
                     .format(fname, str(err)))
示例#52
0
 def on_interpreterButton_clicked(self):
     """
     Private slot to handle the interpreter selection.
     """
     file = E5FileDialog.getOpenFileName(
         self,
         self.tr("Select interpreter for Debug Client"),
         self.interpreterEdit.text(),
         "")
         
     if file:
         self.interpreterEdit.setText(Utilities.toNativeSeparators(file))
示例#53
0
 def on_dirButton_clicked(self):
     """
     Private slot to handle the button press for selecting the target via a
     selection dialog.
     """
     if os.path.isdir(self.source):
         target = E5FileDialog.getExistingDirectory(
             self,
             self.tr("Select target"),
             self.targetEdit.text(),
             E5FileDialog.Options(E5FileDialog.ShowDirsOnly))
     else:
         target = E5FileDialog.getSaveFileName(
             self,
             self.tr("Select target"),
             self.targetEdit.text(),
             "",
             E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
     
     if target:
         self.targetEdit.setText(Utilities.toNativeSeparators(target))
示例#54
0
 def on_idlButton_clicked(self):
     """
     Private slot to handle the IDL compiler selection.
     """
     file = E5FileDialog.getOpenFileName(
         self,
         self.tr("Select IDL compiler"),
         self.idlEdit.text(),
         "")
     
     if file:
         self.idlEdit.setText(Utilities.toNativeSeparators(file))
示例#55
0
 def on_qt4TransButton_clicked(self):
     """
     Private slot to handle the Qt4 translations directory selection.
     """
     dir = E5FileDialog.getExistingDirectory(
         self,
         self.tr("Select Qt4 Translations Directory"),
         self.qt4TransEdit.text(),
         E5FileDialog.Options(E5FileDialog.ShowDirsOnly))
         
     if dir:
         self.qt4TransEdit.setText(Utilities.toNativeSeparators(dir))
示例#56
0
 def on_customViewerSelectionButton_clicked(self):
     """
     Private slot to handle the custom viewer selection.
     """
     file = E5FileDialog.getOpenFileName(
         self,
         self.tr("Select Custom Viewer"),
         self.customViewerEdit.text(),
         "")
     
     if file:
         self.customViewerEdit.setText(Utilities.toNativeSeparators(file))
示例#57
0
 def on_webbrowserButton_clicked(self):
     """
     Private slot to handle the Web browser selection.
     """
     file = E5FileDialog.getOpenFileName(
         self,
         self.tr("Select Web-Browser"),
         self.webbrowserEdit.text(),
         "")
     
     if file:
         self.webbrowserEdit.setText(Utilities.toNativeSeparators(file))
示例#58
0
 def __newToplevelDir(self):
     """
     Private slot to handle the New toplevel directory popup menu entry.
     """
     dname = E5FileDialog.getExistingDirectory(
         None,
         QCoreApplication.translate('Browser', "New toplevel directory"),
         "",
         E5FileDialog.Options(E5FileDialog.ShowDirsOnly))
     if dname:
         dname = os.path.abspath(Utilities.toNativeSeparators(dname))
         self.__model.addTopLevelDir(dname)
 def on_fileButton_clicked(self):
     """
     Private slot to select a file via a file selection dialog.
     """
     file = E5FileDialog.getOpenFileName(
         self,
         self.tr("Select filename of the breakpoint"),
         self.filenameCombo.currentText(),
         "")
         
     if file:
         self.filenameCombo.setEditText(Utilities.toNativeSeparators(file))