Disable unusable settings, Notfications tab

This commit is contained in:
Jaidyn Ann 2021-08-18 18:28:53 -05:00
parent 6e89dbdab1
commit 901f7a8e05
10 changed files with 179 additions and 86 deletions

View File

@ -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 \

View File

@ -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);

View File

@ -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;

View File

@ -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();

View File

@ -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

View File

@ -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();

View File

@ -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 <Box.h>
#include <Catalog.h>
#include <CheckBox.h>
#include <ControlLook.h>
#include <LayoutBuilder.h>
#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);
}
}

View File

@ -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 <View.h>
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

View File

@ -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));

View File

@ -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…