Exemple #1
0
    def _on_focused(self, name):
        """Highlight newly focused mode label.

        Args:
            name: Name of the label focused.
        """
        fg = styles.get("manipulate.fg")
        fg_focused = styles.get("manipulate.focused.fg")
        for manipulation, label in self._labels.items():
            if manipulation == name:
                label.setText(
                    wrap_style_span(f"color: {fg_focused}", manipulation))
            else:
                label.setText(wrap_style_span(f"color: {fg}", manipulation))
 def indicator(self) -> str:
     """Colored mark indicator."""
     if self._indicator is None:
         color = styles.get("mark.color")
         self._indicator = wrap_style_span(
             f"color: {color}", settings.statusbar.mark_indicator.value)
     return self._indicator
 def mark_count(self) -> str:
     """Total number of currently marked images."""
     if self._marked:
         color = styles.get("mark.color")
         return wrap_style_span(f"color: {color}",
                                f"{len(self._marked):02d}")
     return ""
Exemple #4
0
    def _draw_text(self, painter, option, index):
        """Draw text for the library.

        Sets the font and the foreground color using html. The foreground color
        depends on whether the path is a directory and on whether it is
        highlighted as search result or not.

        Args:
            painter: The QPainter.
            option: The QStyleOptionViewItem.
            index: The QModelIndex.
        """
        text = index.model().data(index)
        painter.save()
        color = self._get_foreground_color(index, text)
        text = self.elided(text, option.rect.width() - 1)
        text = wrap_style_span(f"color: {color}; font: {self.font}", text)
        self.doc.setHtml(text)
        self.doc.setTextWidth(option.rect.width() - 1)
        painter.translate(option.rect.x(), option.rect.y())
        self.doc.drawContents(painter)
        painter.restore()
Exemple #5
0
 def indicator() -> str:
     """Colored mark indicator."""
     color = styles.get("mark.color")
     return wrap_style_span(
         f"color: {color}", settings.statusbar.mark_indicator.value
     )
 def highlighted_search_str(self, search: str) -> str:
     """Current search string wrapped in a highlight color span."""
     return utils.add_html(
         utils.wrap_style_span(f"color: {self._highlight_color}", search),
         "b", "u")
Exemple #7
0
def test_wrap_style_span():
    assert (utils.wrap_style_span(
        "color: red", "text") == "<span style='color: red;'>text</span>")
Exemple #8
0
 def unfocus(self):
     fg = styles.get("manipulate.fg")
     self.label.setText(utils.wrap_style_span(f"color: {fg}", self.name))
Exemple #9
0
 def sizeHint(self, option, index):
     """Return size of the QTextDocument as size hint."""
     text = wrap_style_span(f"font: {self.font}", "any")
     self.doc.setHtml(text)
     return QSize(self.doc.idealWidth(), self.doc.size().height())