def on_renameButton_clicked(self):
     """
     Private slot to rename a custom toolbar.
     """
     oldName = self.toolbarComboBox.currentText()
     newName, ok = KQInputDialog.getText(\
         self,
         self.trUtf8("Rename Toolbar"),
         self.trUtf8("New Toolbar Name:"),
         QLineEdit.Normal,
         oldName)
     if ok and not newName.isEmpty():
         if oldName == newName:
             return
         if self.toolbarComboBox.findText(newName) != -1:
             # toolbar with this name already exists
             KQMessageBox.critical(self,
             self.trUtf8("Rename Toolbar"),
             self.trUtf8("""A toolbar with the name <b>%1</b> already exists.""")\
                 .arg(newName),
             QMessageBox.StandardButtons(\
                 QMessageBox.Abort))
             return
         index = self.toolbarComboBox.currentIndex()
         self.toolbarComboBox.setItemText(index, newName)
         tbItem = \
             self.__toolbarItems[self.toolbarComboBox.itemData(index).toULongLong()[0]]
         tbItem.title = newName
         tbItem.isChanged = True
 def on_newButton_clicked(self):
     """
     Private slot to create a new toolbar.
     """
     name, ok = KQInputDialog.getText(\
         self,
         self.trUtf8("New Toolbar"),
         self.trUtf8("Toolbar Name:"),
         QLineEdit.Normal)
     if ok and not name.isEmpty():
         if self.toolbarComboBox.findText(name) != -1:
             # toolbar with this name already exists
             KQMessageBox.critical(self,
             self.trUtf8("New Toolbar"),
             self.trUtf8("""A toolbar with the name <b>%1</b> already exists.""")\
                 .arg(name),
             QMessageBox.StandardButtons(\
                 QMessageBox.Abort))
             return
         
         tbItem = E4ToolBarItem(None, [], False)
         tbItem.title = name
         tbItem.isChanged = True
         self.__toolbarItems[id(tbItem)] = tbItem
         self.__toolBarItemToWidgetActionID[id(tbItem)] = []
         self.toolbarComboBox.addItem(name, QVariant(long(id(tbItem))))
         self.toolbarComboBox.model().sort(0)
         self.toolbarComboBox.setCurrentIndex(self.toolbarComboBox.findText(name))
示例#3
0
    def __sendmail(self, msg):
        """
        Private method to actually send the message.
        
        @param msg the message to be sent (string)
        @return flag indicating success (boolean)
        """
        try:
            server = smtplib.SMTP(str(Preferences.getUser("MailServer")), Preferences.getUser("MailServerPort"))
            if Preferences.getUser("MailServerUseTLS"):
                server.starttls()
            if Preferences.getUser("MailServerAuthentication"):
                # mail server needs authentication
                password = unicode(Preferences.getUser("MailServerPassword"))
                if not password:
                    password, ok = KQInputDialog.getText(
                        self,
                        self.trUtf8("Mail Server Password"),
                        self.trUtf8("Enter your mail server password"),
                        QLineEdit.Password,
                    )
                    if not ok:
                        # abort
                        return False
                try:
                    server.login(unicode(Preferences.getUser("MailServerUser")), str(password))
                except (smtplib.SMTPException, socket.error), e:
                    res = KQMessageBox.critical(
                        self,
                        self.trUtf8("Send bug report"),
                        self.trUtf8("""<p>Authentication failed.<br>Reason: %1</p>""").arg(str(e)),
                        QMessageBox.StandardButtons(QMessageBox.Abort | QMessageBox.Retry),
                        QMessageBox.Retry,
                    )
                    if res == QMessageBox.Retry:
                        return self.__sendmail(msg)
                    else:
                        return False

            QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
            QApplication.processEvents()
            result = server.sendmail(unicode(Preferences.getUser("Email")), self.__toAddress, msg)
            server.quit()
            QApplication.restoreOverrideCursor()
 def on_addButton_clicked(self):
     """
     Private slot to add a new filter.
     """
     filter, ok = KQInputDialog.getText(\
         None,
         self.trUtf8("Add Filter"),
         self.trUtf8("Filter name:"),
         QLineEdit.Normal)
     if filter.isEmpty():
         return
     
     ufilter = unicode(filter)
     if ufilter not in self.__filterMap:
         self.__filterMap[ufilter] = QStringList()
         self.filtersList.addItem(filter)
     
     itm = self.filtersList.findItems(filter, Qt.MatchCaseSensitive)[0]
     self.filtersList.setCurrentItem(itm)
