From 901f7a8e0585d697c56598712c359ec6d6e0e217 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Wed, 18 Aug 2021 18:28:53 -0500 Subject: [PATCH] Disable unusable settings, Notfications tab --- application/Makefile | 4 +- application/preferences/AppPreferences.cpp | 6 +- application/preferences/AppPreferences.h | 4 +- .../preferences/PreferencesBehavior.cpp | 75 +--------- application/preferences/PreferencesBehavior.h | 7 - .../preferences/PreferencesChatWindow.cpp | 2 +- .../preferences/PreferencesNotifications.cpp | 134 ++++++++++++++++++ .../preferences/PreferencesNotifications.h | 28 ++++ .../preferences/PreferencesReplicant.cpp | 1 + application/windows/PreferencesWindow.cpp | 4 +- 10 files changed, 179 insertions(+), 86 deletions(-) create mode 100644 application/preferences/PreferencesNotifications.cpp create mode 100644 application/preferences/PreferencesNotifications.h diff --git a/application/Makefile b/application/Makefile index f312786..2a4544b 100644 --- a/application/Makefile +++ b/application/Makefile @@ -51,9 +51,9 @@ SRCS = \ application/preferences/AccountDialog.cpp \ application/preferences/AccountListItem.cpp \ application/preferences/AppPreferences.cpp \ - application/preferences/PreferencesChatWindow.cpp \ application/preferences/PreferencesBehavior.cpp \ - application/preferences/PreferencesReplicant.cpp \ + application/preferences/PreferencesChatWindow.cpp \ + application/preferences/PreferencesNotifications.cpp \ application/views/AccountsMenu.cpp \ application/views/AccountMenuItem.cpp \ application/views/RenderView.cpp \ diff --git a/application/preferences/AppPreferences.cpp b/application/preferences/AppPreferences.cpp index f7a1e7b..2a17cf4 100644 --- a/application/preferences/AppPreferences.cpp +++ b/application/preferences/AppPreferences.cpp @@ -35,11 +35,12 @@ AppPreferences::Load() MoveToCurrentWorkspace = settings.GetBool("MoveToCurrentWorkpace", false); RaiseOnMessageReceived = settings.GetBool("RaiseOnMessageReceived", false); - RaiseUserIsTyping = settings.GetBool("RaiseUserIsTyping", false); MarkUnreadWindow = settings.GetBool("MarkUnreadWindow", true); NotifyProtocolStatus = settings.GetBool("NotifyProtocolStatus", true); NotifyNewMessage = settings.GetBool("NotifyNewMessage", true); NotifyContactStatus = settings.GetBool("NotifyContactStatus", false); + SoundOnMessageReceived = settings.GetBool("SoundOnMessageReceived", false); + SoundOnMention = settings.GetBool("SoundOnMention", true); HideDeskbar = settings.GetBool("HideDeskbar", false); DisableReplicant = settings.GetBool("DisableReplicant", true); DisableQuitConfirm = settings.GetBool("DisableQuitConfirm", false); @@ -67,11 +68,12 @@ AppPreferences::Save() BMessage settings; settings.AddBool("MoveToCurrentWorkpace", MoveToCurrentWorkspace); settings.AddBool("RaiseOnMessageReceived", RaiseOnMessageReceived); - settings.AddBool("RaiseUserIsTyping", RaiseUserIsTyping); settings.AddBool("MarkUnreadWindow", MarkUnreadWindow); settings.AddBool("NotifyProtocolStatus", NotifyProtocolStatus); settings.AddBool("NotifyNewMessage", NotifyNewMessage); settings.AddBool("NotifyContactStatus", NotifyContactStatus); + settings.AddBool("SoundOnMessageReceived", SoundOnMessageReceived); + settings.AddBool("SoundOnMention", SoundOnMention); settings.AddBool("HideDeskbar", HideDeskbar); settings.AddBool("DisableReplicant", DisableReplicant); settings.AddBool("DisableQuitConfirm", DisableQuitConfirm); diff --git a/application/preferences/AppPreferences.h b/application/preferences/AppPreferences.h index 2f7481e..f868764 100644 --- a/application/preferences/AppPreferences.h +++ b/application/preferences/AppPreferences.h @@ -20,11 +20,13 @@ public: bool MoveToCurrentWorkspace; bool RaiseOnMessageReceived; - bool RaiseUserIsTyping; bool MarkUnreadWindow; + bool NotifyProtocolStatus; bool NotifyContactStatus; bool NotifyNewMessage; + bool SoundOnMessageReceived; + bool SoundOnMention; bool HideDeskbar; bool DisableReplicant; diff --git a/application/preferences/PreferencesBehavior.cpp b/application/preferences/PreferencesBehavior.cpp index e533946..5609cb3 100644 --- a/application/preferences/PreferencesBehavior.cpp +++ b/application/preferences/PreferencesBehavior.cpp @@ -23,9 +23,6 @@ const uint32 kToCurrentWorkspace = 'CBcw'; const uint32 kRaiseOnMessageReceived = 'FCmr'; const uint32 kRaiseUserIsTyping = 'FCit'; -const uint32 kNotifyProtocolsLogin = 'NTpl'; -const uint32 kNotifyContactStatus = 'NTcl'; -const uint32 kNotifyNewMessage = 'NTms'; const uint32 kMarkUnreadWindow = 'MKuw'; const uint32 kHideOffline = 'HiOf'; const uint32 kDisablePrompt = 'DiPr'; @@ -40,47 +37,22 @@ PreferencesBehavior::PreferencesBehavior() fHideOffline = new BCheckBox("HideOfflineContacts", B_TRANSLATE("Hide offline contacts"), new BMessage(kHideOffline)); + fHideOffline->SetEnabled(false); //not implemented as yet fToCurrentWorkspace = new BCheckBox("ToCurrentWorkspace", B_TRANSLATE("Move window to current workspace"), new BMessage(kToCurrentWorkspace)); + fToCurrentWorkspace->SetEnabled(false); // not this either fRaiseOnMessageReceived = new BCheckBox("FocusOnMessageReceived", B_TRANSLATE("Auto-raise when a message is received"), new BMessage(kRaiseOnMessageReceived)); - - fRaiseUserIsTyping = new BCheckBox("FocusUserIsTyping", - B_TRANSLATE("Auto-raise when user is typing"), - new BMessage(kRaiseUserIsTyping)); - - fPlaySoundOnMessageReceived = new BCheckBox("PlaySoundOnMessageReceived", - B_TRANSLATE("Play sound event"), NULL); - fPlaySoundOnMessageReceived->SetEnabled(false); // not implemented + fRaiseOnMessageReceived->SetEnabled(false); // nor this fMarkUnreadWindow = new BCheckBox("MarkUnreadWindow", B_TRANSLATE("Mark unread window chat"), new BMessage(kMarkUnreadWindow)); - /*fMarkUnreadWindow->SetEnabled(false); implementing it right now*/ - - fMarkUnreadReplicant = new BCheckBox("MarkUnreadReplicant", - B_TRANSLATE("Mark unread the Deskbar Replicant"), NULL); - fMarkUnreadReplicant->SetEnabled(false); - // not implemented - - BBox* notificationBox = new BBox("notificationBox"); - notificationBox->SetLabel(B_TRANSLATE("Deskbar notifications")); - - fNotifyProtocols = new BCheckBox("EnableProtocolNotify", - B_TRANSLATE("Enable protocol status notifications"), - new BMessage(kNotifyProtocolsLogin)); - - fNotifyContactStatus = new BCheckBox("EnableContactNotify", - B_TRANSLATE("Enable contact status notifications"), - new BMessage(kNotifyContactStatus)); - - fNotifyNewMessage = new BCheckBox("EnableMessageNotify", - B_TRANSLATE("Enable message notifications"), - new BMessage(kNotifyNewMessage)); + fMarkUnreadWindow->SetEnabled(false); // of unimplemented settings! BBox* generalBox = new BBox("general"); generalBox->SetLabel(B_TRANSLATE("General")); @@ -101,24 +73,13 @@ PreferencesBehavior::PreferencesBehavior() .Add(fHideOffline) .Add(fToCurrentWorkspace) .Add(fRaiseOnMessageReceived) - .Add(fRaiseUserIsTyping) .Add(fMarkUnreadWindow) - .Add(fMarkUnreadReplicant) - .Add(fPlaySoundOnMessageReceived) - .End(); - - BLayoutBuilder::Group<>(notificationBox, B_VERTICAL) - .SetInsets(spacing, spacing * 2, spacing, spacing) - .Add(fNotifyProtocols) - .Add(fNotifyContactStatus) - .Add(fNotifyNewMessage) .End(); BLayoutBuilder::Group<>(this, B_VERTICAL) .SetInsets(B_USE_DEFAULT_SPACING) .Add(generalBox) .Add(incomingBox) - .Add(notificationBox) .AddGlue() .End(); } @@ -129,29 +90,17 @@ PreferencesBehavior::AttachedToWindow() { fHideOffline->SetTarget(this); fToCurrentWorkspace->SetTarget(this); - fRaiseUserIsTyping->SetTarget(this); fRaiseOnMessageReceived->SetTarget(this); - fNotifyProtocols->SetTarget(this); - fNotifyContactStatus->SetTarget(this); - fNotifyNewMessage->SetTarget(this); fDisableQuitConfirm->SetTarget(this); fHideOffline->SetValue( AppPreferences::Get()->HideOffline); fToCurrentWorkspace->SetValue( AppPreferences::Get()->MoveToCurrentWorkspace); - fRaiseUserIsTyping->SetValue( - AppPreferences::Get()->RaiseUserIsTyping); fRaiseOnMessageReceived->SetValue( AppPreferences::Get()->RaiseOnMessageReceived); fMarkUnreadWindow->SetValue( AppPreferences::Get()->MarkUnreadWindow); - fNotifyProtocols->SetValue( - AppPreferences::Get()->NotifyProtocolStatus); - fNotifyContactStatus->SetValue( - AppPreferences::Get()->NotifyContactStatus); - fNotifyNewMessage->SetValue( - AppPreferences::Get()->NotifyNewMessage); fDisableQuitConfirm->SetValue( AppPreferences::Get()->DisableQuitConfirm); } @@ -173,22 +122,6 @@ PreferencesBehavior::MessageReceived(BMessage* message) AppPreferences::Get()->RaiseOnMessageReceived = fRaiseOnMessageReceived->Value(); break; - case kRaiseUserIsTyping: - AppPreferences::Get()->RaiseUserIsTyping - = fRaiseUserIsTyping->Value(); - break; - case kNotifyProtocolsLogin: - AppPreferences::Get()->NotifyProtocolStatus - = fNotifyProtocols->Value(); - break; - case kNotifyContactStatus: - AppPreferences::Get()->NotifyContactStatus - = fNotifyContactStatus->Value(); - break; - case kNotifyNewMessage: - AppPreferences::Get()->NotifyNewMessage - = fNotifyNewMessage->Value(); - break; case kMarkUnreadWindow: AppPreferences::Get()->MarkUnreadWindow = fMarkUnreadWindow->Value(); diff --git a/application/preferences/PreferencesBehavior.h b/application/preferences/PreferencesBehavior.h index b056ea3..54fb245 100644 --- a/application/preferences/PreferencesBehavior.h +++ b/application/preferences/PreferencesBehavior.h @@ -22,16 +22,9 @@ private: BCheckBox* fHideOffline; BCheckBox* fToCurrentWorkspace; BCheckBox* fRaiseOnMessageReceived; - BCheckBox* fRaiseUserIsTyping; - BCheckBox* fPlaySoundOnMessageReceived; BCheckBox* fMarkUnreadWindow; - BCheckBox* fMarkUnreadReplicant; BCheckBox* fDisableQuitConfirm; - - BCheckBox* fNotifyProtocols; - BCheckBox* fNotifyContactStatus; - BCheckBox* fNotifyNewMessage; }; #endif // _PREFERENCES_BEHAVIOR_H diff --git a/application/preferences/PreferencesChatWindow.cpp b/application/preferences/PreferencesChatWindow.cpp index bdab76b..baaa2ce 100644 --- a/application/preferences/PreferencesChatWindow.cpp +++ b/application/preferences/PreferencesChatWindow.cpp @@ -31,7 +31,7 @@ PreferencesChatWindow::PreferencesChatWindow() fIgnoreEmoticons = new BCheckBox("IgnoreEmoticons", B_TRANSLATE("Ignore emoticons"), new BMessage(kIgnoreEmoticons)); - fIgnoreEmoticons->SetEnabled(true); + fIgnoreEmoticons->SetEnabled(false); // No emoticon support currently const float spacing = be_control_look->DefaultItemSpacing(); diff --git a/application/preferences/PreferencesNotifications.cpp b/application/preferences/PreferencesNotifications.cpp new file mode 100644 index 0000000..f58a47b --- /dev/null +++ b/application/preferences/PreferencesNotifications.cpp @@ -0,0 +1,134 @@ +/* + * Copyright 2010, Oliver Ruiz Dorantes. All rights reserved. + * Copyright 2012, Dario Casalinuovo. All rights reserved. + * Copyright 2021, Jaidyn Levesque. All rights reserved. + * Distributed under the terms of the MIT License. + */ + +#include "PreferencesNotifications.h" + +#include +#include +#include +#include +#include + +#include "AppPreferences.h" + + +#undef B_TRANSLATION_CONTEXT +#define B_TRANSLATION_CONTEXT "PreferencesNotifications" + + +const uint32 kNotifyProtocolsLogin = 'NTpl'; +const uint32 kNotifyContactStatus = 'NTcl'; +const uint32 kNotifyNewMessage = 'NTms'; +const uint32 kSoundOnMessageReceived = 'Fmsn'; +const uint32 kSoundOnMention = 'FMsn'; + + +PreferencesNotifications::PreferencesNotifications() + : BView(B_TRANSLATE("Notifications"), B_WILL_DRAW) +{ + BBox* notificationBox = new BBox("notificationBox"); + notificationBox->SetLabel(B_TRANSLATE("Notifications")); + + fNotifyProtocols = new BCheckBox("EnableProtocolNotify", + B_TRANSLATE("Enable protocol status notifications"), + new BMessage(kNotifyProtocolsLogin)); + + fNotifyContactStatus = new BCheckBox("EnableContactNotify", + B_TRANSLATE("Enable contact status notifications"), + new BMessage(kNotifyContactStatus)); + fNotifyContactStatus->SetEnabled(false); // not even this! dear god… + + fNotifyNewMessage = new BCheckBox("EnableMessageNotify", + B_TRANSLATE("Enable message notifications"), + new BMessage(kNotifyNewMessage)); + + BBox* soundsBox = new BBox("soundsBox"); + soundsBox->SetLabel(B_TRANSLATE("Sounds")); + + fSoundOnMessageReceived = new BCheckBox("SoundOnMessageReceived", + B_TRANSLATE("Sound on message received"), NULL); + fSoundOnMessageReceived->SetEnabled(false); // wow that's a lot + + fSoundOnMention = new BCheckBox("SoundOnMention", + B_TRANSLATE("Sound when mentioned"), NULL); + fSoundOnMention->SetEnabled(false); // wow that's a lot + + const float spacing = be_control_look->DefaultItemSpacing(); + + + BLayoutBuilder::Group<>(notificationBox, B_VERTICAL) + .SetInsets(spacing, spacing * 2, spacing, spacing) + .Add(fNotifyProtocols) + .Add(fNotifyContactStatus) + .Add(fNotifyNewMessage) + .End(); + + BLayoutBuilder::Group<>(soundsBox, B_VERTICAL) + .SetInsets(spacing, spacing * 2, spacing, spacing) + .Add(fSoundOnMessageReceived) + .Add(fSoundOnMention) + .End(); + + BLayoutBuilder::Group<>(this, B_VERTICAL) + .SetInsets(B_USE_DEFAULT_SPACING) + .Add(notificationBox) + .Add(soundsBox) + .AddGlue() + .End(); +} + + +void +PreferencesNotifications::AttachedToWindow() +{ + fNotifyProtocols->SetTarget(this); + fNotifyContactStatus->SetTarget(this); + fNotifyNewMessage->SetTarget(this); + fSoundOnMessageReceived->SetTarget(this); + fSoundOnMention->SetTarget(this); + + fNotifyProtocols->SetValue( + AppPreferences::Get()->NotifyProtocolStatus); + fNotifyContactStatus->SetValue( + AppPreferences::Get()->NotifyContactStatus); + fNotifyNewMessage->SetValue( + AppPreferences::Get()->NotifyNewMessage); + fSoundOnMessageReceived->SetValue( + AppPreferences::Get()->SoundOnMessageReceived); + fSoundOnMention->SetValue( + AppPreferences::Get()->SoundOnMention); +} + + +void +PreferencesNotifications::MessageReceived(BMessage* message) +{ + switch (message->what) { + case kNotifyProtocolsLogin: + AppPreferences::Get()->NotifyProtocolStatus + = fNotifyProtocols->Value(); + break; + case kNotifyContactStatus: + AppPreferences::Get()->NotifyContactStatus + = fNotifyContactStatus->Value(); + break; + case kNotifyNewMessage: + AppPreferences::Get()->NotifyNewMessage + = fNotifyNewMessage->Value(); + break; + case kSoundOnMessageReceived: + AppPreferences::Get()->SoundOnMessageReceived + = fSoundOnMessageReceived->Value(); + break; + case kSoundOnMention: + AppPreferences::Get()->SoundOnMention + = fSoundOnMention->Value(); + break; + default: + BView::MessageReceived(message); + } +} diff --git a/application/preferences/PreferencesNotifications.h b/application/preferences/PreferencesNotifications.h new file mode 100644 index 0000000..2adb983 --- /dev/null +++ b/application/preferences/PreferencesNotifications.h @@ -0,0 +1,28 @@ +/* + * Copyright 2010, Oliver Ruiz Dorantes. All rights reserved. + * Copyright 2012, Dario Casalinuovo. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _PREFERENCES_NOTIFICATIONS_H +#define _PREFERENCES_NOTIFICATIONS_H + +#include + +class BCheckBox; + +class PreferencesNotifications : public BView { +public: + PreferencesNotifications(); + + virtual void AttachedToWindow(); + virtual void MessageReceived(BMessage* msg); + +private: + BCheckBox* fNotifyProtocols; + BCheckBox* fNotifyContactStatus; + BCheckBox* fNotifyNewMessage; + BCheckBox* fSoundOnMessageReceived; + BCheckBox* fSoundOnMention; +}; + +#endif // _PREFERENCES_BEHAVIOR_H diff --git a/application/preferences/PreferencesReplicant.cpp b/application/preferences/PreferencesReplicant.cpp index 2ff11f1..faba3d1 100644 --- a/application/preferences/PreferencesReplicant.cpp +++ b/application/preferences/PreferencesReplicant.cpp @@ -35,6 +35,7 @@ PreferencesReplicant::PreferencesReplicant() fDisableReplicant = new BCheckBox("DisableReplicant", B_TRANSLATE("Disable deskbar replicant"), new BMessage(kDisableReplicant)); + fDisableReplicant->SetEnabled(false); // Replicant is broken currently if (!AppPreferences::Get()->HideDeskbar) Looper()->PostMessage(new BMessage(kDisableReplicant)); diff --git a/application/windows/PreferencesWindow.cpp b/application/windows/PreferencesWindow.cpp index 0c82dfd..8777823 100644 --- a/application/windows/PreferencesWindow.cpp +++ b/application/windows/PreferencesWindow.cpp @@ -16,7 +16,7 @@ #include "PreferencesBehavior.h" #include "PreferencesChatWindow.h" -#include "PreferencesReplicant.h" +#include "PreferencesNotifications.h" #undef B_TRANSLATION_CONTEXT @@ -34,7 +34,7 @@ PreferencesWindow::PreferencesWindow() BTabView* tabView = new BTabView("tabView", B_WIDTH_AS_USUAL); tabView->AddTab(new PreferencesBehavior()); tabView->AddTab(new PreferencesChatWindow()); - tabView->AddTab(new PreferencesReplicant()); + tabView->AddTab(new PreferencesNotifications()); // Tab resizing here is a bit wonky. We want each tab to be visible, // but we don't want the tab-view to be too wide…