Page MenuHomePhorge

D42.1732489243.diff
No OneTemporary

Size
9 KB
Referenced Files
None
Subscribers
None

D42.1732489243.diff

diff --git a/src/contents/ui/AddStickerPopup.qml b/src/contents/ui/AddStickerPopup.qml
--- a/src/contents/ui/AddStickerPopup.qml
+++ b/src/contents/ui/AddStickerPopup.qml
@@ -13,7 +13,7 @@
import '.' as Kazv
-Kirigami.OverlaySheet {
+Kazv.SelfDestroyableOverlaySheet {
id: addStickerPopup
property var stickerPackList
diff --git a/src/contents/ui/Bubble.qml b/src/contents/ui/Bubble.qml
--- a/src/contents/ui/Bubble.qml
+++ b/src/contents/ui/Bubble.qml
@@ -15,6 +15,7 @@
ItemDelegate {
id: upper
+ objectName: 'bubble'
default property var children
property var currentEvent: event
property var menuContent: []
@@ -29,16 +30,22 @@
}
background: compactMode ? null : backgroundItem
- property var eventSourcePopup: Kirigami.OverlaySheet {
- title: l10n.get('event-source-popup-title')
+ property var eventSourcePopupComp: Component {
+ Kazv.SelfDestroyableOverlaySheet {
+ shouldSelfDestroy: true
+ title: l10n.get('event-source-popup-title')
- Kazv.EventSourceView {
- event: upper.currentEvent
+ Kazv.EventSourceView {
+ event: upper.currentEvent
+ }
}
}
- property var reactionPopup: Kazv.ReactToEventPopup {
- onAccepted: eventView.reactWith(text)
+ property var reactionPopupComp: Component {
+ Kazv.ReactToEventPopup {
+ shouldSelfDestroy: true
+ onAccepted: eventView.reactWith(text)
+ }
}
function getIsEditable(event) {
@@ -47,44 +54,47 @@
&& event.content.msgtype === 'm.text';
}
- property var menu: Menu {
- objectName: 'bubbleContextMenu'
- property list<QtObject> staticItems: [
- Kirigami.Action {
- objectName: 'replyToMenuItem'
- text: l10n.get('event-reply-action')
- onTriggered: setDraftRelation('m.in_reply_to', currentEvent.eventId)
- enabled: event && !event.redacted
- },
- Kirigami.Action {
- objectName: 'editMenuItem'
- text: l10n.get('event-edit-action')
- onTriggered: {
- setDraftRelation('m.replace', currentEvent.eventId);
- replaceDraftRequested(Helpers.getEventBodyForEditing(event));
+ property var menuComp: Component {
+ Menu {
+ objectName: 'bubbleContextMenu'
+ property list<QtObject> staticItems: [
+ Kirigami.Action {
+ objectName: 'replyToMenuItem'
+ text: l10n.get('event-reply-action')
+ onTriggered: setDraftRelation('m.in_reply_to', currentEvent.eventId)
+ enabled: event && !event.redacted
+ },
+ Kirigami.Action {
+ objectName: 'editMenuItem'
+ text: l10n.get('event-edit-action')
+ onTriggered: {
+ setDraftRelation('m.replace', currentEvent.eventId);
+ replaceDraftRequested(Helpers.getEventBodyForEditing(event));
+ }
+ enabled: event && !event.redacted && !event.isLocalEcho && getIsEditable(event)
+ },
+ Kirigami.Action {
+ objectName: 'deleteMenuItem'
+ text: l10n.get('event-delete')
+ onTriggered: eventView.redactSelf()
+ enabled: event && !event.redacted
+ },
+ Kirigami.Action {
+ objectName: 'reactMenuItem'
+ text: l10n.get('event-react-action')
+ onTriggered: reactionPopupComp.createObject(applicationWindow().overlay).open()
+ enabled: event && !event.redacted
+ },
+ MenuSeparator {},
+ Kirigami.Action {
+ text: l10n.get('event-view-source')
+ onTriggered: eventSourcePopupComp.createObject(applicationWindow().overlay).open()
}
- enabled: event && !event.redacted && !event.isLocalEcho && getIsEditable(event)
- },
- Kirigami.Action {
- objectName: 'deleteMenuItem'
- text: l10n.get('event-delete')
- onTriggered: eventView.redactSelf()
- enabled: event && !event.redacted
- },
- Kirigami.Action {
- objectName: 'reactMenuItem'
- text: l10n.get('event-react-action')
- onTriggered: reactionPopup.open()
- enabled: event && !event.redacted
- },
- MenuSeparator {},
- Kirigami.Action {
- text: l10n.get('event-view-source')
- onTriggered: eventSourcePopup.open()
- }
- ]
+ ]
- contentData: Array.from(staticItems).concat(upper.menuContent)
+ contentData: Array.from(staticItems).concat(upper.menuContent)
+ onClosed: destroy()
+ }
}
function shouldPopupMenu() {
@@ -93,7 +103,7 @@
function maybePopupMenu() {
if (shouldPopupMenu()) {
- menu.popup(parent)
+ menuComp.createObject(parent).popup(parent)
}
}
diff --git a/src/contents/ui/ReactToEventPopup.qml b/src/contents/ui/ReactToEventPopup.qml
--- a/src/contents/ui/ReactToEventPopup.qml
+++ b/src/contents/ui/ReactToEventPopup.qml
@@ -12,7 +12,7 @@
import '.' as Kazv
-Kirigami.OverlaySheet {
+Kazv.SelfDestroyableOverlaySheet {
id: popup
signal accepted(string text)
diff --git a/src/contents/ui/SelfDestroyableOverlaySheet.qml b/src/contents/ui/SelfDestroyableOverlaySheet.qml
new file mode 100644
--- /dev/null
+++ b/src/contents/ui/SelfDestroyableOverlaySheet.qml
@@ -0,0 +1,21 @@
+/*
+ * This file is part of kazv.
+ * SPDX-FileCopyrightText: 2024 tusooa <tusooa@kazv.moe>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+import QtQuick 2.15
+import QtQuick.Layouts 1.15
+import QtQuick.Controls 2.15
+
+import org.kde.kirigami 2.13 as Kirigami
+
+Kirigami.OverlaySheet {
+ property var shouldSelfDestroy: false
+
+ onSheetOpenChanged: {
+ if (!sheetOpen && shouldSelfDestroy) {
+ destroy();
+ }
+ }
+}
diff --git a/src/contents/ui/event-types/Image.qml b/src/contents/ui/event-types/Image.qml
--- a/src/contents/ui/event-types/Image.qml
+++ b/src/contents/ui/event-types/Image.qml
@@ -69,14 +69,17 @@
}
property var canAddSticker: !!event.content.url
- property var addStickerPopup: Kazv.AddStickerPopup {
- stickerPackList: matrixSdk.stickerPackList()
- event: upper.curEvent
+ property var addStickerPopupComp: Component {
+ Kazv.AddStickerPopup {
+ shouldSelfDestroy: true
+ stickerPackList: matrixSdk.stickerPackList()
+ event: upper.curEvent
+ }
}
property var addStickerAction: Kirigami.Action {
text: l10n.get('media-file-menu-add-sticker-action')
- onTriggered: bubble.addStickerPopup.open()
+ onTriggered: bubble.addStickerPopupComp.createObject(applicationWindow().overlay).open()
}
additionalMenuContent: canAddSticker ? [addStickerAction] : []
diff --git a/src/resources.qrc b/src/resources.qrc
--- a/src/resources.qrc
+++ b/src/resources.qrc
@@ -7,6 +7,7 @@
<file alias="TabView.qml">contents/ui/TabView.qml</file>
<file alias="Tab.qml">contents/ui/Tab.qml</file>
<file alias="ClosableScrollablePage.qml">contents/ui/ClosableScrollablePage.qml</file>
+ <file alias="SelfDestroyableOverlaySheet.qml">contents/ui/SelfDestroyableOverlaySheet.qml</file>
<file alias="RoomListView.qml">contents/ui/RoomListView.qml</file>
<file alias="RoomListViewItemDelegate.qml">contents/ui/RoomListViewItemDelegate.qml</file>
<file alias="RoomPage.qml">contents/ui/RoomPage.qml</file>
diff --git a/src/tests/quick-tests/tst_EventView.qml b/src/tests/quick-tests/tst_EventView.qml
--- a/src/tests/quick-tests/tst_EventView.qml
+++ b/src/tests/quick-tests/tst_EventView.qml
@@ -399,7 +399,9 @@
verify(indicator.source === 'state-warning');
verify(indicator.Accessible.name === l10n.get('event-resend'));
- const deleteAction = findChild(eventViewFailed, 'deleteMenuItem');
+ const menuComp = findChild(eventViewFailed, 'bubble').menuComp;
+ const menu = menuComp.createObject(menuComp.parent);
+ const deleteAction = findChild(menu, 'deleteMenuItem');
deleteAction.trigger();
tryVerify(() => item.room.test_removeLocalEchoCalled === 1);
@@ -436,7 +438,8 @@
}
function test_menuText() {
- const menu = findChild(eventViewText, 'bubbleContextMenu');
+ const menuComp = findChild(eventViewText, 'bubble').menuComp;
+ const menu = menuComp.createObject(menuComp.parent);
verify(menu);
tryVerify(() => findChild(menu, 'replyToMenuItem').enabled);
tryVerify(() => findChild(menu, 'editMenuItem').enabled);
@@ -444,7 +447,8 @@
}
function test_menuRedacted() {
- const menu = findChild(eventViewRedacted, 'bubbleContextMenu');
+ const menuComp = findChild(eventViewRedacted, 'bubble').menuComp;
+ const menu = menuComp.createObject(menuComp.parent);
verify(menu);
tryVerify(() => !findChild(menu, 'replyToMenuItem').enabled);
tryVerify(() => !findChild(menu, 'deleteMenuItem').enabled);
@@ -482,11 +486,23 @@
}
function test_eventByOther() {
- const menu = findChild(eventViewTextBySomeoneElse, 'bubbleContextMenu');
+ const menuComp = findChild(eventViewTextBySomeoneElse, 'bubble').menuComp;
+ const menu = menuComp.createObject(menuComp.parent);
verify(menu);
tryVerify(() => !findChild(menu, 'editMenuItem').enabled);
}
+ function test_menuSelfDestruct() {
+ const menuComp = findChild(eventViewTextBySomeoneElse, 'bubble').menuComp;
+ const menu = menuComp.createObject(menuComp.parent);
+ verify(menu);
+ menu.popup(item);
+ menu.dismiss();
+ const menu2 = menuComp.createObject(menuComp.parent);
+ menu2.popup(item);
+ menu2.dismiss();
+ }
+
function test_userLink() {
const text = findChild(eventViewText, 'textEventContent');
text.linkActivated('https://matrix.to/#/@mew:example.com');

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 3:00 PM (11 h, 25 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39845
Default Alt Text
D42.1732489243.diff (9 KB)

Event Timeline