eric6/UI/NotificationWidget.py

changeset 8143
2c730d5fd177
parent 7997
2ca23396c25c
child 8154
5f4b02eefc32
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
53 """ 53 """
54 super(NotificationFrame, self).__init__(parent) 54 super(NotificationFrame, self).__init__(parent)
55 self.setupUi(self) 55 self.setupUi(self)
56 56
57 self.layout().setAlignment( 57 self.layout().setAlignment(
58 self.verticalLayout, Qt.AlignLeft | Qt.AlignVCenter) 58 self.verticalLayout,
59 Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter
60 )
59 61
60 self.setStyleSheet(NotificationFrame.getStyleSheet(kind)) 62 self.setStyleSheet(NotificationFrame.getStyleSheet(kind))
61 63
62 if icon is None: 64 if icon is None:
63 icon = NotificationFrame.getIcon(kind) 65 icon = NotificationFrame.getIcon(kind)
138 self.__notifications = [] 140 self.__notifications = []
139 141
140 self.__settingPosition = setPosition 142 self.__settingPosition = setPosition
141 143
142 flags = ( 144 flags = (
143 Qt.Tool | 145 Qt.WindowType.Tool |
144 Qt.FramelessWindowHint | 146 Qt.WindowType.FramelessWindowHint |
145 Qt.WindowStaysOnTopHint | 147 Qt.WindowType.WindowStaysOnTopHint |
146 Qt.X11BypassWindowManagerHint 148 Qt.WindowType.X11BypassWindowManagerHint
147 ) 149 )
148 if Globals.isWindowsPlatform(): 150 if Globals.isWindowsPlatform():
149 flags |= Qt.ToolTip 151 flags |= Qt.WindowType.ToolTip
150 self.setWindowFlags(flags) 152 self.setWindowFlags(flags)
151 153
152 if self.__settingPosition: 154 if self.__settingPosition:
153 self.setCursor(Qt.OpenHandCursor) 155 self.setCursor(Qt.CursorShape.OpenHandCursor)
154 156
155 def showNotification(self, icon, heading, text, 157 def showNotification(self, icon, heading, text,
156 kind=NotificationTypes.Information, timeout=0): 158 kind=NotificationTypes.Information, timeout=0):
157 """ 159 """
158 Public method to show a notification. 160 Public method to show a notification.
257 clickedLabel = self.childAt(evt.pos()) 259 clickedLabel = self.childAt(evt.pos())
258 clickedNotification = clickedLabel.parent() 260 clickedNotification = clickedLabel.parent()
259 self.__removeNotification(clickedNotification) 261 self.__removeNotification(clickedNotification)
260 return 262 return
261 263
262 if evt.button() == Qt.LeftButton: 264 if evt.button() == Qt.MouseButton.LeftButton:
263 self.__dragPosition = ( 265 self.__dragPosition = (
264 evt.globalPos() - self.frameGeometry().topLeft() 266 evt.globalPos() - self.frameGeometry().topLeft()
265 ) 267 )
266 self.setCursor(Qt.ClosedHandCursor) 268 self.setCursor(Qt.CursorShape.ClosedHandCursor)
267 evt.accept() 269 evt.accept()
268 270
269 def mouseReleaseEvent(self, evt): 271 def mouseReleaseEvent(self, evt):
270 """ 272 """
271 Protected method to handle releases of a mouse button. 273 Protected method to handle releases of a mouse button.
272 274
273 @param evt reference to the mouse event (QMouseEvent) 275 @param evt reference to the mouse event (QMouseEvent)
274 """ 276 """
275 if self.__settingPosition and evt.button() == Qt.LeftButton: 277 if (
276 self.setCursor(Qt.OpenHandCursor) 278 self.__settingPosition and
279 evt.button() == Qt.MouseButton.LeftButton
280 ):
281 self.setCursor(Qt.CursorShape.OpenHandCursor)
277 282
278 def mouseMoveEvent(self, evt): 283 def mouseMoveEvent(self, evt):
279 """ 284 """
280 Protected method to handle dragging the window. 285 Protected method to handle dragging the window.
281 286
282 @param evt reference to the mouse event (QMouseEvent) 287 @param evt reference to the mouse event (QMouseEvent)
283 """ 288 """
284 if evt.buttons() & Qt.LeftButton: 289 if evt.buttons() & Qt.MouseButton.LeftButton:
285 self.move(evt.globalPos() - self.__dragPosition) 290 self.move(evt.globalPos() - self.__dragPosition)
286 evt.accept() 291 evt.accept()

eric ide

mercurial