Cockatrice/libcockatrice_settings/libcockatrice/settings/chat_settings.cpp
BruebachL c99113ab0e
[Client] Tabbed room channels with unread states and collapsible chat (#7478)
* [Client] Add room channel selector with per-channel chat views

* [Client] Tabbed room channels with unread states, collapse, read-only, banners

Reworks the room chat channel display: channels move out of the combobox
into a tab bar below the message input showing every channel available
to the user.

- Each tab shows its unread message count and is tinted when it holds
  unreads or a mention; both colors are user-configurable chat settings
  (channelUnreadColor, channelMentionColor) with a settings-page section.
- Clicking the active tab collapses the chat: message view and input
  hide and the splitter section minimizes to the tab strip; expanding
  restores the previous splitter sizes. Viewing a channel clears its
  unread state.
- Channels the user may read but not write (per write_access_level)
  show with the message input disabled and a read-only placeholder;
  sends are guarded locally, the server still enforces.
- Channel banner_message strings render at the top of their channel
  view on join, like the room join message on Main.
- Replayed channel history no longer inflates unread counts; moderation
  redaction now applies across all channel views.

* Fixup: keep chat tab bar visible when chat is collapsed

QSplitter children are collapsible by default, so setSizes({1, 0})
hid the whole chat group box including the channel tab bar.
Mark the chat widget non-collapsible so collapsing clamps to its
minimum size (title + tab bar) instead.

* [Room] Explicitly initialize MAIN_CHANNEL per review

* [Room] Address channel tab review follow-ups

- gate @all mentions on moderator/admin sender to match ChatView,
  whole-word matching for own name and highlight words
- hide single-channel tab bar so old servers do not show a lone Main
  tab that collapses chat on misclick
- capture target ChatView in sendMessage so errors land in the
  channel the message was sent from
- share ignore/unregistered filtering between RoomSay and
  RoomChannelSay via isRoomMessageIgnored

* [Client] Fix tab_room.cpp formatting per clang-format-18

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
Co-authored-by: BruebachL <bruebachl@cockatrice.example>
2026-10-16 22:46:39 +02:00

183 lines
4.7 KiB
C++

#include "chat_settings.h"
#include "libcockatrice/settings/settings_manager.h"
#include <QVariant>
class QObject;
ChatSettings::ChatSettings(const QString &settingPath, QObject *parent)
: SettingsManager(settingPath + "chat.ini", "chat", QString(), parent)
{
}
bool ChatSettings::getChatMention() const
{
return getValue("mention", QString(), QString(), true).toBool();
}
bool ChatSettings::getChatMentionCompleter() const
{
return getValue("mentionCompleter", QString(), QString(), true).toBool();
}
QString ChatSettings::getChatMentionColor() const
{
return getValue("mentionColor", QString(), QString(), "A6120D").toString();
}
QString ChatSettings::getChatHighlightColor() const
{
return getValue("highlightColor", QString(), QString(), "A6120D").toString();
}
QString ChatSettings::getChannelUnreadColor() const
{
return getValue("channelUnreadColor", QString(), QString(), "1A7B00").toString();
}
QString ChatSettings::getChannelMentionColor() const
{
return getValue("channelMentionColor", QString(), QString(), "A6120D").toString();
}
bool ChatSettings::getChatMentionForeground() const
{
return getValue("mentionForeground", QString(), QString(), true).toBool();
}
bool ChatSettings::getChatHighlightForeground() const
{
return getValue("highlightForeground", QString(), QString(), true).toBool();
}
bool ChatSettings::getIgnoreUnregisteredUsers() const
{
return getValue("ignoreUnregistered").toBool();
}
bool ChatSettings::getIgnoreUnregisteredUserMessages() const
{
return getValue("ignoreUnregisteredMessages").toBool();
}
bool ChatSettings::getIgnoreNonBuddyUserMessages() const
{
return getValue("ignoreNonBuddyMessages").toBool();
}
bool ChatSettings::getShowMessagePopup() const
{
return getValue("showMessagePopups", QString(), QString(), true).toBool();
}
bool ChatSettings::getShowMentionPopup() const
{
return getValue("showMentionPopups", QString(), QString(), true).toBool();
}
bool ChatSettings::getRoomHistory() const
{
return getValue("roomHistory", QString(), QString(), true).toBool();
}
bool ChatSettings::getIgnoreAllPrivateMessages() const
{
return getValue("ignoreAllPrivateMessages", QString(), QString(), false).toBool();
}
bool ChatSettings::getUseGameTime() const
{
return getValue("useGameTime", QString(), QString(), false).toBool();
}
QString ChatSettings::getHighlightWords() const
{
return getValue("highlightWords").toString();
}
void ChatSettings::setChatMention(bool _chatMention)
{
setValue(_chatMention, "mention");
}
void ChatSettings::setChatMentionCompleter(bool _chatMentionCompleter)
{
setValue(_chatMentionCompleter, "mentionCompleter");
emit chatMentionCompleterChanged();
}
void ChatSettings::setChatMentionColor(const QString &_chatMentionColor)
{
setValue(_chatMentionColor, "mentionColor");
}
void ChatSettings::setChatHighlightColor(const QString &_chatHighlightColor)
{
setValue(_chatHighlightColor, "highlightColor");
}
void ChatSettings::setChannelUnreadColor(const QString &_channelUnreadColor)
{
setValue(_channelUnreadColor, "channelUnreadColor");
}
void ChatSettings::setChannelMentionColor(const QString &_channelMentionColor)
{
setValue(_channelMentionColor, "channelMentionColor");
}
void ChatSettings::setChatMentionForeground(bool _chatMentionForeground)
{
setValue(_chatMentionForeground, "mentionForeground");
}
void ChatSettings::setChatHighlightForeground(bool _chatHighlightForeground)
{
setValue(_chatHighlightForeground, "highlightForeground");
}
void ChatSettings::setIgnoreUnregisteredUsers(bool _ignoreUnregisteredUsers)
{
setValue(_ignoreUnregisteredUsers, "ignoreUnregistered");
}
void ChatSettings::setIgnoreUnregisteredUserMessages(bool _ignoreUnregisteredUserMessages)
{
setValue(_ignoreUnregisteredUserMessages, "ignoreUnregisteredMessages");
}
void ChatSettings::setIgnoreNonBuddyUserMessages(bool _ignoreNonBuddyUserMessages)
{
setValue(_ignoreNonBuddyUserMessages, "ignoreNonBuddyMessages");
}
void ChatSettings::setShowMessagePopups(bool _showMessagePopups)
{
setValue(_showMessagePopups, "showMessagePopups");
}
void ChatSettings::setShowMentionPopups(bool _showMentionPopups)
{
setValue(_showMentionPopups, "showMentionPopups");
}
void ChatSettings::setRoomHistory(bool _roomHistory)
{
setValue(_roomHistory, "roomHistory");
}
void ChatSettings::setIgnoreAllPrivateMessages(bool _ignoreAllPrivateMessages)
{
setValue(_ignoreAllPrivateMessages, "ignoreAllPrivateMessages");
}
void ChatSettings::setUseGameTime(bool _useGameTime)
{
setValue(_useGameTime, "useGameTime");
}
void ChatSettings::setHighlightWords(const QString &_highlightWords)
{
setValue(_highlightWords, "highlightWords");
}