File indexing completed on 2025-03-09 04:36:03
0001 /* 0002 SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "libruqolacore_export.h" 0010 #include <QDebug> 0011 #include <QString> 0012 0013 class LIBRUQOLACORE_EXPORT NotificationOptions 0014 { 0015 Q_GADGET 0016 public: 0017 NotificationOptions(); 0018 NotificationOptions(const NotificationOptions &other) = default; 0019 struct LIBRUQOLACORE_EXPORT NotificationValue { 0020 NotificationValue() = default; 0021 explicit NotificationValue(const QString &val, const QString &pref) 0022 : value(val) 0023 , preferenceOrigin(pref) 0024 { 0025 } 0026 QString value; 0027 QString preferenceOrigin; 0028 [[nodiscard]] bool operator==(const NotificationValue &other) const; 0029 [[nodiscard]] QString currentValue() const; 0030 [[nodiscard]] bool isEmpty() const; 0031 }; 0032 0033 enum NotificationType { 0034 Default = 0, 0035 AllMessages, 0036 Mentions, 0037 Nothing, 0038 }; 0039 Q_ENUM(NotificationType) 0040 0041 [[nodiscard]] bool hideUnreadStatus() const; 0042 void setHideUnreadStatus(bool value); 0043 0044 [[nodiscard]] bool disableNotifications() const; 0045 void setDisableNotifications(bool disableNotifications); 0046 0047 [[nodiscard]] QString unreadTrayIconAlert() const; 0048 void setUnreadTrayIconAlert(const QString &unreadTrayIconAlert); 0049 0050 [[nodiscard]] NotificationValue emailNotifications() const; 0051 void setEmailNotifications(const NotificationValue &emailNotifications); 0052 0053 [[nodiscard]] NotificationValue mobilePushNotification() const; 0054 void setMobilePushNotification(const NotificationValue &mobilePushNotification); 0055 0056 [[nodiscard]] NotificationValue desktopNotifications() const; 0057 void setDesktopNotifications(const NotificationValue &desktopNotifications); 0058 0059 [[nodiscard]] QString audioNotificationValue() const; 0060 void setAudioNotificationValue(const QString &audioNotificationValue); 0061 0062 [[nodiscard]] static QJsonObject serialize(const NotificationOptions &message); 0063 [[nodiscard]] static NotificationOptions deserialize(const QJsonObject &o); 0064 0065 void parseNotificationOptions(const QJsonObject &obj); 0066 void updateNotificationOptions(const QJsonObject &obj); 0067 0068 NotificationOptions &operator=(const NotificationOptions &other) = default; 0069 [[nodiscard]] bool operator==(const NotificationOptions &other) const; 0070 [[nodiscard]] bool operator!=(const NotificationOptions &other) const; 0071 0072 [[nodiscard]] bool muteGroupMentions() const; 0073 void setMuteGroupMentions(bool muteGroupMentions); 0074 0075 [[nodiscard]] bool hideMentionStatus() const; 0076 void setHideMentionStatus(bool newMhideMentionStatus); 0077 0078 private: 0079 NotificationValue mDesktopNotifications; 0080 NotificationValue mMobilePushNotification; 0081 NotificationValue mEmailNotifications; 0082 0083 // TODO use enums ???? 0084 QString mUnreadTrayIconAlert; 0085 QString mAudioNotificationValue; // Type 0086 bool mDisableNotifications = false; 0087 bool mHideUnreadStatus = false; 0088 bool mMuteGroupMentions = false; 0089 bool mHideMentionStatus = false; 0090 }; 0091 LIBRUQOLACORE_EXPORT QDebug operator<<(QDebug d, const NotificationOptions &t); 0092 LIBRUQOLACORE_EXPORT QDebug operator<<(QDebug d, const NotificationOptions::NotificationValue &t);