File indexing completed on 2024-07-14 15:12:10

0001 /*
0002    SPDX-FileCopyrightText: 2020-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 
0011 #include <QDebug>
0012 #include <QObject>
0013 
0014 class LIBRUQOLACORE_EXPORT OwnUserPreferences
0015 {
0016     Q_GADGET
0017 public:
0018     OwnUserPreferences();
0019     ~OwnUserPreferences();
0020     void parsePreferences(const QJsonObject &replyObject);
0021     [[nodiscard]] bool operator==(const OwnUserPreferences &other) const;
0022     [[nodiscard]] QStringList highlightWords() const;
0023     void setHighlightWords(const QStringList &highlightWords);
0024 
0025     [[nodiscard]] QString emailNotificationMode() const;
0026     void setEmailNotificationMode(const QString &emailNotificationMode);
0027 
0028     [[nodiscard]] QString desktopNotifications() const;
0029     void setDesktopNotifications(const QString &desktopNotifications);
0030 
0031     [[nodiscard]] bool convertAsciiEmoji() const;
0032     void setConvertAsciiEmoji(bool convertAsciiEmoji);
0033 
0034     [[nodiscard]] bool useEmojis() const;
0035     void setUseEmojis(bool useEmojis);
0036 
0037     [[nodiscard]] bool hideRoles() const;
0038     void setHideRoles(bool hideRoles);
0039 
0040     [[nodiscard]] bool displayAvatars() const;
0041     void setDisplayAvatars(bool hideAvatars);
0042 
0043     [[nodiscard]] int idleTimeLimit() const;
0044     void setIdleTimeLimit(int newIdleTimeLimit);
0045 
0046     [[nodiscard]] bool enableAutoAway() const;
0047     void setEnableAutoAway(bool newEnableAutoAway);
0048 
0049     void updateHighlightWords(const QJsonArray &highlightsArray);
0050 
0051     void setPushNotifications(const QString &pushNotifications);
0052     [[nodiscard]] QString pushNotifications() const;
0053 
0054     [[nodiscard]] bool showUnread() const;
0055     void setShowUnread(bool newShowUnread);
0056 
0057     enum class RoomListSortOrder {
0058         Unknown,
0059         ByLastMessage,
0060         Alphabetically,
0061     };
0062     Q_ENUM(RoomListSortOrder)
0063     [[nodiscard]] RoomListSortOrder roomListSortOrder() const;
0064     void setRoomListSortOrder(RoomListSortOrder roomListSortOrder);
0065 
0066     [[nodiscard]] bool showRoomAvatar() const;
0067     void setShowRoomAvatar(bool newShowRoomAvatar);
0068 
0069     [[nodiscard]] bool showFavorite() const;
0070     void setShowFavorite(bool newShowFavorite);
0071 
0072     [[nodiscard]] bool receiveLoginDetectionEmail() const;
0073     void setReceiveLoginDetectionEmail(bool newReceiveLoginDetectionEmail);
0074 
0075 private:
0076     QStringList mHighlightWords;
0077     QString mEmailNotificationMode;
0078     QString mDesktopNotifications;
0079     QString mPushNotifications;
0080     int mIdleTimeLimit = -1;
0081     bool mConvertAsciiEmoji = true;
0082     bool mUseEmojis = true;
0083     bool mHideRoles = false;
0084     bool mDisplayAvatars = true;
0085     bool mEnableAutoAway = false;
0086     bool mShowUnread = false;
0087     RoomListSortOrder mRoomListSortOrder = RoomListSortOrder::Unknown;
0088     bool mShowRoomAvatar = false;
0089     bool mShowFavorite = true;
0090     bool mReceiveLoginDetectionEmail = false;
0091 };
0092 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0093 Q_DECLARE_METATYPE(OwnUserPreferences)
0094 #endif
0095 Q_DECLARE_TYPEINFO(OwnUserPreferences, Q_MOVABLE_TYPE);
0096 LIBRUQOLACORE_EXPORT QDebug operator<<(QDebug d, const OwnUserPreferences &t);