def __init__(self): super().__init__() 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)) 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)) synchronize.signals.new_library_path_selected.connect( self._select_path) styles.apply(self)
def _init_style(self): """Initialize the stylesheet. This is called on the first paintEvent to ensure all sizes and fonts are correct. """ font_height = QFontMetrics(self.font()).capHeight() groove_height = font_height + 2 * self.PADDING total_height = groove_height + 2 * self.HANDLE_MARGIN sheet = f""" QSlider {{ height: {total_height:d}px; }} QSlider::sub-page {{ background-color: {self._left_color}; }} QSlider::handle {{ width: 24px; background-color: {self._handle_color}; margin: -{SliderWithValue.HANDLE_MARGIN}px 0px; }} QSlider::groove {{ background-color: {self._right_color}; height: {groove_height}px; }} """ styles.apply(self, append=sheet)
def __init__(self): super().__init__() self.timer = QTimer() self._items = {} timeout = api.settings.statusbar.message_timeout.value self.timer.setInterval(timeout) self.timer.setSingleShot(True) self.timer.timeout.connect(self.clear_message) api.status.signals.clear.connect(self.clear_message) self["stack"] = QStackedLayout(self) self["status"] = QWidget() labelbox = widgets.SimpleHBox(self["status"]) self._add_label(labelbox, "left", Qt.AlignLeft) self._add_label(labelbox, "center", Qt.AlignCenter) self._add_label(labelbox, "right", Qt.AlignRight) self["stack"].addWidget(self["status"]) self["message"] = QLabel() self["stack"].addWidget(self["message"]) self["stack"].setCurrentWidget(self["status"]) styles.apply(self) statusbar_loghandler.signals.message.connect(self._on_message) api.status.signals.update.connect(self._on_update_status)
def __init__(self, mainwindow): super().__init__(parent=mainwindow) self._last_selected = "" self._positions: Dict[str, Position] = {} self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Ignored) self.setModel(LibraryModel(self)) self.setItemDelegate(LibraryDelegate()) self.hide() self.activated.connect(self.open_selected) self.doubleClicked.connect(self.open_selected) api.settings.library.width.changed.connect(self.update_width) api.settings.library.show_hidden.changed.connect( self._on_show_hidden_changed) search.search.new_search.connect(self._on_new_search) search.search.cleared.connect(self.repaint) api.modes.LIBRARY.entered.connect(self._on_enter) api.modes.LIBRARY.closed.connect(self._on_closed) api.signals.new_image_opened.connect(self._select_path) synchronize.signals.new_thumbnail_path_selected.connect( self._select_path) styles.apply(self)
def __init__(self): super().__init__(parent=mainwindow.instance()) self._init_content() self.setWindowTitle(self.TITLE) self.setWindowFlags(self.windowFlags() | Qt.Tool) styles.apply(self) self.show()
def __init__(self, parent, manipulator: immanipulate.Manipulator): super().__init__(parent=parent) self._max_size = QSize(0, 0) self._pixmap: Optional[QPixmap] = None self._bottom_right = QPoint(0, 0) styles.apply(self) manipulator.updated.connect(self._update_pixmap)
def __init__(self, parent): super().__init__(parent=parent) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setEditTriggers(self.NoEditTriggers) self.setModel(api.completion.FilterProxyModel()) styles.apply(self)
def __init__(self, parent, manipulate): super().__init__(parent=parent) self._manipulate = manipulate self._max_size = QSize(0, 0) self._pixmap: Optional[QPixmap] = None styles.apply(self) api.modes.MANIPULATE.left.connect(self._on_left) immanipulate.Manipulator.instance.updated.connect(self._update_pixmap) self.hide()
def __init__(self, parent): super().__init__(parent=parent) self.setAttribute(Qt.WA_StyledBackground, True) styles.apply(self) # Add all manipulations from immanipulate manipulator = immanipulate.Manipulator.instance for group in manipulator.manipulations.groups: self._add_group(group) # Connect signals self.currentChanged.connect(manipulator.focus_group_index) # Hide by default self.hide()
def __init__(self, mainwindow): super().__init__(parent=mainwindow) self.setAttribute(Qt.WA_StyledBackground, True) styles.apply(self) # Add all manipulations from immanipulate manipulator = immanipulate.Manipulator.instance for group in manipulator.manipulations.groups: self._add_group(group) self._image = ManipulateImage(mainwindow, manipulator) # Connect signals self.currentChanged.connect(manipulator.focus_group_index) api.modes.MANIPULATE.closed.connect(self._close)
def __init__(self, question: api.prompt.Question, *, parent): super().__init__(parent=parent) self.question = question self.loop = QEventLoop() styles.apply(self) header = f"<h3>{question.title}</h3>{question.body}" self.setText(header + self.bindings_table()) _logger.debug("Initialized %s", self) self.setFocus() self.adjustSize() self.raise_() self.show()
def __init__(self): super().__init__() self._history = history.History( history.read(), max_items=api.settings.command_history_limit.value) self.mode = None self.returnPressed.connect(self._on_return_pressed) self.editingFinished.connect(self._history.reset) self.textEdited.connect(self._on_text_edited) self.textChanged.connect(self._incremental_search) self.cursorPositionChanged.connect(self._on_cursor_position_changed) QCoreApplication.instance().aboutToQuit.connect(self._on_app_quit) api.modes.COMMAND.entered.connect(self._on_entered) styles.apply(self)
def _set_severity_style(self, severity): """Set the style of the statusbar for a temporary message. Adds a colored border to the top of the statusbar. The border color depends on the severity. Args: severity: One of "debug", "info", "warning", "error" """ append = f""" QLabel {{ border-top: {{statusbar.message_border}} {{statusbar.{severity}}}; }} """ styles.apply(self, append)
def __init__(self): super().__init__() layout = QHBoxLayout(self) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) self.left = self.create_label(layout, Qt.AlignLeft) self.center = self.create_label(layout, Qt.AlignCenter) self.right = self.create_label(layout, Qt.AlignRight) styles.apply(self) api.status.signals.update.connect(self._update_status) api.settings.statusbar.show.changed.connect(self._on_show_changed) if not api.settings.statusbar.show.value: self.hide()
def __init__(self, parent): super().__init__(parent=parent) styles.apply(self) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Minimum) self.setTextFormat(Qt.RichText) self._mainwindow_bottom = 0 self._mainwindow_width = 0 self._path = "" self._loaded = False api.signals.new_image_opened.connect(self._on_image_opened) self.hide()
def __init__(self, parent): super().__init__(parent=parent) styles.apply(self) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Minimum) self.setTextFormat(Qt.RichText) self._mainwindow_bottom = 0 self._mainwindow_width = 0 self._path = "" self._current_set = "" api.signals.new_image_opened.connect(self._on_image_opened) api.settings.metadata.current_keyset.changed.connect( self._update_text) self.hide()
def init(self) -> None: """Lazy-initialize command-line when first entering command mode.""" from vimiv.commands import history self._history = history.History( self.PREFIXES, max_items=api.settings.command.history_limit.value, ) self.returnPressed.connect(self._on_return_pressed) self.textEdited.connect(self._on_text_edited) self.textChanged.connect(self._incremental_search) self.cursorPositionChanged.connect(self._on_cursor_position_changed) QCoreApplication.instance().aboutToQuit.connect( # type: ignore self._history.write) styles.apply(self)
def __init__(self, mainwindow): super().__init__(parent=mainwindow) self._timer = QTimer() self._timer.setInterval(api.settings.statusbar.message_timeout.value) self._timer.setSingleShot(True) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Minimum) self.setTextFormat(Qt.RichText) self.setWordWrap(True) styles.apply(self) self.hide() self._timer.timeout.connect(self._clear_message) api.status.signals.clear.connect(self._clear_message) api.settings.statusbar.message_timeout.changed.connect(self._timer.setInterval) utils.log.statusbar_loghandler.message.connect(self._on_message)
def __init__(self) -> None: super().__init__() styles.apply(self) self._scale = ImageScaleFloat(1.0) self.setResizeAnchor(QGraphicsView.AnchorViewCenter) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setFrameShape(QFrame.Box) scene = QGraphicsScene() scene.setSceneRect(QRectF(0, 0, 1, 1)) self.setScene(scene) self.setOptimizationFlags(QGraphicsView.DontSavePainterState) api.signals.pixmap_loaded.connect(self._load_pixmap) api.signals.movie_loaded.connect(self._load_movie) if QGraphicsSvgItem is not None: api.signals.svg_loaded.connect(self._load_svg) api.signals.all_images_cleared.connect(self._on_images_cleared)
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 __init__(self): super().__init__() self.timer = QTimer() self.timer.setInterval(api.settings.statusbar.message_timeout.value) self.timer.setSingleShot(True) self.status = StatusLabels() self.message = QLabel() self.stack = QStackedLayout(self) self.stack.addWidget(self.status) self.stack.addWidget(self.message) self.stack.setCurrentWidget(self.status) styles.apply(self) self.timer.timeout.connect(self.clear_message) api.status.signals.clear.connect(self.clear_message) utils.log.statusbar_loghandler.message.connect(self._on_message) api.status.signals.update.connect(self._on_update_status) api.settings.statusbar.message_timeout.changed.connect( self._on_timeout_changed)
def __init__(self, mainwindow): super().__init__(parent=mainwindow) self._last_selected = "" self._positions = {} self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Ignored) self.setModel(LibraryModel(self)) self.setItemDelegate(LibraryDelegate()) self.hide() self.activated.connect(self._on_activated) api.settings.library.width.changed.connect(self._on_width_changed) api.settings.library.show_hidden.changed.connect( self._on_show_hidden_changed) search.search.new_search.connect(self._on_new_search) search.search.cleared.connect(self._on_search_cleared) api.modes.LIBRARY.entered.connect(self._on_entered) api.modes.LIBRARY.left.connect(self._on_left) styles.apply(self)
def __init__(self, parent): super().__init__(parent=parent) self.setAttribute(Qt.WA_StyledBackground, True) self._error = "No image to manipulate" self._labels = {} self._bars = {} styles.apply(self) layout = QHBoxLayout() for manipulation in ["brightness", "contrast"]: bar = QProgressBar() bar.setValue(0) bar.setMinimum(-127) bar.setMaximum(127) bar.setFormat("%v") label = QLabel(manipulation) layout.addWidget(label) layout.addWidget(bar) self._bars[manipulation] = bar self._labels[manipulation] = label self._on_focused("brightness") # Default selection layout.addStretch() layout.addStretch() self.setLayout(layout) imutils.pixmap_loaded.connect(self._on_pixmap_loaded) imutils.movie_loaded.connect(self._on_movie_loaded) imutils.svg_loaded.connect(self._on_svg_loaded) api.modes.MANIPULATE.entered.connect(self._on_entered) api.modes.MANIPULATE.left.connect(self.hide) manipulator = immanipulate.instance() manipulator.edited.connect(self._on_edited) manipulator.focused.connect(self._on_focused) self.hide()
def _clear_severity_style(self): styles.apply(self)
def __init__(self, title: str, parent=None): super().__init__(parent=parent) self.setWindowTitle(title) self.setWindowFlags(self.windowFlags() | Qt.Tool) # type: ignore styles.apply(self)
def __init__(self): super().__init__() styles.apply(self) self.setAlignment(Qt.AlignCenter)