Example #1
0
 def highlightError(self, index):
     """Hihglights the error message at the given index and jumps to its location."""
     self._currentErrorIndex = index
     # set text format
     pos, anchor, url = self._errors[index]
     es = QTextEdit.ExtraSelection()
     es.cursor = QTextCursor(self.document())
     es.cursor.setPosition(pos)
     es.cursor.setPosition(anchor, QTextCursor.KeepAnchor)
     bg = qutil.mixcolor(self.palette().highlight().color(),
                         self.palette().base().color(), 0.4)
     es.format.setBackground(bg)
     es.format.setProperty(QTextFormat.FullWidthSelection, True)
     self.setExtraSelections([es])
     # scroll log to the message
     cursor = QTextCursor(self.document())
     cursor.setPosition(anchor)
     self.setTextCursor(cursor)
     cursor.setPosition(pos)
     self.setTextCursor(cursor)
     # jump to the error location
     cursor = errors.errors(self._document()).cursor(url, True)
     if cursor:
         self.parentWidget().mainwindow().setTextCursor(cursor,
                                                        findOpenView=True)
Example #2
0
 def setPreviewTexts(self):
     textColor = defaultColor = self.htmlView.palette().color(QPalette.Text)
     # If anything is entered, make the default color somewhat lighter
     for name, desc in headers():
         if self.edits[name].text().strip():
             baseColor = self.htmlView.palette().color(QPalette.Base)
             defaultColor = qutil.mixcolor(textColor, baseColor, 0.6)
             break
     textCssColor = textColor.name()
     defaultCssColor = defaultColor.name()
     msg = _("Click to enter a value.")
     def my_headers():
         for name, desc in headers():
             t = self.edits[name].text().strip()
             if t:
                 yield textCssColor, name, html.escape(t)
             else:
                 yield defaultCssColor, name, html.escape(desc)
     self.htmlView.setHtml(titles_html.format(
         copyrightmsg = _("bottom of first page"),
         taglinemsg = _("bottom of last page"),
         imgurl = QUrl.fromLocalFile(__path__[0]).toString(),
         **{name: '<a style="color: {0};" title="{1}" href="{2}">{3}</a>'.format(
                     color, msg, name, text)
                 for color, name, text in my_headers()}))
Example #3
0
 def setCurrentIndex(self, index):
     if self._documents:
         self._currentIndex = index
         p = QApplication.palette()
         if not self._documents[index].updated:
             color = qutil.mixcolor(QColor(Qt.red), p.color(QPalette.Base), 0.3)
             p.setColor(QPalette.Base, color)
         for w in self.createdWidgets():
             w.setCurrentIndex(index)
             w.setPalette(p)
         self.currentDocumentChanged.emit(self._documents[index])
Example #4
0
 def setCurrentIndex(self, index):
     if self._documents:
         self._currentIndex = index
         p = QApplication.palette()
         if not self._documents[index].updated:
             color = qutil.mixcolor(QColor(Qt.red), p.color(QPalette.Base), 0.3)
             p.setColor(QPalette.Base, color)
         for w in self.createdWidgets():
             w.setCurrentIndex(index)
             w.setPalette(p)
         self.currentDocumentChanged.emit(self._documents[index])
Example #5
0
 def highlightError(self, index):
     """Hihglights the error message at the given index and jumps to its location."""
     self._currentErrorIndex = index
     # set text format
     pos, anchor, url = self._errors[index]
     es = QTextEdit.ExtraSelection()
     es.cursor = QTextCursor(self.document())
     es.cursor.setPosition(pos)
     es.cursor.setPosition(anchor, QTextCursor.KeepAnchor)
     bg = qutil.mixcolor(self.palette().highlight().color(), self.palette().base().color(), 0.4)
     es.format.setBackground(bg)
     es.format.setProperty(QTextFormat.FullWidthSelection, True)
     self.setExtraSelections([es])
     # scroll log to the message
     cursor = QTextCursor(self.document())
     cursor.setPosition(anchor)
     self.setTextCursor(cursor)
     cursor.setPosition(pos)
     self.setTextCursor(cursor)
     # jump to the error location
     cursor = errors.errors(self._document()).cursor(url, True)
     if cursor:
         self.parentWidget().mainwindow().setTextCursor(cursor, findOpenView=True)