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,1368 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""
|
|
3
|
+
Screen Magnifier application window: wires RegionSelector, ScreenGrabber, Upscaler, MagnifierViewWidget,
|
|
4
|
+
ControlPanel, the zoomer (advanced zoom lens), color / face detection (AnalysisController) and the optional analysis
|
|
5
|
+
server (RemoteClient) together.
|
|
6
|
+
"""
|
|
7
|
+
from ManyQt.QtWidgets import QMainWindow, QDockWidget, QToolBar, QAction, QLabel, QFileDialog, QApplication, QMenu, \
|
|
8
|
+
QSystemTrayIcon, QToolButton, QTabBar, QMessageBox, QActionGroup, QScrollArea, QComboBox, QCheckBox, QWidget, \
|
|
9
|
+
QVBoxLayout, QHBoxLayout
|
|
10
|
+
from ManyQt.QtCore import QObject, QSettings, QUrl, Qt, QRect, QRectF, QSize, QPoint, QPointF, QTimer, QElapsedTimer, \
|
|
11
|
+
QEvent, QDir, QDateTime, pyqtSlot
|
|
12
|
+
from ManyQt.QtGui import QImage, QColor, QKeySequence, QIcon, QPixmap, QPainter, QPen, QBrush, QCursor, QDesktopServices
|
|
13
|
+
from os.path import dirname, join, isfile
|
|
14
|
+
from sys import path, platform
|
|
15
|
+
from math import ceil, floor
|
|
16
|
+
from os import getpid
|
|
17
|
+
import sys
|
|
18
|
+
|
|
19
|
+
if not __package__ and dirname(__file__) not in path:
|
|
20
|
+
path.append(dirname(__file__))
|
|
21
|
+
|
|
22
|
+
try:
|
|
23
|
+
from .advancedoverlay import AdvancedOverlayController
|
|
24
|
+
from .support import DONATION_LINKS, restartCommand
|
|
25
|
+
from .facepointer import FacePointer, FOLLOW_ZOOMER
|
|
26
|
+
from .analysiscontroller import AnalysisController
|
|
27
|
+
from .colordetector import sampleColor, refinePick
|
|
28
|
+
from .shortcuts import ShortcutStore, shortcutInfo
|
|
29
|
+
from .advancedpanel import AdvancedOverlayPanel
|
|
30
|
+
from .magnifierview import MagnifierViewWidget
|
|
31
|
+
from .shortcutspanel import ShortcutsPanel
|
|
32
|
+
from .detectionpanel import DetectionPanel
|
|
33
|
+
from .regionselector import RegionSelector
|
|
34
|
+
from .screengrabber import ScreenGrabber
|
|
35
|
+
from .colorpanel import ColorPickerPanel
|
|
36
|
+
from .translator import LanguageManager
|
|
37
|
+
from .controlpanel import ControlPanel
|
|
38
|
+
from .remoteclient import RemoteClient
|
|
39
|
+
from .features import FeatureSettings
|
|
40
|
+
from .zoomoverlay import ZoomOverlay
|
|
41
|
+
from .serverpanel import ServerPanel
|
|
42
|
+
from .upscaler import Upscaler
|
|
43
|
+
except:
|
|
44
|
+
from advancedoverlay import AdvancedOverlayController
|
|
45
|
+
from support import DONATION_LINKS, restartCommand
|
|
46
|
+
from facepointer import FacePointer, FOLLOW_ZOOMER
|
|
47
|
+
from analysiscontroller import AnalysisController
|
|
48
|
+
from colordetector import sampleColor, refinePick
|
|
49
|
+
from shortcuts import ShortcutStore, shortcutInfo
|
|
50
|
+
from advancedpanel import AdvancedOverlayPanel
|
|
51
|
+
from magnifierview import MagnifierViewWidget
|
|
52
|
+
from shortcutspanel import ShortcutsPanel
|
|
53
|
+
from detectionpanel import DetectionPanel
|
|
54
|
+
from regionselector import RegionSelector
|
|
55
|
+
from screengrabber import ScreenGrabber
|
|
56
|
+
from colorpanel import ColorPickerPanel
|
|
57
|
+
from translator import LanguageManager
|
|
58
|
+
from controlpanel import ControlPanel
|
|
59
|
+
from remoteclient import RemoteClient
|
|
60
|
+
from features import FeatureSettings
|
|
61
|
+
from zoomoverlay import ZoomOverlay
|
|
62
|
+
from serverpanel import ServerPanel
|
|
63
|
+
from upscaler import Upscaler
|
|
64
|
+
|
|
65
|
+
APP_QSS = """
|
|
66
|
+
QMainWindow, QDockWidget, QScrollArea { background: #1B1D24; color: #E8EBF2; }
|
|
67
|
+
QToolBar { background: #22252E; border: none; border-bottom: 1px solid #2E3240; spacing: 4px; padding: 4px; }
|
|
68
|
+
QToolBar::separator { background: #3A3F50; width: 1px; margin: 6px 6px; }
|
|
69
|
+
QToolButton { color: #E8EBF2; background: transparent; border: 1px solid transparent; border-radius: 6px;
|
|
70
|
+
padding: 5px 10px; }
|
|
71
|
+
QToolButton:hover { background: #2E3240; }
|
|
72
|
+
QToolButton:checked { background: #3A4BD8; border-color: #4F8BFF; }
|
|
73
|
+
QStatusBar { background: #22252E; color: #AEB5C6; border-top: 1px solid #2E3240; }
|
|
74
|
+
QStatusBar QLabel { color: #AEB5C6; padding: 0 8px; }
|
|
75
|
+
QDockWidget::title { background: #22252E; padding: 6px 10px; color: #9AA3B8; }
|
|
76
|
+
QTabBar::tab { background: #22252E; color: #9AA3B8; padding: 6px 14px; border: none; }
|
|
77
|
+
QTabBar::tab:selected { background: #2A2E3A; color: #E8EBF2; border-bottom: 2px solid #4F8BFF; }
|
|
78
|
+
QMenu { background: #22252E; color: #E8EBF2; border: 1px solid #3A3F50; }
|
|
79
|
+
QMenu::item:selected { background: #3A4BD8; }
|
|
80
|
+
QLabel, QCheckBox { color: #E8EBF2; }
|
|
81
|
+
QComboBox, QPushButton { background: #2A2E3A; color: #E8EBF2; border: 1px solid #3A3F50; border-radius: 6px;
|
|
82
|
+
padding: 5px 8px; }
|
|
83
|
+
QPushButton:hover, QComboBox:hover { border-color: #4F8BFF; }
|
|
84
|
+
QComboBox QAbstractItemView { background: #2A2E3A; color: #E8EBF2; selection-background-color: #3A4BD8; }
|
|
85
|
+
QSlider::groove:horizontal { height: 4px; background: #3A3F50; border-radius: 2px; }
|
|
86
|
+
QSlider::sub-page:horizontal { background: #4F8BFF; border-radius: 2px; }
|
|
87
|
+
QSlider::handle:horizontal { background: #E8EBF2; width: 14px; margin: -6px 0; border-radius: 7px; }
|
|
88
|
+
""" # type: str
|
|
89
|
+
|
|
90
|
+
RESTART_QUESTION = 'The interface language changes when ScreenMagnifier restarts. Restart now?' # type: str
|
|
91
|
+
PLACEHOLDER = ('Select a screen region to magnify\n\n'
|
|
92
|
+
'Ctrl+R - select region\nF - follow cursor\nSpace - freeze\n'
|
|
93
|
+
'Wheel - zoom at cursor\nDrag - pan\nDouble-click - fit\n'
|
|
94
|
+
'I - eyedropper: click to copy colors\nC - copy the color under the mouse\n'
|
|
95
|
+
'Right-click - copy it in any format') # type: str
|
|
96
|
+
|
|
97
|
+
RESOURCES = join(dirname(__file__), 'resources') # type: str # icon-<size>.png, icon.ico, icon.icns
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def makeAppIcon():
|
|
101
|
+
"""
|
|
102
|
+
The application / tray icon: resources/icon-<size>.png (hand-tuned small sizes), or a drawn magnifier.
|
|
103
|
+
:return: QIcon
|
|
104
|
+
"""
|
|
105
|
+
icon = QIcon() # type: QIcon
|
|
106
|
+
for size in (16, 24, 32, 48, 64, 128, 256, 512):
|
|
107
|
+
file = join(RESOURCES, 'icon-{}.png'.format(size)) # type: str
|
|
108
|
+
if isfile(file):
|
|
109
|
+
icon.addFile(file, QSize(size, size))
|
|
110
|
+
if not icon.isNull():
|
|
111
|
+
return icon
|
|
112
|
+
for size in (16, 24, 32, 48, 64, 128):
|
|
113
|
+
pm = QPixmap(size, size) # type: QPixmap
|
|
114
|
+
pm.fill(Qt.transparent)
|
|
115
|
+
p = QPainter(pm) # type: QPainter
|
|
116
|
+
p.setRenderHint(QPainter.Antialiasing, True)
|
|
117
|
+
s = float(size) # type: float
|
|
118
|
+
p.setPen(QPen(QColor('#E8EBF2'), s * 0.13, Qt.SolidLine, Qt.RoundCap))
|
|
119
|
+
p.drawLine(QPoint(int(s * 0.62), int(s * 0.62)), QPoint(int(s * 0.9), int(s * 0.9)))
|
|
120
|
+
p.setPen(QPen(QColor('#4F8BFF'), s * 0.1))
|
|
121
|
+
p.setBrush(QBrush(QColor(79, 139, 255, 70)))
|
|
122
|
+
p.drawEllipse(QRectF(s * 0.1, s * 0.1, s * 0.56, s * 0.56))
|
|
123
|
+
p.end()
|
|
124
|
+
icon.addPixmap(pm)
|
|
125
|
+
return icon
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def excludeFromCapture(widget):
|
|
129
|
+
"""
|
|
130
|
+
Windows 10 2004+: hide a window from screen capture so the magnifier can sit over what it magnifies.
|
|
131
|
+
:param widget: QWidget
|
|
132
|
+
:return: (bool) True if the window is now excluded.
|
|
133
|
+
"""
|
|
134
|
+
if platform != 'win32':
|
|
135
|
+
return False
|
|
136
|
+
try:
|
|
137
|
+
from ctypes import windll
|
|
138
|
+
WDA_EXCLUDEFROMCAPTURE = 0x11 # type: int
|
|
139
|
+
return bool(windll.user32.SetWindowDisplayAffinity(int(widget.winId()), WDA_EXCLUDEFROMCAPTURE))
|
|
140
|
+
except Exception:
|
|
141
|
+
return False
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
class CheckBoxLabelLink(QObject):
|
|
145
|
+
"""
|
|
146
|
+
CheckBoxLabelLink class: a wrapping label that acts as its check box's text - a click on it toggles the box, and
|
|
147
|
+
it follows the box's enabled state.
|
|
148
|
+
"""
|
|
149
|
+
|
|
150
|
+
def __init__(self, box, label, *args, **kwargs):
|
|
151
|
+
"""
|
|
152
|
+
:param box: QCheckBox
|
|
153
|
+
:param label: QLabel
|
|
154
|
+
:param args: any
|
|
155
|
+
:param kwargs: any
|
|
156
|
+
"""
|
|
157
|
+
super(CheckBoxLabelLink, self).__init__(*args, **kwargs)
|
|
158
|
+
self.__m_box = box # type: QCheckBox
|
|
159
|
+
self.__m_label = label # type: QLabel
|
|
160
|
+
|
|
161
|
+
def eventFilter(self, obj, e):
|
|
162
|
+
"""
|
|
163
|
+
:param obj: QObject
|
|
164
|
+
:param e: QEvent
|
|
165
|
+
:return: bool
|
|
166
|
+
"""
|
|
167
|
+
if obj is self.__m_label and e.type() == QEvent.MouseButtonRelease and self.__m_box.isEnabled():
|
|
168
|
+
self.__m_box.click()
|
|
169
|
+
return True
|
|
170
|
+
if obj is self.__m_box and e.type() in (QEvent.EnabledChange, QEvent.ToolTipChange):
|
|
171
|
+
self.__m_label.setEnabled(self.__m_box.isEnabled())
|
|
172
|
+
self.__m_label.setToolTip(self.__m_box.toolTip())
|
|
173
|
+
return super(CheckBoxLabelLink, self).eventFilter(obj, e)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
class MainWindow(QMainWindow):
|
|
177
|
+
"""
|
|
178
|
+
MainWindow class.
|
|
179
|
+
"""
|
|
180
|
+
|
|
181
|
+
def __init__(self, *args, **kwargs):
|
|
182
|
+
"""
|
|
183
|
+
:param excludeFromCapture: (bool) Windows only: make the magnifier invisible to screen capture.
|
|
184
|
+
:param languageManager: (LanguageManager | None) Interface language (main.run installs it before the window).
|
|
185
|
+
:param args: any
|
|
186
|
+
:param kwargs: any
|
|
187
|
+
"""
|
|
188
|
+
excludeSelf = kwargs.pop('excludeFromCapture', True) # type: bool
|
|
189
|
+
languageManager = kwargs.pop('languageManager', None) # type: LanguageManager | None
|
|
190
|
+
super(MainWindow, self).__init__(*args, **kwargs)
|
|
191
|
+
self.__m_languages = languageManager if languageManager is not None else LanguageManager(
|
|
192
|
+
folder=join(dirname(__file__), 'translations'), parent=self) # type: LanguageManager
|
|
193
|
+
self.setWindowTitle(self.tr(u'Screen Magnifier'))
|
|
194
|
+
self.resize(1040, 680)
|
|
195
|
+
self.setStyleSheet(APP_QSS)
|
|
196
|
+
# State.
|
|
197
|
+
self.__m_excludeSelf = bool(excludeSelf) # type: bool
|
|
198
|
+
self.__m_excluded = False # type: bool
|
|
199
|
+
self.__m_selecting = False # type: bool
|
|
200
|
+
self.__m_fitPending = False # type: bool
|
|
201
|
+
self.__m_lastFrames = 0 # type: int
|
|
202
|
+
self.__m_fpsClock = QElapsedTimer() # type: QElapsedTimer
|
|
203
|
+
self.__m_fpsClock.start()
|
|
204
|
+
self.__m_quitting = False # type: bool
|
|
205
|
+
self.__m_trayHintShown = False # type: bool
|
|
206
|
+
self.setWindowIcon(makeAppIcon())
|
|
207
|
+
QApplication.instance().setWindowIcon(self.windowIcon()) # Dialogs and every other window too.
|
|
208
|
+
# Components.
|
|
209
|
+
self.__m_upscaler = Upscaler(method=Upscaler.AIFast if Upscaler.hasSuperRes() else Upscaler.Lanczos,
|
|
210
|
+
sharpness=0.25, errorOccurred=self.onError, parent=self) # type: Upscaler
|
|
211
|
+
# Optional analysis server: upscaling / analysis can run on another computer.
|
|
212
|
+
self.__m_client = RemoteClient(parent=self) # type: RemoteClient
|
|
213
|
+
self.__m_remoteView = self.__m_client.processor('view', self.__m_upscaler.process)
|
|
214
|
+
self.__m_remoteLens = self.__m_client.processor('lens', self.__m_upscaler.process)
|
|
215
|
+
# Color detection and optional AI face detection (local worker thread or server).
|
|
216
|
+
self.__m_analysis = AnalysisController(client=self.__m_client, parent=self) # type: AnalysisController
|
|
217
|
+
self.__m_zoomerTargetBefore = None # type: int | None # restored when the face pointer stops
|
|
218
|
+
self.__m_facePointer = FacePointer(detector=self.__m_analysis.getFaceDetector(),
|
|
219
|
+
ignoreRects=self._facePointerIgnored, moveZoomer=self._moveZoomerTo,
|
|
220
|
+
parent=self) # type: FacePointer
|
|
221
|
+
self.__m_facePointer.enabledChanged.connect(self._onFacePointerToggled)
|
|
222
|
+
self.__m_view = MagnifierViewWidget(zoom=3.0, minZoom=0.25, maxZoom=32.0, processor=self._processView,
|
|
223
|
+
placeholderText=self.tr(PLACEHOLDER), zoomChanged=self.onZoomChanged,
|
|
224
|
+
pixelHovered=self.onPixelHovered) # type: MagnifierViewWidget
|
|
225
|
+
self.__m_grabber = ScreenGrabber(fps=30, frameReady=self.onFrame, captureFailed=self.onCaptureFailed,
|
|
226
|
+
parent=self) # type: ScreenGrabber
|
|
227
|
+
self.__m_selector = RegionSelector(regionSelected=self.onRegionSelected,
|
|
228
|
+
selectionCanceled=self.onSelectionCanceled) # type: RegionSelector
|
|
229
|
+
self.__m_panel = ControlPanel(view=self.__m_view, upscaler=self.__m_upscaler,
|
|
230
|
+
grabber=self.__m_grabber) # type: ControlPanel
|
|
231
|
+
self.__m_upscaler.methodChanged.connect(self.__m_view.refresh)
|
|
232
|
+
self.__m_upscaler.sharpnessChanged.connect(self.__m_view.refresh)
|
|
233
|
+
# In-advanced zoom lens: global hotkeys + click-through overlay, shares the upscaler.
|
|
234
|
+
self.__m_store = ShortcutStore(parent=self) # type: ShortcutStore # window shortcuts (registry)
|
|
235
|
+
self.__m_features = FeatureSettings(parent=self) # type: FeatureSettings # where zones are shown
|
|
236
|
+
self.__m_actions = {} # type: dict # shortcut name -> (QAction, tooltip)
|
|
237
|
+
self.__m_store.changed.connect(self._applyShortcut)
|
|
238
|
+
self.__m_game = AdvancedOverlayController(
|
|
239
|
+
processor=self._processLens, parent=self) # type: AdvancedOverlayController
|
|
240
|
+
self.__m_upscaler.methodChanged.connect(self.__m_game.getOverlay().refresh)
|
|
241
|
+
self.__m_upscaler.sharpnessChanged.connect(self.__m_game.getOverlay().refresh)
|
|
242
|
+
self.__m_view.installEventFilter(self)
|
|
243
|
+
self.setCentralWidget(self.__m_view)
|
|
244
|
+
self.__m_dock = QDockWidget(self.tr(u'Magnifier'), self) # type: QDockWidget
|
|
245
|
+
self.__m_dock.setObjectName('settingsDock')
|
|
246
|
+
self.__m_dock.setWidget(self.__m_panel)
|
|
247
|
+
self.__m_dock.setFeatures(QDockWidget.DockWidgetClosable | QDockWidget.DockWidgetMovable |
|
|
248
|
+
QDockWidget.DockWidgetFloatable)
|
|
249
|
+
self.addDockWidget(Qt.RightDockWidgetArea, self.__m_dock)
|
|
250
|
+
self.__m_gameDock = QDockWidget(self.tr(u'Zoomer'), self) # type: QDockWidget
|
|
251
|
+
self.__m_gameDock.setObjectName('gameDock')
|
|
252
|
+
self.__m_gameDock.setWidget(AdvancedOverlayPanel(controller=self.__m_game, features=self.__m_features))
|
|
253
|
+
self.__m_gameDock.setFeatures(self.__m_dock.features())
|
|
254
|
+
self.addDockWidget(Qt.RightDockWidgetArea, self.__m_gameDock)
|
|
255
|
+
self.tabifyDockWidget(self.__m_dock, self.__m_gameDock)
|
|
256
|
+
self.__m_detectPanel = DetectionPanel(controller=self.__m_analysis, features=self.__m_features,
|
|
257
|
+
facePointer=self.__m_facePointer,
|
|
258
|
+
hotkeyText=self.__m_game.getHotkey) # type: DetectionPanel
|
|
259
|
+
self.__m_serverPanel = ServerPanel(client=self.__m_client, analysis=self.__m_analysis,
|
|
260
|
+
upscaler=self.__m_upscaler) # type: ServerPanel
|
|
261
|
+
self.__m_colorPanel = ColorPickerPanel() # type: ColorPickerPanel
|
|
262
|
+
self.__m_colorDock = QDockWidget(self.tr(u'Colors'), self) # type: QDockWidget
|
|
263
|
+
self.__m_detectDock = QDockWidget(self.tr(u'Detection (Beta)'), self) # type: QDockWidget
|
|
264
|
+
self.__m_serverDock = QDockWidget(self.tr(u'Server'), self) # type: QDockWidget
|
|
265
|
+
self.__m_shortcutDock = QDockWidget(self.tr(u'Shortcuts'), self) # type: QDockWidget
|
|
266
|
+
for dock, name, panel in ((self.__m_colorDock, 'colorDock', self.__m_colorPanel),
|
|
267
|
+
(self.__m_detectDock, 'detectionDock', self.__m_detectPanel),
|
|
268
|
+
(self.__m_serverDock, 'serverDock', self.__m_serverPanel),
|
|
269
|
+
(self.__m_shortcutDock, 'shortcutDock',
|
|
270
|
+
ShortcutsPanel(store=self.__m_store, controller=self.__m_game))):
|
|
271
|
+
dock.setObjectName(name)
|
|
272
|
+
dock.setWidget(panel)
|
|
273
|
+
dock.setFeatures(self.__m_dock.features())
|
|
274
|
+
self.addDockWidget(Qt.RightDockWidgetArea, dock)
|
|
275
|
+
self.tabifyDockWidget(self.__m_dock, dock)
|
|
276
|
+
self.__m_dock.raise_()
|
|
277
|
+
self.__m_grabber.setIgnoreWidgets(self._dockWidgets())
|
|
278
|
+
self._buildToolBar()
|
|
279
|
+
self._buildStatusBar()
|
|
280
|
+
self._buildTray()
|
|
281
|
+
self.__m_game.overlayToggled.connect(self.onGameOverlayToggled)
|
|
282
|
+
self.__m_game.hotkeyTriggered.connect(self.onGameHotkey)
|
|
283
|
+
# Detection / server wiring.
|
|
284
|
+
self.__m_client.upscaleReady.connect(self._onRemoteResult)
|
|
285
|
+
self.__m_analysis.annotationsReady.connect(self._onAnnotations)
|
|
286
|
+
self.__m_view.pixelClicked.connect(self._onPixelClicked)
|
|
287
|
+
self.__m_view.colorPicked.connect(self._onColorPicked)
|
|
288
|
+
self.__m_view.pickHovered.connect(self._onPickHovered)
|
|
289
|
+
self.__m_view.setContextMenuPolicy(Qt.CustomContextMenu)
|
|
290
|
+
self.__m_view.customContextMenuRequested.connect(self._onViewMenu)
|
|
291
|
+
self.__m_colorPanel.colorCopied.connect(self._onColorCopied)
|
|
292
|
+
self.__m_colorPanel.notify.connect(self._notify)
|
|
293
|
+
self.__m_game.colorPickRequested.connect(self._onColorPickHotkey)
|
|
294
|
+
self.__m_game.screenPickRequested.connect(self._onScreenPick)
|
|
295
|
+
self.__m_game.message.connect(self._notify)
|
|
296
|
+
self.__m_game.pickerToggled.connect(lambda on: self._notify(self.tr(
|
|
297
|
+
u'Screen color picker: click anywhere to copy - right-click / Esc cancels - wheel zooms')) if on else None)
|
|
298
|
+
self._action(self.tr(u'Copy color code'), self.copyHoveredColor, 'copyHoveredColor',
|
|
299
|
+
tip=self.tr(u'Copy the color under the mouse in the magnifier'))
|
|
300
|
+
self.__m_game.getGrabber().frameReady.connect(self._onLensFrame)
|
|
301
|
+
self.__m_game.overlayToggled.connect(lambda shown: None if shown else self.__m_analysis.forget('lens'))
|
|
302
|
+
self.__m_features.changed.connect(self._onFeatureChanged)
|
|
303
|
+
QTimer.singleShot(0, self._fullTabNames)
|
|
304
|
+
self._fitPanels()
|
|
305
|
+
# One live color, one text: the Colors tab, the zoomer and the eyedropper share formatter and namer.
|
|
306
|
+
self.__m_mouseInView = False # type: bool
|
|
307
|
+
self.__m_pendingReadout = (QColor(), '') # type: tuple
|
|
308
|
+
self.__m_readoutTimer = QTimer(self) # type: QTimer
|
|
309
|
+
self.__m_readoutTimer.setSingleShot(True)
|
|
310
|
+
self.__m_readoutTimer.timeout.connect(self._applyZoomerReadout)
|
|
311
|
+
lens = self.__m_game.getOverlay()
|
|
312
|
+
lens.setColorFormatter(self.__m_colorPanel.formatCode)
|
|
313
|
+
lens.setColorNamer(self.__m_colorPanel.colorName)
|
|
314
|
+
self.__m_view.setColorFormatter(self.__m_colorPanel.formatCode)
|
|
315
|
+
lens.readoutChanged.connect(self._onZoomerReadout)
|
|
316
|
+
for dock in self._dockWidgets()[1:]:
|
|
317
|
+
dock.visibilityChanged.connect(lambda *a: QTimer.singleShot(0, self._syncPanelAction))
|
|
318
|
+
self.__m_colorPanel.optionsChanged.connect(self._syncLensReadout)
|
|
319
|
+
self._syncLensReadout()
|
|
320
|
+
self.__m_detectPanel.notify.connect(self._notify)
|
|
321
|
+
self.__m_serverPanel.notify.connect(self._notify)
|
|
322
|
+
self.__m_serverPanel.offloadChanged.connect(self._onOffloadChanged)
|
|
323
|
+
self.__m_statsTimer = QTimer(self) # type: QTimer
|
|
324
|
+
self.__m_statsTimer.timeout.connect(self._updateStats)
|
|
325
|
+
self.__m_statsTimer.start(500)
|
|
326
|
+
|
|
327
|
+
# ---------- Helpers ----------
|
|
328
|
+
def _action(self, text, slot, shortcut=None, checkable=False, tip=''):
|
|
329
|
+
"""
|
|
330
|
+
:param text: str | unicode | QString
|
|
331
|
+
:param slot: callable
|
|
332
|
+
:param shortcut: (str | None) Name of a window shortcut of the registry (shortcuts.py), editable in the
|
|
333
|
+
Shortcuts tab; None = no shortcut.
|
|
334
|
+
:param checkable: bool
|
|
335
|
+
:param tip: str | unicode | QString
|
|
336
|
+
:return: QAction
|
|
337
|
+
"""
|
|
338
|
+
act = QAction(text, self) # type: QAction
|
|
339
|
+
act.setCheckable(checkable)
|
|
340
|
+
act.setShortcutContext(Qt.WindowShortcut)
|
|
341
|
+
act.setToolTip(tip or text)
|
|
342
|
+
(act.toggled if checkable else act.triggered).connect(slot)
|
|
343
|
+
self.addAction(act)
|
|
344
|
+
if shortcut:
|
|
345
|
+
self.__m_actions[shortcut] = (act, tip or text)
|
|
346
|
+
self._applyShortcut(shortcut)
|
|
347
|
+
return act
|
|
348
|
+
|
|
349
|
+
@pyqtSlot('QString')
|
|
350
|
+
@pyqtSlot(str)
|
|
351
|
+
def _applyShortcut(self, name):
|
|
352
|
+
"""
|
|
353
|
+
(Re)apply a window shortcut after a change in the Shortcuts tab; the tooltip shows the keys.
|
|
354
|
+
:param name: str | unicode | QString
|
|
355
|
+
:return:
|
|
356
|
+
"""
|
|
357
|
+
entry = self.__m_actions.get(u'{}'.format(name))
|
|
358
|
+
if entry is None:
|
|
359
|
+
return
|
|
360
|
+
act, tip = entry
|
|
361
|
+
keys = self.__m_store.sequences(u'{}'.format(name)) # type: list
|
|
362
|
+
act.setShortcuts([QKeySequence(k) for k in keys])
|
|
363
|
+
act.setToolTip('{} ({})'.format(tip, ', '.join(QKeySequence(k).toString(QKeySequence.NativeText)
|
|
364
|
+
for k in keys)) if keys else tip)
|
|
365
|
+
|
|
366
|
+
def _buildToolBar(self):
|
|
367
|
+
"""
|
|
368
|
+
:return:
|
|
369
|
+
"""
|
|
370
|
+
tb = QToolBar(self.tr(u'Main'), self) # type: QToolBar
|
|
371
|
+
tb.setObjectName('mainToolBar')
|
|
372
|
+
tb.setMovable(False)
|
|
373
|
+
tb.setToolButtonStyle(Qt.ToolButtonTextOnly)
|
|
374
|
+
self.addToolBar(Qt.TopToolBarArea, tb)
|
|
375
|
+
self.__m_actSelect = self._action(self.tr(u'\u2b1a Region'), self.selectRegion, 'selectRegion',
|
|
376
|
+
tip=self.tr(u'Pick a screen region to magnify')) # type: QAction
|
|
377
|
+
self.__m_actFollow = self._action(self.tr(u'\u2316 Follow'), self.setFollowMode, 'followCursor', True,
|
|
378
|
+
self.tr(u'Magnify around the mouse pointer')) # type: QAction
|
|
379
|
+
self.__m_actFreeze = self._action(self.tr(u'\u2744 Freeze'), self.setFrozen, 'freeze', True,
|
|
380
|
+
self.tr(u'Pause live capture')) # type: QAction
|
|
381
|
+
actOut = self._action(self.tr(u'\u2212'), self.__m_view.zoomOut, 'viewZoomOut', tip=self.tr(u'Zoom out'))
|
|
382
|
+
actIn = self._action(self.tr(u'+'), self.__m_view.zoomIn, 'viewZoomIn', tip=self.tr(u'Zoom in'))
|
|
383
|
+
actFit = self._action(self.tr(u'Fit'), self.__m_view.fitToView, 'viewFit', tip=self.tr(u'Fit region'))
|
|
384
|
+
actSave = self._action(self.tr(u'Save\u2026'), self.saveSnapshot, 'saveSnapshot',
|
|
385
|
+
tip=self.tr(u'Save the upscaled region'))
|
|
386
|
+
actCopy = self._action(self.tr(u'Copy'), self.copySnapshot, 'copySnapshot',
|
|
387
|
+
tip=self.tr(u'Copy the upscaled region'))
|
|
388
|
+
actScreenPick = self._action(self.tr(u'Screen color picker'), lambda: self.__m_game.startColorPicker(),
|
|
389
|
+
'screenPickerWindow',
|
|
390
|
+
tip=self.tr(u'Screen color picker (Ctrl+Alt+P anywhere): live zoom at the mouse, '
|
|
391
|
+
'click anywhere on the screen to copy')) # type: QAction
|
|
392
|
+
self.__m_actPick = self._action(self.tr(u'Eyedropper on the magnifier'), self.setPickMode, 'eyedropper', True,
|
|
393
|
+
self.tr(u'Eyedropper: click the zoomed image to copy colors')) # type: QAction
|
|
394
|
+
self._action(self.tr(u'Stop picking'), lambda: self.__m_actPick.setChecked(False), 'stopEyedropper')
|
|
395
|
+
self.__m_actTop = self._action(self.tr(u'Pin on top'), self.setAlwaysOnTop, 'pinOnTop', True,
|
|
396
|
+
self.tr(u'Keep the magnifier above other windows')) # type: QAction
|
|
397
|
+
self.__m_actGame = self._action(self.tr(u'\u25ce Zoomer'), self.setGameOverlay, None, True,
|
|
398
|
+
self.tr(u'Show / hide the in-advanced zoom lens (global hotkey: {})').format(
|
|
399
|
+
self.__m_game.getHotkey('toggle') or '-')) # type: QAction
|
|
400
|
+
self.__m_actQuit = self._action(self.tr(u'Quit'), self.quitApp, 'quit',
|
|
401
|
+
tip=self.tr(u'Quit Screen Magnifier')) # type: QAction
|
|
402
|
+
settings = self._action(self.tr(u'\u2699 Panel'), self.setSidePanelVisible, 'toggleSidePanel', True,
|
|
403
|
+
tip=self.tr(u'Show / hide the side panel (every tab)')) # type: QAction
|
|
404
|
+
self.__m_actPanel = settings # type: QAction
|
|
405
|
+
settings.setChecked(True)
|
|
406
|
+
for a in (self.__m_actSelect, self.__m_actFollow, self.__m_actFreeze, None, actOut, actIn, actFit, None,
|
|
407
|
+
actSave, actCopy, 'pick', None, self.__m_actGame, self.__m_actTop, settings):
|
|
408
|
+
if a is None:
|
|
409
|
+
tb.addSeparator()
|
|
410
|
+
elif a == 'pick': # Both color pickers in one dropdown: a shorter toolbar.
|
|
411
|
+
pick = QToolButton() # type: QToolButton
|
|
412
|
+
pick.setText(self.tr(u'\u25c9 Pick'))
|
|
413
|
+
pick.setToolTip(self.tr(u'Color pickers'))
|
|
414
|
+
pick.setPopupMode(QToolButton.InstantPopup)
|
|
415
|
+
menu = QMenu(pick) # type: QMenu
|
|
416
|
+
menu.setToolTipsVisible(True)
|
|
417
|
+
menu.addAction(self.__m_actPick)
|
|
418
|
+
menu.addAction(actScreenPick)
|
|
419
|
+
pick.setMenu(menu)
|
|
420
|
+
tb.addWidget(pick)
|
|
421
|
+
else:
|
|
422
|
+
tb.addAction(a)
|
|
423
|
+
|
|
424
|
+
def _buildStatusBar(self):
|
|
425
|
+
"""
|
|
426
|
+
:return:
|
|
427
|
+
"""
|
|
428
|
+
self.__m_modeLabel = QLabel(self.tr(u'No region')) # type: QLabel
|
|
429
|
+
self.__m_pixelLabel = QLabel() # type: QLabel
|
|
430
|
+
self.__m_perfLabel = QLabel() # type: QLabel
|
|
431
|
+
sb = self.statusBar()
|
|
432
|
+
sb.addWidget(self.__m_modeLabel)
|
|
433
|
+
sb.addWidget(self.__m_pixelLabel, 1)
|
|
434
|
+
sb.addPermanentWidget(self.__m_perfLabel)
|
|
435
|
+
support = QToolButton() # type: QToolButton # Always visible: right end of the status bar.
|
|
436
|
+
support.setText(self.tr(u'\u2665 Support'))
|
|
437
|
+
support.setToolTip(self.tr(u'Support the project: make a donation'))
|
|
438
|
+
support.setAutoRaise(True)
|
|
439
|
+
support.setPopupMode(QToolButton.InstantPopup)
|
|
440
|
+
support.setMenu(self.supportMenu(support))
|
|
441
|
+
support.setStyleSheet('QToolButton { color: #F2557A; font-weight: bold; padding: 0 6px; } '
|
|
442
|
+
'QToolButton::menu-indicator { image: none; }')
|
|
443
|
+
language = QToolButton() # type: QToolButton # Interface language, next to Support.
|
|
444
|
+
language.setText('\U0001F310 ' + self.__m_languages.nativeName(self.__m_languages.getLanguage()))
|
|
445
|
+
language.setToolTip(self.tr(u'Interface language'))
|
|
446
|
+
language.setAutoRaise(True)
|
|
447
|
+
language.setPopupMode(QToolButton.InstantPopup)
|
|
448
|
+
language.setStyleSheet('QToolButton { padding: 0 6px; } QToolButton::menu-indicator { image: none; }')
|
|
449
|
+
language.setMenu(self.languageMenu(language))
|
|
450
|
+
self.statusBar().addPermanentWidget(language)
|
|
451
|
+
self.__m_langButton = language # type: QToolButton
|
|
452
|
+
self.statusBar().addPermanentWidget(support)
|
|
453
|
+
self.__m_actSupport = support # type: QToolButton
|
|
454
|
+
|
|
455
|
+
def _buildTray(self):
|
|
456
|
+
"""
|
|
457
|
+
System tray icon: keeps the app (and its global hotkeys) running while the window is hidden.
|
|
458
|
+
:return: None
|
|
459
|
+
"""
|
|
460
|
+
self.__m_tray = None # type: QSystemTrayIcon | None
|
|
461
|
+
if not QSystemTrayIcon.isSystemTrayAvailable():
|
|
462
|
+
return
|
|
463
|
+
menu = QMenu(self) # type: QMenu
|
|
464
|
+
menu.addAction(self.tr(u'Show magnifier'), self.showFromTray)
|
|
465
|
+
menu.addAction(self.__m_actGame)
|
|
466
|
+
menu.addSeparator()
|
|
467
|
+
menu.addMenu(self.supportMenu(menu))
|
|
468
|
+
menu.addSeparator()
|
|
469
|
+
menu.addAction(self.__m_actQuit)
|
|
470
|
+
self.__m_tray = QSystemTrayIcon(makeAppIcon(), self) # type: QSystemTrayIcon
|
|
471
|
+
self.__m_tray.setToolTip(self.tr(u'Screen Magnifier'))
|
|
472
|
+
self.__m_tray.setContextMenu(menu)
|
|
473
|
+
self.__m_tray.activated.connect(self.onTrayActivated)
|
|
474
|
+
self.__m_tray.show()
|
|
475
|
+
QApplication.instance().setQuitOnLastWindowClosed(False)
|
|
476
|
+
|
|
477
|
+
def hasTray(self):
|
|
478
|
+
"""
|
|
479
|
+
:return: bool
|
|
480
|
+
"""
|
|
481
|
+
return self.__m_tray is not None
|
|
482
|
+
|
|
483
|
+
def _updateFollowSize(self):
|
|
484
|
+
"""
|
|
485
|
+
In follow mode the capture is exactly what the view can show at the current zoom.
|
|
486
|
+
:return:
|
|
487
|
+
"""
|
|
488
|
+
z = self.__m_view.getZoom() # type: float
|
|
489
|
+
size = QSize(int(ceil(self.__m_view.width() / z)) + 1, int(ceil(self.__m_view.height() / z)) + 1)
|
|
490
|
+
self.__m_grabber.setFollowSize(size)
|
|
491
|
+
|
|
492
|
+
def _syncCapture(self):
|
|
493
|
+
"""
|
|
494
|
+
Run the grabber only when there is something to capture.
|
|
495
|
+
:return:
|
|
496
|
+
"""
|
|
497
|
+
want = not self.__m_selecting and not self.__m_actFreeze.isChecked() and self.isVisible() and \
|
|
498
|
+
not self.isMinimized() and (self.__m_grabber.isFollowCursor() or
|
|
499
|
+
not self.__m_grabber.getRegion().isEmpty()) # type: bool
|
|
500
|
+
self.__m_grabber.setActive(want)
|
|
501
|
+
self._updateModeLabel()
|
|
502
|
+
|
|
503
|
+
def _updateModeLabel(self):
|
|
504
|
+
"""
|
|
505
|
+
:return:
|
|
506
|
+
"""
|
|
507
|
+
if self.__m_grabber.isFollowCursor():
|
|
508
|
+
text = self.tr(u'Following cursor') # type: str
|
|
509
|
+
else:
|
|
510
|
+
r = self.__m_grabber.getRegion() # type: QRect
|
|
511
|
+
text = self.tr(u'No region') if r.isEmpty() else self.tr(u'Region {} \u00d7 {} at ({}, {})').format(
|
|
512
|
+
r.width(), r.height(), r.x(), r.y()) # type: str
|
|
513
|
+
if self.__m_actFreeze.isChecked():
|
|
514
|
+
text += self.tr(u' \u2022 frozen')
|
|
515
|
+
self.__m_modeLabel.setText(text)
|
|
516
|
+
|
|
517
|
+
def _restoreWindow(self):
|
|
518
|
+
"""
|
|
519
|
+
:return:
|
|
520
|
+
"""
|
|
521
|
+
self.__m_selecting = False # type: bool
|
|
522
|
+
self.show()
|
|
523
|
+
self.raise_()
|
|
524
|
+
self.activateWindow()
|
|
525
|
+
|
|
526
|
+
def _upscaledSnapshot(self):
|
|
527
|
+
"""
|
|
528
|
+
:return: (QImage) Whole current frame upscaled at the current magnification (longest side <= 8192 px).
|
|
529
|
+
"""
|
|
530
|
+
frame = self.__m_view.getFrame() # type: QImage
|
|
531
|
+
if frame.isNull():
|
|
532
|
+
return QImage()
|
|
533
|
+
z = min(self.__m_view.getZoom(), 8192.0 / max(frame.width(), frame.height())) # type: float
|
|
534
|
+
img = self.__m_upscaler.process(frame, QSize(max(1, int(frame.width() * z)), max(1, int(frame.height() * z))))
|
|
535
|
+
if self.__m_view.isInvertColors():
|
|
536
|
+
img = img.convertToFormat(QImage.Format_RGB32) # type: QImage
|
|
537
|
+
img.invertPixels()
|
|
538
|
+
return img
|
|
539
|
+
|
|
540
|
+
# ---------- Public API ----------
|
|
541
|
+
@pyqtSlot()
|
|
542
|
+
def selectRegion(self):
|
|
543
|
+
"""
|
|
544
|
+
Hide the magnifier, freeze the desktop and let the user drag a region.
|
|
545
|
+
:return:
|
|
546
|
+
"""
|
|
547
|
+
self.__m_selecting = True # type: bool
|
|
548
|
+
self._syncCapture()
|
|
549
|
+
self.hide()
|
|
550
|
+
QTimer.singleShot(250, self.__m_selector.start)
|
|
551
|
+
|
|
552
|
+
@pyqtSlot(QRect)
|
|
553
|
+
def onRegionSelected(self, rect):
|
|
554
|
+
"""
|
|
555
|
+
:param rect: QRect
|
|
556
|
+
:return:
|
|
557
|
+
"""
|
|
558
|
+
self.__m_grabber.setRegion(rect)
|
|
559
|
+
self.__m_fitPending = True # type: bool
|
|
560
|
+
self.__m_actFreeze.setChecked(False)
|
|
561
|
+
self.__m_actFollow.setChecked(False)
|
|
562
|
+
self._restoreWindow()
|
|
563
|
+
self._syncCapture()
|
|
564
|
+
|
|
565
|
+
@pyqtSlot()
|
|
566
|
+
def onSelectionCanceled(self):
|
|
567
|
+
"""
|
|
568
|
+
:return:
|
|
569
|
+
"""
|
|
570
|
+
self._restoreWindow()
|
|
571
|
+
self._syncCapture()
|
|
572
|
+
|
|
573
|
+
@pyqtSlot(bool)
|
|
574
|
+
@pyqtSlot(int)
|
|
575
|
+
def setFollowMode(self, on):
|
|
576
|
+
"""
|
|
577
|
+
:param on: bool
|
|
578
|
+
:return:
|
|
579
|
+
"""
|
|
580
|
+
self.__m_grabber.setFollowCursor(bool(on))
|
|
581
|
+
self.__m_view.setPanEnabled(not on)
|
|
582
|
+
if on:
|
|
583
|
+
self._updateFollowSize()
|
|
584
|
+
elif not self.__m_grabber.getRegion().isEmpty():
|
|
585
|
+
self.__m_fitPending = True # type: bool
|
|
586
|
+
else:
|
|
587
|
+
self.__m_view.clear()
|
|
588
|
+
self._syncCapture()
|
|
589
|
+
|
|
590
|
+
@pyqtSlot(bool)
|
|
591
|
+
@pyqtSlot(int)
|
|
592
|
+
def setFrozen(self, frozen):
|
|
593
|
+
"""
|
|
594
|
+
:param frozen: bool
|
|
595
|
+
:return:
|
|
596
|
+
"""
|
|
597
|
+
self._syncCapture()
|
|
598
|
+
|
|
599
|
+
@pyqtSlot(bool)
|
|
600
|
+
@pyqtSlot(int)
|
|
601
|
+
def setAlwaysOnTop(self, on):
|
|
602
|
+
"""
|
|
603
|
+
:param on: bool
|
|
604
|
+
:return:
|
|
605
|
+
"""
|
|
606
|
+
self.setWindowFlag(Qt.WindowStaysOnTopHint, bool(on))
|
|
607
|
+
self.show()
|
|
608
|
+
|
|
609
|
+
@pyqtSlot(bool)
|
|
610
|
+
@pyqtSlot(int)
|
|
611
|
+
def setGameOverlay(self, on):
|
|
612
|
+
"""
|
|
613
|
+
:param on: bool
|
|
614
|
+
:return:
|
|
615
|
+
"""
|
|
616
|
+
ov = self.__m_game.getOverlay()
|
|
617
|
+
if bool(on) != ov.isVisible():
|
|
618
|
+
self.__m_game.toggle()
|
|
619
|
+
|
|
620
|
+
@pyqtSlot(bool)
|
|
621
|
+
@pyqtSlot(int)
|
|
622
|
+
def onGameOverlayToggled(self, shown):
|
|
623
|
+
"""
|
|
624
|
+
:param shown: bool
|
|
625
|
+
:return:
|
|
626
|
+
"""
|
|
627
|
+
self.__m_actGame.blockSignals(True)
|
|
628
|
+
self.__m_actGame.setChecked(bool(shown))
|
|
629
|
+
self.__m_actGame.blockSignals(False)
|
|
630
|
+
|
|
631
|
+
@pyqtSlot('QString')
|
|
632
|
+
@pyqtSlot(str)
|
|
633
|
+
def onGameHotkey(self, name):
|
|
634
|
+
"""
|
|
635
|
+
:param name: str | unicode | QString
|
|
636
|
+
:return:
|
|
637
|
+
"""
|
|
638
|
+
if u'{}'.format(name) == 'facePointer':
|
|
639
|
+
self.__m_facePointer.toggle()
|
|
640
|
+
return
|
|
641
|
+
info = shortcutInfo('global', u'{}'.format(name)) # type: tuple | None
|
|
642
|
+
self.statusBar().showMessage(self.tr(u'Global hotkey: {}').format(self.tr(info[3]) if info else name), 1500)
|
|
643
|
+
|
|
644
|
+
@pyqtSlot()
|
|
645
|
+
def showFromTray(self):
|
|
646
|
+
"""
|
|
647
|
+
:return:
|
|
648
|
+
"""
|
|
649
|
+
self.showNormal()
|
|
650
|
+
self.raise_()
|
|
651
|
+
self.activateWindow()
|
|
652
|
+
|
|
653
|
+
@pyqtSlot(QSystemTrayIcon.ActivationReason)
|
|
654
|
+
def onTrayActivated(self, reason):
|
|
655
|
+
"""
|
|
656
|
+
:param reason: QSystemTrayIcon.ActivationReason
|
|
657
|
+
:return:
|
|
658
|
+
"""
|
|
659
|
+
if reason in (QSystemTrayIcon.Trigger, QSystemTrayIcon.DoubleClick):
|
|
660
|
+
if self.isVisible() and not self.isMinimized():
|
|
661
|
+
self.hide()
|
|
662
|
+
else:
|
|
663
|
+
self.showFromTray()
|
|
664
|
+
|
|
665
|
+
@pyqtSlot()
|
|
666
|
+
def _facePointerIgnored(self):
|
|
667
|
+
"""
|
|
668
|
+
:return: (list[QRect]) What the face pointer must not scan: this application's windows (a magnified face is
|
|
669
|
+
not a face to follow), and the zoomer lens unless screen capture does not see it anyway.
|
|
670
|
+
"""
|
|
671
|
+
lens = self.__m_game.getOverlay() # type: ZoomOverlay
|
|
672
|
+
rects = [] # type: list
|
|
673
|
+
for w in QApplication.topLevelWidgets():
|
|
674
|
+
if not w.isVisible() or w.isMinimized():
|
|
675
|
+
continue
|
|
676
|
+
if w is lens and lens.getCaptureStatus() == 'excluded':
|
|
677
|
+
continue # hidden from capture: the faces behind it are the real ones
|
|
678
|
+
rects.append(w.frameGeometry())
|
|
679
|
+
return rects
|
|
680
|
+
|
|
681
|
+
def _moveZoomerTo(self, point):
|
|
682
|
+
"""
|
|
683
|
+
The face pointer in 'Only the zoomer' mode: the zoomer magnifies the face, the mouse pointer stays still.
|
|
684
|
+
:param point: QPoint
|
|
685
|
+
:return:
|
|
686
|
+
"""
|
|
687
|
+
lens = self.__m_game.getOverlay() # type: ZoomOverlay
|
|
688
|
+
if lens.getTarget() != ZoomOverlay.Point:
|
|
689
|
+
if self.__m_zoomerTargetBefore is None:
|
|
690
|
+
self.__m_zoomerTargetBefore = int(lens.getTarget()) # type: int | None
|
|
691
|
+
self.__m_game.setTarget(ZoomOverlay.Point)
|
|
692
|
+
lens.setTargetPoint(point)
|
|
693
|
+
|
|
694
|
+
@pyqtSlot(bool)
|
|
695
|
+
@pyqtSlot(int)
|
|
696
|
+
def _onFacePointerToggled(self, enabled):
|
|
697
|
+
"""
|
|
698
|
+
:param enabled: bool
|
|
699
|
+
:return:
|
|
700
|
+
"""
|
|
701
|
+
if not enabled and self.__m_zoomerTargetBefore is not None:
|
|
702
|
+
self.__m_game.setTarget(self.__m_zoomerTargetBefore) # What the zoomer magnified before.
|
|
703
|
+
self.__m_zoomerTargetBefore = None
|
|
704
|
+
key = self.__m_game.getHotkey('facePointer') or '-' # type: str
|
|
705
|
+
self.statusBar().showMessage(self.tr(u'Face pointer on: move the mouse to take the control back ({} stops it).')
|
|
706
|
+
.format(key) if enabled else self.tr(u'Face pointer off.'), 4000)
|
|
707
|
+
|
|
708
|
+
def quitApp(self):
|
|
709
|
+
"""
|
|
710
|
+
:return:
|
|
711
|
+
"""
|
|
712
|
+
self.__m_facePointer.setEnabled(False)
|
|
713
|
+
self.__m_quitting = True # type: bool
|
|
714
|
+
self.close()
|
|
715
|
+
QApplication.instance().quit()
|
|
716
|
+
|
|
717
|
+
@pyqtSlot()
|
|
718
|
+
def saveSnapshot(self):
|
|
719
|
+
"""
|
|
720
|
+
:return:
|
|
721
|
+
"""
|
|
722
|
+
img = self._upscaledSnapshot() # type: QImage
|
|
723
|
+
if img.isNull():
|
|
724
|
+
self.statusBar().showMessage(self.tr(u'Nothing to save yet.'), 3000)
|
|
725
|
+
return
|
|
726
|
+
name = 'magnified_{}.png'.format(QDateTime.currentDateTime().toString('yyyyMMdd_HHmmss')) # type: str
|
|
727
|
+
res = QFileDialog.getSaveFileName(self, self.tr(u'Save upscaled image'), join(QDir.homePath(), name),
|
|
728
|
+
self.tr(u'PNG image (*.png);;JPEG image (*.jpg *.jpeg)'))
|
|
729
|
+
fileName = res[0] if isinstance(res, tuple) else res # type: str
|
|
730
|
+
if fileName:
|
|
731
|
+
ok = img.save(fileName) # type: bool
|
|
732
|
+
self.statusBar().showMessage(self.tr(u'Saved {} \u00d7 {} image to {}').format(
|
|
733
|
+
img.width(), img.height(), fileName) if ok else self.tr(u'Could not save {}').format(fileName), 5000)
|
|
734
|
+
|
|
735
|
+
@pyqtSlot()
|
|
736
|
+
def copySnapshot(self):
|
|
737
|
+
"""
|
|
738
|
+
:return:
|
|
739
|
+
"""
|
|
740
|
+
img = self._upscaledSnapshot() # type: QImage
|
|
741
|
+
if not img.isNull():
|
|
742
|
+
QApplication.clipboard().setImage(img)
|
|
743
|
+
self.statusBar().showMessage(self.tr(u'Copied {} \u00d7 {} image to the clipboard.').format(
|
|
744
|
+
img.width(), img.height()), 3000)
|
|
745
|
+
|
|
746
|
+
# ---------- Slots ----------
|
|
747
|
+
@pyqtSlot(QImage)
|
|
748
|
+
def onFrame(self, image):
|
|
749
|
+
"""
|
|
750
|
+
:param image: QImage
|
|
751
|
+
:return:
|
|
752
|
+
"""
|
|
753
|
+
origin, dpr = self.__m_grabber.getCaptureRect().topLeft(), self.__m_grabber.getDevicePixelRatio()
|
|
754
|
+
self.__m_view.setFrameOrigin(origin, dpr)
|
|
755
|
+
self.__m_view.setFrame(image)
|
|
756
|
+
if self.__m_features.get('zonesInMagnifier'):
|
|
757
|
+
self.__m_analysis.submit('view', image, origin, dpr)
|
|
758
|
+
if self.__m_fitPending and not self.__m_grabber.isFollowCursor():
|
|
759
|
+
self.__m_fitPending = False # type: bool
|
|
760
|
+
self.__m_view.fitToView()
|
|
761
|
+
|
|
762
|
+
@pyqtSlot(float)
|
|
763
|
+
@pyqtSlot(int)
|
|
764
|
+
def onZoomChanged(self, zoom):
|
|
765
|
+
"""
|
|
766
|
+
:param zoom: float | int
|
|
767
|
+
:return:
|
|
768
|
+
"""
|
|
769
|
+
if self.__m_grabber.isFollowCursor():
|
|
770
|
+
self._updateFollowSize()
|
|
771
|
+
|
|
772
|
+
@pyqtSlot(QPoint, QColor)
|
|
773
|
+
def onPixelHovered(self, pos, color):
|
|
774
|
+
"""
|
|
775
|
+
:param pos: QPoint
|
|
776
|
+
:param color: QColor
|
|
777
|
+
:return:
|
|
778
|
+
"""
|
|
779
|
+
if pos.x() >= 0 and color.isValid():
|
|
780
|
+
self.__m_mouseInView = True # type: bool
|
|
781
|
+
hovered = self._colorAtView(self.__m_view.mapFromGlobal(QCursor.pos())) # type: QColor
|
|
782
|
+
hovered = hovered if hovered.isValid() else self._sampleView(pos) # type: QColor
|
|
783
|
+
self.__m_colorPanel.setLiveColor(hovered, 'magnifier', self.__m_view.zoneAt(pos))
|
|
784
|
+
self.__m_view.setBubbleColor(hovered) # The eyedropper bubble shows the color that will be copied.
|
|
785
|
+
if pos.x() < 0 or not color.isValid():
|
|
786
|
+
self.__m_pixelLabel.setText('')
|
|
787
|
+
return
|
|
788
|
+
g = self.__m_grabber.mapToGlobal(pos) # type: QPoint
|
|
789
|
+
self.__m_pixelLabel.setText(self.tr(u'Screen ({}, {}) {} rgb({}, {}, {})').format(
|
|
790
|
+
g.x(), g.y(), color.name().upper(), color.red(), color.green(), color.blue()))
|
|
791
|
+
|
|
792
|
+
@pyqtSlot('QString')
|
|
793
|
+
@pyqtSlot(str)
|
|
794
|
+
def onCaptureFailed(self, message):
|
|
795
|
+
"""
|
|
796
|
+
:param message: str | unicode | QString
|
|
797
|
+
:return:
|
|
798
|
+
"""
|
|
799
|
+
self.statusBar().showMessage(message, 10000)
|
|
800
|
+
self.__m_view.setPlaceholderText(message)
|
|
801
|
+
|
|
802
|
+
@pyqtSlot('QString')
|
|
803
|
+
@pyqtSlot(str)
|
|
804
|
+
def onError(self, message):
|
|
805
|
+
"""
|
|
806
|
+
:param message: str | unicode | QString
|
|
807
|
+
:return:
|
|
808
|
+
"""
|
|
809
|
+
self.statusBar().showMessage(message, 8000)
|
|
810
|
+
|
|
811
|
+
@pyqtSlot()
|
|
812
|
+
def _updateStats(self):
|
|
813
|
+
"""
|
|
814
|
+
:return:
|
|
815
|
+
"""
|
|
816
|
+
frames = self.__m_grabber.getFrameCount() # type: int
|
|
817
|
+
secs = max(1e-3, self.__m_fpsClock.restart() / 1000.0) # type: float
|
|
818
|
+
fps = (frames - self.__m_lastFrames) / secs # type: float
|
|
819
|
+
self.__m_lastFrames = frames # type: int
|
|
820
|
+
up = self.__m_upscaler.getLastProcessTime() # type: float
|
|
821
|
+
self.__m_panel.showProcessTime(up)
|
|
822
|
+
self.__m_perfLabel.setText(self.tr(u'{:.0f} fps grab {:.1f} ms {} {:.1f} ms {:.2f}\u00d7').format(
|
|
823
|
+
fps if self.__m_grabber.isActive() else 0.0, self.__m_grabber.getLastGrabTime(),
|
|
824
|
+
self.tr(self.__m_upscaler.getMethodName()).split(' (')[0], up, self.__m_view.getZoom()))
|
|
825
|
+
|
|
826
|
+
# ---------- Color codes ----------
|
|
827
|
+
def _sampleView(self, pos):
|
|
828
|
+
"""
|
|
829
|
+
:param pos: (QPoint) Source pixel of the magnifier frame.
|
|
830
|
+
:return: (QColor) Averaged color (sample size of the Colors tab), invalid outside the frame.
|
|
831
|
+
"""
|
|
832
|
+
return sampleColor(self.__m_view.getFrame(), pos.x(), pos.y(), self.__m_colorPanel.getSampleSize())
|
|
833
|
+
|
|
834
|
+
def _colorAtView(self, pos):
|
|
835
|
+
"""
|
|
836
|
+
Color under a magnifier position, from the source chosen in the Colors tab.
|
|
837
|
+
:param pos: (QPoint) Widget position.
|
|
838
|
+
:return: QColor
|
|
839
|
+
"""
|
|
840
|
+
size = self.__m_colorPanel.getSampleSize() # type: int
|
|
841
|
+
if self.__m_colorPanel.getPickSource() == 'zoomed':
|
|
842
|
+
color = self.__m_view.displayedColorAt(pos, size) # type: QColor
|
|
843
|
+
if color.isValid():
|
|
844
|
+
return color
|
|
845
|
+
s = self.__m_view.mapToSource(QPointF(pos)) # type: QPointF
|
|
846
|
+
return self._sampleView(QPoint(int(floor(s.x())), int(floor(s.y()))))
|
|
847
|
+
|
|
848
|
+
@pyqtSlot(bool)
|
|
849
|
+
@pyqtSlot(int)
|
|
850
|
+
def setPickMode(self, on):
|
|
851
|
+
"""
|
|
852
|
+
Eyedropper on the zoomed image.
|
|
853
|
+
:param on: bool
|
|
854
|
+
:return:
|
|
855
|
+
"""
|
|
856
|
+
self.__m_view.setPickMode(bool(on))
|
|
857
|
+
if on:
|
|
858
|
+
self.__m_view.setFocus()
|
|
859
|
+
self.statusBar().showMessage(self.tr(u'Eyedropper: click the zoomed image to copy a color - Esc to stop'))
|
|
860
|
+
else:
|
|
861
|
+
self.statusBar().clearMessage()
|
|
862
|
+
|
|
863
|
+
@pyqtSlot(QPoint, QColor, QColor)
|
|
864
|
+
def _onColorPicked(self, pos, displayed, source):
|
|
865
|
+
"""
|
|
866
|
+
:param pos: QPoint
|
|
867
|
+
:param displayed: QColor
|
|
868
|
+
:param source: QColor
|
|
869
|
+
:return:
|
|
870
|
+
"""
|
|
871
|
+
self.__m_colorPanel.copyColor(self._colorAtView(self._viewPos(pos)))
|
|
872
|
+
|
|
873
|
+
def _viewPos(self, pixel):
|
|
874
|
+
"""
|
|
875
|
+
:param pixel: (QPoint) Source pixel of the magnifier frame.
|
|
876
|
+
:return: (QPoint) Widget position of that pixel's center (where it was clicked).
|
|
877
|
+
"""
|
|
878
|
+
p = self.__m_view.mapFromSource(QPointF(pixel.x() + 0.5, pixel.y() + 0.5)) # type: QPointF
|
|
879
|
+
return QPoint(int(floor(p.x())), int(floor(p.y())))
|
|
880
|
+
|
|
881
|
+
@pyqtSlot(QColor, QColor)
|
|
882
|
+
def _onPickHovered(self, displayed, source):
|
|
883
|
+
"""
|
|
884
|
+
:param displayed: QColor
|
|
885
|
+
:param source: QColor
|
|
886
|
+
:return:
|
|
887
|
+
"""
|
|
888
|
+
pos = self.__m_view.mapFromGlobal(QCursor.pos()) # type: QPoint
|
|
889
|
+
color = self._colorAtView(pos) # type: QColor
|
|
890
|
+
if color.isValid():
|
|
891
|
+
s = self.__m_view.mapToSource(QPointF(pos)) # type: QPointF
|
|
892
|
+
self.__m_colorPanel.setLiveColor(color, 'magnifier',
|
|
893
|
+
self.__m_view.zoneAt(QPoint(int(floor(s.x())), int(floor(s.y())))))
|
|
894
|
+
self.__m_view.setBubbleColor(color)
|
|
895
|
+
|
|
896
|
+
@pyqtSlot(QColor, 'QString')
|
|
897
|
+
def _onZoomerReadout(self, color, zone):
|
|
898
|
+
"""
|
|
899
|
+
The zoomer's color code changed: it becomes the live color of the Colors tab (screen color picker while it
|
|
900
|
+
runs; otherwise the zoomer, unless the mouse is over the magnifier). Coalesced to ~15 updates per second.
|
|
901
|
+
:param color: QColor
|
|
902
|
+
:param zone: str | unicode | QString
|
|
903
|
+
:return:
|
|
904
|
+
"""
|
|
905
|
+
self.__m_pendingReadout = (QColor(color), u'{}'.format(zone)) # type: tuple
|
|
906
|
+
if not self.__m_readoutTimer.isActive():
|
|
907
|
+
self.__m_readoutTimer.start(66)
|
|
908
|
+
|
|
909
|
+
@pyqtSlot()
|
|
910
|
+
def _applyZoomerReadout(self):
|
|
911
|
+
"""
|
|
912
|
+
:return:
|
|
913
|
+
"""
|
|
914
|
+
color, zone = self.__m_pendingReadout
|
|
915
|
+
lens = self.__m_game.getOverlay()
|
|
916
|
+
if self.__m_game.isColorPicking():
|
|
917
|
+
source = 'picker' # type: str
|
|
918
|
+
elif self.__m_mouseInView or not lens.isVisible() or not lens.isShowColorReadout():
|
|
919
|
+
return
|
|
920
|
+
else:
|
|
921
|
+
source = 'zoomer' # type: str
|
|
922
|
+
if color.isValid():
|
|
923
|
+
self.__m_colorPanel.setLiveColor(color, source, zone)
|
|
924
|
+
|
|
925
|
+
@pyqtSlot()
|
|
926
|
+
def copyHoveredColor(self):
|
|
927
|
+
"""
|
|
928
|
+
C key: copy the color under the mouse in the magnifier, in the default format.
|
|
929
|
+
:return:
|
|
930
|
+
"""
|
|
931
|
+
self.__m_colorPanel.copyColor()
|
|
932
|
+
|
|
933
|
+
@pyqtSlot(QPoint, QColor)
|
|
934
|
+
def _onPixelClicked(self, pos, color):
|
|
935
|
+
"""
|
|
936
|
+
A click (not a pan) in the magnifier: detection "Pick" mode first, else optional copy on click.
|
|
937
|
+
:param pos: QPoint
|
|
938
|
+
:param color: QColor
|
|
939
|
+
:return:
|
|
940
|
+
"""
|
|
941
|
+
if self.__m_detectPanel.isPicking():
|
|
942
|
+
refined = refinePick(self.__m_view.getFrame(), pos.x(), pos.y()) # type: QColor # anti-aliasing safe
|
|
943
|
+
self.__m_detectPanel.onPixelClicked(pos, refined if refined.isValid() else color)
|
|
944
|
+
elif self.__m_colorPanel.isCopyOnClick():
|
|
945
|
+
self.__m_colorPanel.copyColor(self._colorAtView(self._viewPos(pos)))
|
|
946
|
+
|
|
947
|
+
@pyqtSlot(QPoint)
|
|
948
|
+
def _onViewMenu(self, pos):
|
|
949
|
+
"""
|
|
950
|
+
Right-click in the magnifier: copy the color there in any format.
|
|
951
|
+
:param pos: (QPoint) Widget position.
|
|
952
|
+
:return:
|
|
953
|
+
"""
|
|
954
|
+
color = self._colorAtView(pos) # type: QColor
|
|
955
|
+
if color.isValid():
|
|
956
|
+
self.__m_colorPanel.setCurrentColor(color)
|
|
957
|
+
menu = self.__m_colorPanel.buildCopyMenu(color, self) # type: QMenu
|
|
958
|
+
(getattr(menu, 'exec_', None) or getattr(menu, 'exec'))(self.__m_view.mapToGlobal(pos))
|
|
959
|
+
|
|
960
|
+
@pyqtSlot()
|
|
961
|
+
def _onColorPickHotkey(self):
|
|
962
|
+
"""
|
|
963
|
+
"Copy the zoomer color code" hotkey (the zoomer is shown with its color code on): copies exactly the color
|
|
964
|
+
shown by the zoomer readout (same function, same pick source and sample size).
|
|
965
|
+
:return:
|
|
966
|
+
"""
|
|
967
|
+
lens = self.__m_game.getOverlay()
|
|
968
|
+
color = lens.readoutColor() # type: QColor
|
|
969
|
+
text = self.__m_colorPanel.copyColor(color) if color.isValid() else '' # type: str
|
|
970
|
+
if text:
|
|
971
|
+
lens.showToast(self.tr(u'{} copied').format(text), color)
|
|
972
|
+
|
|
973
|
+
@pyqtSlot(QPoint)
|
|
974
|
+
def _onScreenPick(self, pos):
|
|
975
|
+
"""
|
|
976
|
+
Screen color picker: copy the exact screen pixel at the click (fresh grab, not the lens frame).
|
|
977
|
+
:param pos: (QPoint) Global position.
|
|
978
|
+
:return:
|
|
979
|
+
"""
|
|
980
|
+
size = self.__m_colorPanel.getSampleSize() # type: int
|
|
981
|
+
image, dpr = ScreenGrabber.grabRect(QRect(pos.x() - size // 2, pos.y() - size // 2, size, size))
|
|
982
|
+
color = sampleColor(image, image.width() // 2, image.height() // 2, max(1, int(round(size * dpr))))
|
|
983
|
+
if not color.isValid():
|
|
984
|
+
color = self.__m_game.getOverlay().centerColor() # type: QColor
|
|
985
|
+
text = self.__m_colorPanel.copyColor(color) # type: str
|
|
986
|
+
if text:
|
|
987
|
+
self.__m_game.getOverlay().showToast(self.tr(u'{} copied').format(text), color)
|
|
988
|
+
self.__m_game.stopColorPicker(900)
|
|
989
|
+
|
|
990
|
+
@pyqtSlot(QColor, 'QString')
|
|
991
|
+
def _onColorCopied(self, color, text):
|
|
992
|
+
"""
|
|
993
|
+
:param color: QColor
|
|
994
|
+
:param text: str | unicode | QString
|
|
995
|
+
:return:
|
|
996
|
+
"""
|
|
997
|
+
if self.isVisible() and not self.isMinimized():
|
|
998
|
+
self.__m_view.showToast(self.tr(u'{} copied').format(text), color)
|
|
999
|
+
|
|
1000
|
+
# ---------- Detection / server wiring ----------
|
|
1001
|
+
def _dockWidgets(self):
|
|
1002
|
+
"""
|
|
1003
|
+
:return: (list[QWidget]) This window and its docks (ignored by follow-cursor capture).
|
|
1004
|
+
"""
|
|
1005
|
+
return [self, self.__m_dock, self.__m_gameDock, self.__m_colorDock, self.__m_detectDock, self.__m_serverDock,
|
|
1006
|
+
self.__m_shortcutDock]
|
|
1007
|
+
|
|
1008
|
+
def _processView(self, image, size):
|
|
1009
|
+
"""
|
|
1010
|
+
Magnifier processor: the server when offloading is on and connected, else the local upscaler.
|
|
1011
|
+
:param image: QImage
|
|
1012
|
+
:param size: QSize
|
|
1013
|
+
:return: QImage
|
|
1014
|
+
"""
|
|
1015
|
+
if self.__m_serverPanel.isOffloadView():
|
|
1016
|
+
return self.__m_remoteView(image, size)
|
|
1017
|
+
return self.__m_upscaler.process(image, size)
|
|
1018
|
+
|
|
1019
|
+
def _processLens(self, image, size):
|
|
1020
|
+
"""
|
|
1021
|
+
Zoomer (advanced zoom lens) processor.
|
|
1022
|
+
:param image: QImage
|
|
1023
|
+
:param size: QSize
|
|
1024
|
+
:return: QImage
|
|
1025
|
+
"""
|
|
1026
|
+
if self.__m_serverPanel.isOffloadLens():
|
|
1027
|
+
return self.__m_remoteLens(image, size)
|
|
1028
|
+
return self.__m_upscaler.process(image, size)
|
|
1029
|
+
|
|
1030
|
+
@pyqtSlot('QString')
|
|
1031
|
+
@pyqtSlot(str)
|
|
1032
|
+
def _onRemoteResult(self, channel):
|
|
1033
|
+
"""
|
|
1034
|
+
A server result arrived: repaint the consumer (it picks the result up from the client's cache).
|
|
1035
|
+
:param channel: str | unicode | QString
|
|
1036
|
+
:return:
|
|
1037
|
+
"""
|
|
1038
|
+
if u'{}'.format(channel) == 'view':
|
|
1039
|
+
self.__m_view.refresh()
|
|
1040
|
+
elif u'{}'.format(channel) == 'lens':
|
|
1041
|
+
self.__m_game.getOverlay().refresh()
|
|
1042
|
+
|
|
1043
|
+
@pyqtSlot()
|
|
1044
|
+
def _onOffloadChanged(self):
|
|
1045
|
+
"""
|
|
1046
|
+
:return:
|
|
1047
|
+
"""
|
|
1048
|
+
self.__m_view.refresh()
|
|
1049
|
+
self.__m_game.getOverlay().refresh()
|
|
1050
|
+
|
|
1051
|
+
@pyqtSlot('QString', object, object, object, object)
|
|
1052
|
+
def _onAnnotations(self, source, annotations, size, overlay, origin):
|
|
1053
|
+
"""
|
|
1054
|
+
:param source: str | unicode | QString
|
|
1055
|
+
:param annotations: list[dict]
|
|
1056
|
+
:param size: QSize
|
|
1057
|
+
:param overlay: QImage
|
|
1058
|
+
:param origin: (list | None) [x, y, dpr] screen position of the analysed frame.
|
|
1059
|
+
:return:
|
|
1060
|
+
"""
|
|
1061
|
+
target = self.__m_view if u'{}'.format(source) == 'view' else self.__m_game.getOverlay()
|
|
1062
|
+
target.setAnnotations(annotations, size if size is not None and size.isValid() else None, origin)
|
|
1063
|
+
target.setOverlayImage(overlay)
|
|
1064
|
+
|
|
1065
|
+
@pyqtSlot(QImage)
|
|
1066
|
+
def _onLensFrame(self, image):
|
|
1067
|
+
"""
|
|
1068
|
+
:param image: QImage
|
|
1069
|
+
:return:
|
|
1070
|
+
"""
|
|
1071
|
+
grabber = self.__m_game.getGrabber()
|
|
1072
|
+
origin, dpr = grabber.getCaptureRect().topLeft(), grabber.getDevicePixelRatio()
|
|
1073
|
+
self.__m_game.getOverlay().setFrameOrigin(origin, dpr)
|
|
1074
|
+
if self.__m_features.get('zonesInZoomer') and self.__m_game.getOverlay().isVisible():
|
|
1075
|
+
self.__m_analysis.submit('lens', image, origin, dpr)
|
|
1076
|
+
|
|
1077
|
+
def supportMenu(self, parent):
|
|
1078
|
+
"""
|
|
1079
|
+
"Support the project" menu: one entry per donation platform (support.py).
|
|
1080
|
+
:param parent: QWidget
|
|
1081
|
+
:return: QMenu
|
|
1082
|
+
"""
|
|
1083
|
+
menu = QMenu(self.tr(u'\u2665 Support the project'), parent) # type: QMenu
|
|
1084
|
+
for name, url in DONATION_LINKS:
|
|
1085
|
+
act = menu.addAction(self.tr(u'Donate with {}').format(name)) # type: QAction
|
|
1086
|
+
act.setToolTip(url)
|
|
1087
|
+
act.triggered.connect(lambda checked=False, u=url: self.openDonation(u))
|
|
1088
|
+
return menu
|
|
1089
|
+
|
|
1090
|
+
def languageMenu(self, parent):
|
|
1091
|
+
"""
|
|
1092
|
+
Interface languages: automatic (system language) or one of the catalogs.
|
|
1093
|
+
:param parent: QWidget
|
|
1094
|
+
:return: QMenu
|
|
1095
|
+
"""
|
|
1096
|
+
lm = self.__m_languages # type: LanguageManager
|
|
1097
|
+
menu = QMenu(parent) # type: QMenu
|
|
1098
|
+
group = QActionGroup(menu) # type: QActionGroup
|
|
1099
|
+
entries = [('auto', self.tr(u'Automatic ({})').format(lm.nativeName(lm.systemLanguage())))] # type: list
|
|
1100
|
+
entries += lm.availableLanguages()
|
|
1101
|
+
for i, (code, name) in enumerate(entries):
|
|
1102
|
+
act = menu.addAction(name) # type: QAction
|
|
1103
|
+
act.setCheckable(True)
|
|
1104
|
+
act.setChecked(code == lm.getRequestedLanguage())
|
|
1105
|
+
act.setData(code)
|
|
1106
|
+
group.addAction(act)
|
|
1107
|
+
act.triggered.connect(lambda checked=False, c=code: self.chooseLanguage(c))
|
|
1108
|
+
if i == 0:
|
|
1109
|
+
menu.addSeparator()
|
|
1110
|
+
return menu
|
|
1111
|
+
|
|
1112
|
+
def getLanguageManager(self):
|
|
1113
|
+
"""
|
|
1114
|
+
:return: LanguageManager
|
|
1115
|
+
"""
|
|
1116
|
+
return self.__m_languages
|
|
1117
|
+
|
|
1118
|
+
@pyqtSlot('QString')
|
|
1119
|
+
@pyqtSlot(str)
|
|
1120
|
+
def chooseLanguage(self, code):
|
|
1121
|
+
"""
|
|
1122
|
+
Save the interface language; it applies when the application restarts (offered right away).
|
|
1123
|
+
:param code: (str | unicode | QString) Language code or 'auto'.
|
|
1124
|
+
:return:
|
|
1125
|
+
"""
|
|
1126
|
+
lm = self.__m_languages # type: LanguageManager
|
|
1127
|
+
QSettings('ScreenMagnifier', 'General').setValue('language', u'{}'.format(code))
|
|
1128
|
+
if lm.resolve(code) == lm.getLanguage():
|
|
1129
|
+
return
|
|
1130
|
+
text = self.tr(RESTART_QUESTION) # type: str
|
|
1131
|
+
other = lm.translateIn(code, RESTART_QUESTION) # type: str # also in the language just chosen
|
|
1132
|
+
if other != text:
|
|
1133
|
+
text += '\n\n' + other
|
|
1134
|
+
box = QMessageBox(QMessageBox.Question, self.tr(u'Language'), text, QMessageBox.NoButton,
|
|
1135
|
+
self) # type: QMessageBox
|
|
1136
|
+
restart = box.addButton(self.tr(u'Restart now'), QMessageBox.AcceptRole)
|
|
1137
|
+
box.addButton(self.tr(u'Later'), QMessageBox.RejectRole)
|
|
1138
|
+
(getattr(box, 'exec_', None) or getattr(box, 'exec'))()
|
|
1139
|
+
if box.clickedButton() is restart:
|
|
1140
|
+
self.restartApplication()
|
|
1141
|
+
|
|
1142
|
+
@pyqtSlot()
|
|
1143
|
+
def restartApplication(self):
|
|
1144
|
+
"""
|
|
1145
|
+
Start a new instance (it waits until this one has exited), then quit.
|
|
1146
|
+
:return:
|
|
1147
|
+
"""
|
|
1148
|
+
from subprocess import Popen
|
|
1149
|
+
command, env = restartCommand(sys.argv, ('--wait-pid', u'{}'.format(getpid())))
|
|
1150
|
+
flags = {'creationflags': 0x00000008} if platform == 'win32' else {'start_new_session': True} # Detached.
|
|
1151
|
+
Popen(command, env=env, close_fds=True, **flags)
|
|
1152
|
+
self.quitApp()
|
|
1153
|
+
|
|
1154
|
+
@pyqtSlot('QString')
|
|
1155
|
+
@pyqtSlot(str)
|
|
1156
|
+
def openDonation(self, url):
|
|
1157
|
+
"""
|
|
1158
|
+
:param url: str | unicode | QString
|
|
1159
|
+
:return:
|
|
1160
|
+
"""
|
|
1161
|
+
if not QDesktopServices.openUrl(QUrl(u'{}'.format(url))):
|
|
1162
|
+
QApplication.clipboard().setText(u'{}'.format(url))
|
|
1163
|
+
self._notify(self.tr(u'Could not open a browser - the link was copied: {}').format(url))
|
|
1164
|
+
|
|
1165
|
+
def _fitPanels(self):
|
|
1166
|
+
"""
|
|
1167
|
+
Every side-panel tab fits any panel width, in every language (translations are often longer than English):
|
|
1168
|
+
descriptive labels wrap, combo boxes do not force their width (the list still shows full texts), and a
|
|
1169
|
+
horizontal scroll bar appears only if something still cannot shrink - nothing is ever cut off.
|
|
1170
|
+
:return:
|
|
1171
|
+
"""
|
|
1172
|
+
for dock in self._dockWidgets()[1:]:
|
|
1173
|
+
area = dock.widget()
|
|
1174
|
+
if not isinstance(area, QScrollArea) or area.widget() is None:
|
|
1175
|
+
continue
|
|
1176
|
+
area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
|
1177
|
+
for label in area.widget().findChildren(QLabel):
|
|
1178
|
+
image = label.pixmap() # None (PyQt5) or a null QPixmap (PyQt6) when the label shows text
|
|
1179
|
+
if label.property('role') in ('mono', 'big') or (image is not None and not image.isNull()):
|
|
1180
|
+
continue # Color codes stay on one line; images are not text.
|
|
1181
|
+
label.setWordWrap(True)
|
|
1182
|
+
for combo in area.widget().findChildren(QComboBox):
|
|
1183
|
+
combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
|
|
1184
|
+
combo.setMinimumContentsLength(10)
|
|
1185
|
+
QApplication.sendEvent(combo, QEvent(QEvent.StyleChange)) # QComboBox caches its minimum size
|
|
1186
|
+
combo.updateGeometry()
|
|
1187
|
+
for box in area.widget().findChildren(QCheckBox):
|
|
1188
|
+
if box.minimumSizeHint().width() > 220:
|
|
1189
|
+
self._wrapCheckBox(box)
|
|
1190
|
+
if hasattr(self, "resizeDocks"):
|
|
1191
|
+
self.resizeDocks([self.__m_dock], [440], Qt.Horizontal)
|
|
1192
|
+
else:
|
|
1193
|
+
self.__m_dock.resize(440, self.__m_dock.height())
|
|
1194
|
+
|
|
1195
|
+
@staticmethod
|
|
1196
|
+
def _wrapCheckBox(box):
|
|
1197
|
+
"""
|
|
1198
|
+
QCheckBox cannot wrap its text: move a long text into a word-wrapping label beside the box (clicking the
|
|
1199
|
+
label toggles it; enabled state and tooltip follow). The QCheckBox object, its signals and state are kept.
|
|
1200
|
+
:param box: QCheckBox
|
|
1201
|
+
:return: None
|
|
1202
|
+
"""
|
|
1203
|
+
layout = box.parentWidget().layout() if box.parentWidget() is not None else None
|
|
1204
|
+
index = layout.indexOf(box) if layout is not None else -1 # type: int
|
|
1205
|
+
if index < 0 or not isinstance(layout, (QVBoxLayout, QHBoxLayout)):
|
|
1206
|
+
return
|
|
1207
|
+
row = QWidget(box.parentWidget()) # type: QWidget
|
|
1208
|
+
line = QHBoxLayout(row) # type: QHBoxLayout
|
|
1209
|
+
line.setContentsMargins(0, 0, 0, 0)
|
|
1210
|
+
line.setSpacing(6)
|
|
1211
|
+
label = QLabel(box.text(), row) # type: QLabel
|
|
1212
|
+
label.setWordWrap(True)
|
|
1213
|
+
label.setToolTip(box.toolTip())
|
|
1214
|
+
label.setEnabled(box.isEnabled())
|
|
1215
|
+
link = CheckBoxLabelLink(box, label, parent=row) # type: CheckBoxLabelLink
|
|
1216
|
+
label.installEventFilter(link)
|
|
1217
|
+
box.installEventFilter(link)
|
|
1218
|
+
layout.insertWidget(index, row)
|
|
1219
|
+
box.setAccessibleName(box.text()) # screen readers still announce the check box by its text
|
|
1220
|
+
box.setProperty('fullText', box.text())
|
|
1221
|
+
box.setText('')
|
|
1222
|
+
line.addWidget(box, 0, Qt.AlignTop)
|
|
1223
|
+
line.addWidget(label, 1)
|
|
1224
|
+
|
|
1225
|
+
def _fullTabNames(self):
|
|
1226
|
+
"""
|
|
1227
|
+
Side panel tabs keep their full names ("Magnifier", not "M..."): the tab bar scrolls when they do not fit.
|
|
1228
|
+
:return:
|
|
1229
|
+
"""
|
|
1230
|
+
for bar in self.findChildren(QTabBar):
|
|
1231
|
+
bar.setElideMode(Qt.ElideNone)
|
|
1232
|
+
bar.setUsesScrollButtons(True)
|
|
1233
|
+
bar.setExpanding(False)
|
|
1234
|
+
|
|
1235
|
+
@pyqtSlot(bool)
|
|
1236
|
+
@pyqtSlot(int)
|
|
1237
|
+
def setSidePanelVisible(self, on):
|
|
1238
|
+
"""
|
|
1239
|
+
Show / hide the whole side panel (every tab).
|
|
1240
|
+
:param on: bool
|
|
1241
|
+
:return:
|
|
1242
|
+
"""
|
|
1243
|
+
for dock in self._dockWidgets()[1:]:
|
|
1244
|
+
dock.setVisible(bool(on))
|
|
1245
|
+
if on:
|
|
1246
|
+
self.__m_dock.raise_()
|
|
1247
|
+
if self.__m_actPanel.isChecked() != bool(on):
|
|
1248
|
+
self.__m_actPanel.blockSignals(True)
|
|
1249
|
+
self.__m_actPanel.setChecked(bool(on))
|
|
1250
|
+
self.__m_actPanel.blockSignals(False)
|
|
1251
|
+
|
|
1252
|
+
def _syncPanelAction(self):
|
|
1253
|
+
"""
|
|
1254
|
+
Docks closed / reopened by hand: the Panel button follows (checked while any tab is shown).
|
|
1255
|
+
:return:
|
|
1256
|
+
"""
|
|
1257
|
+
shown = any(d.isVisible() for d in self._dockWidgets()[1:]) # type: bool
|
|
1258
|
+
self.__m_actPanel.blockSignals(True)
|
|
1259
|
+
self.__m_actPanel.setChecked(shown)
|
|
1260
|
+
self.__m_actPanel.blockSignals(False)
|
|
1261
|
+
|
|
1262
|
+
def _onFeatureChanged(self, name, on):
|
|
1263
|
+
"""
|
|
1264
|
+
A "where are the zones shown" switch changed: switching one off clears its zones immediately.
|
|
1265
|
+
:param name: str | unicode | QString
|
|
1266
|
+
:param on: bool
|
|
1267
|
+
:return:
|
|
1268
|
+
"""
|
|
1269
|
+
source = {'zonesInMagnifier': 'view', 'zonesInZoomer': 'lens'}.get(u'{}'.format(name)) # type: str | None
|
|
1270
|
+
if source and not on:
|
|
1271
|
+
self.__m_analysis.forget(source)
|
|
1272
|
+
|
|
1273
|
+
def _syncLensReadout(self):
|
|
1274
|
+
"""
|
|
1275
|
+
The zoomer color code follows the Colors tab (pick source, sample size), so it always shows what is copied.
|
|
1276
|
+
:return:
|
|
1277
|
+
"""
|
|
1278
|
+
lens = self.__m_game.getOverlay()
|
|
1279
|
+
lens.setReadoutSource(self.__m_colorPanel.getPickSource())
|
|
1280
|
+
lens.setReadoutSample(self.__m_colorPanel.getSampleSize())
|
|
1281
|
+
lens.update() # the copy format may have changed: same text everywhere
|
|
1282
|
+
self.__m_view.update()
|
|
1283
|
+
|
|
1284
|
+
def _notify(self, message):
|
|
1285
|
+
"""
|
|
1286
|
+
Status bar message; also a tray balloon when the window is hidden (e.g. while gaming).
|
|
1287
|
+
:param message: str | unicode | QString
|
|
1288
|
+
:return:
|
|
1289
|
+
"""
|
|
1290
|
+
self.statusBar().showMessage(u'{}'.format(message), 4000)
|
|
1291
|
+
if self.__m_tray is not None and not self.isVisible():
|
|
1292
|
+
self.__m_tray.showMessage(
|
|
1293
|
+
self.tr(u'Screen Magnifier'), u'{}'.format(message), QSystemTrayIcon.Information, 2500)
|
|
1294
|
+
|
|
1295
|
+
# ---------- Qt overrides ----------
|
|
1296
|
+
def eventFilter(self, obj, e):
|
|
1297
|
+
"""
|
|
1298
|
+
:param obj: QObject
|
|
1299
|
+
:param e: QEvent
|
|
1300
|
+
:return: bool
|
|
1301
|
+
"""
|
|
1302
|
+
if obj is self.__m_view and e.type() == QEvent.Resize and self.__m_grabber.isFollowCursor():
|
|
1303
|
+
self._updateFollowSize()
|
|
1304
|
+
if obj is self.__m_view and e.type() in (QEvent.Enter, QEvent.Leave):
|
|
1305
|
+
self.__m_mouseInView = e.type() == QEvent.Enter # type: bool
|
|
1306
|
+
if not self.__m_mouseInView: # The live color goes back to the zoomer, if it shows its color code.
|
|
1307
|
+
lens = self.__m_game.getOverlay()
|
|
1308
|
+
self._onZoomerReadout(lens.readoutColor(), lens.zoneAtCrosshair())
|
|
1309
|
+
return super(MainWindow, self).eventFilter(obj, e)
|
|
1310
|
+
|
|
1311
|
+
def hideEvent(self, e):
|
|
1312
|
+
"""
|
|
1313
|
+
:param e: QHideEvent
|
|
1314
|
+
:return:
|
|
1315
|
+
"""
|
|
1316
|
+
super(MainWindow, self).hideEvent(e)
|
|
1317
|
+
self._syncCapture()
|
|
1318
|
+
|
|
1319
|
+
def changeEvent(self, e):
|
|
1320
|
+
"""
|
|
1321
|
+
:param e: QEvent
|
|
1322
|
+
:return:
|
|
1323
|
+
"""
|
|
1324
|
+
super(MainWindow, self).changeEvent(e)
|
|
1325
|
+
if e.type() == QEvent.WindowStateChange:
|
|
1326
|
+
self._syncCapture()
|
|
1327
|
+
|
|
1328
|
+
def showEvent(self, e):
|
|
1329
|
+
"""
|
|
1330
|
+
:param e: QShowEvent
|
|
1331
|
+
:return:
|
|
1332
|
+
"""
|
|
1333
|
+
super(MainWindow, self).showEvent(e)
|
|
1334
|
+
if not self.__m_selecting:
|
|
1335
|
+
QTimer.singleShot(0, self._syncCapture)
|
|
1336
|
+
if self.__m_excludeSelf:
|
|
1337
|
+
excluded = excludeFromCapture(self) # type: bool
|
|
1338
|
+
if excluded != self.__m_excluded:
|
|
1339
|
+
self.__m_excluded = excluded # type: bool
|
|
1340
|
+
# Invisible to capture: the magnifier may hover over what it magnifies.
|
|
1341
|
+
self.__m_grabber.setIgnoreWidgets([] if excluded else self._dockWidgets())
|
|
1342
|
+
|
|
1343
|
+
def closeEvent(self, e):
|
|
1344
|
+
"""
|
|
1345
|
+
Closing the window hides it to the tray (hotkeys keep working); Quit really exits.
|
|
1346
|
+
:param e: QCloseEvent
|
|
1347
|
+
:return: None
|
|
1348
|
+
"""
|
|
1349
|
+
if self.__m_tray is not None and not self.__m_quitting:
|
|
1350
|
+
e.ignore()
|
|
1351
|
+
self.hide()
|
|
1352
|
+
if not self.__m_trayHintShown:
|
|
1353
|
+
self.__m_trayHintShown = True # type: bool
|
|
1354
|
+
self.__m_tray.showMessage(self.tr(u'Screen Magnifier is still running'), self.tr(
|
|
1355
|
+
'Press {} in any app or game to toggle the zoom lens. Right-click the tray icon to quit.').format(
|
|
1356
|
+
self.__m_game.getHotkey(
|
|
1357
|
+
'toggle') or self.tr(u'The game-zoom hotkey')), QSystemTrayIcon.Information, 4000)
|
|
1358
|
+
return
|
|
1359
|
+
self.__m_game.shutdown()
|
|
1360
|
+
self.__m_analysis.shutdown()
|
|
1361
|
+
self.__m_client.disconnectFromServer()
|
|
1362
|
+
self.__m_serverPanel.stopLocalServer()
|
|
1363
|
+
if self.__m_tray is not None:
|
|
1364
|
+
self.__m_tray.hide()
|
|
1365
|
+
self.__m_grabber.stop()
|
|
1366
|
+
self.__m_statsTimer.stop()
|
|
1367
|
+
self.__m_selector.close()
|
|
1368
|
+
super(MainWindow, self).closeEvent(e)
|