Skip to content

Commit e3e8c8b

Browse files
committed
Fix bugs in notification
1 parent 39129e8 commit e3e8c8b

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/libs/application/uishell/src/BubbleNotificationHandle.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef UISHELL_BUBBLENOTIFICATIONHANDLE_H
22
#define UISHELL_BUBBLENOTIFICATIONHANDLE_H
33

4+
#include <QDateTime>
45
#include <QObject>
56

67
#include <SVSCraftCore/SVSCraftNamespace.h>
@@ -22,6 +23,7 @@ namespace UIShell {
2223
Q_PROPERTY(bool progressAbortable READ progressAbortable NOTIFY progressAbortableChanged)
2324
Q_PROPERTY(bool permanentlyHideable READ permanentlyHideable NOTIFY permanentlyHideableChanged)
2425
Q_PROPERTY(int textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
26+
Q_PROPERTY(QDateTime time READ time NOTIFY timeChanged)
2527

2628
public:
2729
inline explicit BubbleNotificationHandle(QObject *parent = nullptr) : QObject(parent) {
@@ -119,6 +121,14 @@ namespace UIShell {
119121
}
120122
}
121123

124+
inline QDateTime time() const { return m_time; }
125+
inline void setTime(const QDateTime &time) {
126+
if (m_time != time) {
127+
m_time = time;
128+
emit timeChanged();
129+
}
130+
}
131+
122132
signals:
123133
void titleChanged();
124134
void textChanged();
@@ -131,6 +141,7 @@ namespace UIShell {
131141
void progressAbortableChanged();
132142
void permanentlyHideableChanged();
133143
void textFormatChanged();
144+
void timeChanged();
134145

135146
void hideClicked();
136147
void closeClicked();
@@ -153,6 +164,7 @@ namespace UIShell {
153164
bool m_progressAbortable{};
154165
bool m_permanentlyHideable{};
155166
int m_textFormat{Qt::AutoText};
167+
QDateTime m_time{};
156168
};
157169

158170
}

src/plugins/coreplugin/internal/notification/NotificationManager.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ namespace Core::Internal {
7777
connect(handle, &UIShell::BubbleNotificationHandle::closeClicked, this, removeMessage);
7878
connect(handle, &QObject::destroyed, this, removeMessage);
7979

80+
handle->setTime(QDateTime::currentDateTime());
81+
8082
if (mode != ProjectWindowInterface::DoNotShowBubble) {
8183
m_bubbleMessages.append(message);
8284
}

src/plugins/coreplugin/qml/panels/NotificationsPanel.qml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ QtObject {
5353
Connections {
5454
target: d.notificationManager
5555
function onMessageAdded(index, message) {
56-
notificationItemsModel.insert(index, bubbleNotificationComponent.createObject(pane, {
56+
let i = notificationItemsModel.count - index
57+
notificationItemsModel.insert(i, bubbleNotificationComponent.createObject(pane, {
5758
handle: message.handle
5859
}))
5960
}
6061
function onMessageRemoved(index, message) {
61-
let o = notificationItemsModel.get(index)
62-
notificationItemsModel.remove(index)
62+
let i = notificationItemsModel.count - index - 1
63+
let o = notificationItemsModel.get(i)
64+
notificationItemsModel.remove(i)
6365
o.destroy()
6466
}
6567
}

0 commit comments

Comments
 (0)