mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-15 11:38:49 -07:00
add option to delete a user's messages (#4362)
* add option to delete a user's messages add optional parameter remove_messages to the ban and warn commands add event for clients to redact messages implement server side command and message handling implement server history removal todo: client side implementation add option to remove messages to moderator action dialogs add storage of message beginnings to chatview add redactMessage command handle Event_RemoveMessages on rooms this approach is favored over parsing the chatroom after the fact but will use additional memory to store the block indexes this also leaves a problem in that user messages from the chat backlog are not removed in the same way because they don't have a user associated with them add workaround for old qt versions add action for users to remove messages from users in chats add chat history to userMessagePositions with regex proper const usage for userName allow removing the messages of unregistered users add menus to usernames in chat history this allows you to remove user messages on chat history as well this also allows moderators to take actions on users in chat history Apply suggestions from code review * readd missing call to handler
This commit is contained in:
parent
c25bf491e4
commit
1e995cd97c
22 changed files with 280 additions and 78 deletions
|
|
@ -18,6 +18,17 @@ class QMouseEvent;
|
|||
class UserContextMenu;
|
||||
class TabGame;
|
||||
|
||||
class UserMessagePosition
|
||||
{
|
||||
public:
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 13, 0))
|
||||
UserMessagePosition() = default; // older qt versions require a default constructor to use in containers
|
||||
#endif
|
||||
UserMessagePosition(QTextCursor &cursor);
|
||||
int relativePosition;
|
||||
QTextBlock block;
|
||||
};
|
||||
|
||||
class ChatView : public QTextBrowser
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -36,7 +47,7 @@ private:
|
|||
const UserlistProxy *const userlistProxy;
|
||||
UserContextMenu *userContextMenu;
|
||||
QString lastSender;
|
||||
QString userName;
|
||||
QString ownUserName;
|
||||
QString mention;
|
||||
QTextCharFormat mentionFormat;
|
||||
QTextCharFormat highlightFormat;
|
||||
|
|
@ -48,16 +59,18 @@ private:
|
|||
HoveredItemType hoveredItemType;
|
||||
QString hoveredContent;
|
||||
QAction *messageClicked;
|
||||
QMap<QString, QVector<UserMessagePosition>> userMessagePositions;
|
||||
|
||||
QTextFragment getFragmentUnderMouse(const QPoint &pos) const;
|
||||
QTextCursor prepareBlock(bool same = false);
|
||||
void appendCardTag(QTextCursor &cursor, const QString &cardName);
|
||||
void appendUrlTag(QTextCursor &cursor, QString url);
|
||||
QColor getCustomMentionColor();
|
||||
QColor getCustomHighlightColor();
|
||||
void showSystemPopup(QString &sender);
|
||||
void showSystemPopup(const QString &userName);
|
||||
bool isModeratorSendingGlobal(QFlags<ServerInfo_User::UserLevelFlag> userLevelFlag, QString message);
|
||||
void checkTag(QTextCursor &cursor, QString &message);
|
||||
void checkMention(QTextCursor &cursor, QString &message, QString &sender, UserLevelFlags userLevel);
|
||||
void checkMention(QTextCursor &cursor, QString &message, const QString &userName, UserLevelFlags userLevel);
|
||||
void checkWord(QTextCursor &cursor, QString &message);
|
||||
QString extractNextWord(QString &message, QString &rest);
|
||||
|
||||
|
|
@ -82,11 +95,12 @@ public:
|
|||
QString optionalFontColor = QString());
|
||||
void appendMessage(QString message,
|
||||
RoomMessageTypeFlags messageType = {},
|
||||
QString sender = QString(),
|
||||
const QString &userName = QString(),
|
||||
UserLevelFlags userLevel = UserLevelFlags(),
|
||||
QString UserPrivLevel = "NONE",
|
||||
bool playerBold = false);
|
||||
void clearChat();
|
||||
void redactMessages(const QString &userName, int amount);
|
||||
|
||||
protected:
|
||||
void enterEvent(QEvent *event);
|
||||
|
|
@ -101,7 +115,7 @@ signals:
|
|||
void deleteCardInfoPopup(QString cardName);
|
||||
void addMentionTag(QString mentionTag);
|
||||
void messageClickedSignal();
|
||||
void showMentionPopup(QString &sender);
|
||||
void showMentionPopup(const QString &userName);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue