2010-05-19 13:05:30 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2010, Oliver Ruiz Dorantes. All rights reserved.
|
2012-03-01 20:23:21 -06:00
|
|
|
* Copyright 2012, Dario Casalinuovo. All rights reserved.
|
2010-05-19 13:05:30 -05:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <Button.h>
|
|
|
|
#include <CheckBox.h>
|
|
|
|
#include <ControlLook.h>
|
2012-03-03 20:27:16 -06:00
|
|
|
#include <Deskbar.h>
|
2010-05-19 13:05:30 -05:00
|
|
|
#include <GroupLayout.h>
|
|
|
|
#include <GroupLayoutBuilder.h>
|
|
|
|
#include <ScrollView.h>
|
|
|
|
#include <StringView.h>
|
|
|
|
|
2012-03-03 20:27:16 -06:00
|
|
|
#include "AccountManager.h"
|
2010-05-19 13:05:30 -05:00
|
|
|
#include "CayaProtocol.h"
|
|
|
|
#include "PreferencesBehavior.h"
|
|
|
|
#include "CayaPreferences.h"
|
|
|
|
#include "ProtocolManager.h"
|
|
|
|
#include "ProtocolSettings.h"
|
|
|
|
#include "MainWindow.h"
|
2012-03-03 20:27:16 -06:00
|
|
|
#include "ReplicantStatusView.h"
|
2010-05-19 13:05:30 -05:00
|
|
|
#include "TheApp.h"
|
|
|
|
|
|
|
|
const uint32 kToCurrentWorkspace = 'CBcw';
|
2012-06-07 11:46:07 -05:00
|
|
|
const uint32 kRaiseOnMessageReceived = 'FCmr';
|
|
|
|
const uint32 kRaiseUserIsTyping = 'FCit';
|
2012-03-08 16:55:13 -06:00
|
|
|
const uint32 kNotifyProtocolsLogin = 'NTpl';
|
|
|
|
const uint32 kNotifyContactStatus = 'NTcl';
|
2013-04-06 14:47:04 -05:00
|
|
|
const uint32 kNotifyNewMessage = 'NTms';
|
|
|
|
const uint32 kMarkUnreadWindow = 'MKuw';
|
|
|
|
const uint32 kHideOffline = 'HiOf';
|
2010-05-19 13:05:30 -05:00
|
|
|
|
2010-05-19 15:37:26 -05:00
|
|
|
|
2010-05-19 13:05:30 -05:00
|
|
|
PreferencesBehavior::PreferencesBehavior()
|
2012-06-07 11:46:07 -05:00
|
|
|
: BView("Behavior", B_WILL_DRAW)
|
2010-05-19 13:05:30 -05:00
|
|
|
{
|
|
|
|
|
2010-05-30 17:02:50 -05:00
|
|
|
fOnIncoming = new BStringView("onIncoming", "On incoming message...");
|
2010-05-30 17:00:09 -05:00
|
|
|
fOnIncoming->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
|
|
|
|
fOnIncoming->SetFont(be_bold_font);
|
2013-04-06 14:47:04 -05:00
|
|
|
|
|
|
|
fHideOffline = new BCheckBox("HideOfflineContacts",
|
|
|
|
"Hide offline contacts",
|
|
|
|
new BMessage(kHideOffline));
|
2010-05-19 13:05:30 -05:00
|
|
|
|
|
|
|
fToCurrentWorkspace = new BCheckBox("ToCurrentWorkspace",
|
|
|
|
"Move window to current workspace",
|
|
|
|
new BMessage(kToCurrentWorkspace));
|
|
|
|
|
2012-06-07 11:46:07 -05:00
|
|
|
fRaiseOnMessageReceived = new BCheckBox("FocusOnMessageReceived",
|
|
|
|
"Auto-raise when a message is received",
|
|
|
|
new BMessage(kRaiseOnMessageReceived));
|
2012-03-08 18:35:02 -06:00
|
|
|
|
2012-06-07 11:46:07 -05:00
|
|
|
fRaiseUserIsTyping = new BCheckBox("FocusUserIsTyping",
|
|
|
|
"Auto-raise when user is typing",
|
|
|
|
new BMessage(kRaiseUserIsTyping));
|
2010-05-19 13:05:30 -05:00
|
|
|
|
|
|
|
fPlaySoundOnMessageReceived = new BCheckBox("PlaySoundOnMessageReceived",
|
|
|
|
"Play sound event", NULL);
|
|
|
|
fPlaySoundOnMessageReceived->SetEnabled(false); // not implemented
|
|
|
|
|
|
|
|
fMarkUnreadWindow = new BCheckBox("MarkUnreadWindow",
|
2013-04-06 14:47:04 -05:00
|
|
|
"Mark unread window chat", new BMessage(kMarkUnreadWindow));
|
|
|
|
/*fMarkUnreadWindow->SetEnabled(false); implementing it right now*/
|
2012-03-03 20:27:16 -06:00
|
|
|
|
|
|
|
fMarkUnreadReplicant = new BCheckBox("MarkUnreadReplicant",
|
|
|
|
"Mark unread the Deskbar Replicant", NULL);
|
|
|
|
fMarkUnreadReplicant->SetEnabled(false);
|
2010-05-30 17:00:09 -05:00
|
|
|
// not implemented
|
2010-05-19 13:05:30 -05:00
|
|
|
|
2012-03-11 19:40:37 -05:00
|
|
|
fNotifications = new BStringView("notifications",
|
|
|
|
"Deskbar Notifications (experimental)");
|
|
|
|
|
2012-03-08 16:55:13 -06:00
|
|
|
fNotifications->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
|
|
|
|
fNotifications->SetFont(be_bold_font);
|
2011-12-14 17:36:27 -06:00
|
|
|
|
2012-03-08 16:55:13 -06:00
|
|
|
fNotifyProtocols = new BCheckBox("EnableProtocolNotify",
|
|
|
|
"Enable protocol status notifications",new BMessage(kNotifyProtocolsLogin));
|
2011-12-14 17:36:27 -06:00
|
|
|
|
2012-03-08 16:55:13 -06:00
|
|
|
fNotifyContactStatus = new BCheckBox("EnableContactNotify",
|
|
|
|
"Enable contact status notifications",new BMessage(kNotifyContactStatus));
|
2013-04-06 14:47:04 -05:00
|
|
|
|
|
|
|
fNotifyNewMessage = new BCheckBox("EnableMessageNotify",
|
|
|
|
"Enable message notifications", new BMessage(kNotifyNewMessage));
|
2011-12-14 17:36:27 -06:00
|
|
|
|
2010-05-19 13:05:30 -05:00
|
|
|
const float spacing = be_control_look->DefaultItemSpacing();
|
|
|
|
|
|
|
|
SetLayout(new BGroupLayout(B_HORIZONTAL, spacing));
|
|
|
|
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
2010-05-30 17:00:09 -05:00
|
|
|
.Add(fOnIncoming)
|
2010-05-19 13:05:30 -05:00
|
|
|
.AddGroup(B_VERTICAL, spacing)
|
2013-04-06 14:47:04 -05:00
|
|
|
.Add(fHideOffline)
|
2010-05-19 13:05:30 -05:00
|
|
|
.Add(fToCurrentWorkspace)
|
2012-06-07 11:46:07 -05:00
|
|
|
.Add(fRaiseOnMessageReceived)
|
|
|
|
.Add(fRaiseUserIsTyping)
|
2010-05-19 13:05:30 -05:00
|
|
|
.Add(fMarkUnreadWindow)
|
2012-03-03 20:27:16 -06:00
|
|
|
.Add(fMarkUnreadReplicant)
|
2010-05-19 13:05:30 -05:00
|
|
|
.Add(fPlaySoundOnMessageReceived)
|
2012-03-08 16:55:13 -06:00
|
|
|
. SetInsets(spacing * 2, spacing, spacing, spacing)
|
2012-03-01 20:23:21 -06:00
|
|
|
.End()
|
2012-03-08 16:55:13 -06:00
|
|
|
.Add(fNotifications)
|
2012-03-01 20:23:21 -06:00
|
|
|
.AddGroup(B_VERTICAL, spacing)
|
2012-03-08 16:55:13 -06:00
|
|
|
.Add(fNotifyProtocols)
|
|
|
|
.Add(fNotifyContactStatus)
|
2013-04-06 14:47:04 -05:00
|
|
|
.Add(fNotifyNewMessage)
|
2012-03-08 16:55:13 -06:00
|
|
|
. SetInsets(spacing * 2, spacing, spacing, spacing)
|
2010-05-19 13:05:30 -05:00
|
|
|
.End()
|
2010-05-19 17:06:25 -05:00
|
|
|
.AddGlue()
|
2010-05-19 13:05:30 -05:00
|
|
|
.SetInsets(spacing, spacing, spacing, spacing)
|
2010-10-24 01:27:09 -05:00
|
|
|
.TopView()
|
2010-05-19 13:05:30 -05:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PreferencesBehavior::AttachedToWindow()
|
|
|
|
{
|
2013-04-06 14:47:04 -05:00
|
|
|
fHideOffline->SetTarget(this);
|
2010-05-19 13:05:30 -05:00
|
|
|
fToCurrentWorkspace->SetTarget(this);
|
2012-06-07 11:46:07 -05:00
|
|
|
fRaiseUserIsTyping->SetTarget(this);
|
|
|
|
fRaiseOnMessageReceived->SetTarget(this);
|
2012-03-08 16:55:13 -06:00
|
|
|
fNotifyProtocols->SetTarget(this);
|
|
|
|
fNotifyContactStatus->SetTarget(this);
|
2013-04-06 14:47:04 -05:00
|
|
|
fNotifyNewMessage->SetTarget(this);
|
|
|
|
|
|
|
|
fHideOffline->SetValue(
|
|
|
|
CayaPreferences::Item()->HideOffline);
|
2010-05-19 15:37:26 -05:00
|
|
|
fToCurrentWorkspace->SetValue(
|
|
|
|
CayaPreferences::Item()->MoveToCurrentWorkspace);
|
2012-06-07 11:46:07 -05:00
|
|
|
fRaiseUserIsTyping->SetValue(
|
|
|
|
CayaPreferences::Item()->RaiseUserIsTyping);
|
|
|
|
fRaiseOnMessageReceived->SetValue(
|
|
|
|
CayaPreferences::Item()->RaiseOnMessageReceived);
|
2013-04-06 14:47:04 -05:00
|
|
|
fMarkUnreadWindow->SetValue(
|
|
|
|
CayaPreferences::Item()->MarkUnreadWindow);
|
2012-03-08 16:55:13 -06:00
|
|
|
fNotifyProtocols->SetValue(
|
|
|
|
CayaPreferences::Item()->NotifyProtocolStatus);
|
|
|
|
fNotifyContactStatus->SetValue(
|
|
|
|
CayaPreferences::Item()->NotifyContactStatus);
|
2013-04-06 14:47:04 -05:00
|
|
|
fNotifyNewMessage->SetValue(
|
|
|
|
CayaPreferences::Item()->NotifyNewMessage);
|
2010-05-19 13:05:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PreferencesBehavior::MessageReceived(BMessage* message)
|
|
|
|
{
|
|
|
|
switch (message->what) {
|
2013-04-06 14:47:04 -05:00
|
|
|
case kHideOffline:
|
|
|
|
CayaPreferences::Item()->HideOffline
|
|
|
|
= fHideOffline->Value();
|
|
|
|
break;
|
2010-05-19 13:05:30 -05:00
|
|
|
case kToCurrentWorkspace:
|
2010-05-19 15:37:26 -05:00
|
|
|
CayaPreferences::Item()->MoveToCurrentWorkspace
|
|
|
|
= fToCurrentWorkspace->Value();
|
2010-05-19 13:05:30 -05:00
|
|
|
break;
|
2012-06-07 11:46:07 -05:00
|
|
|
case kRaiseOnMessageReceived:
|
|
|
|
CayaPreferences::Item()->RaiseOnMessageReceived
|
|
|
|
= fRaiseOnMessageReceived->Value();
|
2012-03-08 18:35:02 -06:00
|
|
|
break;
|
2012-06-07 11:46:07 -05:00
|
|
|
case kRaiseUserIsTyping:
|
|
|
|
CayaPreferences::Item()->RaiseUserIsTyping
|
|
|
|
= fRaiseUserIsTyping->Value();
|
2010-05-19 13:05:30 -05:00
|
|
|
break;
|
2012-03-08 16:55:13 -06:00
|
|
|
case kNotifyProtocolsLogin:
|
|
|
|
CayaPreferences::Item()->NotifyProtocolStatus
|
|
|
|
= fNotifyProtocols->Value();
|
2012-03-03 20:27:16 -06:00
|
|
|
break;
|
2012-03-08 16:55:13 -06:00
|
|
|
case kNotifyContactStatus:
|
|
|
|
CayaPreferences::Item()->NotifyContactStatus
|
|
|
|
= fNotifyContactStatus->Value();
|
2012-03-03 20:27:16 -06:00
|
|
|
break;
|
2013-04-06 14:47:04 -05:00
|
|
|
case kNotifyNewMessage:
|
|
|
|
CayaPreferences::Item()->NotifyNewMessage
|
|
|
|
= fNotifyNewMessage->Value();
|
|
|
|
break;
|
|
|
|
case kMarkUnreadWindow:
|
|
|
|
CayaPreferences::Item()->MarkUnreadWindow
|
|
|
|
= fMarkUnreadWindow->Value();
|
|
|
|
break;
|
2010-05-19 13:05:30 -05:00
|
|
|
default:
|
|
|
|
BView::MessageReceived(message);
|
|
|
|
}
|
|
|
|
}
|