示例#5
0
 def on_addAllowedHostButton_clicked(self):
     """
     Private slot called to add a new allowed host.
     """
     allowedHost, ok = KQInputDialog.getText(
         None,
         self.trUtf8("Add allowed host"),
         self.trUtf8("Enter the IP address of an allowed host"),
         QLineEdit.Normal,
     )
     if ok and not allowedHost.isEmpty():
         if QHostAddress(allowedHost).protocol() in [QAbstractSocket.IPv4Protocol, QAbstractSocket.IPv6Protocol]:
             self.allowedHostsList.addItem(allowedHost)
         else:
             KQMessageBox.critical(
                 None,
                 self.trUtf8("Add allowed host"),
                 self.trUtf8(
                     """<p>The entered address <b>%1</b> is not"""
                     """ a valid IP v4 or IP v6 address. Aborting...</p>"""
                 ).arg(allowedHost),
             )
 def start(self, path, tags = True):
     """
     Public slot to start the svn status command.
     
     @param path name of directory to be listed (string)
     @param tags flag indicating a list of tags is requested
             (False = branches, True = tags)
     """
     self.errorGroup.hide()
     
     if not tags:
         self.setWindowTitle(self.trUtf8("Subversion Branches List"))
     self.activateWindow()
     QApplication.processEvents()
     
     dname, fname = self.vcs.splitPath(path)
     
     reposURL = self.vcs.svnGetReposName(dname)
     if reposURL is None:
         KQMessageBox.critical(None,
             self.trUtf8("Subversion Error"),
             self.trUtf8("""The URL of the project repository could not be"""
                 """ retrieved from the working copy. The list operation will"""
                 """ be aborted"""))
         self.close()
         return False
     
     if self.vcs.otherData["standardLayout"]:
         # determine the base path of the project in the repository
         rx_base = QRegExp('(.+)/(trunk|tags|branches).*')
         if not rx_base.exactMatch(reposURL):
             KQMessageBox.critical(None,
                 self.trUtf8("Subversion Error"),
                 self.trUtf8("""The URL of the project repository has an"""
                     """ invalid format. The list operation will"""
                     """ be aborted"""))
             return False
         
         reposRoot = unicode(rx_base.cap(1))
         
         if tags:
             path = "%s/tags" % reposRoot
         else:
             path = "%s/branches" % reposRoot
     else:
         reposPath, ok = KQInputDialog.getText(\
             self,
             self.trUtf8("Subversion List"),
             self.trUtf8("Enter the repository URL containing the tags or branches"),
             QLineEdit.Normal,
             self.vcs.svnNormalizeURL(reposURL))
         if not ok:
             self.close()
             return False
         if reposPath.isEmpty():
             KQMessageBox.critical(None,
                 self.trUtf8("Subversion List"),
                 self.trUtf8("""The repository URL is empty. Aborting..."""))
             self.close()
             return False
         path = unicode(reposPath)
     
     locker = QMutexLocker(self.vcs.vcsExecutionMutex)
     self.tagsList = QStringList()
     cwd = os.getcwd()
     os.chdir(dname)
     try:
         entries = self.client.list(path, recurse = False)
         for dirent, lock in entries:
             if dirent["path"] != path:
                 name = dirent["path"].replace(path + '/', "")
                 self.__generateItem(dirent["created_rev"].number, 
                                     dirent["last_author"], 
                                     formatTime(dirent["time"]), 
                                     name)
                 if self.vcs.otherData["standardLayout"]:
                     self.tagsList.append(name)
                 else:
                     self.tagsList.append(path + '/' + name)
                 if self._clientCancelCallback():
                     break
         res = True
     except pysvn.ClientError, e:
         self.__showError(e.args[0])
         res = False
 def start(self, path, tags, tagsList, allTagsList):
     """
     Public slot to start the svn status command.
     
     @param path name of directory to be listed (string)
     @param tags flag indicating a list of tags is requested
             (False = branches, True = tags)
     @param tagsList reference to string list receiving the tags (QStringList)
     @param allsTagsLisr reference to string list all tags (QStringList)
     """
     self.errorGroup.hide()
     
     self.intercept = False
     if not tags:
         self.setWindowTitle(self.trUtf8("Subversion Branches List"))
     self.activateWindow()
     
     self.tagsList = tagsList
     self.allTagsList = allTagsList
     dname, fname = self.vcs.splitPath(path)
     
     self.process.kill()
     
     reposURL = self.vcs.svnGetReposName(dname)
     if reposURL is None:
         KQMessageBox.critical(None,
             self.trUtf8("Subversion Error"),
             self.trUtf8("""The URL of the project repository could not be"""
                 """ retrieved from the working copy. The list operation will"""
                 """ be aborted"""))
         self.close()
         return
     
     args = QStringList()
     args.append('list')
     self.vcs.addArguments(args, self.vcs.options['global'])
     args.append('--verbose')
     
     if self.vcs.otherData["standardLayout"]:
         # determine the base path of the project in the repository
         rx_base = QRegExp('(.+)/(trunk|tags|branches).*')
         if not rx_base.exactMatch(reposURL):
             KQMessageBox.critical(None,
                 self.trUtf8("Subversion Error"),
                 self.trUtf8("""The URL of the project repository has an"""
                     """ invalid format. The list operation will"""
                     """ be aborted"""))
             return
         
         reposRoot = unicode(rx_base.cap(1))
         
         if tags:
             args.append("%s/tags" % reposRoot)
         else:
             args.append("%s/branches" % reposRoot)
         self.path = None
     else:
         reposPath, ok = KQInputDialog.getText(\
             self,
             self.trUtf8("Subversion List"),
             self.trUtf8("Enter the repository URL containing the tags or branches"),
             QLineEdit.Normal,
             self.vcs.svnNormalizeURL(reposURL))
         if not ok:
             self.close()
             return
         if reposPath.isEmpty():
             KQMessageBox.critical(None,
                 self.trUtf8("Subversion List"),
                 self.trUtf8("""The repository URL is empty. Aborting..."""))
             self.close()
             return
         args.append(reposPath)
         self.path = unicode(reposPath)
     
     self.process.setWorkingDirectory(dname)
     
     self.process.start('svn', args)
     procStarted = self.process.waitForStarted()
     if not procStarted:
         self.inputGroup.setEnabled(False)
         self.inputGroup.hide()
         KQMessageBox.critical(None,
             self.trUtf8('Process Generation Error'),
             self.trUtf8(
                 'The process %1 could not be started. '
                 'Ensure, that it is in the search path.'
             ).arg('svn'))
     else:
         self.inputGroup.setEnabled(True)
         self.inputGroup.show()