Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F113840
D45.1732489235.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D45.1732489235.diff
View Options
diff --git a/src/contents/ui/MessageNotification.qml b/src/contents/ui/MessageNotification.qml
--- a/src/contents/ui/MessageNotification.qml
+++ b/src/contents/ui/MessageNotification.qml
@@ -5,16 +5,37 @@
*/
import QtQuick 2.15
-import org.kde.notification 1.0 as KN
+import moe.kazv.mxc.kazv 0.0 as MK
+import '.'
+// in KF6, this will override our own NotificationAction.qml
+import org.kde.notification 1.0
-KN.Notification {
+Notification {
+ id: notification
componentName: 'kazv'
eventId: 'message'
text: 'test text'
title: 'test title'
property var roomId
- defaultAction: l10n.get('notification-open')
- onDefaultActivated: {
+ property var defaultActionText: l10n.get('notification-open')
+ property var defaultActionV6: NotificationAction {
+ label: defaultActionText
+ }
+ defaultAction: MK.KazvUtil.kfQtMajorVersion === 5 ? defaultActionText : defaultActionV6
+
+ function switchToRoom() {
switchToRoomRequested(roomId);
}
+
+ property var conn: Connections {
+ target: MK.KazvUtil.kfQtMajorVersion === 5 ? notification : notification.defaultAction
+
+ function onActivated() {
+ switchToRoom();
+ }
+
+ function onDefaultActivated() {
+ switchToRoom();
+ }
+ }
}
diff --git a/src/contents/ui/NotificationAction.qml b/src/contents/ui/NotificationAction.qml
new file mode 100644
--- /dev/null
+++ b/src/contents/ui/NotificationAction.qml
@@ -0,0 +1,14 @@
+/*
+ * This file is part of kazv.
+ * SPDX-FileCopyrightText: 2024 tusooa <tusooa@kazv.moe>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+// This file is just to provide a fake NotificationAction in KF5
+// so QML's naming resolution will not complain.
+
+import QtQuick 2.15
+
+QtObject {
+ property var label
+}
diff --git a/src/kazv-util.hpp b/src/kazv-util.hpp
--- a/src/kazv-util.hpp
+++ b/src/kazv-util.hpp
@@ -17,6 +17,8 @@
QML_ELEMENT
QML_SINGLETON
+ Q_PROPERTY(int kfQtMajorVersion CONSTANT MEMBER m_kfQtMajorVersion)
+
public:
KazvUtil(QObject *parent = 0);
~KazvUtil() override;
@@ -28,4 +30,7 @@
/// @return The user id for a given matrix link, or the empty string
/// if @c url is not a matrix link pointing to a user
QString matrixLinkUserId(const QString &url) const;
+
+private:
+ int m_kfQtMajorVersion;
};
diff --git a/src/kazv-util.cpp b/src/kazv-util.cpp
--- a/src/kazv-util.cpp
+++ b/src/kazv-util.cpp
@@ -14,6 +14,7 @@
KazvUtil::KazvUtil(QObject *parent)
: QObject(parent)
+ , m_kfQtMajorVersion(KAZV_KF_QT_MAJOR_VERSION)
{}
KazvUtil::~KazvUtil() = default;
diff --git a/src/resources.qrc b/src/resources.qrc
--- a/src/resources.qrc
+++ b/src/resources.qrc
@@ -75,7 +75,7 @@
<file alias="MessageNotification.qml">contents/ui/MessageNotification.qml</file>
<file alias="Notifier.qml">contents/ui/Notifier.qml</file>
-
+ <file alias="NotificationAction.qml">contents/ui/NotificationAction.qml</file>
<file alias="l10n.js">js/l10n.js</file>
<file alias="fluent-bundle.js">js/transformed-libs/fluent-bundle.js</file>
<file alias="fluent-sequence.js">js/transformed-libs/fluent-sequence.js</file>
diff --git a/src/tests/quick-tests/tst_Notifications.qml b/src/tests/quick-tests/tst_Notifications.qml
--- a/src/tests/quick-tests/tst_Notifications.qml
+++ b/src/tests/quick-tests/tst_Notifications.qml
@@ -11,6 +11,7 @@
import '../../contents/ui' as Kazv
import 'test-helpers.js' as Helpers
import 'test-helpers' as TestHelpers
+import moe.kazv.mxc.kazv 0.0 as MK
TestCase {
id: notificationsTest
@@ -35,7 +36,11 @@
}
function test_messageNotification() {
- notification.defaultActivated();
+ if (MK.KazvUtil.kfQtMajorVersion === 5) {
+ notification.defaultActivated();
+ } else {
+ notification.defaultAction.activated();
+ }
tryCompare(switchToRoomSpy, 'count', 1);
compare(switchToRoomSpy.signalArguments[0][0], '!foo:example.com');
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 3:00 PM (11 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39844
Default Alt Text
D45.1732489235.diff (3 KB)
Attached To
Mode
D45: Fix notification tests for KF6
Attached
Detach File
Event Timeline
Log In to Comment