eric6/UI/NotificationWidget.py

changeset 7996
ce1d288659ae
parent 7961
9a11cf4ca0d6
child 7997
2ca23396c25c
equal deleted inserted replaced
7995:d570d9aab754 7996:ce1d288659ae
133 self.setLayout(self.__layout) 133 self.setLayout(self.__layout)
134 134
135 self.__timeout = 5000 135 self.__timeout = 5000
136 self.__dragPosition = QPoint() 136 self.__dragPosition = QPoint()
137 self.__timers = {} 137 self.__timers = {}
138 self.__notifications = []
138 139
139 self.__settingPosition = setPosition 140 self.__settingPosition = setPosition
140 141
141 flags = ( 142 flags = (
142 Qt.Tool | 143 Qt.Tool |
169 @type int 170 @type int
170 """ 171 """
171 notificationFrame = NotificationFrame( 172 notificationFrame = NotificationFrame(
172 icon, heading, text, kind=kind, parent=self) 173 icon, heading, text, kind=kind, parent=self)
173 self.__layout.addWidget(notificationFrame) 174 self.__layout.addWidget(notificationFrame)
175 self.__notifications.append(notificationFrame)
174 176
175 self.show() 177 self.show()
176 178
177 self.__adjustSizeAndPosition() 179 self.__adjustSizeAndPosition()
178 180
179 if timeout: 181 if timeout:
180 timer = QTimer() 182 timer = QTimer()
181 self.__timers[repr(notificationFrame)] = timer 183 self.__timers[id(notificationFrame)] = timer
182 timer.setSingleShot(True) 184 timer.setSingleShot(True)
183 timer.timeout.connect( 185 timer.timeout.connect(
184 lambda: self.__removeNotification(notificationFrame) 186 lambda: self.__removeNotification(notificationFrame)
185 ) 187 )
186 timer.setInterval(timeout * 1000) 188 timer.setInterval(timeout * 1000)
223 @type NotificationFrame 225 @type NotificationFrame
224 """ 226 """
225 notification.hide() 227 notification.hide()
226 228
227 # delete timer of an auto close notification 229 # delete timer of an auto close notification
228 key = repr(notification) 230 key = id(notification)
229 if key in self.__timers: 231 if key in self.__timers:
230 self.__timers[key].stop() 232 self.__timers[key].stop()
231 del self.__timers[key] 233 del self.__timers[key]
232 234
233 # delete the notification 235 # delete the notification
234 index = self.__layout.indexOf(notification) 236 index = self.__layout.indexOf(notification)
235 self.__layout.takeAt(index) 237 self.__layout.takeAt(index)
238 self.__notifications.remove(notification)
236 notification.deleteLater() 239 notification.deleteLater()
237 240
238 if self.__layout.count(): 241 if self.__layout.count():
239 self.__adjustSizeAndPosition() 242 self.__adjustSizeAndPosition()
240 else: 243 else:

eric ide

mercurial