7
7
from typing import Any ,override
8
8
from uuid import UUID
9
9
10
- from PyQt6 .QtCore import Qt ,QThread ,QTimer ,pyqtSlot # pyright: ignore [reportUnknownVariableType]
11
- from PyQt6 .QtGui import QGuiApplication ,QShowEvent
10
+ from PyQt6 .QtCore import (
11
+ Qt ,
12
+ QThread ,
13
+ QTimer ,
14
+ pyqtSlot ,# pyright: ignore [reportUnknownVariableType]
15
+ )
16
+ from PyQt6 .QtGui import QShowEvent
12
17
from PyQt6 .QtWidgets import (
13
18
QApplication ,
14
19
QHBoxLayout ,
@@ -73,9 +78,8 @@ def get_client_instance(cls):
73
78
if cls ._instance is None :
74
79
cls ._instance = TrayMonitor ()
75
80
cls ._thread = TrayMonitorThread (cls ._instance )
76
- cls ._thread .start ()
77
81
78
- return cls ._instance
82
+ return cls ._instance , cls . _thread
79
83
80
84
def __init__ (
81
85
self ,
@@ -89,7 +93,7 @@ def __init__(
89
93
show_battery :bool ,
90
94
show_volume :bool ,
91
95
):
92
- super ().__init__ (class_name = class_name )#pyright : ignore [reportArgumentType]
96
+ super ().__init__ (class_name = class_name )#type : ignore
93
97
self .label_collapsed = label_collapsed
94
98
self .label_expanded = label_expanded
95
99
self .label_position = label_position if label_position in {"left" ,"right" }else "left"
@@ -117,16 +121,16 @@ def __init__(
117
121
118
122
# This timer will check if icons are still valid and have actual process attached
119
123
self .icon_check_timer = QTimer (self )
120
- self .icon_check_timer .timeout .connect (self .check_icons )#pyright : ignore [reportUnknownMemberType]
124
+ self .icon_check_timer .timeout .connect (self .check_icons )#type : ignore
121
125
self .icon_check_timer .start (5000 )
122
126
123
127
self .sort_timer = QTimer (self )
124
- self .sort_timer .timeout .connect (self .sort_icons )#pyright : ignore [reportUnknownMemberType]
128
+ self .sort_timer .timeout .connect (self .sort_icons )#type : ignore
125
129
self .sort_timer .setSingleShot (True )
126
130
127
131
self .unpinned_vis_btn = QPushButton ()
128
132
self .unpinned_vis_btn .setCheckable (True )
129
- self .unpinned_vis_btn .clicked .connect (self .toggle_unpinned_widget_visibility )#pyright : ignore [reportUnknownMemberType]
133
+ self .unpinned_vis_btn .clicked .connect (self .toggle_unpinned_widget_visibility )#type : ignore
130
134
131
135
self .unpinned_widget = DropWidget (self )
132
136
self .unpinned_layout = self .unpinned_widget .main_layout
@@ -140,10 +144,10 @@ def __init__(
140
144
self .unpinned_widget .setProperty ("class" ,"unpinned-container" )
141
145
self .unpinned_vis_btn .setProperty ("class" ,"unpinned-visibility-btn" )
142
146
143
- self .unpinned_widget .drag_started .connect (self .on_drag_started )#pyright : ignore [reportUnknownMemberType]
144
- self .unpinned_widget .drag_ended .connect (self .on_drag_ended )#pyright : ignore [reportUnknownMemberType]
145
- self .pinned_widget .drag_started .connect (self .on_drag_started )#pyright : ignore [reportUnknownMemberType]
146
- self .pinned_widget .drag_ended .connect (self .on_drag_ended )#pyright : ignore [reportUnknownMemberType]
147
+ self .unpinned_widget .drag_started .connect (self .on_drag_started )#type : ignore
148
+ self .unpinned_widget .drag_ended .connect (self .on_drag_ended )#type : ignore
149
+ self .pinned_widget .drag_started .connect (self .on_drag_started )#type : ignore
150
+ self .pinned_widget .drag_ended .connect (self .on_drag_ended )#type : ignore
147
151
148
152
self .widget_layout .addWidget (self .unpinned_widget )
149
153
self .widget_layout .addWidget (self .pinned_widget )
@@ -152,22 +156,25 @@ def __init__(
152
156
self .widget_layout .insertWidget (0 ,self .unpinned_vis_btn )
153
157
else :
154
158
self .widget_layout .insertWidget (- 1 ,self .unpinned_vis_btn )
155
-
159
+
156
160
QTimer .singleShot (0 ,self .setup_client )# pyright: ignore [reportUnknownMemberType]
157
161
158
162
def setup_client (self ):
159
163
"""Setup the tray monitor client and connect signals"""
160
164
self .load_state ()
161
- client = SystrayWidget .get_client_instance ()
162
- client .icon_modified .connect (self .on_icon_modified )#pyright : ignore [reportUnknownMemberType]
163
- client .icon_deleted .connect (self .on_icon_deleted )#pyright : ignore [reportUnknownMemberType]
165
+ client , thread = SystrayWidget .get_client_instance ()
166
+ client .icon_modified .connect (self .on_icon_modified )#type : ignore
167
+ client .icon_deleted .connect (self .on_icon_deleted )#type : ignore
164
168
165
169
app_inst = QApplication .instance ()
166
170
if app_inst is not None :
167
- app_inst .aboutToQuit .connect (self .save_state )# pyright: ignore [reportUnknownMemberType]
171
+ app_inst .aboutToQuit .connect (self .save_state )# type: ignore
172
+
173
+ if thread is not None and not thread .isRunning ():
174
+ thread .start ()
168
175
169
176
# We need to send this message for each instance of the taskbar widget on init
170
- client .send_taskbar_created ()
177
+ QTimer . singleShot ( 200 , client .send_taskbar_created ) # pyright: ignore [reportUnknownMemberType]
171
178
172
179
@override
173
180
def showEvent (self ,a0 :QShowEvent | None )-> None :
@@ -177,19 +184,19 @@ def showEvent(self, a0: QShowEvent | None) -> None:
177
184
self .unpinned_vis_btn .setText (self .label_expanded if self .show_unpinned else self .label_collapsed )
178
185
self .unpinned_widget .setVisible (self .show_unpinned )
179
186
180
- @pyqtSlot ()# pyright: ignore [reportUntypedFunctionDecorator]
187
+ @pyqtSlot ()
181
188
def on_drag_started (self ):
182
189
"""Handle drag started signal for drag-and-drop functionality"""
183
190
# Always show pinned widget during drag operations
184
191
self .update_pinned_widget_visibility (force_show = True )
185
192
186
- @pyqtSlot ()# pyright: ignore [reportUntypedFunctionDecorator]
193
+ @pyqtSlot ()
187
194
def on_drag_ended (self ):
188
195
"""Handle drag ended signal for drag-and-drop functionality"""
189
196
# Update visibility based on content
190
197
self .update_pinned_widget_visibility ()
191
198
192
- @pyqtSlot (IconData )# pyright: ignore [reportUntypedFunctionDecorator]
199
+ @pyqtSlot (IconData )
193
200
def on_icon_modified (self ,data :IconData ):
194
201
"""Handle icon modified signal sent by the tray monitor"""
195
202
if data .guid in self .filtered_guids :
@@ -198,8 +205,8 @@ def on_icon_modified(self, data: IconData):
198
205
if icon is None :
199
206
icon = IconWidget ()
200
207
icon .data = IconData ()
201
- icon .pinned_changed .connect (self .on_icon_pinned_changed )#pyright : ignore [reportUnknownMemberType]
202
- icon .icon_moved .connect (self .on_icon_moved )#pyright : ignore [reportUnknownMemberType]
208
+ icon .pinned_changed .connect (self .on_icon_pinned_changed )#type : ignore
209
+ icon .icon_moved .connect (self .on_icon_moved )#type : ignore
203
210
self .icons .append (icon )
204
211
205
212
# Check if the saved data exists for the icon by uuid and exe path
@@ -226,16 +233,16 @@ def on_icon_modified(self, data: IconData):
226
233
icon .setHidden (data .uFlags & NIF_STATE != 0 and data .dwState == 1 )
227
234
self .update_pinned_widget_visibility ()
228
235
229
- @pyqtSlot (IconData )# pyright: ignore [reportUntypedFunctionDecorator]
230
- def on_icon_deleted (self ,data :IconData ):
236
+ @pyqtSlot (IconData )
237
+ def on_icon_deleted (self ,data :IconData )-> None :
231
238
"""Handles the icon deleted signal sent by the tray monitor"""
232
239
icon = self .find_icon (data .guid ,data .hWnd ,data .uID )
233
240
if icon is not None :
234
241
self .icons .remove (icon )
235
242
icon .deleteLater ()
236
243
self .update_pinned_widget_visibility ()
237
244
238
- @pyqtSlot (object )# pyright: ignore [reportUntypedFunctionDecorator]
245
+ @pyqtSlot (object )
239
246
def on_icon_pinned_changed (self ,icon :IconWidget ):
240
247
"""Handles the icon pinned changed signal sent when user [Mod]+Clicks on the icon"""
241
248
if icon .parent ()is self .unpinned_widget :
@@ -253,7 +260,7 @@ def on_icon_pinned_changed(self, icon: IconWidget):
253
260
self .save_state ()
254
261
self .update_pinned_widget_visibility ()
255
262
256
- @pyqtSlot (object )# pyright: ignore [reportUntypedFunctionDecorator]
263
+ @pyqtSlot (object )
257
264
def on_icon_moved (self ,icon :IconWidget ):
258
265
"""Handle icon moved signal"""
259
266
if icon .parent ()is self .unpinned_widget :