mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 09:05:10 -07:00
[Client] Add setting to ignore all private messages (#7260)
* [Client] Add setting to ignore all private messages (#1250) * Early return --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
fff506dbbe
commit
760fe88fa3
7 changed files with 40 additions and 0 deletions
|
|
@ -59,6 +59,10 @@ MessagesSettingsPage::MessagesSettingsPage()
|
|||
connect(&roomHistory, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance().chat(),
|
||||
&ChatSettings::setRoomHistory);
|
||||
|
||||
ignoreAllPrivateMessagesCheckBox.setChecked(SettingsCache::instance().chat().getIgnoreAllPrivateMessages());
|
||||
connect(&ignoreAllPrivateMessagesCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance().chat(),
|
||||
&ChatSettings::setIgnoreAllPrivateMessages);
|
||||
|
||||
customAlertString = new QLineEdit();
|
||||
customAlertString->setText(SettingsCache::instance().chat().getHighlightWords());
|
||||
connect(customAlertString, &QLineEdit::textChanged, &SettingsCache::instance().chat(),
|
||||
|
|
@ -76,6 +80,7 @@ MessagesSettingsPage::MessagesSettingsPage()
|
|||
chatGrid->addWidget(&messagePopups, 5, 0);
|
||||
chatGrid->addWidget(&mentionPopups, 6, 0);
|
||||
chatGrid->addWidget(&roomHistory, 7, 0);
|
||||
chatGrid->addWidget(&ignoreAllPrivateMessagesCheckBox, 8, 0);
|
||||
chatGroupBox = new QGroupBox;
|
||||
chatGroupBox->setLayout(chatGrid);
|
||||
|
||||
|
|
@ -256,6 +261,7 @@ void MessagesSettingsPage::retranslateUi()
|
|||
messagePopups.setText(tr("Enable desktop notifications for private messages"));
|
||||
mentionPopups.setText(tr("Enable desktop notification for mentions"));
|
||||
roomHistory.setText(tr("Enable room message history on join"));
|
||||
ignoreAllPrivateMessagesCheckBox.setText(tr("Ignore all private messages"));
|
||||
hexLabel.setText(tr("(Color is hexadecimal)"));
|
||||
hexHighlightLabel.setText(tr("(Color is hexadecimal)"));
|
||||
customAlertStringLabel.setText(tr("Separate words with a space, alphanumeric characters only"));
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ private:
|
|||
QCheckBox messagePopups;
|
||||
QCheckBox mentionPopups;
|
||||
QCheckBox roomHistory;
|
||||
QCheckBox ignoreAllPrivateMessagesCheckBox;
|
||||
QGroupBox *chatGroupBox;
|
||||
QGroupBox *highlightGroupBox;
|
||||
QGroupBox *messageGroupBox;
|
||||
|
|
|
|||
|
|
@ -1284,7 +1284,21 @@ void TabSupervisor::processGameEventContainer(const GameEventContainer &cont)
|
|||
|
||||
void TabSupervisor::processUserMessageEvent(const Event_UserMessage &event)
|
||||
{
|
||||
// "Ignore all private messages" silences every PM, including messages to
|
||||
// already-open tabs — unlike the unregistered/non-buddy filters below,
|
||||
// which only apply when creating a new tab. Messages from moderators/admins
|
||||
// are exempt to ensure warnings still reach users.
|
||||
QString senderName = QString::fromStdString(event.sender_name());
|
||||
if (SettingsCache::instance().chat().getIgnoreAllPrivateMessages()) {
|
||||
const ServerInfo_User *onlineUserInfo = userListManager->getOnlineUser(senderName);
|
||||
if (!onlineUserInfo) {
|
||||
return;
|
||||
}
|
||||
const UserLevelFlags userLevel(onlineUserInfo->user_level());
|
||||
if (!userLevel.testFlag(ServerInfo_User::IsModerator) && !userLevel.testFlag(ServerInfo_User::IsAdmin)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
TabMessage *tab = messageTabs.value(senderName);
|
||||
if (!tab) {
|
||||
tab = messageTabs.value(QString::fromStdString(event.receiver_name()));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue