示例#1
0
    def on_convertButton_clicked(self):
        # TODO Don't always process when the button is pressed.
        clipboard = self.app.clipboard()
        mime = clipboard.mimeData()
        sourceEncoding = self.sourceCharsetCombo.currentText().lower()
        try:
            if mime.hasHtml() or mime.hasText():
                html, text = mime.html(), mime.text()
                html, text = charset_converter.convert(html, text,
                                                       sourceEncoding)

                new_mime = QMimeData()
                new_mime.setHtml(html)
                new_mime.setText(text)

                clipboard.setMimeData(new_mime)
                subject = QCoreApplication.translate("charset", "Converted")
                content = QCoreApplication.translate("charset",
                                                     "From {0} to UTF-8")
                n = Notify.Notification.new(subject,
                                            content.format(sourceEncoding), "")
            else:
                subject = QCoreApplication.translate("charset",
                                                     "Cannot convert")
                content = QCoreApplication.translate(
                    "charset", "No HTML/plain text data in clipboard.")
                n = Notify.Notification.new(subject, content)
        except UnicodeEncodeError:
            subject = QCoreApplication.translate("charset", "Cannot convert")
            content = QCoreApplication.translate(
                "charset", "Mixed Unicode in clipboard.")
            n = Notify.Notification.new(subject, content, "")
        n.show()
示例#2
0
    def on_convertButton_clicked(self):
        # TODO Don't always process when the button is pressed.
        clipboard = self.app.clipboard()
        mime = clipboard.mimeData()
        sourceEncoding = self.sourceCharsetCombo.currentText().lower()
        try:
            if mime.hasHtml() or mime.hasText():
                html, text = mime.html(), mime.text()
                html, text = charset_converter.convert(html, text,
                                                       sourceEncoding)

                new_mime = QMimeData()
                new_mime.setHtml(html)
                new_mime.setText(text)

                clipboard.setMimeData(new_mime)
                n = Notify.Notification.new("Converted",
                                            sourceEncoding + "-> utf-8", "")
            else:
                n = Notify.Notification.new(
                    "Cannot convert", "No HTML/plain text data in clipboard.",
                    "")
        except UnicodeEncodeError:
            n = Notify.Notification.new("Cannot convert",
                                        "Mixed Unicode in clipboard.", "")
        n.show()
    def on_convertButton_clicked(self):
        # TODO Don't always process when the button is pressed.
        clipboard = self.app.clipboard()
        mime = clipboard.mimeData()
        sourceEncoding = self.sourceCharsetCombo.currentText().lower()
        try:
            if mime.hasHtml() or mime.hasText():
                html, text = mime.html(), mime.text()
                html, text = charset_converter.convert(
                    html, text, sourceEncoding)

                new_mime = QMimeData()
                new_mime.setHtml(html)
                new_mime.setText(text)

                clipboard.setMimeData(new_mime)
                n = Notify.Notification.new(
                    "Converted", sourceEncoding + "-> utf-8", "")
            else:
                n = Notify.Notification.new(
                    "Cannot convert",
                    "No HTML/plain text data in clipboard.",
                    "")
        except UnicodeEncodeError:
            n = Notify.Notification.new(
                "Cannot convert", "Mixed Unicode in clipboard.", "")
        n.show()
示例#4
0
    def on_convertButton_clicked(self):
        # TODO Don't always process when the button is pressed.
        clipboard = self.app.clipboard()
        mime = clipboard.mimeData()
        sourceEncoding = self.sourceCharsetCombo.currentText().lower()
        try:
            if mime.hasHtml() or mime.hasText():
                html, text = mime.html(), mime.text()
                html, text = charset_converter.convert(
                    html, text, sourceEncoding)

                new_mime = QMimeData()
                new_mime.setHtml(html)
                new_mime.setText(text)

                clipboard.setMimeData(new_mime)
                subject = QCoreApplication.translate(
                    "charset",
                    "Converted")
                content = QCoreApplication.translate(
                    "charset",
                    "From {0} to UTF-8")
                n = Notify.Notification.new(
                    subject, content.format(sourceEncoding), "")
            else:
                subject = QCoreApplication.translate(
                    "charset",
                    "Cannot convert")
                content = QCoreApplication.translate(
                    "charset",
                    "No HTML/plain text data in clipboard.")
                n = Notify.Notification.new(subject, content)
        except UnicodeEncodeError:
            subject = QCoreApplication.translate(
                "charset",
                "Cannot convert")
            content = QCoreApplication.translate(
                "charset",
                "Mixed Unicode in clipboard.")
            n = Notify.Notification.new(
                subject, content, "")
        n.show()