def thumbnail(colorname: str) -> QPixmap: """Return QIcon of size 256 filled with one color and a frame. Args: colorname: Color in hex format. """ pixmap = QPixmap(256, 256) frame_color = styles.get("thumbnail.frame.fg") _draw(pixmap, colorname, 10, frame_color) return pixmap
def __init__(self, image): super().__init__(image) self._add_rotate_binding("l", ">", angle=0.2) self._add_rotate_binding("L", angle=1.0) self._add_rotate_binding("h", "<", counter_clockwise=True, angle=0.2) self._add_rotate_binding("H", counter_clockwise=True, angle=1.0) self.color = QColor(styles.get("image.straighten.color")) self.angle = 0.0 self._init_size = self.transform.size
def __init__(self): widgets.ScrollWheelCumulativeMixin.__init__( self, self._scroll_wheel_callback) QListWidget.__init__(self) self._paths: List[str] = [] fail_pixmap = create_pixmap( color=styles.get("thumbnail.error.bg"), frame_color=styles.get("thumbnail.frame.fg"), size=256, frame_size=10, ) self._manager = thumbnail_manager.ThumbnailManager(fail_pixmap) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setViewMode(QListWidget.IconMode) default_size = api.settings.thumbnail.size.value self.setIconSize(QSize(default_size, default_size)) self.setResizeMode(QListWidget.Adjust) self.setItemDelegate(ThumbnailDelegate(self)) self.setDragEnabled(False) api.signals.all_images_cleared.connect(self.clear) api.signals.new_image_opened.connect(self._select_path) api.signals.new_images_opened.connect(self._on_new_images_opened) api.settings.thumbnail.size.changed.connect(self._on_size_changed) search.search.new_search.connect(self._on_new_search) search.search.cleared.connect(self._on_search_cleared) self._manager.created.connect(self._on_thumbnail_created) self.activated.connect(self.open_selected) self.doubleClicked.connect(self.open_selected) api.mark.marked.connect(self._mark_highlight) api.mark.unmarked.connect( lambda path: self._mark_highlight(path, marked=False)) api.mark.markdone.connect(self.repaint) synchronize.signals.new_library_path_selected.connect( self._select_path) styles.apply(self)
def __init__(self): super().__init__() self.doc = QTextDocument(self) self.doc.setDocumentMargin(0) # Named properties for html self.font = styles.get("library.font") self.fg = styles.get("library.fg") self.dir_fg = styles.get("library.directory.fg") self.search_fg = styles.get("library.search.highlighted.fg") # QColor options for background drawing self.selection_bg = QColor(styles.get("library.selected.bg")) self.selection_bg_unfocus = QColor( styles.get("library.selected.bg.unfocus")) self.even_bg = QColor(styles.get("library.even.bg")) self.odd_bg = QColor(styles.get("library.odd.bg")) self.search_bg = QColor(styles.get("library.search.highlighted.bg"))
def __init__(self, parent): super().__init__(parent) # QColor options for background drawing self.bg = QColor(styles.get("thumbnail.bg")) self.selection_bg = QColor(styles.get("thumbnail.selected.bg")) self.selection_bg_unfocus = QColor(styles.get("thumbnail.selected.bg.unfocus")) self.search_bg = QColor(styles.get("thumbnail.search.highlighted.bg")) self.mark_bg = QColor(styles.get("mark.color")) self.padding = int(styles.get("thumbnail.padding"))
def __init__(self, parent): super().__init__(parent=parent) self._show_timer = QTimer(self) self._show_timer.setSingleShot(True) self._show_timer.setInterval(api.settings.keyhint.delay.value) self._show_timer.timeout.connect(self.show) self._suffix_color = styles.get("keyhint.suffix_color") self._mainwindow_bottom = 0 styles.apply(self) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Minimum) self.setTextFormat(Qt.RichText) partial_handler = eventhandler.EventHandlerMixin.partial_handler partial_handler.partial_matches.connect(self._on_partial_matches) partial_handler.partial_cleared.connect(self._on_partial_cleared) api.settings.keyhint.delay.changed.connect(self._on_delay_changed) self.hide()
def indicator() -> str: """Colored mark indicator.""" color = styles.get("mark.color") return wrap_style_span( f"color: {color}", settings.statusbar.mark_indicator.value )
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 ""
def item_size(self): """Return the size of one icon including padding.""" padding = int(styles.get("thumbnail.padding").replace("px", "")) return self.iconSize().width() + 2 * padding
def n_columns(self) -> int: """Return the number of columns.""" sb_width = int(styles.get("image.scrollbar.width").replace("px", "")) return (self.width() - sb_width) // self.item_size()
def unfocus(self): fg = styles.get("manipulate.fg") self.label.setText(utils.wrap_style_span(f"color: {fg}", self.name))
def test_fail_get_nonexisting_style_option(mocker, new_style): styles._style = new_style assert styles.get("anything") == "" styles._style = None
def error_thumbnail() -> QPixmap: """Return thumbnail to display for failed thumbnails.""" color = styles.get("thumbnail.error.bg") return thumbnail(color)
def default_thumbnail() -> QPixmap: """Return thumbnail to display for default thumbnails.""" color = styles.get("thumbnail.default.bg") return thumbnail(color)