| 1 |
from typing import ClassVar |
| 2 |
|
| 3 |
from qt.core import QAction, QColor, QIcon, QImage, QMenu, QObject, QPainter, QPaintEvent, QProxyStyle, QRect, QSize, QWidget, pyqtSignal |
| 4 |
|
| 5 |
def set_no_activate_on_click(widget: QWidget) -> None: |
| 6 |
"Prevent widget from activating (getting focus) when it is clicked" |
| 7 |
pass |
| 8 |
|
| 9 |
def draw_snake_spinner(painter: QPainter, rect: QRect, angle: int, light: QColor, dark: QColor) -> None: |
| 10 |
"Draw a single frame of the snake spinner animation, at angle, inside rect using painter" |
| 11 |
pass |
| 12 |
|
| 13 |
def set_menu_on_action(ac: QAction, menu: QMenu) -> None: |
| 14 |
"Associate menu with the QAction ac, so that it can be retrieved with menu_for_action()" |
| 15 |
pass |
| 16 |
|
| 17 |
def menu_for_action(ac: QAction) -> QMenu | None: |
| 18 |
"Return the QMenu previously associated with ac using set_menu_on_action(), or None" |
| 19 |
pass |
| 20 |
|
| 21 |
def set_image_allocation_limit(megabytes: int) -> None: |
| 22 |
"Set the maximum amount of memory, in MB, Qt is allowed to allocate for a single image" |
| 23 |
pass |
| 24 |
|
| 25 |
def get_image_allocation_limit() -> int: |
| 26 |
"Return the maximum amount of memory, in MB, Qt is allowed to allocate for a single image" |
| 27 |
pass |
| 28 |
|
| 29 |
def image_from_hicon(handle: int) -> QImage: |
| 30 |
"Create a QImage from a Windows HICON native handle" |
| 31 |
pass |
| 32 |
|
| 33 |
def image_from_hbitmap(handle: int) -> QImage: |
| 34 |
"Create a QImage from a Windows HBITMAP native handle" |
| 35 |
pass |
| 36 |
|
| 37 |
def contrast_ratio(c1: QColor, c2: QColor) -> float: |
| 38 |
"Return the WCAG contrast ratio between the two colors" |
| 39 |
pass |
| 40 |
|
| 41 |
def utf16_slice(src: str, pos: int, n: int = -1) -> str: |
| 42 |
"Return the sub-string of src starting at UTF-16 code unit pos and containing n UTF-16 code units (-1 for the rest of the string)" |
| 43 |
pass |
| 44 |
|
| 45 |
def set_icon_theme(is_dark: bool, has_dark_user_theme: bool, has_light_user_theme: bool, has_any_user_theme: bool) -> None: |
| 46 |
"Configure the icon theme engine based on whether the palette is dark and which user icon themes are installed" |
| 47 |
pass |
| 48 |
|
| 49 |
def icon_from_name(name: str, fallback_data: bytes) -> QIcon: |
| 50 |
"Return a QIcon for the named icon from the current icon theme, using fallback_data (image data) if not found" |
| 51 |
pass |
| 52 |
|
| 53 |
def icon_from_paths(any_path: str, light_path: str, dark_path: str) -> QIcon: |
| 54 |
"Return a QIcon that is theme aware, constructed from the given light/dark/any variant image paths" |
| 55 |
pass |
| 56 |
|
| 57 |
def install_qt_translator(v: int | None) -> None: |
| 58 |
"Install v (a native QTranslator pointer) as an application translator, or the default translator if v is None" |
| 59 |
pass |
| 60 |
|
| 61 |
class CalibreStyle(QProxyStyle): |
| 62 |
"A QProxyStyle subclass implementing calibre specific UI style tweaks" |
| 63 |
|
| 64 |
def __init__(self, transient_scroller: int) -> None: |
| 65 |
"Create the style, transient_scroller controls whether scrollbars are transient" |
| 66 |
pass |
| 67 |
|
| 68 |
class SpinAnimator(QObject): |
| 69 |
'Drives the animation for a spinning "busy" indicator' |
| 70 |
|
| 71 |
updated: ClassVar[pyqtSignal] |
| 72 |
|
| 73 |
def __init__(self, parent: QObject | None = None, speed_factor: int = 300) -> None: |
| 74 |
"Create the animator, optionally parented to parent, animating at speed_factor" |
| 75 |
pass |
| 76 |
|
| 77 |
def get_arc_length(self) -> float: |
| 78 |
"Return the current arc length of the spinner, in degrees" |
| 79 |
pass |
| 80 |
|
| 81 |
def get_arc_rotation(self) -> int: |
| 82 |
"Return the current rotation of the spinner arc, in degrees" |
| 83 |
pass |
| 84 |
|
| 85 |
def get_overall_rotation(self) -> int: |
| 86 |
"Return the current overall rotation of the spinner, in degrees" |
| 87 |
pass |
| 88 |
|
| 89 |
def draw(self, painter: QPainter, bounds: QRect, color: QColor, thickness: float = 0.0) -> None: |
| 90 |
"Draw the current animation frame using painter, inside bounds, in color, with the given line thickness" |
| 91 |
pass |
| 92 |
|
| 93 |
def start(self) -> None: |
| 94 |
"Start the animation" |
| 95 |
pass |
| 96 |
|
| 97 |
def stop(self) -> None: |
| 98 |
"Stop the animation" |
| 99 |
pass |
| 100 |
|
| 101 |
def is_running(self) -> bool: |
| 102 |
"Return True if the animation is currently running" |
| 103 |
pass |
| 104 |
|
| 105 |
def set_arc_length(self, val: float) -> None: |
| 106 |
"Set the arc length of the spinner, in degrees" |
| 107 |
pass |
| 108 |
|
| 109 |
def set_arc_rotation(self, val: int) -> None: |
| 110 |
"Set the rotation of the spinner arc, in degrees" |
| 111 |
pass |
| 112 |
|
| 113 |
def set_overall_rotation(self, val: int) -> None: |
| 114 |
"Set the overall rotation of the spinner, in degrees" |
| 115 |
pass |
| 116 |
|
| 117 |
class QProgressIndicator(QWidget): |
| 118 |
"A widget that displays a spinning busy/progress indicator" |
| 119 |
|
| 120 |
running_state_changed: ClassVar[pyqtSignal] |
| 121 |
|
| 122 |
def __init__(self, parent: QWidget | None = None, size: int = 64, interval: int = 0) -> None: |
| 123 |
"Create the indicator, optionally parented to parent, with the given size and animation interval (0 for default)" |
| 124 |
pass |
| 125 |
|
| 126 |
def isAnimated(self) -> bool: |
| 127 |
"Return True if the animation is currently running" |
| 128 |
pass |
| 129 |
|
| 130 |
def sizeHint(self) -> QSize: |
| 131 |
"Return the recommended size for the widget" |
| 132 |
pass |
| 133 |
|
| 134 |
def heightForWidth(self, a0: int) -> int: |
| 135 |
"Return the recommended height for the given width" |
| 136 |
pass |
| 137 |
|
| 138 |
def displaySize(self) -> QSize: |
| 139 |
"Return the size at which the indicator is displayed" |
| 140 |
pass |
| 141 |
|
| 142 |
def startAnimation(self) -> None: |
| 143 |
"Start the animation" |
| 144 |
pass |
| 145 |
|
| 146 |
def start(self) -> None: |
| 147 |
"Start the animation" |
| 148 |
pass |
| 149 |
|
| 150 |
def stopAnimation(self) -> None: |
| 151 |
"Stop the animation" |
| 152 |
pass |
| 153 |
|
| 154 |
def stop(self) -> None: |
| 155 |
"Stop the animation" |
| 156 |
pass |
| 157 |
|
| 158 |
def setDisplaySize(self, size: QSize | int) -> None: |
| 159 |
"Set the size at which the indicator is displayed" |
| 160 |
pass |
| 161 |
|
| 162 |
def setSizeHint(self, size: QSize | int) -> None: |
| 163 |
"Set the recommended size for the widget" |
| 164 |
pass |
| 165 |
|
| 166 |
def paintEvent(self, a0: QPaintEvent | None) -> None: |
| 167 |
pass |