ScreenMagnifier 1.11.0.post8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ScreenMagnifier might be problematic. Click here for more details.
- ScreenMagnifier/__init__.py +68 -0
- ScreenMagnifier/__main__.py +17 -0
- ScreenMagnifier/advancedoverlay.py +593 -0
- ScreenMagnifier/advancedpanel.py +521 -0
- ScreenMagnifier/analysiscontroller.py +533 -0
- ScreenMagnifier/analysisserver.py +404 -0
- ScreenMagnifier/colordetector/__init__.py +28 -0
- ScreenMagnifier/colordetector/colordetector.py +570 -0
- ScreenMagnifier/colordetector/core.py +434 -0
- ScreenMagnifier/colordetector/main.py +23 -0
- ScreenMagnifier/colordetector/mainwindow.py +182 -0
- ScreenMagnifier/colorpanel.py +424 -0
- ScreenMagnifier/colorswatches/__init__.py +16 -0
- ScreenMagnifier/colorswatches/colorswatches.py +316 -0
- ScreenMagnifier/colorswatches/main.py +23 -0
- ScreenMagnifier/colorswatches/mainwindow.py +60 -0
- ScreenMagnifier/controlpanel.py +234 -0
- ScreenMagnifier/detectionpanel.py +790 -0
- ScreenMagnifier/facedetector/__init__.py +24 -0
- ScreenMagnifier/facedetector/core.py +314 -0
- ScreenMagnifier/facedetector/facedetector.py +288 -0
- ScreenMagnifier/facedetector/main.py +23 -0
- ScreenMagnifier/facedetector/mainwindow.py +122 -0
- ScreenMagnifier/facedetector/models/__init__.py +4 -0
- ScreenMagnifier/facepointer.py +1121 -0
- ScreenMagnifier/features.py +50 -0
- ScreenMagnifier/hotkeys/__init__.py +16 -0
- ScreenMagnifier/hotkeys/hotkeys.py +379 -0
- ScreenMagnifier/hotkeys/main.py +23 -0
- ScreenMagnifier/hotkeys/mainwindow.py +56 -0
- ScreenMagnifier/imagefilters/__init__.py +24 -0
- ScreenMagnifier/imagefilters/core.py +172 -0
- ScreenMagnifier/imagefilters/imagefilters.py +220 -0
- ScreenMagnifier/imagefilters/main.py +23 -0
- ScreenMagnifier/imagefilters/mainwindow.py +120 -0
- ScreenMagnifier/magnifierview/__init__.py +16 -0
- ScreenMagnifier/magnifierview/magnifierview.py +1249 -0
- ScreenMagnifier/magnifierview/main.py +23 -0
- ScreenMagnifier/magnifierview/mainwindow.py +91 -0
- ScreenMagnifier/main.py +157 -0
- ScreenMagnifier/mainwindow.py +1368 -0
- ScreenMagnifier/mousecatcher/__init__.py +16 -0
- ScreenMagnifier/mousecatcher/main.py +23 -0
- ScreenMagnifier/mousecatcher/mainwindow.py +78 -0
- ScreenMagnifier/mousecatcher/mousecatcher.py +251 -0
- ScreenMagnifier/mousemove.py +259 -0
- ScreenMagnifier/netprotocol/__init__.py +25 -0
- ScreenMagnifier/netprotocol/main.py +23 -0
- ScreenMagnifier/netprotocol/mainwindow.py +91 -0
- ScreenMagnifier/netprotocol/netprotocol.py +372 -0
- ScreenMagnifier/netprotocol/wire.py +189 -0
- ScreenMagnifier/regionselector/__init__.py +16 -0
- ScreenMagnifier/regionselector/main.py +23 -0
- ScreenMagnifier/regionselector/mainwindow.py +70 -0
- ScreenMagnifier/regionselector/regionselector.py +549 -0
- ScreenMagnifier/remoteclient.py +636 -0
- ScreenMagnifier/resources/icon-128.png +0 -0
- ScreenMagnifier/resources/icon-16.png +0 -0
- ScreenMagnifier/resources/icon-24.png +0 -0
- ScreenMagnifier/resources/icon-256.png +0 -0
- ScreenMagnifier/resources/icon-32.png +0 -0
- ScreenMagnifier/resources/icon-48.png +0 -0
- ScreenMagnifier/resources/icon-512.png +0 -0
- ScreenMagnifier/resources/icon-64.png +0 -0
- ScreenMagnifier/resources/icon.icns +0 -0
- ScreenMagnifier/resources/icon.ico +0 -0
- ScreenMagnifier/screengrabber/__init__.py +16 -0
- ScreenMagnifier/screengrabber/main.py +23 -0
- ScreenMagnifier/screengrabber/mainwindow.py +79 -0
- ScreenMagnifier/screengrabber/screengrabber.py +558 -0
- ScreenMagnifier/server.py +150 -0
- ScreenMagnifier/serverpanel.py +379 -0
- ScreenMagnifier/shortcuteditor/__init__.py +16 -0
- ScreenMagnifier/shortcuteditor/main.py +23 -0
- ScreenMagnifier/shortcuteditor/mainwindow.py +54 -0
- ScreenMagnifier/shortcuteditor/shortcuteditor.py +411 -0
- ScreenMagnifier/shortcuts.py +118 -0
- ScreenMagnifier/shortcutspanel.py +140 -0
- ScreenMagnifier/support.py +127 -0
- ScreenMagnifier/translations/ar.json +387 -0
- ScreenMagnifier/translations/de.json +387 -0
- ScreenMagnifier/translations/es.json +387 -0
- ScreenMagnifier/translations/fr.json +387 -0
- ScreenMagnifier/translations/it.json +387 -0
- ScreenMagnifier/translations/ja.json +387 -0
- ScreenMagnifier/translations/ko.json +387 -0
- ScreenMagnifier/translations/pt_BR.json +387 -0
- ScreenMagnifier/translations/ru.json +387 -0
- ScreenMagnifier/translations/tr.json +387 -0
- ScreenMagnifier/translations/zh_CN.json +387 -0
- ScreenMagnifier/translator/__init__.py +16 -0
- ScreenMagnifier/translator/main.py +23 -0
- ScreenMagnifier/translator/mainwindow.py +62 -0
- ScreenMagnifier/translator/translator.py +284 -0
- ScreenMagnifier/upscaler/__init__.py +24 -0
- ScreenMagnifier/upscaler/core.py +315 -0
- ScreenMagnifier/upscaler/main.py +23 -0
- ScreenMagnifier/upscaler/mainwindow.py +128 -0
- ScreenMagnifier/upscaler/models/FSRCNN-small_x2.pb +0 -0
- ScreenMagnifier/upscaler/models/FSRCNN-small_x3.pb +0 -0
- ScreenMagnifier/upscaler/models/FSRCNN-small_x4.pb +0 -0
- ScreenMagnifier/upscaler/models/FSRCNN_x2.pb +0 -0
- ScreenMagnifier/upscaler/models/FSRCNN_x3.pb +0 -0
- ScreenMagnifier/upscaler/models/FSRCNN_x4.pb +0 -0
- ScreenMagnifier/upscaler/models/LICENSE-FSRCNN +201 -0
- ScreenMagnifier/upscaler/models/__init__.py +4 -0
- ScreenMagnifier/upscaler/upscaler.py +285 -0
- ScreenMagnifier/wincheck.py +65 -0
- ScreenMagnifier/zoomoverlay/__init__.py +16 -0
- ScreenMagnifier/zoomoverlay/main.py +23 -0
- ScreenMagnifier/zoomoverlay/mainwindow.py +99 -0
- ScreenMagnifier/zoomoverlay/zoomoverlay.py +1779 -0
- screenmagnifier-1.11.0.post8.dist-info/METADATA +591 -0
- screenmagnifier-1.11.0.post8.dist-info/RECORD +117 -0
- screenmagnifier-1.11.0.post8.dist-info/WHEEL +5 -0
- screenmagnifier-1.11.0.post8.dist-info/entry_points.txt +5 -0
- screenmagnifier-1.11.0.post8.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1779 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
ZoomOverlay: a click-through, focus-less, always-on-top magnifier lens for use over games and other
|
|
4
|
+
full-screen applications.
|
|
5
|
+
- Never takes the keyboard focus and lets every mouse click through to the application below.
|
|
6
|
+
- Target: screen center (e.g. a game crosshair), a pinned point, or the mouse cursor.
|
|
7
|
+
- Placement: on the target (scope style) or in a screen corner (picture-in-picture).
|
|
8
|
+
- Circle, rounded-rectangle (adjustable corner radius) or rectangle lens, crosshair, border, opacity, animated
|
|
9
|
+
zoom badge.
|
|
10
|
+
- Frames are pushed with setFrame(); sourceRect() tells the capture code which global rect to grab.
|
|
11
|
+
- Windows 10 2004+: the lens hides itself from screen capture so it can sit on top of what it magnifies,
|
|
12
|
+
and it re-asserts its top-most position every second (borderless games like to climb above it).
|
|
13
|
+
- The lens is a constant-alpha layered window (shape from a window mask, no per-pixel alpha): Windows
|
|
14
|
+
refuses to hide per-pixel-alpha (UpdateLayeredWindow) windows from capture with ERROR_NOT_ENOUGH_MEMORY.
|
|
15
|
+
- externalSource: when frames come from a capture that can never contain the lens (e.g. a direct capture of
|
|
16
|
+
the game window), scope mode works without hiding the lens at all.
|
|
17
|
+
- Self-capture guard: when the lens covers what it magnifies, it first checks with a tiny probe pattern that
|
|
18
|
+
it really is invisible to screen capture. If it is not (the OS ignored the exclusion), it moves to a free
|
|
19
|
+
screen corner instead of showing a "hall of mirrors", and reports why (captureStatusChanged).
|
|
20
|
+
"""
|
|
21
|
+
from ManyQt.QtCore import Qt, QTimer, QElapsedTimer, QRect, QRectF, QPoint, QPointF, QSize, QLineF, pyqtSignal, \
|
|
22
|
+
pyqtSlot, pyqtProperty, Q_ENUMS, qVersion
|
|
23
|
+
from ManyQt.QtGui import QPainter, QColor, QPen, QImage, QFont, QFontMetrics, QPainterPath, QRegion, QCursor, \
|
|
24
|
+
QGuiApplication, QTransform
|
|
25
|
+
from ManyQt.QtWidgets import QWidget
|
|
26
|
+
from enum import IntEnum
|
|
27
|
+
from sys import platform
|
|
28
|
+
|
|
29
|
+
try:
|
|
30
|
+
from sys import getwindowsversion # Windows only.
|
|
31
|
+
except:
|
|
32
|
+
getwindowsversion = None
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def clamp(x, a, b):
|
|
36
|
+
"""
|
|
37
|
+
:param x: float | int
|
|
38
|
+
:param a: float | int
|
|
39
|
+
:param b: float | int
|
|
40
|
+
:return: float | int
|
|
41
|
+
"""
|
|
42
|
+
return a if x < a else b if x > b else x
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def screenAtPoint(point):
|
|
46
|
+
"""
|
|
47
|
+
:param point: QPoint
|
|
48
|
+
:return: QScreen
|
|
49
|
+
"""
|
|
50
|
+
screen = QGuiApplication.screenAt(point) if hasattr(QGuiApplication, 'screenAt') else None
|
|
51
|
+
return screen if screen is not None else QGuiApplication.primaryScreen()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
WDA_NONE = 0x00 # type: int
|
|
55
|
+
WDA_EXCLUDEFROMCAPTURE = 0x11 # type: int
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _user32():
|
|
59
|
+
"""
|
|
60
|
+
Private user32 handle with its own prototypes (does not clash with other modules' argtypes).
|
|
61
|
+
:return: ctypes.WinDLL
|
|
62
|
+
"""
|
|
63
|
+
from ctypes import WinDLL, POINTER, c_int, c_long, c_ubyte
|
|
64
|
+
from ctypes.wintypes import HWND, BOOL, DWORD
|
|
65
|
+
u = WinDLL('user32', use_last_error=True)
|
|
66
|
+
u.SetWindowDisplayAffinity.argtypes = [HWND, DWORD]
|
|
67
|
+
u.SetWindowDisplayAffinity.restype = BOOL
|
|
68
|
+
u.GetWindowDisplayAffinity.argtypes = [HWND, POINTER(DWORD)]
|
|
69
|
+
u.GetWindowDisplayAffinity.restype = BOOL
|
|
70
|
+
u.GetWindowLongW.argtypes = [HWND, c_int]
|
|
71
|
+
u.GetWindowLongW.restype = c_long
|
|
72
|
+
u.SetWindowLongW.argtypes = [HWND, c_int, c_long]
|
|
73
|
+
u.SetWindowLongW.restype = c_long
|
|
74
|
+
u.SetLayeredWindowAttributes.argtypes = [HWND, DWORD, c_ubyte, DWORD]
|
|
75
|
+
u.SetLayeredWindowAttributes.restype = BOOL
|
|
76
|
+
u.GetLayeredWindowAttributes.argtypes = [HWND, POINTER(DWORD), POINTER(c_ubyte), POINTER(DWORD)]
|
|
77
|
+
u.GetLayeredWindowAttributes.restype = BOOL
|
|
78
|
+
return u
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def winGetDisplayAffinity(widget):
|
|
82
|
+
"""
|
|
83
|
+
:param widget: QWidget
|
|
84
|
+
:return: (int | None) Current display affinity of the window, None when unavailable.
|
|
85
|
+
"""
|
|
86
|
+
if platform != 'win32':
|
|
87
|
+
return None
|
|
88
|
+
try:
|
|
89
|
+
from ctypes.wintypes import DWORD, HWND
|
|
90
|
+
from ctypes import byref
|
|
91
|
+
value = DWORD(0)
|
|
92
|
+
if _user32().GetWindowDisplayAffinity(HWND(int(widget.winId())), byref(value)):
|
|
93
|
+
return int(value.value)
|
|
94
|
+
except:
|
|
95
|
+
pass
|
|
96
|
+
return None
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def winSetCaptureExcluded(widget, exclude=True, forceLayered=True, alpha=255):
|
|
100
|
+
"""
|
|
101
|
+
Hide (or show again) a top-level window from every screen-capture API (Windows 10 2004+).
|
|
102
|
+
Strategy: keep an affinity that is already set; set it; if Windows refuses (ERROR_NOT_ENOUGH_MEMORY is
|
|
103
|
+
returned for some layered windows), retry with WS_EX_LAYERED removed for the call, then restore it.
|
|
104
|
+
:param widget: QWidget
|
|
105
|
+
:param exclude: bool
|
|
106
|
+
:param forceLayered: (bool) Older Windows builds only honor the exclusion for WS_EX_LAYERED windows.
|
|
107
|
+
:param alpha: (int) Constant window alpha restored with SetLayeredWindowAttributes after a retry.
|
|
108
|
+
:return: (tuple[bool, str | unicode | QString]) Success and, on failure, a human-readable reason.
|
|
109
|
+
"""
|
|
110
|
+
if platform != 'win32':
|
|
111
|
+
return False, u'Only Windows can hide a window from screen capture'
|
|
112
|
+
try:
|
|
113
|
+
from ctypes import byref, c_ubyte, get_last_error
|
|
114
|
+
from ctypes.wintypes import HWND, DWORD
|
|
115
|
+
build = getwindowsversion().build # type: int
|
|
116
|
+
if exclude and build < 19041:
|
|
117
|
+
return False, u'Needs Windows 10 version 2004 (build 19041) or newer, this is build {}'.format(build)
|
|
118
|
+
u = _user32()
|
|
119
|
+
hwnd = HWND(int(widget.winId()))
|
|
120
|
+
GWL_EXSTYLE, WS_EX_LAYERED, LWA_ALPHA = -20, 0x80000, 0x2
|
|
121
|
+
wanted = WDA_EXCLUDEFROMCAPTURE if exclude else WDA_NONE # type: int
|
|
122
|
+
|
|
123
|
+
def current():
|
|
124
|
+
"""
|
|
125
|
+
:return: int | None
|
|
126
|
+
"""
|
|
127
|
+
value = DWORD(0)
|
|
128
|
+
return int(value.value) if u.GetWindowDisplayAffinity(hwnd, byref(value)) else None
|
|
129
|
+
|
|
130
|
+
if current() == wanted:
|
|
131
|
+
return True, u''
|
|
132
|
+
style = u.GetWindowLongW(hwnd, GWL_EXSTYLE) # type: int
|
|
133
|
+
if exclude and forceLayered and not style & WS_EX_LAYERED:
|
|
134
|
+
u.SetWindowLongW(hwnd, GWL_EXSTYLE, style | WS_EX_LAYERED)
|
|
135
|
+
u.SetLayeredWindowAttributes(hwnd, 0, int(alpha), LWA_ALPHA) # Keep it visible on screen.
|
|
136
|
+
style |= WS_EX_LAYERED
|
|
137
|
+
if u.SetWindowDisplayAffinity(hwnd, wanted):
|
|
138
|
+
return True, u''
|
|
139
|
+
error = get_last_error() # type: int
|
|
140
|
+
if style & WS_EX_LAYERED:
|
|
141
|
+
# Retry as a plain window, then make it layered again (needed for click-through).
|
|
142
|
+
u.SetWindowLongW(hwnd, GWL_EXSTYLE, style & ~WS_EX_LAYERED)
|
|
143
|
+
ok = bool(u.SetWindowDisplayAffinity(hwnd, wanted)) # type: bool
|
|
144
|
+
u.SetWindowLongW(hwnd, GWL_EXSTYLE, style)
|
|
145
|
+
u.SetLayeredWindowAttributes(hwnd, 0, int(alpha), LWA_ALPHA)
|
|
146
|
+
if ok and current() in (None, wanted):
|
|
147
|
+
return True, ''
|
|
148
|
+
perPixel = '' # type: str
|
|
149
|
+
if style & WS_EX_LAYERED:
|
|
150
|
+
key, a, flags = DWORD(0), c_ubyte(0), DWORD(0)
|
|
151
|
+
if not u.GetLayeredWindowAttributes(hwnd, byref(key), byref(a), byref(flags)):
|
|
152
|
+
perPixel = ', per-pixel-alpha window' # type: str
|
|
153
|
+
return False, u'SetWindowDisplayAffinity failed (Windows error {}, build {}{})'.format(error, build, perPixel)
|
|
154
|
+
except Exception as e:
|
|
155
|
+
return False, u'Capture exclusion unavailable: {}'.format(e)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def winMakeOverlay(widget):
|
|
159
|
+
"""
|
|
160
|
+
Windows: no activation on click/show, click-through, keep top-most.
|
|
161
|
+
:param widget: QWidget
|
|
162
|
+
:return: None
|
|
163
|
+
"""
|
|
164
|
+
if platform != 'win32':
|
|
165
|
+
return
|
|
166
|
+
try:
|
|
167
|
+
from ctypes.wintypes import HWND
|
|
168
|
+
from ctypes import windll
|
|
169
|
+
user32 = windll.user32
|
|
170
|
+
hwnd = HWND(int(widget.winId()))
|
|
171
|
+
GWL_EXSTYLE, WS_EX_TRANSPARENT, WS_EX_LAYERED = -20, 0x20, 0x80000
|
|
172
|
+
WS_EX_TOOLWINDOW, WS_EX_NOACTIVATE = 0x80, 0x08000000
|
|
173
|
+
style = user32.GetWindowLongW(hwnd, GWL_EXSTYLE) # type: int
|
|
174
|
+
style |= WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW
|
|
175
|
+
if style & WS_EX_LAYERED: # Qt made it layered (translucent / transparent for input).
|
|
176
|
+
style |= WS_EX_TRANSPARENT
|
|
177
|
+
user32.SetWindowLongW(hwnd, GWL_EXSTYLE, style)
|
|
178
|
+
winKeepTopMost(widget)
|
|
179
|
+
except:
|
|
180
|
+
pass
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def winKeepTopMost(widget):
|
|
184
|
+
"""
|
|
185
|
+
:param widget: QWidget
|
|
186
|
+
:return: (bool) True if handled natively.
|
|
187
|
+
"""
|
|
188
|
+
if platform != 'win32':
|
|
189
|
+
return False
|
|
190
|
+
try:
|
|
191
|
+
from ctypes.wintypes import HWND, UINT
|
|
192
|
+
from ctypes import c_int, windll
|
|
193
|
+
user32 = windll.user32
|
|
194
|
+
user32.SetWindowPos.argtypes = [HWND, HWND, c_int, c_int, c_int, c_int, UINT]
|
|
195
|
+
SWP_NOSIZE, SWP_NOMOVE, SWP_NOACTIVATE = 0x0001, 0x0002, 0x0010
|
|
196
|
+
return bool(user32.SetWindowPos(
|
|
197
|
+
HWND(int(widget.winId())), HWND(-1), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE))
|
|
198
|
+
except:
|
|
199
|
+
return False
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
class ZoomOverlay(QWidget):
|
|
203
|
+
"""
|
|
204
|
+
ZoomOverlay class.
|
|
205
|
+
"""
|
|
206
|
+
|
|
207
|
+
class Target(IntEnum):
|
|
208
|
+
"""
|
|
209
|
+
Target enumeration class: what is magnified.
|
|
210
|
+
"""
|
|
211
|
+
Center = 0 # type: int
|
|
212
|
+
Point = 1 # type: int
|
|
213
|
+
Cursor = 2 # type: int
|
|
214
|
+
|
|
215
|
+
class Placement(IntEnum):
|
|
216
|
+
"""
|
|
217
|
+
Placement enumeration class: where the lens is drawn.
|
|
218
|
+
"""
|
|
219
|
+
OnTarget = 0 # type: int
|
|
220
|
+
TopLeft = 1 # type: int
|
|
221
|
+
TopRight = 2 # type: int
|
|
222
|
+
BottomLeft = 3 # type: int
|
|
223
|
+
BottomRight = 4 # type: int
|
|
224
|
+
NearTarget = 5 # type: int # Beside the target (follows a cursor target), never over the picked pixel.
|
|
225
|
+
Custom = 6 # type: int # A rectangle of the user's choice (position and size, any aspect ratio).
|
|
226
|
+
FullScreen = 7 # type: int # A whole screen (the target's screen, or a chosen one).
|
|
227
|
+
|
|
228
|
+
class Shape(IntEnum):
|
|
229
|
+
"""
|
|
230
|
+
Shape enumeration class.
|
|
231
|
+
"""
|
|
232
|
+
Circle = 0 # type: int
|
|
233
|
+
RoundedRect = 1 # type: int
|
|
234
|
+
Rectangle = 2 # type: int
|
|
235
|
+
|
|
236
|
+
Center = Target.Center # type: int
|
|
237
|
+
Point = Target.Point # type: int
|
|
238
|
+
Cursor = Target.Cursor # type: int
|
|
239
|
+
OnTarget = Placement.OnTarget # type: int
|
|
240
|
+
TopLeft = Placement.TopLeft # type: int
|
|
241
|
+
TopRight = Placement.TopRight # type: int
|
|
242
|
+
BottomLeft = Placement.BottomLeft # type: int
|
|
243
|
+
BottomRight = Placement.BottomRight # type: int
|
|
244
|
+
NearTarget = Placement.NearTarget # type: int
|
|
245
|
+
Custom = Placement.Custom # type: int
|
|
246
|
+
FullScreen = Placement.FullScreen # type: int
|
|
247
|
+
Circle = Shape.Circle # type: int
|
|
248
|
+
RoundedRect = Shape.RoundedRect # type: int
|
|
249
|
+
Rectangle = Shape.Rectangle # type: int
|
|
250
|
+
zoomChanged = pyqtSignal(float) # type: pyqtSignal
|
|
251
|
+
readoutChanged = pyqtSignal(QColor, 'QString') # type: pyqtSignal # color code / zone under the crosshair
|
|
252
|
+
overlayToggled = pyqtSignal(bool) # type: pyqtSignal
|
|
253
|
+
sourceChanged = pyqtSignal() # type: pyqtSignal
|
|
254
|
+
captureStatusChanged = pyqtSignal('QString') # type: pyqtSignal
|
|
255
|
+
captureDetailChanged = pyqtSignal('QString') # type: pyqtSignal
|
|
256
|
+
PROBE_COLORS = (QColor(255, 0, 255), QColor(0, 255, 0)) # type: tuple[QColor, QColor]
|
|
257
|
+
PROBE_CELL = 8 # type: int # Probe = 2 x 2 cells of this size (px) at the lens centre.
|
|
258
|
+
PROBE_DELAY_MS = 150 # type: int # Time for the compositor to put the probe on screen.
|
|
259
|
+
FALLBACK_ORDER = (Placement.TopRight, Placement.TopLeft, Placement.BottomRight, Placement.BottomLeft) # type: tuple
|
|
260
|
+
|
|
261
|
+
def __init__(self, *args, **kwargs):
|
|
262
|
+
"""
|
|
263
|
+
:param zoom: (float | int) Magnification, 1 .. 16.
|
|
264
|
+
:param lensSize: (QSize) Lens size in px (placements other than Custom / FullScreen).
|
|
265
|
+
:param customRect: (QRect) Lens rect of the Custom placement (global, device-independent px).
|
|
266
|
+
:param fullScreenIndex: (int) Screen of the FullScreen placement, -1 = the screen of the target.
|
|
267
|
+
:param cornerRadius: (int) Corner radius of the RoundedRect shape in px (at most half the short side).
|
|
268
|
+
:param target: ZoomOverlay.Target | int
|
|
269
|
+
:param targetPoint: (QPoint) Global point used by Target.Point.
|
|
270
|
+
:param placement: ZoomOverlay.Placement | int
|
|
271
|
+
:param shape: ZoomOverlay.Shape | int
|
|
272
|
+
:param processor: (callable | None) f(QImage, QSize) -> QImage upscaler.
|
|
273
|
+
:param borderColor: QColor | Qt.GlobalColor | int | str
|
|
274
|
+
:param borderWidth: float | int
|
|
275
|
+
:param showCrosshair: bool
|
|
276
|
+
:param showColorReadout: (bool) Live color code (swatch, HEX, RGB) of the crosshair pixel.
|
|
277
|
+
:param pixelated: (bool) Exact pixels + pixel grid instead of the upscaler (color picking).
|
|
278
|
+
:param readoutSource: (str | unicode | QString)
|
|
279
|
+
Color code of: 'original' screen pixel or 'zoomed' (displayed) image.
|
|
280
|
+
:param readoutSample: (int) Average of N x N pixels for the color code (1, 3, 5, 9).
|
|
281
|
+
:param colorFormatter: (callable | None) QColor -> str: text of the color code (e.g. the application's copy
|
|
282
|
+
format, so the code shown is the code copied); None = #RRGGBB.
|
|
283
|
+
:param colorNamer: (callable | None) QColor -> str: color name shown under the code; None = no name.
|
|
284
|
+
:param crosshairColor: QColor | Qt.GlobalColor | int | str
|
|
285
|
+
:param lensOpacity: (float | int) 0.2 .. 1.0
|
|
286
|
+
:param margin: (int) Distance from the screen edges for corner placements.
|
|
287
|
+
:param excludeFromCapture: (bool) Windows: hide the lens from screen capture.
|
|
288
|
+
:param externalSource: (bool) Frames never contain the lens (e.g. direct game-window capture).
|
|
289
|
+
:param zoomChanged: callable | None
|
|
290
|
+
:param overlayToggled: callable | None
|
|
291
|
+
:param args: any
|
|
292
|
+
:param kwargs: any
|
|
293
|
+
"""
|
|
294
|
+
zoom = kwargs.pop('zoom', 2.5) # type: float
|
|
295
|
+
lensSize = kwargs.pop('lensSize', QSize(380, 380)) # type: QSize
|
|
296
|
+
customRect = kwargs.pop('customRect', QRect()) # type: QRect
|
|
297
|
+
fullScreenIndex = kwargs.pop('fullScreenIndex', -1) # type: int
|
|
298
|
+
target = kwargs.pop('target', ZoomOverlay.Center) # type: int
|
|
299
|
+
targetPoint = kwargs.pop('targetPoint', QPoint()) # type: QPoint
|
|
300
|
+
placement = kwargs.pop(
|
|
301
|
+
'placement', ZoomOverlay.OnTarget if platform == 'win32' else ZoomOverlay.TopRight) # type: int
|
|
302
|
+
shape = kwargs.pop('shape', ZoomOverlay.Circle) # type: int
|
|
303
|
+
cornerRadius = kwargs.pop('cornerRadius', 45) # type: int
|
|
304
|
+
processor = kwargs.pop('processor', None) # type: callable | None
|
|
305
|
+
borderColor = kwargs.pop('borderColor', '#4F8BFF') # type: QColor
|
|
306
|
+
borderWidth = kwargs.pop('borderWidth', 3) # type: float
|
|
307
|
+
showCrosshair = kwargs.pop('showCrosshair', True) # type: bool
|
|
308
|
+
showColorReadout = kwargs.pop('showColorReadout', True) # type: bool
|
|
309
|
+
pixelated = kwargs.pop('pixelated', False) # type: bool
|
|
310
|
+
readoutSource = kwargs.pop('readoutSource', 'original') # type: str
|
|
311
|
+
readoutSample = kwargs.pop('readoutSample', 1) # type: int
|
|
312
|
+
colorFormatter = kwargs.pop('colorFormatter', None) # type: callable | None
|
|
313
|
+
colorNamer = kwargs.pop('colorNamer', None) # type: callable | None
|
|
314
|
+
crosshairColor = kwargs.pop('crosshairColor', '#FF3B6B') # type: QColor
|
|
315
|
+
lensOpacity = kwargs.pop('lensOpacity', 1.0) # type: float
|
|
316
|
+
margin = kwargs.pop('margin', 32) # type: int
|
|
317
|
+
excludeFromCapture = kwargs.pop('excludeFromCapture', True) # type: bool
|
|
318
|
+
externalSource = kwargs.pop('externalSource', False) # type: bool
|
|
319
|
+
zoomChanged = kwargs.pop('zoomChanged', None) # type: callable | None
|
|
320
|
+
overlayToggled = kwargs.pop('overlayToggled', None) # type: callable | None
|
|
321
|
+
super(ZoomOverlay, self).__init__(*args, **kwargs)
|
|
322
|
+
if callable(zoomChanged):
|
|
323
|
+
self.zoomChanged.connect(zoomChanged)
|
|
324
|
+
if callable(overlayToggled):
|
|
325
|
+
self.overlayToggled.connect(overlayToggled)
|
|
326
|
+
# Options.
|
|
327
|
+
self.__m_zoom = clamp(float(zoom), 1.0, 16.0) # type: float
|
|
328
|
+
self.__m_lensSize = QSize(max(64, lensSize.width()), max(64, lensSize.height())) # type: QSize
|
|
329
|
+
self.__m_target = ZoomOverlay.Target(int(target)) # type: ZoomOverlay.Target
|
|
330
|
+
self.__m_targetPoint = QPoint(targetPoint) # type: QPoint
|
|
331
|
+
self.__m_placement = ZoomOverlay.Placement(int(placement)) # type: ZoomOverlay.Placement
|
|
332
|
+
self.__m_shape = ZoomOverlay.Shape(int(shape)) # type: ZoomOverlay.Shape
|
|
333
|
+
self.__m_processor = processor if callable(processor) else None # type: callable | None
|
|
334
|
+
self.__m_borderColor = borderColor if isinstance(borderColor, QColor) else QColor(borderColor) # type: QColor
|
|
335
|
+
self.__m_borderWidth = max(0.0, float(borderWidth)) # type: float
|
|
336
|
+
self.__m_showCrosshair = bool(showCrosshair) # type: bool
|
|
337
|
+
self.__m_showColorReadout = bool(showColorReadout) # type: bool
|
|
338
|
+
self.__m_pixelated = bool(pixelated) # type: bool
|
|
339
|
+
self.__m_readoutSource = 'zoomed' if u'{}'.format(readoutSource) == 'zoomed' else 'original' # type: str
|
|
340
|
+
self.__m_readoutSample = max(1, int(readoutSample)) # type: int
|
|
341
|
+
self.__m_colorFormatter = colorFormatter if callable(colorFormatter) else None
|
|
342
|
+
self.__m_colorNamer = colorNamer if callable(colorNamer) else None
|
|
343
|
+
self.__m_names = {} # type: dict # rgb -> name cache (the namer runs at frame rate)
|
|
344
|
+
self.__m_lastReadout = (None, '') # type: tuple # last (rgb, zone) emitted by readoutChanged
|
|
345
|
+
self.__m_crosshairColor = crosshairColor if isinstance(crosshairColor, QColor) else QColor(
|
|
346
|
+
crosshairColor) # type: QColor
|
|
347
|
+
self.__m_lensOpacity = clamp(float(lensOpacity), 0.2, 1.0) # type: float
|
|
348
|
+
self.__m_margin = max(0, int(margin)) # type: int
|
|
349
|
+
self.__m_excludeFromCapture = bool(excludeFromCapture) # type: bool
|
|
350
|
+
self.__m_externalSource = bool(externalSource) # type: bool
|
|
351
|
+
# State.
|
|
352
|
+
self.__m_captureExcluded = False # type: bool
|
|
353
|
+
self.__m_captureStatus = 'unknown' # type: str # unknown | notNeeded | testing | excluded | failed
|
|
354
|
+
self.__m_captureDetail = '' # type: str
|
|
355
|
+
self.__m_fallbackPlacement = None # type: ZoomOverlay.Placement | None
|
|
356
|
+
self.__m_fallbackScreen = None # type: int | None # FullScreen moved to another (safe) screen.
|
|
357
|
+
self.__m_customRect = QRect(customRect) # type: QRect
|
|
358
|
+
self.__m_cornerRadius = max(0, int(cornerRadius)) # type: int
|
|
359
|
+
self.__m_fullScreenIndex = int(fullScreenIndex) # type: int
|
|
360
|
+
self.__m_probing = False # type: bool
|
|
361
|
+
self.__m_centerScreen = None # type: QScreen | None
|
|
362
|
+
self.__m_frame = QImage() # type: QImage
|
|
363
|
+
self.__m_annotations = [] # type: list
|
|
364
|
+
self.__m_annotationSize = QSize() # type: QSize
|
|
365
|
+
self.__m_overlayImage = QImage() # type: QImage
|
|
366
|
+
self.__m_annotationOrigin = None # type: list | None # [x, y, dpr] screen position of the analysed frame.
|
|
367
|
+
self.__m_frameOrigin = None # type: list | None # [x, y, dpr] screen position of the shown frame.
|
|
368
|
+
self.__m_serial = 0 # type: int
|
|
369
|
+
self.__m_cacheKey = None # type: tuple | None
|
|
370
|
+
self.__m_cacheImage = QImage() # type: QImage
|
|
371
|
+
self.__m_badgeOpacity = 0.0 # type: float
|
|
372
|
+
self.__m_toastText = '' # type: str
|
|
373
|
+
self.__m_toastColor = QColor() # type: QColor
|
|
374
|
+
self.__m_toastOpacity = 0.0 # type: float
|
|
375
|
+
self.__m_toastClock = QElapsedTimer() # type: QElapsedTimer
|
|
376
|
+
self.__m_badgeClock = QElapsedTimer() # type: QElapsedTimer
|
|
377
|
+
self.__m_badgeTimer = QTimer(self) # type: QTimer
|
|
378
|
+
self.__m_badgeTimer.timeout.connect(self._tick)
|
|
379
|
+
self.__m_topTimer = QTimer(self) # type: QTimer
|
|
380
|
+
self.__m_topTimer.timeout.connect(self._keepOnTop)
|
|
381
|
+
# Window flags: frameless, top-most, no taskbar entry, no focus, click-through.
|
|
382
|
+
flags = Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Tool | Qt.WindowDoesNotAcceptFocus
|
|
383
|
+
if hasattr(Qt, 'WindowTransparentForInput'):
|
|
384
|
+
flags |= Qt.WindowTransparentForInput
|
|
385
|
+
if platform.startswith('linux'):
|
|
386
|
+
flags |= Qt.X11BypassWindowManagerHint # Stay above full-screen X11 windows, never focused.
|
|
387
|
+
self.setWindowFlags(flags)
|
|
388
|
+
self.setAttribute(Qt.WA_ShowWithoutActivating, True)
|
|
389
|
+
self.setAttribute(Qt.WA_TransparentForMouseEvents, True)
|
|
390
|
+
# No WA_TranslucentBackground: per-pixel alpha windows (UpdateLayeredWindow) cannot be hidden from
|
|
391
|
+
# capture. The lens shape comes from a window mask instead.
|
|
392
|
+
self.setAttribute(Qt.WA_NoSystemBackground, True)
|
|
393
|
+
self.setFocusPolicy(Qt.NoFocus)
|
|
394
|
+
self.setWindowOpacity(self.__m_lensOpacity)
|
|
395
|
+
self.resize(self.__m_lensSize)
|
|
396
|
+
if platform == 'win32' and self.__m_excludeFromCapture:
|
|
397
|
+
self.winId() # Create the native window now: the exclusion is most reliable before the first show.
|
|
398
|
+
self.__m_captureExcluded, self.__m_captureDetail = winSetCaptureExcluded(
|
|
399
|
+
self, alpha=int(round(self.__m_lensOpacity * 255)))
|
|
400
|
+
|
|
401
|
+
# ---------- Helpers ----------
|
|
402
|
+
def _lensPath(self, rect):
|
|
403
|
+
"""
|
|
404
|
+
:param rect: QRectF
|
|
405
|
+
:return: QPainterPath
|
|
406
|
+
"""
|
|
407
|
+
path = QPainterPath() # type: QPainterPath
|
|
408
|
+
if self._isRectangular():
|
|
409
|
+
path.addRect(rect)
|
|
410
|
+
elif self.__m_shape == ZoomOverlay.Circle:
|
|
411
|
+
path.addEllipse(rect)
|
|
412
|
+
else:
|
|
413
|
+
r = self._radiusFor(rect) # type: float
|
|
414
|
+
path.addRoundedRect(rect, r, r)
|
|
415
|
+
return path
|
|
416
|
+
|
|
417
|
+
def _radiusFor(self, rect):
|
|
418
|
+
"""
|
|
419
|
+
:param rect: QRectF | QRect
|
|
420
|
+
:return: (float | int) Corner radius actually drawn: the chosen one, at most half the short side (a pill / circle).
|
|
421
|
+
"""
|
|
422
|
+
if self._isRectangular() or self.__m_shape == ZoomOverlay.Circle:
|
|
423
|
+
return 0.0
|
|
424
|
+
return min(float(self.__m_cornerRadius), min(rect.width(), rect.height()) / 2.0)
|
|
425
|
+
|
|
426
|
+
def _isRectangular(self):
|
|
427
|
+
"""
|
|
428
|
+
:return: (bool) Drawn as a plain rectangle: the Rectangle shape, or a full-screen lens.
|
|
429
|
+
"""
|
|
430
|
+
return self.__m_shape == ZoomOverlay.Rectangle or (
|
|
431
|
+
self.getEffectivePlacement() == ZoomOverlay.FullScreen)
|
|
432
|
+
|
|
433
|
+
def _updateMask(self):
|
|
434
|
+
"""
|
|
435
|
+
A window mask gives the lens its shape even without a compositor.
|
|
436
|
+
:return:
|
|
437
|
+
"""
|
|
438
|
+
if self._isRectangular():
|
|
439
|
+
self.clearMask()
|
|
440
|
+
elif self.__m_shape == ZoomOverlay.Circle:
|
|
441
|
+
self.setMask(QRegion(self.rect(), QRegion.Ellipse))
|
|
442
|
+
else:
|
|
443
|
+
try:
|
|
444
|
+
poly = self._lensPath(QRectF(self.rect())).toFillPolygon().toPolygon()
|
|
445
|
+
except:
|
|
446
|
+
poly = self._lensPath(QRectF(self.rect())).toFillPolygon(QTransform()).toPolygon()
|
|
447
|
+
self.setMask(QRegion(poly))
|
|
448
|
+
|
|
449
|
+
def _reposition(self):
|
|
450
|
+
"""
|
|
451
|
+
:return:
|
|
452
|
+
"""
|
|
453
|
+
geo = self.lensGeometry() # type: QRect
|
|
454
|
+
if geo != self.geometry():
|
|
455
|
+
resized = geo.size() != self.size() # type: bool
|
|
456
|
+
self.setGeometry(geo)
|
|
457
|
+
if resized:
|
|
458
|
+
self._updateMask() # the shape follows the new size (custom area, full screen, fallback)
|
|
459
|
+
|
|
460
|
+
def _reevaluate(self):
|
|
461
|
+
"""
|
|
462
|
+
Placement-relevant option changed while visible: check again whether the lens is safe where it is.
|
|
463
|
+
:return:
|
|
464
|
+
"""
|
|
465
|
+
if self.isVisible():
|
|
466
|
+
self.__m_captureStatus = 'unknown' # type: str
|
|
467
|
+
QTimer.singleShot(0, self._evaluateCapture)
|
|
468
|
+
|
|
469
|
+
def _changed(self):
|
|
470
|
+
"""
|
|
471
|
+
Geometry-affecting option changed.
|
|
472
|
+
:return:
|
|
473
|
+
"""
|
|
474
|
+
if self.isVisible():
|
|
475
|
+
self._reposition()
|
|
476
|
+
self.__m_cacheKey = None
|
|
477
|
+
self.update()
|
|
478
|
+
self.sourceChanged.emit()
|
|
479
|
+
|
|
480
|
+
def _keepOnTop(self):
|
|
481
|
+
"""
|
|
482
|
+
:return:
|
|
483
|
+
"""
|
|
484
|
+
if not winKeepTopMost(self):
|
|
485
|
+
self.raise_()
|
|
486
|
+
if self.__m_captureExcluded and winGetDisplayAffinity(self) not in (None, WDA_EXCLUDEFROMCAPTURE):
|
|
487
|
+
winSetCaptureExcluded(self, alpha=int(round(self.__m_lensOpacity * 255))) # Put it back.
|
|
488
|
+
|
|
489
|
+
def _setStatus(self, status, detail=''):
|
|
490
|
+
"""
|
|
491
|
+
:param status: str | unicode | QString
|
|
492
|
+
:param detail: str | unicode | QString
|
|
493
|
+
:return:
|
|
494
|
+
"""
|
|
495
|
+
self.__m_captureStatus = status # type: str
|
|
496
|
+
self.__m_captureDetail = detail # type: str
|
|
497
|
+
self.captureStatusChanged.emit(status)
|
|
498
|
+
|
|
499
|
+
@staticmethod
|
|
500
|
+
def _screens():
|
|
501
|
+
"""
|
|
502
|
+
:return: (list[QScreen])
|
|
503
|
+
"""
|
|
504
|
+
return QGuiApplication.screens()
|
|
505
|
+
|
|
506
|
+
def _fullScreenGeometry(self):
|
|
507
|
+
"""
|
|
508
|
+
:return: (QRect) The screen of the FullScreen placement: the safe screen chosen by the fallback, the screen
|
|
509
|
+
the user chose, or the screen of the target.
|
|
510
|
+
"""
|
|
511
|
+
screens = self._screens() # type: list
|
|
512
|
+
index = self.__m_fallbackScreen if self.__m_fallbackScreen is not None else self.__m_fullScreenIndex
|
|
513
|
+
return screens[index].geometry() if 0 <= index < len(screens) else screenAtPoint(self.targetPos()).geometry()
|
|
514
|
+
|
|
515
|
+
def _customGeometry(self):
|
|
516
|
+
"""
|
|
517
|
+
:return: (QRect) The Custom rect, kept on a screen (a monitor may have been removed since it was drawn).
|
|
518
|
+
"""
|
|
519
|
+
r = QRect(self.__m_customRect) # type: QRect
|
|
520
|
+
if r.width() < 64 or r.height() < 64: # not drawn yet: the regular lens at the screen centre
|
|
521
|
+
g = screenAtPoint(self.targetPos()).geometry() # type: QRect
|
|
522
|
+
r = QRect(0, 0, self.__m_lensSize.width(), self.__m_lensSize.height())
|
|
523
|
+
r.moveCenter(g.center())
|
|
524
|
+
return r
|
|
525
|
+
g = screenAtPoint(r.center()).geometry() # type: QRect
|
|
526
|
+
r.setSize(r.size().boundedTo(g.size()))
|
|
527
|
+
r.moveLeft(int(clamp(r.left(), g.left(), g.right() - r.width() + 1)))
|
|
528
|
+
r.moveTop(int(clamp(r.top(), g.top(), g.bottom() - r.height() + 1)))
|
|
529
|
+
return r
|
|
530
|
+
|
|
531
|
+
def _geometryFor(self, placement):
|
|
532
|
+
"""
|
|
533
|
+
:param placement: ZoomOverlay.Placement
|
|
534
|
+
:return: (QRect) Lens window rect for a given placement.
|
|
535
|
+
"""
|
|
536
|
+
if placement == ZoomOverlay.Custom:
|
|
537
|
+
return self._customGeometry()
|
|
538
|
+
if placement == ZoomOverlay.FullScreen:
|
|
539
|
+
return self._fullScreenGeometry()
|
|
540
|
+
c = self.targetPos() # type: QPoint
|
|
541
|
+
g = screenAtPoint(c).geometry() # type: QRect
|
|
542
|
+
w, h, m = self.__m_lensSize.width(), self.__m_lensSize.height(), self.__m_margin # type: int, int, int
|
|
543
|
+
if placement == ZoomOverlay.OnTarget:
|
|
544
|
+
x, y = c.x() - w // 2, c.y() - h // 2 # type: int, int
|
|
545
|
+
elif placement == ZoomOverlay.NearTarget: # Beside the target, flipped near the screen edges.
|
|
546
|
+
off = int(max(28, max(w, h) / (2.0 * self.__m_zoom) + 12)) # type: int # clear of the source area
|
|
547
|
+
x = c.x() + off if c.x() + off + w <= g.right() else c.x() - off - w # type: int
|
|
548
|
+
y = c.y() + off if c.y() + off + h <= g.bottom() else c.y() - off - h # type: int
|
|
549
|
+
else:
|
|
550
|
+
x = g.left() + m if placement in (ZoomOverlay.TopLeft, ZoomOverlay.BottomLeft) else g.right() - m - w + 1
|
|
551
|
+
y = g.top() + m if placement in (ZoomOverlay.TopLeft, ZoomOverlay.TopRight) else g.bottom() - m - h + 1
|
|
552
|
+
x = int(clamp(x, g.left(), max(g.left(), g.right() - w + 1))) # type: int
|
|
553
|
+
y = int(clamp(y, g.top(), max(g.top(), g.bottom() - h + 1))) # type: int
|
|
554
|
+
return QRect(x, y, w, h)
|
|
555
|
+
|
|
556
|
+
def _useFallback(self, detail):
|
|
557
|
+
"""
|
|
558
|
+
The lens would capture itself: move it to the first screen corner that does not cover the source.
|
|
559
|
+
:param detail: (str | unicode | QString)Why the exclusion is not possible.
|
|
560
|
+
:return:
|
|
561
|
+
"""
|
|
562
|
+
if self.__m_placement == ZoomOverlay.FullScreen: # a second monitor is safe on every system
|
|
563
|
+
src = self.sourceRect() # type: QRect
|
|
564
|
+
for index, screen in enumerate(self._screens()):
|
|
565
|
+
if not screen.geometry().intersects(src):
|
|
566
|
+
self.__m_fallbackScreen = index # type: int | None
|
|
567
|
+
self.__m_frame = QImage() # type: QImage
|
|
568
|
+
self._reposition()
|
|
569
|
+
self._setStatus('otherScreen', detail)
|
|
570
|
+
self.update()
|
|
571
|
+
self.sourceChanged.emit()
|
|
572
|
+
return
|
|
573
|
+
self.__m_fallbackPlacement = ZoomOverlay.FALLBACK_ORDER[0] # corners use the regular lens size
|
|
574
|
+
src = self.sourceRect() # type: QRect # (the source of the corner lens)
|
|
575
|
+
fallback = ZoomOverlay.FALLBACK_ORDER[0]
|
|
576
|
+
for pl in ZoomOverlay.FALLBACK_ORDER:
|
|
577
|
+
if not self._geometryFor(pl).intersects(src):
|
|
578
|
+
fallback = pl
|
|
579
|
+
break
|
|
580
|
+
self.__m_fallbackPlacement = fallback
|
|
581
|
+
self.__m_frame = QImage() # type: QImage # Drop any frame that may contain the lens itself.
|
|
582
|
+
self._reposition()
|
|
583
|
+
self._setStatus('failed', detail)
|
|
584
|
+
self.update()
|
|
585
|
+
self.sourceChanged.emit()
|
|
586
|
+
|
|
587
|
+
def _evaluateCapture(self):
|
|
588
|
+
"""
|
|
589
|
+
Decide whether the requested placement is safe: runs after the native window is really shown.
|
|
590
|
+
:return: None
|
|
591
|
+
"""
|
|
592
|
+
if not self.isVisible():
|
|
593
|
+
return
|
|
594
|
+
self.__m_fallbackPlacement = None
|
|
595
|
+
self.__m_fallbackScreen = None
|
|
596
|
+
if not self._geometryFor(self.__m_placement).intersects(self.sourceRect()):
|
|
597
|
+
self._reposition()
|
|
598
|
+
self._setStatus('notNeeded')
|
|
599
|
+
return
|
|
600
|
+
if self.__m_externalSource:
|
|
601
|
+
self._reposition()
|
|
602
|
+
self._setStatus('windowCapture')
|
|
603
|
+
self.update()
|
|
604
|
+
self.sourceChanged.emit()
|
|
605
|
+
return
|
|
606
|
+
if self.__m_excludeFromCapture:
|
|
607
|
+
ok, detail = winSetCaptureExcluded(self, alpha=int(round(self.__m_lensOpacity * 255)))
|
|
608
|
+
self.setWindowOpacity(self.__m_lensOpacity) # Re-sync Qt after a possible style retry.
|
|
609
|
+
else:
|
|
610
|
+
ok, detail = False, u'Hiding the lens from capture is turned off'
|
|
611
|
+
self.__m_captureExcluded = ok # type: bool
|
|
612
|
+
if not ok:
|
|
613
|
+
self._useFallback(detail)
|
|
614
|
+
return
|
|
615
|
+
self._reposition()
|
|
616
|
+
self._startProbe()
|
|
617
|
+
|
|
618
|
+
def _startProbe(self):
|
|
619
|
+
"""
|
|
620
|
+
Paint a tiny 2 x 2 color pattern at the lens center, then check whether screen capture sees it.
|
|
621
|
+
:return:
|
|
622
|
+
"""
|
|
623
|
+
self.__m_probing = True # type: bool
|
|
624
|
+
self.__m_frame = QImage() # type: QImage
|
|
625
|
+
self._setStatus('testing')
|
|
626
|
+
self.setWindowOpacity(1.0)
|
|
627
|
+
self.repaint()
|
|
628
|
+
QTimer.singleShot(ZoomOverlay.PROBE_DELAY_MS, self._finishProbe)
|
|
629
|
+
|
|
630
|
+
def _probeRect(self):
|
|
631
|
+
"""
|
|
632
|
+
:return: (QRect) Probe pattern rect in local coordinates.
|
|
633
|
+
"""
|
|
634
|
+
cell = ZoomOverlay.PROBE_CELL # type: int
|
|
635
|
+
return QRect(self.width() // 2 - cell, self.height() // 2 - cell, cell * 2, cell * 2)
|
|
636
|
+
|
|
637
|
+
def _probeSeenByCapture(self):
|
|
638
|
+
"""
|
|
639
|
+
:return: (bool | None) True if the probe shows up in a screen grab, None if the grab failed.
|
|
640
|
+
"""
|
|
641
|
+
local = self._probeRect() # type: QRect
|
|
642
|
+
topLeft = self.mapToGlobal(local.topLeft()) # type: QPoint
|
|
643
|
+
screen = screenAtPoint(topLeft)
|
|
644
|
+
sg = screen.geometry() # type: QRect
|
|
645
|
+
pm = screen.grabWindow(0, topLeft.x() - sg.x(), topLeft.y() - sg.y(), local.width(), local.height())
|
|
646
|
+
if pm.isNull() or pm.width() < 2 or pm.height() < 2:
|
|
647
|
+
return None
|
|
648
|
+
img = pm.toImage() # type: QImage
|
|
649
|
+
hits = 0 # type: int
|
|
650
|
+
for fx, fy, ci in ((0.25, 0.25, 0), (0.75, 0.25, 1), (0.25, 0.75, 1), (0.75, 0.75, 0)):
|
|
651
|
+
col = QColor(img.pixel(int(fx * img.width()), int(fy * img.height()))) # type: QColor
|
|
652
|
+
ref = ZoomOverlay.PROBE_COLORS[ci] # type: QColor
|
|
653
|
+
if abs(col.red() - ref.red()) <= 48 and abs(col.green() - ref.green()) <= 48 and \
|
|
654
|
+
abs(col.blue() - ref.blue()) <= 48:
|
|
655
|
+
hits += 1
|
|
656
|
+
return hits >= 3
|
|
657
|
+
|
|
658
|
+
def _finishProbe(self):
|
|
659
|
+
"""
|
|
660
|
+
:return: None
|
|
661
|
+
"""
|
|
662
|
+
if not self.__m_probing:
|
|
663
|
+
return
|
|
664
|
+
self.__m_probing = False # type: bool
|
|
665
|
+
self.setWindowOpacity(self.__m_lensOpacity)
|
|
666
|
+
if not self.isVisible():
|
|
667
|
+
return
|
|
668
|
+
seen = self._probeSeenByCapture() # type: bool | None
|
|
669
|
+
if seen:
|
|
670
|
+
self._useFallback(u'Windows accepted the request to hide the lens, but the lens still appears in '
|
|
671
|
+
u'screen captures (build {})'.format(
|
|
672
|
+
getwindowsversion().build if platform == 'win32' else '-'))
|
|
673
|
+
return
|
|
674
|
+
self._setStatus('excluded', '' if seen is False else 'could not be verified')
|
|
675
|
+
self.update()
|
|
676
|
+
self.sourceChanged.emit()
|
|
677
|
+
|
|
678
|
+
def _showBadge(self):
|
|
679
|
+
"""
|
|
680
|
+
:return:
|
|
681
|
+
"""
|
|
682
|
+
self.__m_badgeClock.start()
|
|
683
|
+
self.__m_badgeOpacity = 1.0 # type: float
|
|
684
|
+
if not self.__m_badgeTimer.isActive():
|
|
685
|
+
self.__m_badgeTimer.start(16)
|
|
686
|
+
|
|
687
|
+
# ---------- Animation tick ----------
|
|
688
|
+
def _tick(self):
|
|
689
|
+
"""
|
|
690
|
+
:return:
|
|
691
|
+
"""
|
|
692
|
+
if self.__m_badgeOpacity > 0.0:
|
|
693
|
+
t = self.__m_badgeClock.elapsed() # type: int
|
|
694
|
+
self.__m_badgeOpacity = 1.0 if t < 800 else max(0.0, 1.0 - (t - 800) / 400.0) # type: float
|
|
695
|
+
if self.__m_toastOpacity > 0.0:
|
|
696
|
+
t = self.__m_toastClock.elapsed() # type: int
|
|
697
|
+
self.__m_toastOpacity = 1.0 if t < 1100 else max(0.0, 1.0 - (t - 1100) / 400.0) # type: float
|
|
698
|
+
if self.__m_badgeOpacity <= 0.0 and self.__m_toastOpacity <= 0.0:
|
|
699
|
+
self.__m_badgeTimer.stop()
|
|
700
|
+
self.update()
|
|
701
|
+
|
|
702
|
+
# ---------- Public API ----------
|
|
703
|
+
def getFrame(self):
|
|
704
|
+
"""
|
|
705
|
+
:return: (QImage) Last frame shown in the lens (its center is the target point).
|
|
706
|
+
"""
|
|
707
|
+
return self.__m_frame
|
|
708
|
+
|
|
709
|
+
def displayedColor(self, size=1):
|
|
710
|
+
"""
|
|
711
|
+
Color under the crosshair as the lens SHOWS it (upscaled / sharpened image).
|
|
712
|
+
:param size: (int) Average of size x size displayed pixels.
|
|
713
|
+
:return: (QColor) Invalid before the first frame.
|
|
714
|
+
"""
|
|
715
|
+
img = self.__m_cacheImage # type: QImage
|
|
716
|
+
if img.isNull():
|
|
717
|
+
return QColor()
|
|
718
|
+
cx, cy, half = img.width() // 2, img.height() // 2, max(0, int(size) // 2) # type: int, int, int
|
|
719
|
+
r = g = b = n = 0 # type: int
|
|
720
|
+
for y in range(max(0, cy - half), min(img.height(), cy + half + 1)):
|
|
721
|
+
for x in range(max(0, cx - half), min(img.width(), cx + half + 1)):
|
|
722
|
+
c = QColor(img.pixel(x, y)) # type: QColor
|
|
723
|
+
r, g, b, n = r + c.red(), g + c.green(), b + c.blue(), n + 1
|
|
724
|
+
return QColor(r // n, g // n, b // n)
|
|
725
|
+
|
|
726
|
+
def targetPos(self):
|
|
727
|
+
"""
|
|
728
|
+
:return: (QPoint) Global point being magnified.
|
|
729
|
+
"""
|
|
730
|
+
if self.__m_target == ZoomOverlay.Cursor:
|
|
731
|
+
return QCursor.pos()
|
|
732
|
+
if self.__m_target == ZoomOverlay.Point and not self.__m_targetPoint.isNull():
|
|
733
|
+
return QPoint(self.__m_targetPoint)
|
|
734
|
+
screen = self.__m_centerScreen or screenAtPoint(QCursor.pos())
|
|
735
|
+
return screen.geometry().center()
|
|
736
|
+
|
|
737
|
+
def sourceRect(self):
|
|
738
|
+
"""
|
|
739
|
+
:return: (QRect) Global, device-independent rect that must be captured.
|
|
740
|
+
"""
|
|
741
|
+
c = self.targetPos() # type: QPoint
|
|
742
|
+
size = self._geometryFor(self.getEffectivePlacement()).size() # type: QSize # the lens in use
|
|
743
|
+
w = max(2, int(round(size.width() / self.__m_zoom))) # type: int
|
|
744
|
+
h = max(2, int(round(size.height() / self.__m_zoom))) # type: int
|
|
745
|
+
return QRect(c.x() - w // 2, c.y() - h // 2, w, h)
|
|
746
|
+
|
|
747
|
+
def lensGeometry(self):
|
|
748
|
+
"""
|
|
749
|
+
:return: (QRect) Where the lens window goes (fallback corner included).
|
|
750
|
+
"""
|
|
751
|
+
return self._geometryFor(self.getEffectivePlacement())
|
|
752
|
+
|
|
753
|
+
def getEffectivePlacement(self):
|
|
754
|
+
"""
|
|
755
|
+
:return: (ZoomOverlay.Placement) The placement in use: the requested one, or the safe fallback corner.
|
|
756
|
+
"""
|
|
757
|
+
return self.__m_fallbackPlacement if self.__m_fallbackPlacement is not None else self.__m_placement
|
|
758
|
+
|
|
759
|
+
def getCaptureStatus(self):
|
|
760
|
+
"""
|
|
761
|
+
:return: (str | unicode | QString)unknown | notNeeded | testing | excluded | windowCapture | failed
|
|
762
|
+
"""
|
|
763
|
+
return self.__m_captureStatus
|
|
764
|
+
|
|
765
|
+
def isExternalSource(self):
|
|
766
|
+
"""
|
|
767
|
+
:return: bool
|
|
768
|
+
"""
|
|
769
|
+
return self.__m_externalSource
|
|
770
|
+
|
|
771
|
+
@pyqtSlot(bool)
|
|
772
|
+
@pyqtSlot(int)
|
|
773
|
+
def setExternalSource(self, externalSource):
|
|
774
|
+
"""
|
|
775
|
+
:param externalSource: (bool) True when frames come from a capture that never contains the lens.
|
|
776
|
+
:return:
|
|
777
|
+
"""
|
|
778
|
+
externalSource = bool(externalSource) # type: bool
|
|
779
|
+
if externalSource != self.__m_externalSource:
|
|
780
|
+
self.__m_externalSource = externalSource # type: bool
|
|
781
|
+
self._reevaluate()
|
|
782
|
+
|
|
783
|
+
def appendCaptureDetail(self, text):
|
|
784
|
+
"""
|
|
785
|
+
Add information to the current status detail (e.g. why a capture fallback failed too).
|
|
786
|
+
:param text: str | unicode | QString
|
|
787
|
+
:return:
|
|
788
|
+
"""
|
|
789
|
+
if u'{}'.format(text) and u'{}'.format(text) not in self.__m_captureDetail:
|
|
790
|
+
self.__m_captureDetail = '; '.join(t for t in (self.__m_captureDetail, u'{}'.format(text)) if t) # type: str
|
|
791
|
+
self.captureDetailChanged.emit(self.__m_captureDetail)
|
|
792
|
+
|
|
793
|
+
def getCaptureDetail(self):
|
|
794
|
+
"""
|
|
795
|
+
:return: (str | unicode | QString)Reason when the status is 'failed'.
|
|
796
|
+
"""
|
|
797
|
+
return self.__m_captureDetail
|
|
798
|
+
|
|
799
|
+
def isOverlappingSource(self):
|
|
800
|
+
"""
|
|
801
|
+
:return: (bool) True when the lens covers the area it magnifies (needs capture exclusion).
|
|
802
|
+
"""
|
|
803
|
+
return self._geometryFor(self.__m_placement).intersects(self.sourceRect())
|
|
804
|
+
|
|
805
|
+
def isCaptureExcluded(self):
|
|
806
|
+
"""
|
|
807
|
+
:return: bool
|
|
808
|
+
"""
|
|
809
|
+
return self.__m_captureExcluded
|
|
810
|
+
|
|
811
|
+
@staticmethod
|
|
812
|
+
def canExcludeFromCapture():
|
|
813
|
+
"""
|
|
814
|
+
:return: (bool) True on platforms where the lens can hide itself from capture.
|
|
815
|
+
"""
|
|
816
|
+
return platform == 'win32'
|
|
817
|
+
|
|
818
|
+
@pyqtSlot()
|
|
819
|
+
def showOverlay(self):
|
|
820
|
+
"""
|
|
821
|
+
:return:
|
|
822
|
+
"""
|
|
823
|
+
if self.isVisible():
|
|
824
|
+
return
|
|
825
|
+
self.__m_centerScreen = screenAtPoint(QCursor.pos())
|
|
826
|
+
self.__m_frame = QImage() # type: QImage
|
|
827
|
+
self.setGeometry(self.lensGeometry())
|
|
828
|
+
self._updateMask()
|
|
829
|
+
self.__m_fallbackPlacement = None
|
|
830
|
+
self.__m_fallbackScreen = None
|
|
831
|
+
self.__m_captureStatus = 'unknown' # type: str
|
|
832
|
+
self.show()
|
|
833
|
+
self._keepOnTop()
|
|
834
|
+
self.__m_topTimer.start(1000)
|
|
835
|
+
self.overlayToggled.emit(True)
|
|
836
|
+
self.sourceChanged.emit()
|
|
837
|
+
QTimer.singleShot(0, self._evaluateCapture)
|
|
838
|
+
|
|
839
|
+
@pyqtSlot()
|
|
840
|
+
def hideOverlay(self):
|
|
841
|
+
"""
|
|
842
|
+
:return:
|
|
843
|
+
"""
|
|
844
|
+
if not self.isVisible():
|
|
845
|
+
return
|
|
846
|
+
self.__m_topTimer.stop()
|
|
847
|
+
self.__m_probing = False # type: bool
|
|
848
|
+
self.setWindowOpacity(self.__m_lensOpacity)
|
|
849
|
+
self.hide()
|
|
850
|
+
self.__m_frame = QImage() # type: QImage
|
|
851
|
+
self.overlayToggled.emit(False)
|
|
852
|
+
|
|
853
|
+
@pyqtSlot()
|
|
854
|
+
def toggle(self):
|
|
855
|
+
"""
|
|
856
|
+
:return:
|
|
857
|
+
"""
|
|
858
|
+
self.hideOverlay() if self.isVisible() else self.showOverlay()
|
|
859
|
+
|
|
860
|
+
def _paintAnnotations(self, p, r, path):
|
|
861
|
+
"""
|
|
862
|
+
Annotations / overlay image mapped from frame pixels onto the lens rect, clipped to the lens shape.
|
|
863
|
+
:param p: QPainter
|
|
864
|
+
:param r: (QRectF) Lens image rect.
|
|
865
|
+
:param path: (QPainterPath) Lens shape.
|
|
866
|
+
:return: None
|
|
867
|
+
"""
|
|
868
|
+
f = self.__m_frame # type: QImage
|
|
869
|
+
if f.isNull():
|
|
870
|
+
return
|
|
871
|
+
p.save()
|
|
872
|
+
p.setClipPath(path)
|
|
873
|
+
a, o = self.__m_annotationOrigin, self.__m_frameOrigin
|
|
874
|
+
size = self.__m_annotationSize # type: QSize
|
|
875
|
+
aw = size.width() if size.width() > 0 else f.width() # type: int
|
|
876
|
+
ah = size.height() if size.height() > 0 else f.height() # type: int
|
|
877
|
+
if a and o and float(a[2]) > 0: # Screen-locked: from both frames' positions and pixels-per-point.
|
|
878
|
+
fx = fy = float(o[2]) / float(a[2]) # type: float # annotation px -> frame px
|
|
879
|
+
dx, dy = (float(a[0]) - float(o[0])) * float(o[2]), (float(a[1]) - float(o[1])) * float(o[2])
|
|
880
|
+
else:
|
|
881
|
+
fx, fy, dx, dy = f.width() / float(aw), f.height() / float(ah), 0.0, 0.0
|
|
882
|
+
kx, ky = r.width() / float(f.width()), r.height() / float(f.height()) # type: float, float # frame -> lens
|
|
883
|
+
sx, sy = fx * kx, fy * ky # type: float, float # annotation px -> lens px
|
|
884
|
+
if not self.__m_overlayImage.isNull():
|
|
885
|
+
p.setRenderHint(QPainter.SmoothPixmapTransform, False)
|
|
886
|
+
ov = self.__m_overlayImage # type: QImage
|
|
887
|
+
p.drawImage(QRectF(r.left() + dx * kx, r.top() + dy * ky, aw * sx, ah * sy), ov,
|
|
888
|
+
QRectF(0, 0, ov.width(), ov.height()))
|
|
889
|
+
for a in self.__m_annotations:
|
|
890
|
+
rect = a.get('rect')
|
|
891
|
+
if not rect or len(rect) != 4:
|
|
892
|
+
continue
|
|
893
|
+
q = QRectF(r.left() + (rect[0] * fx + dx) * kx, r.top() + (rect[1] * fy + dy) * ky, rect[2] * sx,
|
|
894
|
+
rect[3] * sy) # type: QRectF
|
|
895
|
+
color = QColor(a.get('color', '#FFD400')) # type: QColor
|
|
896
|
+
if a.get('style') == 'blur':
|
|
897
|
+
src = QRect(int(rect[0] * fx + dx), int(rect[1] * fy + dy), max(1, int(rect[2] * fx)),
|
|
898
|
+
max(1, int(rect[3] * fy))).intersected(f.rect()) # type: QRect
|
|
899
|
+
if not src.isEmpty():
|
|
900
|
+
cells = max(1, int(a.get('blocks', 8))) # type: int
|
|
901
|
+
small = f.copy(src).scaled(cells, max(1, int(cells * src.height() / float(src.width()))),
|
|
902
|
+
Qt.IgnoreAspectRatio, Qt.SmoothTransformation) # type: QImage
|
|
903
|
+
p.setRenderHint(QPainter.SmoothPixmapTransform, False)
|
|
904
|
+
p.drawImage(q, small, QRectF(0, 0, small.width(), small.height()))
|
|
905
|
+
continue
|
|
906
|
+
p.setBrush(Qt.NoBrush)
|
|
907
|
+
p.setPen(QPen(QColor(0, 0, 0, 150), 4))
|
|
908
|
+
p.drawRect(q)
|
|
909
|
+
p.setPen(QPen(color, 2))
|
|
910
|
+
p.drawRect(q)
|
|
911
|
+
for pt in a.get('points', []) or []:
|
|
912
|
+
p.setPen(QPen(QColor(0, 0, 0, 160), 1))
|
|
913
|
+
p.setBrush(color)
|
|
914
|
+
p.drawEllipse(QPointF(r.left() + (pt[0] * fx + dx) * kx, r.top() + (pt[1] * fy + dy) * ky), 3.0, 3.0)
|
|
915
|
+
p.restore()
|
|
916
|
+
|
|
917
|
+
def centerColor(self):
|
|
918
|
+
"""
|
|
919
|
+
:return: (QColor) Exact color of the screen pixel under the crosshair (center of the last frame).
|
|
920
|
+
"""
|
|
921
|
+
f = self.__m_frame # type: QImage
|
|
922
|
+
return QColor(f.pixel(f.width() // 2, f.height() // 2)) if not f.isNull() else QColor()
|
|
923
|
+
|
|
924
|
+
def _paintPixelGrid(self, p, r, path):
|
|
925
|
+
"""
|
|
926
|
+
Pixel grid and center-pixel outline (pixel-exact mode, when a screen pixel is >= 6 lens px wide).
|
|
927
|
+
:param p: QPainter
|
|
928
|
+
:param r: QRectF
|
|
929
|
+
:param path: QPainterPath
|
|
930
|
+
:return: None
|
|
931
|
+
"""
|
|
932
|
+
f = self.__m_frame # type: QImage
|
|
933
|
+
if f.isNull():
|
|
934
|
+
return
|
|
935
|
+
kx, ky = r.width() / float(f.width()), r.height() / float(f.height()) # type: float, float
|
|
936
|
+
p.save()
|
|
937
|
+
p.setClipPath(path)
|
|
938
|
+
p.setRenderHint(QPainter.Antialiasing, False)
|
|
939
|
+
if kx >= 6.0:
|
|
940
|
+
lines = [QLineF(r.left() + i * kx, r.top(), r.left() + i * kx, r.bottom()) for i in range(f.width() + 1)]
|
|
941
|
+
lines += [QLineF(r.left(), r.top() + j * ky, r.right(), r.top() + j * ky) for j in range(f.height() + 1)]
|
|
942
|
+
p.setPen(QPen(QColor(0, 0, 0, 60), 1))
|
|
943
|
+
p.drawLines(lines)
|
|
944
|
+
cell = QRectF(r.left() + (f.width() // 2) * kx, r.top() + (f.height() // 2) * ky, kx, ky) # type: QRectF
|
|
945
|
+
p.setBrush(Qt.NoBrush)
|
|
946
|
+
p.setPen(QPen(QColor(0, 0, 0, 220), 3))
|
|
947
|
+
p.drawRect(cell.adjusted(-1, -1, 1, 1))
|
|
948
|
+
p.setPen(QPen(QColor(255, 255, 255, 240), 1))
|
|
949
|
+
p.drawRect(cell.adjusted(-1, -1, 1, 1))
|
|
950
|
+
p.restore()
|
|
951
|
+
|
|
952
|
+
def readoutColor(self):
|
|
953
|
+
"""
|
|
954
|
+
THE color code of the zoomer: what the readout shows and what copying takes (same function, always equal).
|
|
955
|
+
:return: (QColor) Invalid before the first frame.
|
|
956
|
+
"""
|
|
957
|
+
if self.__m_readoutSource == 'zoomed' and not self.__m_pixelated:
|
|
958
|
+
shown = self.displayedColor(self.__m_readoutSample) # type: QColor
|
|
959
|
+
if shown.isValid():
|
|
960
|
+
return shown
|
|
961
|
+
f = self.__m_frame # type: QImage
|
|
962
|
+
if f.isNull():
|
|
963
|
+
return QColor()
|
|
964
|
+
cx, cy, half = f.width() // 2, f.height() // 2, self.__m_readoutSample // 2 # type: int, int, int
|
|
965
|
+
r = g = b = n = 0 # type: int
|
|
966
|
+
for y in range(max(0, cy - half), min(f.height(), cy + half + 1)):
|
|
967
|
+
for x in range(max(0, cx - half), min(f.width(), cx + half + 1)):
|
|
968
|
+
c = QColor(f.pixel(x, y)) # type: QColor
|
|
969
|
+
r, g, b, n = r + c.red(), g + c.green(), b + c.blue(), n + 1
|
|
970
|
+
return QColor(int(round(r / float(n))), int(round(g / float(n))), int(round(b / float(n))))
|
|
971
|
+
|
|
972
|
+
def zoneAtCrosshair(self):
|
|
973
|
+
"""
|
|
974
|
+
:return: (str | unicode | QString) Label of the color zone (annotation) under the crosshair, '' if none.
|
|
975
|
+
"""
|
|
976
|
+
f = self.__m_frame # type: QImage
|
|
977
|
+
if f.isNull() or not self.__m_annotations:
|
|
978
|
+
return ''
|
|
979
|
+
a, o = self.__m_annotationOrigin, self.__m_frameOrigin
|
|
980
|
+
size = self.__m_annotationSize # type: QSize
|
|
981
|
+
if a and o and float(a[2]) > 0:
|
|
982
|
+
fx = fy = float(o[2]) / float(a[2]) # type: float
|
|
983
|
+
dx, dy = (float(a[0]) - float(o[0])) * float(o[2]), (float(a[1]) - float(o[1])) * float(o[2])
|
|
984
|
+
else:
|
|
985
|
+
fx = f.width() / float(size.width() if size.width() > 0 else f.width()) # type: float
|
|
986
|
+
fy = f.height() / float(size.height() if size.height() > 0 else f.height()) # type: float
|
|
987
|
+
dx = dy = 0.0 # type: float
|
|
988
|
+
cx, cy = (f.width() / 2.0 - dx) / fx, (f.height() / 2.0 - dy) / fy # type: float, float # annotation px
|
|
989
|
+
for ann in self.__m_annotations:
|
|
990
|
+
x, y, w, h = ann.get('rect', [0, 0, 0, 0])
|
|
991
|
+
if ann.get('label') and x <= cx < x + w and y <= cy < y + h:
|
|
992
|
+
return u'{}'.format(ann['label'])
|
|
993
|
+
return ''
|
|
994
|
+
|
|
995
|
+
def readoutText(self):
|
|
996
|
+
"""
|
|
997
|
+
The two lines of the color code - the SAME text the application shows elsewhere and copies.
|
|
998
|
+
:return: (tuple[str | unicode | QString, str | unicode | QString])
|
|
999
|
+
Code (formatter, default #RRGGBB) and details (RGB for HEX codes, name, zone).
|
|
1000
|
+
"""
|
|
1001
|
+
color = self.readoutColor() # type: QColor
|
|
1002
|
+
if not color.isValid():
|
|
1003
|
+
return '', ''
|
|
1004
|
+
try:
|
|
1005
|
+
code = u'{}'.format(self.__m_colorFormatter(color)) if self.__m_colorFormatter else u'{}'.format(color.name()).upper()
|
|
1006
|
+
except Exception:
|
|
1007
|
+
code = u'{}'.format(color.name()).upper() # type: str
|
|
1008
|
+
details = [] # type: list
|
|
1009
|
+
if code.startswith('#') or code.startswith('0x') or len(code) == 6:
|
|
1010
|
+
details.append('{}, {}, {}'.format(color.red(), color.green(), color.blue()))
|
|
1011
|
+
if self.__m_colorNamer is not None:
|
|
1012
|
+
if color.rgb() not in self.__m_names:
|
|
1013
|
+
try:
|
|
1014
|
+
self.__m_names[color.rgb()] = u'{}'.format(self.__m_colorNamer(color))
|
|
1015
|
+
except Exception:
|
|
1016
|
+
self.__m_names[color.rgb()] = ''
|
|
1017
|
+
if len(self.__m_names) > 4096:
|
|
1018
|
+
self.__m_names.clear()
|
|
1019
|
+
if self.__m_names.get(color.rgb()):
|
|
1020
|
+
details.append(self.__m_names[color.rgb()])
|
|
1021
|
+
zone = self.zoneAtCrosshair() # type: str
|
|
1022
|
+
if zone: # First: in a round lens the end of the line may be shortened with '...'.
|
|
1023
|
+
details.insert(0, 'zone: ' + zone)
|
|
1024
|
+
return code, u' \u00b7 '.join(details)
|
|
1025
|
+
|
|
1026
|
+
def _emitReadout(self):
|
|
1027
|
+
"""
|
|
1028
|
+
readoutChanged when the color code or its zone changed (shown lens with the color code on).
|
|
1029
|
+
:return:
|
|
1030
|
+
"""
|
|
1031
|
+
color = self.readoutColor() # type: QColor
|
|
1032
|
+
key = (color.rgb() if color.isValid() else None, self.zoneAtCrosshair()) # type: tuple
|
|
1033
|
+
if key != self.__m_lastReadout:
|
|
1034
|
+
self.__m_lastReadout = key # type: tuple
|
|
1035
|
+
self.readoutChanged.emit(color, key[1])
|
|
1036
|
+
|
|
1037
|
+
def _paintReadout(self, p, r):
|
|
1038
|
+
"""
|
|
1039
|
+
Live color of the crosshair pixel: swatch + HEX + RGB, updated with every frame.
|
|
1040
|
+
:param p: QPainter
|
|
1041
|
+
:param r: QRectF
|
|
1042
|
+
:return: None
|
|
1043
|
+
"""
|
|
1044
|
+
color = self.readoutColor() # type: QColor
|
|
1045
|
+
if not color.isValid():
|
|
1046
|
+
return
|
|
1047
|
+
p.save()
|
|
1048
|
+
p.setRenderHint(QPainter.Antialiasing, True)
|
|
1049
|
+
font = QFont(self.font()) # type: QFont
|
|
1050
|
+
font.setPointSizeF(10.5)
|
|
1051
|
+
font.setBold(True)
|
|
1052
|
+
small = QFont(font) # type: QFont
|
|
1053
|
+
small.setBold(False)
|
|
1054
|
+
small.setPointSizeF(8.5)
|
|
1055
|
+
hexText, rgbText = self.readoutText() # type: str, str
|
|
1056
|
+
w = max(QFontMetrics(font).boundingRect(hexText).width(),
|
|
1057
|
+
QFontMetrics(small).boundingRect(rgbText).width()) + 52
|
|
1058
|
+
w = min(w, r.width() - 16) # type: float
|
|
1059
|
+
h = 40.0 # type: float
|
|
1060
|
+
if self.__m_shape == ZoomOverlay.Circle and not self._isRectangular():
|
|
1061
|
+
inset = r.height() * 0.16 # type: float
|
|
1062
|
+
radius = r.width() / 2.0 # type: float # Fit the circle's width at the box's lower edge.
|
|
1063
|
+
dy = (r.bottom() - inset) - r.center().y() # type: float
|
|
1064
|
+
w = min(w, 2.0 * (max(0.0, radius * radius - dy * dy) ** 0.5) - 10.0) # type: float
|
|
1065
|
+
else: # rounded corners: lift the box with the radius and keep it clear of the corner arcs
|
|
1066
|
+
radius = self._radiusFor(r) # type: float
|
|
1067
|
+
inset = max(r.height() * 0.05, radius * 0.29) # type: float
|
|
1068
|
+
if inset < radius:
|
|
1069
|
+
cut = radius - (max(0.0, radius * radius - (radius - inset) ** 2) ** 0.5) # type: float
|
|
1070
|
+
w = min(w, r.width() - 2.0 * cut - 10.0) # type: float
|
|
1071
|
+
box = QRectF(r.center().x() - w / 2.0, r.bottom() - inset - h, w, h) # type: QRectF
|
|
1072
|
+
hexText = QFontMetrics(font).elidedText(hexText, Qt.ElideRight, int(w - 46)) # type: str
|
|
1073
|
+
rgbText = QFontMetrics(small).elidedText(rgbText, Qt.ElideRight, int(w - 46)) # type: str
|
|
1074
|
+
bg = QPainterPath() # type: QPainterPath
|
|
1075
|
+
bg.addRoundedRect(box, 10, 10)
|
|
1076
|
+
p.fillPath(bg, QColor(14, 15, 20, 225))
|
|
1077
|
+
p.setPen(QPen(QColor(255, 255, 255, 210), 1.5))
|
|
1078
|
+
p.setBrush(color)
|
|
1079
|
+
p.drawRoundedRect(QRectF(box.left() + 8, box.top() + 8, 24, 24), 6, 6)
|
|
1080
|
+
p.setPen(QColor(240, 242, 248))
|
|
1081
|
+
p.setFont(font)
|
|
1082
|
+
p.drawText(QRectF(box.left() + 40, box.top() + 3, w - 44, 20), Qt.AlignLeft | Qt.AlignVCenter, hexText)
|
|
1083
|
+
p.setFont(small)
|
|
1084
|
+
p.setPen(QColor(170, 178, 196))
|
|
1085
|
+
p.drawText(QRectF(box.left() + 40, box.top() + 20, w - 44, 16), Qt.AlignLeft | Qt.AlignVCenter, rgbText)
|
|
1086
|
+
p.restore()
|
|
1087
|
+
|
|
1088
|
+
def isShowColorReadout(self):
|
|
1089
|
+
"""
|
|
1090
|
+
:return: bool
|
|
1091
|
+
"""
|
|
1092
|
+
return self.__m_showColorReadout
|
|
1093
|
+
|
|
1094
|
+
@pyqtSlot(bool)
|
|
1095
|
+
@pyqtSlot(int)
|
|
1096
|
+
def setShowColorReadout(self, showColorReadout):
|
|
1097
|
+
"""
|
|
1098
|
+
:param showColorReadout: (bool) Live color code of the crosshair pixel inside the lens.
|
|
1099
|
+
:return:
|
|
1100
|
+
"""
|
|
1101
|
+
self.__m_showColorReadout = bool(showColorReadout) # type: bool
|
|
1102
|
+
self.update()
|
|
1103
|
+
|
|
1104
|
+
def getColorFormatter(self):
|
|
1105
|
+
"""
|
|
1106
|
+
:return: callable | None
|
|
1107
|
+
"""
|
|
1108
|
+
return self.__m_colorFormatter
|
|
1109
|
+
|
|
1110
|
+
@pyqtSlot(object)
|
|
1111
|
+
def setColorFormatter(self, colorFormatter):
|
|
1112
|
+
"""
|
|
1113
|
+
:param colorFormatter: (callable | None) QColor -> str.
|
|
1114
|
+
:return:
|
|
1115
|
+
"""
|
|
1116
|
+
self.__m_colorFormatter = colorFormatter if callable(colorFormatter) else None
|
|
1117
|
+
self.update()
|
|
1118
|
+
|
|
1119
|
+
def getColorNamer(self):
|
|
1120
|
+
"""
|
|
1121
|
+
:return: callable | None
|
|
1122
|
+
"""
|
|
1123
|
+
return self.__m_colorNamer
|
|
1124
|
+
|
|
1125
|
+
@pyqtSlot(object)
|
|
1126
|
+
def setColorNamer(self, colorNamer):
|
|
1127
|
+
"""
|
|
1128
|
+
:param colorNamer: (callable | None) QColor -> str.
|
|
1129
|
+
:return:
|
|
1130
|
+
"""
|
|
1131
|
+
self.__m_colorNamer = colorNamer if callable(colorNamer) else None
|
|
1132
|
+
self.__m_names = {} # type: dict
|
|
1133
|
+
self.update()
|
|
1134
|
+
|
|
1135
|
+
def getReadoutSource(self):
|
|
1136
|
+
"""
|
|
1137
|
+
:return: (str | unicode | QString) 'original' or 'zoomed'.
|
|
1138
|
+
"""
|
|
1139
|
+
return self.__m_readoutSource
|
|
1140
|
+
|
|
1141
|
+
@pyqtSlot('QString')
|
|
1142
|
+
@pyqtSlot(str)
|
|
1143
|
+
def setReadoutSource(self, readoutSource):
|
|
1144
|
+
"""
|
|
1145
|
+
:param readoutSource: (str | unicode | QString) 'original' (screen pixel) or 'zoomed' (displayed image).
|
|
1146
|
+
:return:
|
|
1147
|
+
"""
|
|
1148
|
+
self.__m_readoutSource = 'zoomed' if u'{}'.format(readoutSource) == 'zoomed' else 'original' # type: str
|
|
1149
|
+
self.update()
|
|
1150
|
+
|
|
1151
|
+
def getReadoutSample(self):
|
|
1152
|
+
"""
|
|
1153
|
+
:return: int
|
|
1154
|
+
"""
|
|
1155
|
+
return self.__m_readoutSample
|
|
1156
|
+
|
|
1157
|
+
@pyqtSlot(int)
|
|
1158
|
+
def setReadoutSample(self, readoutSample):
|
|
1159
|
+
"""
|
|
1160
|
+
:param readoutSample: (int) N x N average.
|
|
1161
|
+
:return:
|
|
1162
|
+
"""
|
|
1163
|
+
self.__m_readoutSample = max(1, int(readoutSample)) # type: int
|
|
1164
|
+
self.update()
|
|
1165
|
+
|
|
1166
|
+
def isPixelated(self):
|
|
1167
|
+
"""
|
|
1168
|
+
:return: bool
|
|
1169
|
+
"""
|
|
1170
|
+
return self.__m_pixelated
|
|
1171
|
+
|
|
1172
|
+
@pyqtSlot(bool)
|
|
1173
|
+
@pyqtSlot(int)
|
|
1174
|
+
def setPixelated(self, pixelated):
|
|
1175
|
+
"""
|
|
1176
|
+
:param pixelated: (bool) Exact pixels (no upscaler) + pixel grid: what a color picker needs.
|
|
1177
|
+
:return:
|
|
1178
|
+
"""
|
|
1179
|
+
self.__m_pixelated = bool(pixelated) # type: bool
|
|
1180
|
+
self.__m_cacheKey = None
|
|
1181
|
+
self.update()
|
|
1182
|
+
|
|
1183
|
+
# ---------- Annotations API ----------
|
|
1184
|
+
def getAnnotations(self):
|
|
1185
|
+
"""
|
|
1186
|
+
:return: list[dict]
|
|
1187
|
+
"""
|
|
1188
|
+
return list(self.__m_annotations)
|
|
1189
|
+
|
|
1190
|
+
def setAnnotations(self, annotations, sourceSize=None, origin=None):
|
|
1191
|
+
"""
|
|
1192
|
+
:param annotations: (list[dict]) {'rect': [x, y, w, h], 'color': '#RRGGBB', 'style': 'box' | 'blur',
|
|
1193
|
+
'points': [[x, y], ...]} in source-frame pixels.
|
|
1194
|
+
:param sourceSize: (QSize | None) Size of the frame the coordinates refer to; None = current frame.
|
|
1195
|
+
:param origin: (list | None) [x, y, dpr] screen position of that frame (see setFrameOrigin()).
|
|
1196
|
+
:return:
|
|
1197
|
+
"""
|
|
1198
|
+
self.__m_annotations = list(annotations or []) # type: list
|
|
1199
|
+
self.__m_annotationOrigin = list(origin) if origin else None
|
|
1200
|
+
self.__m_annotationSize = QSize(sourceSize) if sourceSize is not None else QSize(self.__m_frame.size())
|
|
1201
|
+
self.update()
|
|
1202
|
+
|
|
1203
|
+
@pyqtSlot(QPoint, float)
|
|
1204
|
+
def setFrameOrigin(self, origin, dpr=1.0):
|
|
1205
|
+
"""
|
|
1206
|
+
Screen position of the frames passed to setFrame() (top-left, device independent) and their pixel ratio.
|
|
1207
|
+
:param origin: QPoint
|
|
1208
|
+
:param dpr: (float | int) Frame pixels per screen point.
|
|
1209
|
+
:return:
|
|
1210
|
+
"""
|
|
1211
|
+
self.__m_frameOrigin = [origin.x(), origin.y(), float(dpr)] if origin is not None else None
|
|
1212
|
+
|
|
1213
|
+
@pyqtSlot()
|
|
1214
|
+
def clearAnnotations(self):
|
|
1215
|
+
"""
|
|
1216
|
+
:return:
|
|
1217
|
+
"""
|
|
1218
|
+
self.__m_annotations = [] # type: list
|
|
1219
|
+
self.__m_overlayImage = QImage() # type: QImage
|
|
1220
|
+
self.update()
|
|
1221
|
+
|
|
1222
|
+
def getOverlayImage(self):
|
|
1223
|
+
"""
|
|
1224
|
+
:return: QImage
|
|
1225
|
+
"""
|
|
1226
|
+
return self.__m_overlayImage
|
|
1227
|
+
|
|
1228
|
+
@pyqtSlot(QImage)
|
|
1229
|
+
def setOverlayImage(self, overlayImage):
|
|
1230
|
+
"""
|
|
1231
|
+
:param overlayImage: (QImage) ARGB image aligned with the whole frame, null = none.
|
|
1232
|
+
:return:
|
|
1233
|
+
"""
|
|
1234
|
+
self.__m_overlayImage = QImage() if overlayImage is None else overlayImage # type: QImage
|
|
1235
|
+
self.update()
|
|
1236
|
+
|
|
1237
|
+
@pyqtSlot(QImage)
|
|
1238
|
+
def setFrame(self, frame):
|
|
1239
|
+
"""
|
|
1240
|
+
:param frame: QImage
|
|
1241
|
+
:return:
|
|
1242
|
+
"""
|
|
1243
|
+
if not self.isVisible() or self.__m_probing or self.__m_captureStatus in ('unknown', 'testing'):
|
|
1244
|
+
return # Never show a frame that may contain the lens itself.
|
|
1245
|
+
if self.__m_target == ZoomOverlay.Cursor or self.getEffectivePlacement() != ZoomOverlay.OnTarget:
|
|
1246
|
+
self._reposition() # The cursor moves, or the corner may be on another screen.
|
|
1247
|
+
self.__m_frame = frame # type: QImage
|
|
1248
|
+
self.__m_serial += 1
|
|
1249
|
+
self.update()
|
|
1250
|
+
|
|
1251
|
+
@pyqtSlot()
|
|
1252
|
+
def zoomIn(self):
|
|
1253
|
+
"""
|
|
1254
|
+
:return:
|
|
1255
|
+
"""
|
|
1256
|
+
self.setZoom(self.__m_zoom * 1.25)
|
|
1257
|
+
|
|
1258
|
+
@pyqtSlot()
|
|
1259
|
+
def zoomOut(self):
|
|
1260
|
+
"""
|
|
1261
|
+
:return:
|
|
1262
|
+
"""
|
|
1263
|
+
self.setZoom(self.__m_zoom / 1.25)
|
|
1264
|
+
|
|
1265
|
+
def getZoom(self):
|
|
1266
|
+
"""
|
|
1267
|
+
:return: float | int
|
|
1268
|
+
"""
|
|
1269
|
+
return self.__m_zoom
|
|
1270
|
+
|
|
1271
|
+
@pyqtSlot(float)
|
|
1272
|
+
@pyqtSlot(int)
|
|
1273
|
+
def setZoom(self, zoom):
|
|
1274
|
+
"""
|
|
1275
|
+
:param zoom: (float | int) 1 .. 16
|
|
1276
|
+
:return:
|
|
1277
|
+
"""
|
|
1278
|
+
zoom = clamp(float(zoom), 1.0, 16.0) # type: float
|
|
1279
|
+
if abs(zoom - self.__m_zoom) > 1e-6:
|
|
1280
|
+
self.__m_zoom = zoom # type: float
|
|
1281
|
+
if self.isVisible():
|
|
1282
|
+
self._showBadge()
|
|
1283
|
+
self._changed()
|
|
1284
|
+
self.zoomChanged.emit(zoom)
|
|
1285
|
+
|
|
1286
|
+
def getLensSize(self):
|
|
1287
|
+
"""
|
|
1288
|
+
:return: QSize
|
|
1289
|
+
"""
|
|
1290
|
+
return QSize(self.__m_lensSize)
|
|
1291
|
+
|
|
1292
|
+
@pyqtSlot(QSize)
|
|
1293
|
+
def setLensSize(self, lensSize):
|
|
1294
|
+
"""
|
|
1295
|
+
:param lensSize: QSize
|
|
1296
|
+
:return:
|
|
1297
|
+
"""
|
|
1298
|
+
self.__m_lensSize = QSize(max(64, lensSize.width()), max(64, lensSize.height())) # type: QSize
|
|
1299
|
+
self._changed()
|
|
1300
|
+
|
|
1301
|
+
def getTarget(self):
|
|
1302
|
+
"""
|
|
1303
|
+
:return: ZoomOverlay.Target
|
|
1304
|
+
"""
|
|
1305
|
+
return self.__m_target
|
|
1306
|
+
|
|
1307
|
+
@pyqtSlot(Target)
|
|
1308
|
+
@pyqtSlot(int)
|
|
1309
|
+
def setTarget(self, target):
|
|
1310
|
+
"""
|
|
1311
|
+
:param target: ZoomOverlay.Target | int
|
|
1312
|
+
:return:
|
|
1313
|
+
"""
|
|
1314
|
+
self.__m_target = ZoomOverlay.Target(int(target)) # type: ZoomOverlay.Target
|
|
1315
|
+
self._changed()
|
|
1316
|
+
self._reevaluate()
|
|
1317
|
+
|
|
1318
|
+
def getTargetPoint(self):
|
|
1319
|
+
"""
|
|
1320
|
+
:return: QPoint
|
|
1321
|
+
"""
|
|
1322
|
+
return QPoint(self.__m_targetPoint)
|
|
1323
|
+
|
|
1324
|
+
@pyqtSlot(QPoint)
|
|
1325
|
+
def setTargetPoint(self, targetPoint):
|
|
1326
|
+
"""
|
|
1327
|
+
:param targetPoint: QPoint
|
|
1328
|
+
:return:
|
|
1329
|
+
"""
|
|
1330
|
+
self.__m_targetPoint = QPoint(targetPoint) # type: QPoint
|
|
1331
|
+
self._changed()
|
|
1332
|
+
|
|
1333
|
+
def getPlacement(self):
|
|
1334
|
+
"""
|
|
1335
|
+
:return: ZoomOverlay.Placement
|
|
1336
|
+
"""
|
|
1337
|
+
return self.__m_placement
|
|
1338
|
+
|
|
1339
|
+
@pyqtSlot(Placement)
|
|
1340
|
+
@pyqtSlot(int)
|
|
1341
|
+
def setPlacement(self, placement):
|
|
1342
|
+
"""
|
|
1343
|
+
:param placement: ZoomOverlay.Placement | int
|
|
1344
|
+
:return:
|
|
1345
|
+
"""
|
|
1346
|
+
self.__m_placement = ZoomOverlay.Placement(int(placement)) # type: ZoomOverlay.Placement
|
|
1347
|
+
self._changed()
|
|
1348
|
+
self._reevaluate()
|
|
1349
|
+
|
|
1350
|
+
def getCustomRect(self):
|
|
1351
|
+
"""
|
|
1352
|
+
:return: (QRect) Lens rect of the Custom placement (global, device-independent px).
|
|
1353
|
+
"""
|
|
1354
|
+
return QRect(self.__m_customRect)
|
|
1355
|
+
|
|
1356
|
+
@pyqtSlot(QRect)
|
|
1357
|
+
def setCustomRect(self, customRect):
|
|
1358
|
+
"""
|
|
1359
|
+
:param customRect: QRect
|
|
1360
|
+
:return:
|
|
1361
|
+
"""
|
|
1362
|
+
self.__m_customRect = QRect(customRect).normalized() # type: QRect
|
|
1363
|
+
if self.__m_placement == ZoomOverlay.Custom:
|
|
1364
|
+
self._changed()
|
|
1365
|
+
self._reevaluate()
|
|
1366
|
+
|
|
1367
|
+
def getFullScreenIndex(self):
|
|
1368
|
+
"""
|
|
1369
|
+
:return: (int) Screen of the FullScreen placement, -1 = the screen of the target.
|
|
1370
|
+
"""
|
|
1371
|
+
return self.__m_fullScreenIndex
|
|
1372
|
+
|
|
1373
|
+
@pyqtSlot(int)
|
|
1374
|
+
def setFullScreenIndex(self, fullScreenIndex):
|
|
1375
|
+
"""
|
|
1376
|
+
:param fullScreenIndex: int
|
|
1377
|
+
:return:
|
|
1378
|
+
"""
|
|
1379
|
+
self.__m_fullScreenIndex = int(fullScreenIndex) # type: int
|
|
1380
|
+
if self.__m_placement == ZoomOverlay.FullScreen:
|
|
1381
|
+
self._changed()
|
|
1382
|
+
self._reevaluate()
|
|
1383
|
+
|
|
1384
|
+
def getFallbackScreen(self):
|
|
1385
|
+
"""
|
|
1386
|
+
:return: (int | None) The safe screen a full-screen lens moved to, None if it did not.
|
|
1387
|
+
"""
|
|
1388
|
+
return self.__m_fallbackScreen
|
|
1389
|
+
|
|
1390
|
+
def getCornerRadius(self):
|
|
1391
|
+
"""
|
|
1392
|
+
:return: (int) Corner radius of the RoundedRect shape in px.
|
|
1393
|
+
"""
|
|
1394
|
+
return self.__m_cornerRadius
|
|
1395
|
+
|
|
1396
|
+
@pyqtSlot(int)
|
|
1397
|
+
def setCornerRadius(self, cornerRadius):
|
|
1398
|
+
"""
|
|
1399
|
+
:param cornerRadius: (int) px, 0 = square corners (drawn at most half the short side).
|
|
1400
|
+
:return:
|
|
1401
|
+
"""
|
|
1402
|
+
self.__m_cornerRadius = max(0, int(cornerRadius)) # type: int
|
|
1403
|
+
self._updateMask()
|
|
1404
|
+
self.update()
|
|
1405
|
+
|
|
1406
|
+
def getShape(self):
|
|
1407
|
+
"""
|
|
1408
|
+
:return: ZoomOverlay.Shape
|
|
1409
|
+
"""
|
|
1410
|
+
return self.__m_shape
|
|
1411
|
+
|
|
1412
|
+
@pyqtSlot(Shape)
|
|
1413
|
+
@pyqtSlot(int)
|
|
1414
|
+
def setShape(self, shape):
|
|
1415
|
+
"""
|
|
1416
|
+
:param shape: ZoomOverlay.Shape | int
|
|
1417
|
+
:return:
|
|
1418
|
+
"""
|
|
1419
|
+
self.__m_shape = ZoomOverlay.Shape(int(shape)) # type: ZoomOverlay.Shape
|
|
1420
|
+
self._updateMask()
|
|
1421
|
+
self.update()
|
|
1422
|
+
|
|
1423
|
+
def getProcessor(self):
|
|
1424
|
+
"""
|
|
1425
|
+
:return: callable | None
|
|
1426
|
+
"""
|
|
1427
|
+
return self.__m_processor
|
|
1428
|
+
|
|
1429
|
+
@pyqtSlot(object)
|
|
1430
|
+
def setProcessor(self, processor):
|
|
1431
|
+
"""
|
|
1432
|
+
:param processor: callable | None
|
|
1433
|
+
:return:
|
|
1434
|
+
"""
|
|
1435
|
+
self.__m_processor = processor if callable(processor) else None # type: callable | None
|
|
1436
|
+
self.refresh()
|
|
1437
|
+
|
|
1438
|
+
@pyqtSlot()
|
|
1439
|
+
def refresh(self):
|
|
1440
|
+
"""
|
|
1441
|
+
Re-run the processor (call after changing its settings).
|
|
1442
|
+
:return:
|
|
1443
|
+
"""
|
|
1444
|
+
self.__m_cacheKey = None
|
|
1445
|
+
self.update()
|
|
1446
|
+
|
|
1447
|
+
def getBorderColor(self):
|
|
1448
|
+
"""
|
|
1449
|
+
:return: QColor
|
|
1450
|
+
"""
|
|
1451
|
+
return self.__m_borderColor
|
|
1452
|
+
|
|
1453
|
+
@pyqtSlot(QColor)
|
|
1454
|
+
@pyqtSlot(Qt.GlobalColor)
|
|
1455
|
+
@pyqtSlot(int)
|
|
1456
|
+
@pyqtSlot(str)
|
|
1457
|
+
@pyqtSlot('QString')
|
|
1458
|
+
def setBorderColor(self, borderColor):
|
|
1459
|
+
"""
|
|
1460
|
+
:param borderColor: QColor | Qt.GlobalColor | int | str | QString
|
|
1461
|
+
:return:
|
|
1462
|
+
"""
|
|
1463
|
+
self.__m_borderColor = borderColor if isinstance(borderColor, QColor) else QColor(borderColor) # type: QColor
|
|
1464
|
+
self.update()
|
|
1465
|
+
|
|
1466
|
+
def getBorderWidth(self):
|
|
1467
|
+
"""
|
|
1468
|
+
:return: float | int
|
|
1469
|
+
"""
|
|
1470
|
+
return self.__m_borderWidth
|
|
1471
|
+
|
|
1472
|
+
@pyqtSlot(float)
|
|
1473
|
+
@pyqtSlot(int)
|
|
1474
|
+
def setBorderWidth(self, borderWidth):
|
|
1475
|
+
"""
|
|
1476
|
+
:param borderWidth: float | int
|
|
1477
|
+
:return:
|
|
1478
|
+
"""
|
|
1479
|
+
self.__m_borderWidth = max(0.0, float(borderWidth)) # type: float
|
|
1480
|
+
self.update()
|
|
1481
|
+
|
|
1482
|
+
def isShowCrosshair(self):
|
|
1483
|
+
"""
|
|
1484
|
+
:return: bool
|
|
1485
|
+
"""
|
|
1486
|
+
return self.__m_showCrosshair
|
|
1487
|
+
|
|
1488
|
+
@pyqtSlot(bool)
|
|
1489
|
+
@pyqtSlot(int)
|
|
1490
|
+
def setShowCrosshair(self, showCrosshair):
|
|
1491
|
+
"""
|
|
1492
|
+
:param showCrosshair: bool
|
|
1493
|
+
:return:
|
|
1494
|
+
"""
|
|
1495
|
+
self.__m_showCrosshair = bool(showCrosshair) # type: bool
|
|
1496
|
+
self.update()
|
|
1497
|
+
|
|
1498
|
+
def getCrosshairColor(self):
|
|
1499
|
+
"""
|
|
1500
|
+
:return: QColor
|
|
1501
|
+
"""
|
|
1502
|
+
return self.__m_crosshairColor
|
|
1503
|
+
|
|
1504
|
+
@pyqtSlot(QColor)
|
|
1505
|
+
@pyqtSlot(Qt.GlobalColor)
|
|
1506
|
+
@pyqtSlot(int)
|
|
1507
|
+
@pyqtSlot(str)
|
|
1508
|
+
@pyqtSlot('QString')
|
|
1509
|
+
def setCrosshairColor(self, crosshairColor):
|
|
1510
|
+
"""
|
|
1511
|
+
:param crosshairColor: QColor | Qt.GlobalColor | int | str | QString
|
|
1512
|
+
:return:
|
|
1513
|
+
"""
|
|
1514
|
+
self.__m_crosshairColor = crosshairColor if isinstance(crosshairColor, QColor) else QColor(
|
|
1515
|
+
crosshairColor) # type: QColor
|
|
1516
|
+
self.update()
|
|
1517
|
+
|
|
1518
|
+
def getLensOpacity(self):
|
|
1519
|
+
"""
|
|
1520
|
+
:return: float | int
|
|
1521
|
+
"""
|
|
1522
|
+
return self.__m_lensOpacity
|
|
1523
|
+
|
|
1524
|
+
@pyqtSlot(float)
|
|
1525
|
+
@pyqtSlot(int)
|
|
1526
|
+
def setLensOpacity(self, lensOpacity):
|
|
1527
|
+
"""
|
|
1528
|
+
:param lensOpacity: (float | int) 0.2 .. 1.0
|
|
1529
|
+
:return:
|
|
1530
|
+
"""
|
|
1531
|
+
self.__m_lensOpacity = clamp(float(lensOpacity), 0.2, 1.0) # type: float
|
|
1532
|
+
self.setWindowOpacity(self.__m_lensOpacity)
|
|
1533
|
+
|
|
1534
|
+
def getMargin(self):
|
|
1535
|
+
"""
|
|
1536
|
+
:return: int
|
|
1537
|
+
"""
|
|
1538
|
+
return self.__m_margin
|
|
1539
|
+
|
|
1540
|
+
@pyqtSlot(int)
|
|
1541
|
+
def setMargin(self, margin):
|
|
1542
|
+
"""
|
|
1543
|
+
:param margin: int
|
|
1544
|
+
:return:
|
|
1545
|
+
"""
|
|
1546
|
+
self.__m_margin = max(0, int(margin)) # type: int
|
|
1547
|
+
self._changed()
|
|
1548
|
+
|
|
1549
|
+
def isExcludeFromCapture(self):
|
|
1550
|
+
"""
|
|
1551
|
+
:return: bool
|
|
1552
|
+
"""
|
|
1553
|
+
return self.__m_excludeFromCapture
|
|
1554
|
+
|
|
1555
|
+
@pyqtSlot(bool)
|
|
1556
|
+
@pyqtSlot(int)
|
|
1557
|
+
def setExcludeFromCapture(self, excludeFromCapture):
|
|
1558
|
+
"""
|
|
1559
|
+
:param excludeFromCapture: bool
|
|
1560
|
+
:return:
|
|
1561
|
+
"""
|
|
1562
|
+
self.__m_excludeFromCapture = bool(excludeFromCapture) # type: bool
|
|
1563
|
+
if self.isVisible() and not self.__m_excludeFromCapture:
|
|
1564
|
+
winSetCaptureExcluded(self, exclude=False)
|
|
1565
|
+
self._reevaluate()
|
|
1566
|
+
|
|
1567
|
+
# ---------- Qt overrides ----------
|
|
1568
|
+
def sizeHint(self):
|
|
1569
|
+
"""
|
|
1570
|
+
:return: QSize
|
|
1571
|
+
"""
|
|
1572
|
+
return QSize(self.__m_lensSize)
|
|
1573
|
+
|
|
1574
|
+
def showEvent(self, e):
|
|
1575
|
+
"""
|
|
1576
|
+
:param e: QShowEvent
|
|
1577
|
+
:return:
|
|
1578
|
+
"""
|
|
1579
|
+
super(ZoomOverlay, self).showEvent(e)
|
|
1580
|
+
winMakeOverlay(self)
|
|
1581
|
+
|
|
1582
|
+
def resizeEvent(self, e):
|
|
1583
|
+
"""
|
|
1584
|
+
:param e: QResizeEvent
|
|
1585
|
+
:return:
|
|
1586
|
+
"""
|
|
1587
|
+
super(ZoomOverlay, self).resizeEvent(e)
|
|
1588
|
+
self._updateMask()
|
|
1589
|
+
|
|
1590
|
+
# ---------- Painting ----------
|
|
1591
|
+
def paintEvent(self, event):
|
|
1592
|
+
"""
|
|
1593
|
+
:param event: QPaintEvent
|
|
1594
|
+
:return:
|
|
1595
|
+
"""
|
|
1596
|
+
p = QPainter(self) # type: QPainter
|
|
1597
|
+
p.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform, True)
|
|
1598
|
+
bw = self.__m_borderWidth # type: float
|
|
1599
|
+
r = QRectF(self.rect()).adjusted(bw / 2.0, bw / 2.0, -bw / 2.0, -bw / 2.0) # type: QRectF
|
|
1600
|
+
path = self._lensPath(r) # type: QPainterPath
|
|
1601
|
+
p.fillRect(self.rect(), QColor(14, 15, 20))
|
|
1602
|
+
if self.__m_probing:
|
|
1603
|
+
pr = self._probeRect() # type: QRect
|
|
1604
|
+
cell = ZoomOverlay.PROBE_CELL # type: int
|
|
1605
|
+
a, b = ZoomOverlay.PROBE_COLORS
|
|
1606
|
+
p.setRenderHint(QPainter.Antialiasing, False)
|
|
1607
|
+
p.fillRect(QRect(pr.x(), pr.y(), cell, cell), a)
|
|
1608
|
+
p.fillRect(QRect(pr.x() + cell, pr.y(), cell, cell), b)
|
|
1609
|
+
p.fillRect(QRect(pr.x(), pr.y() + cell, cell, cell), b)
|
|
1610
|
+
p.fillRect(QRect(pr.x() + cell, pr.y() + cell, cell, cell), a)
|
|
1611
|
+
p.end()
|
|
1612
|
+
return
|
|
1613
|
+
f = self.__m_frame # type: QImage
|
|
1614
|
+
if not f.isNull():
|
|
1615
|
+
dpr = float(self.devicePixelRatioF()) if hasattr(self, 'devicePixelRatioF') else 1.0 # type: float
|
|
1616
|
+
px = QSize(max(1, int(round(r.width() * dpr))), max(1, int(round(r.height() * dpr)))) # type: QSize
|
|
1617
|
+
key = (self.__m_serial, px.width(), px.height(), self.__m_pixelated) # type: tuple
|
|
1618
|
+
if key != self.__m_cacheKey:
|
|
1619
|
+
img = QImage() # type: QImage
|
|
1620
|
+
if self.__m_pixelated: # Exact pixels for color picking.
|
|
1621
|
+
img = f.scaled(px, Qt.IgnoreAspectRatio, Qt.FastTransformation) # type: QImage
|
|
1622
|
+
elif self.__m_processor is not None:
|
|
1623
|
+
try:
|
|
1624
|
+
img = self.__m_processor(f, px) # type: QImage
|
|
1625
|
+
except Exception:
|
|
1626
|
+
img = QImage() # type: QImage
|
|
1627
|
+
if img is None or img.isNull():
|
|
1628
|
+
img = f.scaled(px, Qt.IgnoreAspectRatio, Qt.SmoothTransformation) # type: QImage
|
|
1629
|
+
self.__m_cacheKey = key # type: tuple
|
|
1630
|
+
self.__m_cacheImage = img # type: QImage
|
|
1631
|
+
p.save()
|
|
1632
|
+
p.setClipPath(path)
|
|
1633
|
+
p.drawImage(r, self.__m_cacheImage, QRectF(0, 0, self.__m_cacheImage.width(), self.__m_cacheImage.height()))
|
|
1634
|
+
p.restore()
|
|
1635
|
+
if self.__m_annotations or not self.__m_overlayImage.isNull():
|
|
1636
|
+
self._paintAnnotations(p, r, path)
|
|
1637
|
+
if self.__m_pixelated:
|
|
1638
|
+
self._paintPixelGrid(p, r, path)
|
|
1639
|
+
elif self.__m_showCrosshair:
|
|
1640
|
+
self._paintCrosshair(p, r)
|
|
1641
|
+
if self.__m_showColorReadout:
|
|
1642
|
+
self._paintReadout(p, r)
|
|
1643
|
+
self._emitReadout()
|
|
1644
|
+
if bw > 0:
|
|
1645
|
+
p.setPen(QPen(QColor(0, 0, 0, 140), bw + 2))
|
|
1646
|
+
p.setBrush(Qt.NoBrush)
|
|
1647
|
+
p.drawPath(path)
|
|
1648
|
+
p.setPen(QPen(self.__m_borderColor, bw))
|
|
1649
|
+
p.drawPath(path)
|
|
1650
|
+
if self.__m_badgeOpacity > 0.0:
|
|
1651
|
+
self._paintBadge(p, r.adjusted(0, 0, 0, -48) if self.__m_showColorReadout else r)
|
|
1652
|
+
if self.__m_toastOpacity > 0.0:
|
|
1653
|
+
self._paintToast(p, r.adjusted(0, r.height() * 0.08, 0, 0))
|
|
1654
|
+
p.end()
|
|
1655
|
+
|
|
1656
|
+
def _paintCrosshair(self, p, r):
|
|
1657
|
+
"""
|
|
1658
|
+
:param p: QPainter
|
|
1659
|
+
:param r: QRectF
|
|
1660
|
+
:return:
|
|
1661
|
+
"""
|
|
1662
|
+
c = r.center() # type: QPointF
|
|
1663
|
+
arm = min(r.width(), r.height()) * 0.09 # type: float
|
|
1664
|
+
gap = max(4.0, arm * 0.35) # type: float
|
|
1665
|
+
lines = [QLineF(c.x() - gap - arm, c.y(), c.x() - gap, c.y()),
|
|
1666
|
+
QLineF(c.x() + gap, c.y(), c.x() + gap + arm, c.y()),
|
|
1667
|
+
QLineF(c.x(), c.y() - gap - arm, c.x(), c.y() - gap),
|
|
1668
|
+
QLineF(c.x(), c.y() + gap, c.x(), c.y() + gap + arm)]
|
|
1669
|
+
p.setPen(QPen(QColor(0, 0, 0, 150), 3.5))
|
|
1670
|
+
p.drawLines(lines)
|
|
1671
|
+
p.setPen(QPen(self.__m_crosshairColor, 1.5))
|
|
1672
|
+
p.drawLines(lines)
|
|
1673
|
+
p.setPen(Qt.NoPen)
|
|
1674
|
+
p.setBrush(self.__m_crosshairColor)
|
|
1675
|
+
p.drawEllipse(c, 1.6, 1.6)
|
|
1676
|
+
|
|
1677
|
+
def _paintBadge(self, p, r):
|
|
1678
|
+
"""
|
|
1679
|
+
:param p: QPainter
|
|
1680
|
+
:param r: QRectF
|
|
1681
|
+
:return:
|
|
1682
|
+
"""
|
|
1683
|
+
p.setOpacity(self.__m_badgeOpacity)
|
|
1684
|
+
font = QFont(self.font()) # type: QFont
|
|
1685
|
+
font.setPointSizeF(12)
|
|
1686
|
+
font.setBold(True)
|
|
1687
|
+
p.setFont(font)
|
|
1688
|
+
text = '{:.1f}\u00d7'.format(self.__m_zoom) # type: str
|
|
1689
|
+
fm = QFontMetrics(font) # type: QFontMetrics
|
|
1690
|
+
tw = fm.horizontalAdvance(text) if hasattr(fm, 'horizontalAdvance') else fm.width(text) # type: int
|
|
1691
|
+
box = QRectF(r.center().x() - (tw + 22) / 2.0, r.bottom() - fm.height() - 34, tw + 22, fm.height() + 10)
|
|
1692
|
+
p.setPen(Qt.NoPen)
|
|
1693
|
+
p.setBrush(QColor(14, 15, 20, 210))
|
|
1694
|
+
p.drawRoundedRect(box, box.height() / 2.0, box.height() / 2.0)
|
|
1695
|
+
p.setPen(QColor(240, 242, 248))
|
|
1696
|
+
p.drawText(box, Qt.AlignCenter, text)
|
|
1697
|
+
p.setOpacity(1.0)
|
|
1698
|
+
|
|
1699
|
+
def _paintToast(self, p, area):
|
|
1700
|
+
"""
|
|
1701
|
+
Confirmation bubble (e.g. "#3A7BD5 copied") with an optional color swatch.
|
|
1702
|
+
:param p: QPainter
|
|
1703
|
+
:param area: (QRectF) Area the bubble is centred in (top).
|
|
1704
|
+
:return:
|
|
1705
|
+
"""
|
|
1706
|
+
p.save()
|
|
1707
|
+
p.setRenderHint(QPainter.Antialiasing, True)
|
|
1708
|
+
p.setOpacity(self.__m_toastOpacity)
|
|
1709
|
+
font = QFont(self.font()) # type: QFont
|
|
1710
|
+
font.setPointSizeF(10.5)
|
|
1711
|
+
font.setBold(True)
|
|
1712
|
+
p.setFont(font)
|
|
1713
|
+
fm = QFontMetrics(font) # type: QFontMetrics
|
|
1714
|
+
text = self.__m_toastText # type: str
|
|
1715
|
+
tw = fm.horizontalAdvance(text) if hasattr(fm, 'horizontalAdvance') else fm.width(text) # type: int
|
|
1716
|
+
swatch = 16 if self.__m_toastColor.isValid() else 0 # type: int
|
|
1717
|
+
w = tw + 28 + (swatch + 8 if swatch else 0) # type: float
|
|
1718
|
+
box = QRectF(area.center().x() - w / 2.0, area.top() + 16, w, fm.height() + 14) # type: QRectF
|
|
1719
|
+
path = QPainterPath() # type: QPainterPath
|
|
1720
|
+
path.addRoundedRect(box, box.height() / 2.0, box.height() / 2.0)
|
|
1721
|
+
p.fillPath(path, QColor(18, 20, 28, 225))
|
|
1722
|
+
x = box.left() + 14 # type: float
|
|
1723
|
+
if swatch:
|
|
1724
|
+
p.setPen(QPen(QColor(255, 255, 255, 200), 1.5))
|
|
1725
|
+
p.setBrush(self.__m_toastColor)
|
|
1726
|
+
p.drawEllipse(QRectF(x, box.center().y() - swatch / 2.0, swatch, swatch))
|
|
1727
|
+
x += swatch + 8
|
|
1728
|
+
p.setPen(QColor(240, 242, 248))
|
|
1729
|
+
p.drawText(QRectF(x, box.top(), tw + 4, box.height()), Qt.AlignVCenter | Qt.AlignLeft, text)
|
|
1730
|
+
p.restore()
|
|
1731
|
+
|
|
1732
|
+
@pyqtSlot('QString')
|
|
1733
|
+
@pyqtSlot(str)
|
|
1734
|
+
def showToast(self, text, color=None):
|
|
1735
|
+
"""
|
|
1736
|
+
Show a short animated confirmation (fades out after about 1.5 s).
|
|
1737
|
+
:param text: str | unicode | QString
|
|
1738
|
+
:param color: (QColor | str | None) Swatch shown before the text.
|
|
1739
|
+
:return:
|
|
1740
|
+
"""
|
|
1741
|
+
self.__m_toastText = u'{}'.format(text) # type: str
|
|
1742
|
+
self.__m_toastColor = QColor(color) if color is not None else QColor() # type: QColor
|
|
1743
|
+
self.__m_toastClock.start()
|
|
1744
|
+
self.__m_toastOpacity = 1.0 # type: float
|
|
1745
|
+
if not self.__m_badgeTimer.isActive():
|
|
1746
|
+
self.__m_badgeTimer.start(16)
|
|
1747
|
+
self.update()
|
|
1748
|
+
|
|
1749
|
+
# ---------- Properties ----------
|
|
1750
|
+
Q_ENUMS('Target' if qVersion()[0] == '4' else Target)
|
|
1751
|
+
Q_ENUMS('Placement' if qVersion()[0] == '4' else Placement)
|
|
1752
|
+
Q_ENUMS('Shape' if qVersion()[0] == '4' else Shape)
|
|
1753
|
+
zoom = pyqtProperty(float, fget=getZoom, fset=setZoom, notify=zoomChanged) # type: pyqtProperty
|
|
1754
|
+
lensSize = pyqtProperty(QSize, fget=getLensSize, fset=setLensSize) # type: pyqtProperty
|
|
1755
|
+
target = pyqtProperty(int, fget=getTarget, fset=setTarget) # type: pyqtProperty
|
|
1756
|
+
targetPoint = pyqtProperty(QPoint, fget=getTargetPoint, fset=setTargetPoint) # type: pyqtProperty
|
|
1757
|
+
placement = pyqtProperty(int, fget=getPlacement, fset=setPlacement) # type: pyqtProperty
|
|
1758
|
+
shape = pyqtProperty(int, fget=getShape, fset=setShape) # type: pyqtProperty
|
|
1759
|
+
customRect = pyqtProperty(QRect, fget=getCustomRect, fset=setCustomRect) # type: pyqtProperty
|
|
1760
|
+
cornerRadius = pyqtProperty(int, fget=getCornerRadius, fset=setCornerRadius) # type: pyqtProperty
|
|
1761
|
+
fullScreenIndex = pyqtProperty(int, fget=getFullScreenIndex, fset=setFullScreenIndex) # type: pyqtProperty
|
|
1762
|
+
processor = pyqtProperty(object, fget=getProcessor, fset=setProcessor) # type: pyqtProperty
|
|
1763
|
+
borderColor = pyqtProperty(QColor, fget=getBorderColor, fset=setBorderColor) # type: pyqtProperty
|
|
1764
|
+
borderWidth = pyqtProperty(float, fget=getBorderWidth, fset=setBorderWidth) # type: pyqtProperty
|
|
1765
|
+
showCrosshair = pyqtProperty(bool, fget=isShowCrosshair, fset=setShowCrosshair) # type: pyqtProperty
|
|
1766
|
+
crosshairColor = pyqtProperty(QColor, fget=getCrosshairColor, fset=setCrosshairColor) # type: pyqtProperty
|
|
1767
|
+
lensOpacity = pyqtProperty(float, fget=getLensOpacity, fset=setLensOpacity) # type: pyqtProperty
|
|
1768
|
+
margin = pyqtProperty(int, fget=getMargin, fset=setMargin) # type: pyqtProperty
|
|
1769
|
+
excludeFromCapture = pyqtProperty(bool, fget=isExcludeFromCapture, fset=setExcludeFromCapture) # type: pyqtProperty
|
|
1770
|
+
externalSource = pyqtProperty(bool, fget=isExternalSource, fset=setExternalSource) # type: pyqtProperty
|
|
1771
|
+
overlayImage = pyqtProperty(QImage, fget=getOverlayImage, fset=setOverlayImage) # type: pyqtProperty
|
|
1772
|
+
frame = pyqtProperty(QImage, fget=getFrame, fset=setFrame) # type: pyqtProperty
|
|
1773
|
+
showColorReadout = pyqtProperty(bool, fget=isShowColorReadout, fset=setShowColorReadout) # type: pyqtProperty
|
|
1774
|
+
pixelated = pyqtProperty(bool, fget=isPixelated, fset=setPixelated) # type: pyqtProperty
|
|
1775
|
+
readoutSource = pyqtProperty('QString', fget=getReadoutSource, fset=setReadoutSource) # type: pyqtProperty
|
|
1776
|
+
readoutSample = pyqtProperty(int, fget=getReadoutSample, fset=setReadoutSample) # type: pyqtProperty
|
|
1777
|
+
annotations = pyqtProperty(list, fget=getAnnotations, fset=setAnnotations) # type: pyqtProperty
|
|
1778
|
+
colorFormatter = pyqtProperty(object, fget=getColorFormatter, fset=setColorFormatter) # type: pyqtProperty
|
|
1779
|
+
colorNamer = pyqtProperty(object, fget=getColorNamer, fset=setColorNamer) # type: pyqtProperty
|