allow mod global msg
This commit is contained in:
parent
31890450dc
commit
1bda6e53b2
3 changed files with 53 additions and 22 deletions
|
@ -343,6 +343,23 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
||||||
cursor.setCharFormat(defaultFormat);
|
cursor.setCharFormat(defaultFormat);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else if (isModeratorSendingGlobal(userLevel, fullMentionUpToSpaceOrEnd))
|
||||||
|
{
|
||||||
|
// Moderator Sending Global Message
|
||||||
|
mentionFormat.setBackground(QBrush(getCustomMentionColor()));
|
||||||
|
mentionFormat.setForeground(settingsCache->getChatMentionForeground() ? QBrush(Qt::white) : QBrush(Qt::black));
|
||||||
|
cursor.insertText("@" + fullMentionUpToSpaceOrEnd, mentionFormat);
|
||||||
|
message = message.mid(fullMentionUpToSpaceOrEnd.size() + 1);
|
||||||
|
QApplication::alert(this);
|
||||||
|
if (settingsCache->getShowMentionPopup() && shouldShowSystemPopup())
|
||||||
|
{
|
||||||
|
QString ref = sender.left(sender.length() - 2);
|
||||||
|
showSystemPopup(ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor.setCharFormat(defaultFormat);
|
||||||
|
break;
|
||||||
|
}
|
||||||
else if (fullMentionUpToSpaceOrEnd.right(1).indexOf(notALetterOrNumber) == -1 || fullMentionUpToSpaceOrEnd.size() < 2)
|
else if (fullMentionUpToSpaceOrEnd.right(1).indexOf(notALetterOrNumber) == -1 || fullMentionUpToSpaceOrEnd.size() < 2)
|
||||||
{
|
{
|
||||||
cursor.insertText("@" + mentionIntact, defaultFormat);
|
cursor.insertText("@" + mentionIntact, defaultFormat);
|
||||||
|
@ -368,6 +385,19 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
||||||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ChatView::isModeratorSendingGlobal(QFlags<ServerInfo_User::UserLevelFlag> userLevelFlag, QString message)
|
||||||
|
{
|
||||||
|
int userLevel = QString::number(userLevelFlag).toInt();
|
||||||
|
|
||||||
|
QStringList getAttentionList;
|
||||||
|
getAttentionList << "/all"; // Send a message to all users
|
||||||
|
|
||||||
|
if (getAttentionList.contains(message) && (userLevel & ServerInfo_User::IsModerator || userLevel & ServerInfo_User::IsAdmin))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void ChatView::actMessageClicked() {
|
void ChatView::actMessageClicked() {
|
||||||
emit messageClickedSignal();
|
emit messageClickedSignal();
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ private:
|
||||||
QColor getCustomMentionColor();
|
QColor getCustomMentionColor();
|
||||||
bool shouldShowSystemPopup();
|
bool shouldShowSystemPopup();
|
||||||
void showSystemPopup(QString &sender);
|
void showSystemPopup(QString &sender);
|
||||||
|
bool isModeratorSendingGlobal(QFlags<ServerInfo_User::UserLevelFlag> userLevelFlag, QString message);
|
||||||
private slots:
|
private slots:
|
||||||
void openLink(const QUrl &link);
|
void openLink(const QUrl &link);
|
||||||
void actMessageClicked();
|
void actMessageClicked();
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
message ServerInfo_User {
|
message ServerInfo_User {
|
||||||
enum UserLevelFlag {
|
enum UserLevelFlag {
|
||||||
IsNothing = 0;
|
IsNothing = 0;
|
||||||
IsUser = 1;
|
IsUser = 1;
|
||||||
IsRegistered = 2;
|
IsRegistered = 2;
|
||||||
IsModerator = 4;
|
IsModerator = 4;
|
||||||
IsAdmin = 8;
|
IsAdmin = 8;
|
||||||
};
|
};
|
||||||
enum Gender {
|
enum Gender {
|
||||||
GenderUnknown = -1;
|
GenderUnknown = -1;
|
||||||
Male = 0;
|
Male = 0;
|
||||||
Female = 1;
|
Female = 1;
|
||||||
};
|
};
|
||||||
optional string name = 1;
|
optional string name = 1;
|
||||||
optional uint32 user_level = 2;
|
optional uint32 user_level = 2;
|
||||||
optional string address = 3;
|
optional string address = 3;
|
||||||
optional string real_name = 4;
|
optional string real_name = 4;
|
||||||
optional Gender gender = 5 [default = GenderUnknown];
|
optional Gender gender = 5 [default = GenderUnknown];
|
||||||
optional string country = 6;
|
optional string country = 6;
|
||||||
optional bytes avatar_bmp = 7;
|
optional bytes avatar_bmp = 7;
|
||||||
optional sint32 id = 8 [default = -1];
|
optional sint32 id = 8 [default = -1];
|
||||||
optional sint32 server_id = 9 [default = -1];
|
optional sint32 server_id = 9 [default = -1];
|
||||||
optional uint64 session_id = 10;
|
optional uint64 session_id = 10;
|
||||||
optional uint64 accountage_secs = 11;
|
optional uint64 accountage_secs = 11;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue