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,521 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
AdvancedOverlayPanel: settings for the in-advanced zoom lens (global hotkeys, target, placement, lens look).
|
|
4
|
+
"""
|
|
5
|
+
from ManyQt.QtWidgets import QGridLayout, QSpinBox, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QSlider, QComboBox, QFrame, \
|
|
6
|
+
QCheckBox, QPushButton, QScrollArea
|
|
7
|
+
from ManyQt.QtCore import QRect, QTimer, Qt, pyqtSlot
|
|
8
|
+
from ManyQt.QtGui import QGuiApplication
|
|
9
|
+
from os.path import dirname
|
|
10
|
+
from sys import path
|
|
11
|
+
|
|
12
|
+
if not __package__ and dirname(__file__) not in path:
|
|
13
|
+
path.append(dirname(__file__))
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
from .advancedoverlay import AdvancedOverlayController
|
|
17
|
+
from .regionselector import RegionSelector
|
|
18
|
+
from .imagefilters import ImageFilters
|
|
19
|
+
from .zoomoverlay import ZoomOverlay
|
|
20
|
+
except:
|
|
21
|
+
from advancedoverlay import AdvancedOverlayController
|
|
22
|
+
from regionselector import RegionSelector
|
|
23
|
+
from imagefilters import ImageFilters
|
|
24
|
+
from zoomoverlay import ZoomOverlay
|
|
25
|
+
|
|
26
|
+
PANEL_QSS = """
|
|
27
|
+
QWidget#gameContent { background: transparent; }
|
|
28
|
+
QLabel[role="title"] { color: #9AA3B8; font-size: 10px; font-weight: bold; letter-spacing: 1px; padding-top: 10px; }
|
|
29
|
+
QLabel[role="value"] { color: #E8EBF2; font-weight: bold; }
|
|
30
|
+
QLabel[role="hint"] { color: #7C8498; font-size: 10px; }
|
|
31
|
+
QLabel[role="ok"] { color: #43C16A; font-weight: bold; }
|
|
32
|
+
QLabel[role="bad"] { color: #FF5A6E; font-weight: bold; }
|
|
33
|
+
QLabel[role="warn"] { color: #FFB86B; font-size: 10px; }
|
|
34
|
+
QKeySequenceEdit QLineEdit { background: #2A2E3A; color: #E8EBF2; border: 1px solid #3A3F50; border-radius: 6px;
|
|
35
|
+
padding: 4px 6px; }
|
|
36
|
+
QPushButton[role="primary"] { background: #3A4BD8; border-color: #4F8BFF; font-weight: bold; padding: 8px; }
|
|
37
|
+
QPushButton[role="small"] { padding: 2px 6px; min-width: 18px; }
|
|
38
|
+
""" # type: str
|
|
39
|
+
|
|
40
|
+
TARGET_NAMES = ['Screen centre', 'Pinned point', 'Mouse cursor'] # type: list[str]
|
|
41
|
+
PLACEMENT_NAMES = ['On target (scope)', 'Top-left corner', 'Top-right corner', 'Bottom-left corner',
|
|
42
|
+
'Bottom-right corner', 'Next to the target (follows a mouse target)', 'Custom area',
|
|
43
|
+
'Full screen'] # type: list[str]
|
|
44
|
+
SHAPE_NAMES = ['Circle', 'Rounded square', 'Rectangle'] # type: list[str]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class AdvancedOverlayPanel(QScrollArea):
|
|
49
|
+
"""
|
|
50
|
+
AdvancedOverlayPanel class.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
def __init__(self, *args, **kwargs):
|
|
54
|
+
"""
|
|
55
|
+
:param controller: AdvancedOverlayController
|
|
56
|
+
:param args: any
|
|
57
|
+
:param kwargs: any
|
|
58
|
+
"""
|
|
59
|
+
controller = kwargs.pop('controller', None) # type: AdvancedOverlayController
|
|
60
|
+
features = kwargs.pop('features', None) # type: FeatureSettings | None
|
|
61
|
+
super(AdvancedOverlayPanel, self).__init__(*args, **kwargs)
|
|
62
|
+
self.__m_ctrl = controller # type: AdvancedOverlayController
|
|
63
|
+
self.__m_features = features # type: FeatureSettings | None
|
|
64
|
+
self.setWidgetResizable(True)
|
|
65
|
+
self.setFrameShape(QFrame.NoFrame)
|
|
66
|
+
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
|
67
|
+
self.setMinimumWidth(250)
|
|
68
|
+
content = QWidget() # type: QWidget
|
|
69
|
+
content.setObjectName('gameContent')
|
|
70
|
+
content.setStyleSheet(PANEL_QSS)
|
|
71
|
+
self.__m_layout = QVBoxLayout(content) # type: QVBoxLayout
|
|
72
|
+
self.__m_layout.setContentsMargins(14, 6, 14, 14)
|
|
73
|
+
self.__m_layout.setSpacing(6)
|
|
74
|
+
self._buildTop()
|
|
75
|
+
self._buildLens()
|
|
76
|
+
self._buildColorTools()
|
|
77
|
+
self.__m_layout.addStretch(1)
|
|
78
|
+
self.setWidget(content)
|
|
79
|
+
ov = controller.getOverlay() # type: ZoomOverlay
|
|
80
|
+
controller.settingsChanged.connect(self.refresh)
|
|
81
|
+
controller.overlayToggled.connect(self.refresh)
|
|
82
|
+
ov.zoomChanged.connect(self.refresh)
|
|
83
|
+
controller.getHotkeys().registrationChanged.connect(self.refresh)
|
|
84
|
+
if features is not None:
|
|
85
|
+
features.changed.connect(lambda *a: self.refresh())
|
|
86
|
+
ov.captureStatusChanged.connect(self.refresh)
|
|
87
|
+
ov.captureDetailChanged.connect(self.refresh)
|
|
88
|
+
self.refresh()
|
|
89
|
+
|
|
90
|
+
# ---------- Helpers ----------
|
|
91
|
+
@staticmethod
|
|
92
|
+
def _label(text, role):
|
|
93
|
+
"""
|
|
94
|
+
:param text: str | unicode | QString
|
|
95
|
+
:param role: str | unicode | QString
|
|
96
|
+
:return: QLabel
|
|
97
|
+
"""
|
|
98
|
+
lbl = QLabel(text) # type: QLabel
|
|
99
|
+
lbl.setProperty('role', role)
|
|
100
|
+
return lbl
|
|
101
|
+
|
|
102
|
+
def _buildAreaControls(self):
|
|
103
|
+
"""
|
|
104
|
+
Custom area (draw it on the screen, or type it) and full-screen screen choice.
|
|
105
|
+
:return:
|
|
106
|
+
"""
|
|
107
|
+
ctrl = self.__m_ctrl # type: AdvancedOverlayController
|
|
108
|
+
self.__m_customBox = QWidget() # type: QWidget
|
|
109
|
+
grid = QGridLayout(self.__m_customBox) # type: QGridLayout
|
|
110
|
+
grid.setContentsMargins(0, 0, 0, 0)
|
|
111
|
+
self.__m_draw = QPushButton(self.tr(u'Draw the area on the screen\u2026')) # type: QPushButton
|
|
112
|
+
self.__m_draw.setToolTip(self.tr(u'Drag a rectangle anywhere on the screen: the lens will fill it'))
|
|
113
|
+
self.__m_draw.clicked.connect(self._drawArea)
|
|
114
|
+
grid.addWidget(self.__m_draw, 0, 0, 1, 4)
|
|
115
|
+
self.__m_areaSpins = [] # type: list[QSpinBox]
|
|
116
|
+
for i, (label, lo) in enumerate(((self.tr(u'X'), -32768), (self.tr(u'Y'), -32768), (self.tr(u'Width'), 64),
|
|
117
|
+
(self.tr(u'Height'), 64))):
|
|
118
|
+
spin = QSpinBox() # type: QSpinBox
|
|
119
|
+
spin.setRange(lo, 32768)
|
|
120
|
+
spin.setToolTip(self.tr(u'Pixels')) # (no suffix: keeps the tab narrow in every language)
|
|
121
|
+
spin.setKeyboardTracking(False) # apply when typing is done, not at every digit
|
|
122
|
+
spin.valueChanged.connect(self._typedArea)
|
|
123
|
+
grid.addWidget(QLabel(label), 1 + i // 2, (i % 2) * 2)
|
|
124
|
+
grid.addWidget(spin, 1 + i // 2, (i % 2) * 2 + 1)
|
|
125
|
+
self.__m_areaSpins.append(spin)
|
|
126
|
+
grid.setColumnStretch(1, 1)
|
|
127
|
+
grid.setColumnStretch(3, 1)
|
|
128
|
+
self.__m_layout.addWidget(self.__m_customBox)
|
|
129
|
+
self.__m_screen = QComboBox() # type: QComboBox
|
|
130
|
+
self.__m_screen.setToolTip(self.tr(u'Screen covered by the full-screen lens'))
|
|
131
|
+
self.__m_screen.activated.connect(lambda i: ctrl.setFullScreenIndex(i - 1))
|
|
132
|
+
self.__m_layout.addWidget(self.__m_screen)
|
|
133
|
+
self.__m_selector = None # type: RegionSelector | None # created on first use
|
|
134
|
+
self.__m_lensWasVisible = False # type: bool
|
|
135
|
+
app = QGuiApplication.instance()
|
|
136
|
+
app.screenAdded.connect(lambda *a: self.refresh())
|
|
137
|
+
if hasattr(app, "screenRemoved"):
|
|
138
|
+
app.screenRemoved.connect(lambda *a: self.refresh())
|
|
139
|
+
|
|
140
|
+
def _buildCornerRadius(self):
|
|
141
|
+
"""
|
|
142
|
+
Corner radius of the rounded-square lens (hidden for the other shapes and the full-screen lens).
|
|
143
|
+
:return:
|
|
144
|
+
"""
|
|
145
|
+
self.__m_cornerBox = QWidget() # type: QWidget
|
|
146
|
+
box = QVBoxLayout(self.__m_cornerBox) # type: QVBoxLayout
|
|
147
|
+
box.setContentsMargins(0, 0, 0, 0)
|
|
148
|
+
row = QHBoxLayout() # type: QHBoxLayout
|
|
149
|
+
row.addWidget(AdvancedOverlayPanel._label(self.tr(u'Corner radius').upper(), 'title'))
|
|
150
|
+
row.addStretch(1)
|
|
151
|
+
self.__m_cornerValue = QLabel() # type: QLabel
|
|
152
|
+
self.__m_cornerValue.setProperty('role', 'value')
|
|
153
|
+
self.__m_cornerValue.setAlignment(Qt.AlignRight | Qt.AlignBottom)
|
|
154
|
+
row.addWidget(self.__m_cornerValue)
|
|
155
|
+
box.addLayout(row)
|
|
156
|
+
self.__m_corner = QSlider(Qt.Horizontal) # type: QSlider
|
|
157
|
+
self.__m_corner.setRange(0, 200)
|
|
158
|
+
self.__m_corner.setToolTip(self.tr(u'0 = square corners; the largest values make a pill or a circle'))
|
|
159
|
+
self.__m_corner.valueChanged.connect(self._cornerChanged)
|
|
160
|
+
box.addWidget(self.__m_corner)
|
|
161
|
+
self.__m_layout.addWidget(self.__m_cornerBox)
|
|
162
|
+
|
|
163
|
+
@pyqtSlot(int)
|
|
164
|
+
def _cornerChanged(self, radius):
|
|
165
|
+
"""
|
|
166
|
+
:param radius: int
|
|
167
|
+
:return:
|
|
168
|
+
"""
|
|
169
|
+
self.__m_ctrl.setCornerRadius(radius)
|
|
170
|
+
self.__m_cornerValue.setText(self._cornerText())
|
|
171
|
+
|
|
172
|
+
def _cornerText(self):
|
|
173
|
+
"""
|
|
174
|
+
:return: (str | unicode | QString) The radius, and what is drawn when the lens is too small for it.
|
|
175
|
+
"""
|
|
176
|
+
ov = self.__m_ctrl.getOverlay() # type: ZoomOverlay
|
|
177
|
+
geo = ov.lensGeometry() # type: QRect
|
|
178
|
+
drawn = int(min(ov.getCornerRadius(), min(geo.width(), geo.height()) // 2)) # type: int
|
|
179
|
+
return '{} px'.format(drawn) if drawn == ov.getCornerRadius() else self.tr(u'{} px (max)').format(drawn)
|
|
180
|
+
|
|
181
|
+
def _screenItems(self):
|
|
182
|
+
"""
|
|
183
|
+
:return: (list[str | unicode | QString]) Screen choices: the target's screen, then every screen.
|
|
184
|
+
"""
|
|
185
|
+
items = [self.tr(u'Screen of the target')] # type: list[str]
|
|
186
|
+
primary = QGuiApplication.primaryScreen()
|
|
187
|
+
for i, screen in enumerate(QGuiApplication.screens()):
|
|
188
|
+
g = screen.geometry()
|
|
189
|
+
text = self.tr(u'Screen {} \u00b7 {} \u00d7 {}').format(i + 1, g.width(), g.height()) # type: str
|
|
190
|
+
items.append(text + (self.tr(u' (primary)') if screen is primary else ''))
|
|
191
|
+
return items
|
|
192
|
+
|
|
193
|
+
@pyqtSlot()
|
|
194
|
+
def _drawArea(self):
|
|
195
|
+
"""
|
|
196
|
+
Hide the window (and a visible lens, which may cover the screen), then let the user drag the lens area.
|
|
197
|
+
:return:
|
|
198
|
+
"""
|
|
199
|
+
if self.__m_selector is None:
|
|
200
|
+
self.__m_selector = RegionSelector(regionSelected=self._onAreaDrawn,
|
|
201
|
+
selectionCanceled=self._restoreAfterDrawing) # type: RegionSelector
|
|
202
|
+
ov = self.__m_ctrl.getOverlay() # type: ZoomOverlay
|
|
203
|
+
self.__m_lensWasVisible = ov.isVisible() # type: bool
|
|
204
|
+
if self.__m_lensWasVisible:
|
|
205
|
+
ov.hideOverlay()
|
|
206
|
+
self.window().hide()
|
|
207
|
+
QTimer.singleShot(250, self.__m_selector.start)
|
|
208
|
+
|
|
209
|
+
@pyqtSlot(QRect)
|
|
210
|
+
def _onAreaDrawn(self, rect):
|
|
211
|
+
"""
|
|
212
|
+
:param rect: (QRect) Global, device-independent area.
|
|
213
|
+
:return:
|
|
214
|
+
"""
|
|
215
|
+
if rect.width() >= 64 and rect.height() >= 64:
|
|
216
|
+
self.__m_ctrl.setCustomRect(rect)
|
|
217
|
+
self.__m_ctrl.setPlacement(ZoomOverlay.Custom)
|
|
218
|
+
self._restoreAfterDrawing()
|
|
219
|
+
|
|
220
|
+
@pyqtSlot()
|
|
221
|
+
def _restoreAfterDrawing(self):
|
|
222
|
+
"""
|
|
223
|
+
:return:
|
|
224
|
+
"""
|
|
225
|
+
self.window().show()
|
|
226
|
+
self.window().raise_()
|
|
227
|
+
if self.__m_lensWasVisible:
|
|
228
|
+
self.__m_ctrl.getOverlay().showOverlay()
|
|
229
|
+
self.refresh()
|
|
230
|
+
|
|
231
|
+
@pyqtSlot()
|
|
232
|
+
def _typedArea(self):
|
|
233
|
+
"""
|
|
234
|
+
:return:
|
|
235
|
+
"""
|
|
236
|
+
x, y, w, h = [spin.value() for spin in self.__m_areaSpins]
|
|
237
|
+
self.__m_ctrl.setCustomRect(QRect(x, y, w, h))
|
|
238
|
+
self.refresh()
|
|
239
|
+
|
|
240
|
+
def _titleRow(self, title, valueLabel=None):
|
|
241
|
+
"""
|
|
242
|
+
:param title: str | unicode | QString
|
|
243
|
+
:param valueLabel: QLabel | None
|
|
244
|
+
:return:
|
|
245
|
+
"""
|
|
246
|
+
row = QHBoxLayout() # type: QHBoxLayout
|
|
247
|
+
row.addWidget(AdvancedOverlayPanel._label(title.upper(), 'title'))
|
|
248
|
+
row.addStretch(1)
|
|
249
|
+
if valueLabel is not None:
|
|
250
|
+
valueLabel.setProperty('role', 'value')
|
|
251
|
+
valueLabel.setAlignment(Qt.AlignRight | Qt.AlignBottom)
|
|
252
|
+
row.addWidget(valueLabel)
|
|
253
|
+
self.__m_layout.addLayout(row)
|
|
254
|
+
|
|
255
|
+
def _slider(self, lo, hi, slot):
|
|
256
|
+
"""
|
|
257
|
+
:param lo: int
|
|
258
|
+
:param hi: int
|
|
259
|
+
:param slot: callable
|
|
260
|
+
:return: QSlider
|
|
261
|
+
"""
|
|
262
|
+
s = QSlider(Qt.Horizontal) # type: QSlider
|
|
263
|
+
s.setRange(lo, hi)
|
|
264
|
+
s.valueChanged.connect(slot)
|
|
265
|
+
self.__m_layout.addWidget(s)
|
|
266
|
+
return s
|
|
267
|
+
|
|
268
|
+
def _combo(self, items, slot):
|
|
269
|
+
"""
|
|
270
|
+
:param items: list[str | unicode | QString]
|
|
271
|
+
:param slot: callable
|
|
272
|
+
:return: QComboBox
|
|
273
|
+
"""
|
|
274
|
+
c = QComboBox() # type: QComboBox
|
|
275
|
+
c.addItems([self.tr(i) for i in items])
|
|
276
|
+
c.currentIndexChanged.connect(slot)
|
|
277
|
+
self.__m_layout.addWidget(c)
|
|
278
|
+
return c
|
|
279
|
+
|
|
280
|
+
def _buildTop(self):
|
|
281
|
+
"""
|
|
282
|
+
:return:
|
|
283
|
+
"""
|
|
284
|
+
self.__m_toggle = QPushButton() # type: QPushButton
|
|
285
|
+
self.__m_toggle.setProperty('role', 'primary')
|
|
286
|
+
self.__m_toggle.setFocusPolicy(Qt.NoFocus)
|
|
287
|
+
self.__m_toggle.clicked.connect(self.__m_ctrl.toggle)
|
|
288
|
+
self.__m_layout.addWidget(self.__m_toggle)
|
|
289
|
+
|
|
290
|
+
def _buildColorTools(self):
|
|
291
|
+
"""
|
|
292
|
+
The zoomer's two optional color features, side by side.
|
|
293
|
+
:return:
|
|
294
|
+
"""
|
|
295
|
+
self._titleRow(self.tr(u'Color tools in the zoomer'))
|
|
296
|
+
self.__m_readout = QCheckBox(self.tr(u'Color code under the crosshair (live HEX / RGB)')) # type: QCheckBox
|
|
297
|
+
self.__m_readout.toggled.connect(self.__m_ctrl.setColorReadout)
|
|
298
|
+
self.__m_layout.addWidget(self.__m_readout)
|
|
299
|
+
self.__m_zones = QCheckBox(
|
|
300
|
+
self.tr(u'Color zones (target colors and faces of the Detection tab)')) # type: QCheckBox
|
|
301
|
+
self.__m_zones.setEnabled(self.__m_features is not None)
|
|
302
|
+
if self.__m_features is not None:
|
|
303
|
+
self.__m_zones.toggled.connect(lambda on: self.__m_features.set('zonesInZoomer', on))
|
|
304
|
+
self.__m_layout.addWidget(self.__m_zones)
|
|
305
|
+
self.__m_colorHint = AdvancedOverlayPanel._label('', 'hint') # type: QLabel
|
|
306
|
+
self.__m_colorHint.setWordWrap(True)
|
|
307
|
+
self.__m_layout.addWidget(self.__m_colorHint)
|
|
308
|
+
|
|
309
|
+
def _buildLens(self):
|
|
310
|
+
"""
|
|
311
|
+
:return:
|
|
312
|
+
"""
|
|
313
|
+
ctrl = self.__m_ctrl # type: AdvancedOverlayController
|
|
314
|
+
self.__m_pointLabel = QLabel() # type: QLabel
|
|
315
|
+
self._titleRow(self.tr(u'Magnify'), self.__m_pointLabel)
|
|
316
|
+
self.__m_target = self._combo(TARGET_NAMES, ctrl.setTarget) # type: QComboBox
|
|
317
|
+
self._titleRow(self.tr(u'Show the lens'))
|
|
318
|
+
self.__m_placement = self._combo(PLACEMENT_NAMES, ctrl.setPlacement) # type: QComboBox
|
|
319
|
+
self._buildAreaControls()
|
|
320
|
+
self.__m_overlapHint = AdvancedOverlayPanel._label('', 'hint') # type: QLabel
|
|
321
|
+
self.__m_overlapHint.setWordWrap(True)
|
|
322
|
+
self.__m_layout.addWidget(self.__m_overlapHint)
|
|
323
|
+
self.__m_shape = self._combo(SHAPE_NAMES, ctrl.setShape) # type: QComboBox
|
|
324
|
+
self.__m_shape.currentIndexChanged.connect(lambda *a: self.refresh()) # show / hide the corner radius
|
|
325
|
+
self._buildCornerRadius()
|
|
326
|
+
self.__m_zoomValue = QLabel() # type: QLabel
|
|
327
|
+
self._titleRow(self.tr(u'Magnification'), self.__m_zoomValue)
|
|
328
|
+
self.__m_zoom = self._slider(10, 160, lambda v: ctrl.setZoom(v / 10.0)) # type: QSlider
|
|
329
|
+
self.__m_sizeValue = QLabel() # type: QLabel
|
|
330
|
+
self._titleRow(self.tr(u'Lens size'), self.__m_sizeValue)
|
|
331
|
+
self.__m_size = self._slider(8, 45, lambda v: ctrl.setLensSize(v * 20)) # type: QSlider
|
|
332
|
+
self.__m_opacityValue = QLabel() # type: QLabel
|
|
333
|
+
self._titleRow(self.tr(u'Opacity'), self.__m_opacityValue)
|
|
334
|
+
self.__m_opacity = self._slider(30, 100, lambda v: ctrl.setOpacity(v / 100.0)) # type: QSlider
|
|
335
|
+
self.__m_fpsValue = QLabel() # type: QLabel
|
|
336
|
+
self._titleRow(self.tr(u'Frame rate'), self.__m_fpsValue)
|
|
337
|
+
self.__m_fps = self._slider(15, 144, ctrl.setFps) # type: QSlider
|
|
338
|
+
self.__m_crosshair = QCheckBox(self.tr(u'Crosshair')) # type: QCheckBox
|
|
339
|
+
self.__m_crosshair.toggled.connect(ctrl.setCrosshair)
|
|
340
|
+
self.__m_layout.addWidget(self.__m_crosshair)
|
|
341
|
+
tip = AdvancedOverlayPanel._label(self.tr(
|
|
342
|
+
u'Run the game in borderless / windowed full-screen: exclusive full-screen hides every overlay. '
|
|
343
|
+
u'The lens never takes focus and lets all clicks through to the game.'), 'hint') # type: QLabel
|
|
344
|
+
tip.setWordWrap(True)
|
|
345
|
+
self.__m_layout.addWidget(tip)
|
|
346
|
+
self._buildFilters()
|
|
347
|
+
|
|
348
|
+
def _buildFilters(self):
|
|
349
|
+
"""
|
|
350
|
+
FILTERS: an effect (with its strength) and brightness / contrast / saturation for the lens image.
|
|
351
|
+
:return:
|
|
352
|
+
"""
|
|
353
|
+
filters = self.__m_ctrl.getFilters() # type: ImageFilters
|
|
354
|
+
self._titleRow(self.tr(u'Filters'))
|
|
355
|
+
self.__m_effect = self._combo([self.tr(n) for n in ImageFilters.EFFECT_NAMES], filters.setEffect) # type: QComboBox
|
|
356
|
+
if not ImageFilters.isAvailable(): # without NumPy, Qt alone does Invert and Grayscale
|
|
357
|
+
model = self.__m_effect.model()
|
|
358
|
+
for i, name in enumerate(ImageFilters.EFFECT_NAMES):
|
|
359
|
+
if name not in ('None', 'Grayscale', 'Invert') and hasattr(model, 'item'):
|
|
360
|
+
model.item(i).setEnabled(False)
|
|
361
|
+
self.__m_layout.addWidget(AdvancedOverlayPanel._label(
|
|
362
|
+
self.tr(u'Install numpy for every effect and the sliders.'), 'hint'))
|
|
363
|
+
self.__m_filterSliders = {} # type: dict
|
|
364
|
+
for name, title, lo in (('strength', self.tr(u'Strength'), 0), ('brightness', self.tr(u'Brightness'), -100),
|
|
365
|
+
('contrast', self.tr(u'Contrast'), -100), ('saturation', self.tr(u'Saturation'), -100)):
|
|
366
|
+
box = QWidget() # type: QWidget
|
|
367
|
+
column = QVBoxLayout(box) # type: QVBoxLayout
|
|
368
|
+
column.setContentsMargins(0, 0, 0, 0)
|
|
369
|
+
row = QHBoxLayout() # type: QHBoxLayout
|
|
370
|
+
row.addWidget(AdvancedOverlayPanel._label(title.upper(), 'title'))
|
|
371
|
+
row.addStretch(1)
|
|
372
|
+
value = QLabel() # type: QLabel
|
|
373
|
+
value.setProperty('role', 'value')
|
|
374
|
+
row.addWidget(value)
|
|
375
|
+
column.addLayout(row)
|
|
376
|
+
slider = QSlider(Qt.Horizontal) # type: QSlider
|
|
377
|
+
slider.setRange(lo, 100)
|
|
378
|
+
slider.valueChanged.connect(getattr(filters, 'set' + name[0].upper() + name[1:]))
|
|
379
|
+
slider.valueChanged.connect(lambda v, label=value, signed=lo < 0: label.setText(
|
|
380
|
+
('{:+d}' if signed and v else '{}').format(v) + ('' if signed else ' %')))
|
|
381
|
+
column.addWidget(slider)
|
|
382
|
+
box.setEnabled(ImageFilters.isAvailable())
|
|
383
|
+
self.__m_layout.addWidget(box)
|
|
384
|
+
self.__m_filterSliders[name] = (box, slider, value)
|
|
385
|
+
reset = QPushButton(self.tr(u'Reset the filters')) # type: QPushButton
|
|
386
|
+
reset.clicked.connect(filters.reset)
|
|
387
|
+
self.__m_layout.addWidget(reset)
|
|
388
|
+
filters.changed.connect(self._refreshFilters)
|
|
389
|
+
|
|
390
|
+
def _refreshFilters(self):
|
|
391
|
+
"""
|
|
392
|
+
:return:
|
|
393
|
+
"""
|
|
394
|
+
filters = self.__m_ctrl.getFilters() # type: ImageFilters
|
|
395
|
+
self.__m_effect.blockSignals(True)
|
|
396
|
+
self.__m_effect.setCurrentIndex(filters.getEffect())
|
|
397
|
+
self.__m_effect.blockSignals(False)
|
|
398
|
+
for name, (box, slider, value) in self.__m_filterSliders.items():
|
|
399
|
+
v = getattr(filters, 'get' + name[0].upper() + name[1:])() # type: int
|
|
400
|
+
if slider.value() != v:
|
|
401
|
+
slider.blockSignals(True)
|
|
402
|
+
slider.setValue(v)
|
|
403
|
+
slider.blockSignals(False)
|
|
404
|
+
signed = slider.minimum() < 0 # type: bool
|
|
405
|
+
value.setText(('{:+d}' if signed and v else '{}').format(v) + ('' if signed else ' %'))
|
|
406
|
+
self.__m_filterSliders['strength'][0].setVisible(filters.getEffect() != 0) # only with an effect
|
|
407
|
+
|
|
408
|
+
@pyqtSlot()
|
|
409
|
+
def _refreshCaptureStatus(self, ov):
|
|
410
|
+
"""
|
|
411
|
+
Explain whether 'On target' really works (the lens must be invisible to screen capture).
|
|
412
|
+
:param ov: ZoomOverlay
|
|
413
|
+
:return:
|
|
414
|
+
"""
|
|
415
|
+
status = ov.getCaptureStatus() # type: str
|
|
416
|
+
text, role = '', 'hint' # type: str, str
|
|
417
|
+
if ov.getPlacement() in (ZoomOverlay.Custom, ZoomOverlay.FullScreen):
|
|
418
|
+
if status == 'testing':
|
|
419
|
+
text = self.tr(u'Checking that the lens is hidden from screen capture\u2026')
|
|
420
|
+
elif status == 'excluded':
|
|
421
|
+
text, role = self.tr(u'\u2713 Lens hidden from screen capture: it can cover what it magnifies.'), 'ok'
|
|
422
|
+
elif status == 'windowCapture':
|
|
423
|
+
text, role = self.tr(u'\u2713 Capturing the game window directly (Windows could not hide the lens '
|
|
424
|
+
'from screen capture).'), 'ok'
|
|
425
|
+
elif status == 'otherScreen':
|
|
426
|
+
text, role = self.tr(u'\u26a0 The lens cannot cover what it magnifies here: {}. The full-screen lens '
|
|
427
|
+
'is shown on screen {} instead.').format(
|
|
428
|
+
ov.getCaptureDetail(), (ov.getFallbackScreen() or 0) + 1), 'warn'
|
|
429
|
+
elif status == 'failed':
|
|
430
|
+
corner = self.tr(PLACEMENT_NAMES[int(ov.getEffectivePlacement())]).lower() # type: str
|
|
431
|
+
text, role = self.tr(u'\u26a0 The lens cannot cover what it magnifies here: {}. It is shown in the {} '
|
|
432
|
+
'instead.').format(ov.getCaptureDetail(), corner), 'warn'
|
|
433
|
+
elif not ZoomOverlay.canExcludeFromCapture() and ov.getPlacement() == ZoomOverlay.FullScreen:
|
|
434
|
+
text = self.tr(u'Only Windows 10 (2004+) / 11 can hide the lens from capture: on this system a '
|
|
435
|
+
'full-screen lens needs a second screen (it moves there automatically).')
|
|
436
|
+
elif ov.getPlacement() == ZoomOverlay.OnTarget:
|
|
437
|
+
if status == 'testing':
|
|
438
|
+
text = self.tr(u'Checking that the lens is hidden from screen capture\u2026')
|
|
439
|
+
elif status == 'excluded':
|
|
440
|
+
text, role = self.tr(u'\u2713 Lens hidden from screen capture: scope mode active.'), 'ok'
|
|
441
|
+
elif status == 'windowCapture':
|
|
442
|
+
text, role = self.tr(u'\u2713 Scope mode active: capturing the game window directly (Windows '
|
|
443
|
+
'could not hide the lens from screen capture).'), 'ok'
|
|
444
|
+
elif status == 'failed':
|
|
445
|
+
corner = self.tr(PLACEMENT_NAMES[int(ov.getEffectivePlacement())]).lower() # type: str
|
|
446
|
+
text, role = self.tr(u'\u26a0 Scope mode is not possible here: {}. Without it the lens would '
|
|
447
|
+
'magnify itself, so it is shown in the {} instead.').format(
|
|
448
|
+
ov.getCaptureDetail(), corner), 'warn'
|
|
449
|
+
elif not ZoomOverlay.canExcludeFromCapture():
|
|
450
|
+
text = self.tr(u'Only Windows 10 (2004+) / 11 can hide the lens from capture; on this system it '
|
|
451
|
+
'will be shown in a free corner.')
|
|
452
|
+
self.__m_overlapHint.setText(text)
|
|
453
|
+
self.__m_overlapHint.setProperty('role', role)
|
|
454
|
+
self.__m_overlapHint.setVisible(bool(text))
|
|
455
|
+
self.__m_overlapHint.style().unpolish(self.__m_overlapHint)
|
|
456
|
+
self.__m_overlapHint.style().polish(self.__m_overlapHint)
|
|
457
|
+
|
|
458
|
+
# ---------- Public API ----------
|
|
459
|
+
@pyqtSlot()
|
|
460
|
+
def refresh(self):
|
|
461
|
+
"""
|
|
462
|
+
Pull every value from the controller / overlay into the widgets.
|
|
463
|
+
:return:
|
|
464
|
+
"""
|
|
465
|
+
ctrl = self.__m_ctrl # type: AdvancedOverlayController
|
|
466
|
+
ov = ctrl.getOverlay() # type: ZoomOverlay
|
|
467
|
+
widgets = [self.__m_readout, self.__m_zones, self.__m_target, self.__m_placement, self.__m_shape, self.__m_zoom,
|
|
468
|
+
self.__m_size, self.__m_opacity, self.__m_fps, self.__m_crosshair] # type: list
|
|
469
|
+
for w in widgets:
|
|
470
|
+
w.blockSignals(True)
|
|
471
|
+
self.__m_readout.setChecked(ov.isShowColorReadout())
|
|
472
|
+
self.__m_zones.setChecked(self.__m_features is not None and self.__m_features.get('zonesInZoomer'))
|
|
473
|
+
self.__m_target.setCurrentIndex(int(ov.getTarget()))
|
|
474
|
+
self.__m_placement.setCurrentIndex(int(ov.getPlacement()))
|
|
475
|
+
self.__m_shape.setCurrentIndex(int(ov.getShape()))
|
|
476
|
+
self.__m_zoom.setValue(int(round(ov.getZoom() * 10)))
|
|
477
|
+
self.__m_size.setValue(int(round(ov.getLensSize().width() / 20.0)))
|
|
478
|
+
self.__m_opacity.setValue(int(round(ov.getLensOpacity() * 100)))
|
|
479
|
+
self.__m_fps.setValue(ctrl.getGrabber().getFps())
|
|
480
|
+
self.__m_crosshair.setChecked(ov.isShowCrosshair())
|
|
481
|
+
for w in widgets:
|
|
482
|
+
w.blockSignals(False)
|
|
483
|
+
placement = ov.getPlacement()
|
|
484
|
+
area = ov.lensGeometry() if placement == ZoomOverlay.Custom else ov.getCustomRect() # type: QRect
|
|
485
|
+
for spin, value in zip(self.__m_areaSpins, (area.x(), area.y(), area.width(), area.height())):
|
|
486
|
+
spin.blockSignals(True)
|
|
487
|
+
spin.setValue(value)
|
|
488
|
+
spin.blockSignals(False)
|
|
489
|
+
self.__m_screen.blockSignals(True)
|
|
490
|
+
self.__m_screen.clear()
|
|
491
|
+
self.__m_screen.addItems(self._screenItems())
|
|
492
|
+
self.__m_screen.setCurrentIndex(max(0, min(self.__m_screen.count() - 1, ov.getFullScreenIndex() + 1)))
|
|
493
|
+
self.__m_screen.blockSignals(False)
|
|
494
|
+
self.__m_customBox.setVisible(placement == ZoomOverlay.Custom)
|
|
495
|
+
self.__m_screen.setVisible(placement == ZoomOverlay.FullScreen)
|
|
496
|
+
sized = placement not in (ZoomOverlay.Custom, ZoomOverlay.FullScreen) # type: bool
|
|
497
|
+
self.__m_size.setEnabled(sized) # the custom area / the screen gives the size
|
|
498
|
+
self.__m_shape.setEnabled(placement != ZoomOverlay.FullScreen) # always a rectangle
|
|
499
|
+
self.__m_corner.blockSignals(True)
|
|
500
|
+
self.__m_corner.setValue(ov.getCornerRadius())
|
|
501
|
+
self.__m_corner.blockSignals(False)
|
|
502
|
+
self.__m_cornerValue.setText(self._cornerText())
|
|
503
|
+
self._refreshFilters()
|
|
504
|
+
self.__m_cornerBox.setVisible(ov.getShape() == ZoomOverlay.RoundedRect and placement != ZoomOverlay.FullScreen)
|
|
505
|
+
self.__m_zoomValue.setText('{:.1f}\u00d7'.format(ov.getZoom()))
|
|
506
|
+
geo = ov.lensGeometry() # type: QRect
|
|
507
|
+
self.__m_sizeValue.setText('{} px'.format(ov.getLensSize().width()) if sized else
|
|
508
|
+
'{} \u00d7 {}'.format(geo.width(), geo.height()))
|
|
509
|
+
self.__m_opacityValue.setText('{} %'.format(self.__m_opacity.value()))
|
|
510
|
+
self.__m_fpsValue.setText('{} fps'.format(self.__m_fps.value()))
|
|
511
|
+
tp = ov.getTargetPoint()
|
|
512
|
+
self.__m_pointLabel.setText('({}, {})'.format(tp.x(), tp.y()) if ov.getTarget() == ZoomOverlay.Point else '')
|
|
513
|
+
self._refreshCaptureStatus(ov)
|
|
514
|
+
self.__m_colorHint.setText(self.tr(u'Copy the color code: {}. Screen color picker (click anywhere on the screen): '
|
|
515
|
+
'{}. Change them in the Shortcuts tab; pick format and sample in the Colors '
|
|
516
|
+
'tab.').format(ctrl.getHotkey('copyZoomerColor') or self.tr(u'no shortcut'),
|
|
517
|
+
ctrl.getHotkey('screenPicker') or self.tr(u'no shortcut')))
|
|
518
|
+
self.__m_toggle.setText((self.tr(u'Hide the zoomer ({})') if ov.isVisible() else self.tr(
|
|
519
|
+
u'Show the zoomer ({})')).format(ctrl.getHotkey('toggle') or self.tr(u'no shortcut')))
|
|
520
|
+
|
|
521
|
+
# ---------- Qt overrides ----------
|