Add preference for hiding join/part messages

This commit is contained in:
Jaidyn Ann 2022-02-21 18:33:46 -06:00
parent ce4d3c2a26
commit b7b45a8db0
5 changed files with 25 additions and 10 deletions

View File

@ -44,6 +44,7 @@ AppPreferences::Load()
HideDeskbar = settings.GetBool("HideDeskbar", false);
DisableReplicant = settings.GetBool("DisableReplicant", true);
DisableQuitConfirm = settings.GetBool("DisableQuitConfirm", false);
MembershipUpdates = settings.GetBool("MembershipUpdates", true);
IgnoreEmoticons = settings.GetBool("IgnoreEmoticons", true);
HideOffline = settings.GetBool("HideOffline", false);
@ -79,6 +80,7 @@ AppPreferences::Save()
settings.AddBool("DisableReplicant", DisableReplicant);
settings.AddBool("DisableQuitConfirm", DisableQuitConfirm);
settings.AddBool("IgnoreEmoticons", IgnoreEmoticons);
settings.AddBool("MembershipUpdates", MembershipUpdates);
settings.AddBool("HideOffline", HideOffline);
settings.AddFloat("MainWindowListWeight", MainWindowListWeight);

View File

@ -1,7 +1,7 @@
/*
* Copyright 2010, Oliver Ruiz Dorantes. All rights reserved.
* Copyright 2012, Casalinuovo Dario. All rights reserved.
* Copyright 2021, Jaidyn Levesque <jadedctrl@teknik.io>
* Copyright 2021-2022, Jaidyn Levesque <jadedctrl@teknik.io>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef _APP_PREFERENCES_H
@ -33,6 +33,7 @@ public:
bool DisableQuitConfirm;
bool IgnoreEmoticons;
bool MembershipUpdates;
bool HideOffline;

View File

@ -1,7 +1,7 @@
/*
* Copyright 2010, Oliver Ruiz Dorantes. All rights reserved.
* Copyright 2012, Dario Casalinuovo. All rights reserved.
* Copyright 2021, Jaidyn Levesque. All rights reserved.
* Copyright 2021-2022, Jaidyn Levesque. All rights reserved.
* Distributed under the terms of the MIT License.
*/
@ -21,6 +21,7 @@
const uint32 kIgnoreEmoticons = 'CBhe';
const uint32 kMembershipUpdates = 'CBmu';
PreferencesChatWindow::PreferencesChatWindow()
@ -29,6 +30,9 @@ PreferencesChatWindow::PreferencesChatWindow()
BBox* chatBox = new BBox("chatBox");
chatBox->SetLabel(B_TRANSLATE("Chat settings"));
fMembershipUpdates = new BCheckBox("MembershipUpdates",
B_TRANSLATE("Show join/part messages"), new BMessage(kMembershipUpdates));
fIgnoreEmoticons = new BCheckBox("IgnoreEmoticons",
B_TRANSLATE("Ignore emoticons"), new BMessage(kIgnoreEmoticons));
fIgnoreEmoticons->SetEnabled(false); // No emoticon support currently
@ -38,6 +42,7 @@ PreferencesChatWindow::PreferencesChatWindow()
BLayoutBuilder::Group<>(chatBox, B_VERTICAL)
.SetInsets(spacing, spacing * 2, spacing, spacing)
.Add(fMembershipUpdates)
.Add(fIgnoreEmoticons)
.End();
@ -54,6 +59,8 @@ PreferencesChatWindow::AttachedToWindow()
{
fIgnoreEmoticons->SetTarget(this);
fIgnoreEmoticons->SetValue(AppPreferences::Get()->IgnoreEmoticons);
fMembershipUpdates->SetTarget(this);
fMembershipUpdates->SetValue(AppPreferences::Get()->MembershipUpdates);
}
@ -62,8 +69,10 @@ PreferencesChatWindow::MessageReceived(BMessage* message)
{
switch (message->what) {
case kIgnoreEmoticons:
AppPreferences::Get()->IgnoreEmoticons
= fIgnoreEmoticons->Value();
AppPreferences::Get()->IgnoreEmoticons = fIgnoreEmoticons->Value();
break;
case kMembershipUpdates:
AppPreferences::Get()->MembershipUpdates = fMembershipUpdates->Value();
break;
default:
BView::MessageReceived(message);

View File

@ -19,6 +19,7 @@ public:
private:
BCheckBox* fIgnoreEmoticons;
BCheckBox* fMembershipUpdates;
};
#endif // _PREFERENCES_BEHAVIOR_H

View File

@ -145,16 +145,18 @@ ConversationView::ImMessage(BMessage* msg)
}
case IM_ROOM_PARTICIPANT_JOINED:
{
_UserMessage(B_TRANSLATE("%user% has joined the room.\n"),
B_TRANSLATE("%user% has joined the room (%body%).\n"),
msg);
if (AppPreferences::Get()->MembershipUpdates == true)
_UserMessage(B_TRANSLATE("%user% has joined the room.\n"),
B_TRANSLATE("%user% has joined the room (%body%).\n"),
msg);
break;
}
case IM_ROOM_PARTICIPANT_LEFT:
{
_UserMessage(B_TRANSLATE("%user% has left the room.\n"),
B_TRANSLATE("%user% has left the room (%body%).\n"),
msg);
if (AppPreferences::Get()->MembershipUpdates == true)
_UserMessage(B_TRANSLATE("%user% has left the room.\n"),
B_TRANSLATE("%user% has left the room (%body%).\n"),
msg);
break;
}
case IM_ROOM_PARTICIPANT_KICKED: