From 21bd23cbf5ae05581882567d32a971e0501cb1bd Mon Sep 17 00:00:00 2001 From: Ye ShanShan Date: Tue, 15 Oct 2024 17:39:10 +0800 Subject: [PATCH] fix: bubble doesn't hide Remove doesn't work when the bubble isn't shown, NotifyItem isn't deleted. NotifyHeader is hide by ListView's item. Missing cursorShape when hovered link. task: https://pms.uniontech.com/task-view-365219.html --- panels/notification/bubble/bubblemodel.cpp | 8 +++++++- panels/notification/bubble/package/BubbleContent.qml | 5 +++++ panels/notification/center/NotifyCenter.qml | 1 + panels/notification/center/NotifyItemContent.qml | 5 +++++ panels/notification/center/NotifyView.qml | 1 + panels/notification/center/notifymodel.cpp | 2 ++ 6 files changed, 21 insertions(+), 1 deletion(-) diff --git a/panels/notification/bubble/bubblemodel.cpp b/panels/notification/bubble/bubblemodel.cpp index 8e3a6924c..693cf18de 100644 --- a/panels/notification/bubble/bubblemodel.cpp +++ b/panels/notification/bubble/bubblemodel.cpp @@ -91,9 +91,15 @@ QList BubbleModel::items() const void BubbleModel::remove(int index) { - if (index < 0 || index >= displayRowCount()) + if (index < 0 || index >= m_bubbles.size()) return; + if (index >= rowCount(QModelIndex())) { + auto bubble = m_bubbles.takeAt(index); + bubble->deleteLater(); + return; + } + beginRemoveRows(QModelIndex(), index, index); auto bubble = m_bubbles.takeAt(index); bubble->deleteLater(); diff --git a/panels/notification/bubble/package/BubbleContent.qml b/panels/notification/bubble/package/BubbleContent.qml index adbd584cd..9a01c4949 100644 --- a/panels/notification/bubble/package/BubbleContent.qml +++ b/panels/notification/bubble/package/BubbleContent.qml @@ -88,6 +88,7 @@ D.Control { // The third line: body and image RowLayout { Text { + id: bodyText visible: bubble.body !== "" Layout.alignment: Qt.AlignLeft Layout.rightMargin: 5 @@ -103,6 +104,10 @@ D.Control { console.log("Link actived", link) D.ApplicationHelper.openUrl(link) } + HoverHandler { + enabled: bodyText.hoveredLink !== "" + cursorShape: Qt.PointingHandCursor + } } Item { diff --git a/panels/notification/center/NotifyCenter.qml b/panels/notification/center/NotifyCenter.qml index a0bb0af6f..28f17bebf 100644 --- a/panels/notification/center/NotifyCenter.qml +++ b/panels/notification/center/NotifyCenter.qml @@ -31,6 +31,7 @@ FocusScope { height: 40 width: parent.width notifyModel: notifyModel + z: 1 } NotifyView { diff --git a/panels/notification/center/NotifyItemContent.qml b/panels/notification/center/NotifyItemContent.qml index 897675751..4e6b4cc50 100644 --- a/panels/notification/center/NotifyItemContent.qml +++ b/panels/notification/center/NotifyItemContent.qml @@ -182,6 +182,7 @@ NotifyItem { Layout.fillWidth: true Layout.alignment: Qt.AlignLeft | Qt.AlignTop Text { + id: bodyText Layout.alignment: Qt.AlignLeft Layout.fillWidth: true visible: text !== "" @@ -195,6 +196,10 @@ NotifyItem { onLinkActivated: function (link) { root.linkActivated(link) } + HoverHandler { + enabled: bodyText.hoveredLink !== "" + cursorShape: Qt.PointingHandCursor + } } Item { Layout.preferredHeight: 1 diff --git a/panels/notification/center/NotifyView.qml b/panels/notification/center/NotifyView.qml index aba9c7268..f5a93c641 100644 --- a/panels/notification/center/NotifyView.qml +++ b/panels/notification/center/NotifyView.qml @@ -23,6 +23,7 @@ Control { contentItem: ListView { id: view spacing: 10 + snapMode: ListView.SnapToItem // activeFocusOnTab: true ScrollBar.vertical: ScrollBar { } diff --git a/panels/notification/center/notifymodel.cpp b/panels/notification/center/notifymodel.cpp index 92c5b20d8..6b4e8ed8e 100644 --- a/panels/notification/center/notifymodel.cpp +++ b/panels/notification/center/notifymodel.cpp @@ -103,11 +103,13 @@ void NotifyModel::collapseApp(int row) beginRemoveRows(QModelIndex(), start, start + notifies.size()); // remove group m_appNotifies.removeOne(notify); + notify->deleteLater(); // remove normal for (int i = 0; i < notifies.size(); i++) { auto item = notifies[i]; m_appNotifies.removeOne(item); + item->deleteLater(); } endRemoveRows();