6 """ |
6 """ |
7 Module implementing a Notification widget. |
7 Module implementing a Notification widget. |
8 """ |
8 """ |
9 |
9 |
10 from enum import Enum |
10 from enum import Enum |
|
11 import contextlib |
11 |
12 |
12 from PyQt5.QtCore import Qt, QTimer, QPoint |
13 from PyQt5.QtCore import Qt, QTimer, QPoint |
13 from PyQt5.QtWidgets import QFrame, QWidget, QVBoxLayout |
14 from PyQt5.QtWidgets import QFrame, QWidget, QVBoxLayout |
14 |
15 |
15 from .Ui_NotificationFrame import Ui_NotificationFrame |
16 from .Ui_NotificationFrame import Ui_NotificationFrame |
235 del self.__timers[key] |
236 del self.__timers[key] |
236 |
237 |
237 # delete the notification |
238 # delete the notification |
238 index = self.__layout.indexOf(notification) |
239 index = self.__layout.indexOf(notification) |
239 self.__layout.takeAt(index) |
240 self.__layout.takeAt(index) |
240 try: |
241 with contextlib.suppress(ValueError): |
241 self.__notifications.remove(notification) |
242 self.__notifications.remove(notification) |
242 notification.deleteLater() |
243 notification.deleteLater() |
243 except ValueError: |
|
244 # it was already delete by other method; ignore |
|
245 pass |
|
246 |
244 |
247 if self.__layout.count(): |
245 if self.__layout.count(): |
248 self.__adjustSizeAndPosition() |
246 self.__adjustSizeAndPosition() |
249 else: |
247 else: |
250 self.hide() |
248 self.hide() |