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.
|
2021-07-24 13:25:44 -05:00
|
|
|
* Copyright 2021, Jaidyn Levesque. All rights reserved.
|
2010-05-19 13:05:30 -05:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
|
2021-07-24 13:25:44 -05:00
|
|
|
#include "PreferencesBehavior.h"
|
|
|
|
|
|
|
|
#include <Box.h>
|
2021-07-19 09:54:27 -05:00
|
|
|
#include <Catalog.h>
|
2010-05-19 13:05:30 -05:00
|
|
|
#include <CheckBox.h>
|
|
|
|
#include <ControlLook.h>
|
2021-07-24 13:25:44 -05:00
|
|
|
#include <LayoutBuilder.h>
|
2010-05-19 13:05:30 -05:00
|
|
|
|
2021-06-20 12:44:20 -05:00
|
|
|
#include "AppPreferences.h"
|
2010-05-19 13:05:30 -05:00
|
|
|
|
2021-07-19 09:54:27 -05:00
|
|
|
|
|
|
|
#undef B_TRANSLATION_CONTEXT
|
|
|
|
#define B_TRANSLATION_CONTEXT "PreferencesBehavior"
|
|
|
|
|
|
|
|
|
2010-05-19 13:05:30 -05:00
|
|
|
const uint32 kToCurrentWorkspace = 'CBcw';
|
2012-06-07 11:46:07 -05:00
|
|
|
const uint32 kRaiseOnMessageReceived = 'FCmr';
|
|
|
|
const uint32 kRaiseUserIsTyping = 'FCit';
|
2013-04-06 14:47:04 -05:00
|
|
|
const uint32 kMarkUnreadWindow = 'MKuw';
|
|
|
|
const uint32 kHideOffline = 'HiOf';
|
2015-10-01 23:17:54 -05:00
|
|
|
const uint32 kDisablePrompt = 'DiPr';
|
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()
|
2021-07-19 09:54:27 -05:00
|
|
|
: BView(B_TRANSLATE("Behavior"), B_WILL_DRAW)
|
2010-05-19 13:05:30 -05:00
|
|
|
{
|
2021-07-24 13:25:44 -05:00
|
|
|
BBox* incomingBox = new BBox("incoming");
|
|
|
|
incomingBox->SetLabel(B_TRANSLATE("On incoming" B_UTF8_ELLIPSIS));
|
2013-04-06 14:47:04 -05:00
|
|
|
|
|
|
|
fHideOffline = new BCheckBox("HideOfflineContacts",
|
2021-07-19 09:54:27 -05:00
|
|
|
B_TRANSLATE("Hide offline contacts"),
|
2013-04-06 14:47:04 -05:00
|
|
|
new BMessage(kHideOffline));
|
2021-08-18 18:28:53 -05:00
|
|
|
fHideOffline->SetEnabled(false); //not implemented as yet
|
2010-05-19 13:05:30 -05:00
|
|
|
|
|
|
|
fToCurrentWorkspace = new BCheckBox("ToCurrentWorkspace",
|
2021-07-19 09:54:27 -05:00
|
|
|
B_TRANSLATE("Move window to current workspace"),
|
2010-05-19 13:05:30 -05:00
|
|
|
new BMessage(kToCurrentWorkspace));
|
2021-08-18 18:28:53 -05:00
|
|
|
fToCurrentWorkspace->SetEnabled(false); // not this either
|
2010-05-19 13:05:30 -05:00
|
|
|
|
2012-06-07 11:46:07 -05:00
|
|
|
fRaiseOnMessageReceived = new BCheckBox("FocusOnMessageReceived",
|
2021-07-19 09:54:27 -05:00
|
|
|
B_TRANSLATE("Auto-raise when a message is received"),
|
2012-06-07 11:46:07 -05:00
|
|
|
new BMessage(kRaiseOnMessageReceived));
|
2021-08-18 18:28:53 -05:00
|
|
|
fRaiseOnMessageReceived->SetEnabled(false); // nor this
|
2010-05-19 13:05:30 -05:00
|
|
|
|
|
|
|
fMarkUnreadWindow = new BCheckBox("MarkUnreadWindow",
|
2021-07-19 09:54:27 -05:00
|
|
|
B_TRANSLATE("Mark unread window chat"),
|
|
|
|
new BMessage(kMarkUnreadWindow));
|
2021-08-18 18:28:53 -05:00
|
|
|
fMarkUnreadWindow->SetEnabled(false); // of unimplemented settings!
|
2011-12-14 17:36:27 -06:00
|
|
|
|
2021-07-24 13:25:44 -05:00
|
|
|
BBox* generalBox = new BBox("general");
|
|
|
|
generalBox->SetLabel(B_TRANSLATE("General"));
|
2015-10-01 23:17:54 -05:00
|
|
|
|
|
|
|
fDisableQuitConfirm = new BCheckBox("DisableQuitConfirm",
|
2021-07-19 09:54:27 -05:00
|
|
|
B_TRANSLATE("Don't ask confirmation at Quit"),
|
|
|
|
new BMessage(kDisablePrompt));
|
2010-05-19 13:05:30 -05:00
|
|
|
const float spacing = be_control_look->DefaultItemSpacing();
|
|
|
|
|
2021-07-24 13:25:44 -05:00
|
|
|
|
|
|
|
BLayoutBuilder::Group<>(generalBox, B_VERTICAL)
|
|
|
|
.SetInsets(spacing, spacing * 2, spacing, spacing)
|
|
|
|
.Add(fDisableQuitConfirm)
|
|
|
|
.End();
|
|
|
|
|
|
|
|
BLayoutBuilder::Group<>(incomingBox, B_VERTICAL)
|
|
|
|
.SetInsets(spacing, spacing * 2, spacing, spacing)
|
|
|
|
.Add(fHideOffline)
|
|
|
|
.Add(fToCurrentWorkspace)
|
|
|
|
.Add(fRaiseOnMessageReceived)
|
|
|
|
.Add(fMarkUnreadWindow)
|
|
|
|
.End();
|
|
|
|
|
|
|
|
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
|
|
|
.SetInsets(B_USE_DEFAULT_SPACING)
|
|
|
|
.Add(generalBox)
|
|
|
|
.Add(incomingBox)
|
2010-05-19 17:06:25 -05:00
|
|
|
.AddGlue()
|
2021-07-24 13:25:44 -05:00
|
|
|
.End();
|
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
|
|
|
fRaiseOnMessageReceived->SetTarget(this);
|
2015-10-01 23:17:54 -05:00
|
|
|
fDisableQuitConfirm->SetTarget(this);
|
2013-04-06 14:47:04 -05:00
|
|
|
|
|
|
|
fHideOffline->SetValue(
|
2021-07-28 19:10:09 -05:00
|
|
|
AppPreferences::Get()->HideOffline);
|
2010-05-19 15:37:26 -05:00
|
|
|
fToCurrentWorkspace->SetValue(
|
2021-07-28 19:10:09 -05:00
|
|
|
AppPreferences::Get()->MoveToCurrentWorkspace);
|
2012-06-07 11:46:07 -05:00
|
|
|
fRaiseOnMessageReceived->SetValue(
|
2021-07-28 19:10:09 -05:00
|
|
|
AppPreferences::Get()->RaiseOnMessageReceived);
|
2013-04-06 14:47:04 -05:00
|
|
|
fMarkUnreadWindow->SetValue(
|
2021-07-28 19:10:09 -05:00
|
|
|
AppPreferences::Get()->MarkUnreadWindow);
|
2015-10-01 23:17:54 -05:00
|
|
|
fDisableQuitConfirm->SetValue(
|
2021-07-28 19:10:09 -05:00
|
|
|
AppPreferences::Get()->DisableQuitConfirm);
|
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:
|
2021-07-28 19:10:09 -05:00
|
|
|
AppPreferences::Get()->HideOffline
|
2013-04-06 14:47:04 -05:00
|
|
|
= fHideOffline->Value();
|
|
|
|
break;
|
2010-05-19 13:05:30 -05:00
|
|
|
case kToCurrentWorkspace:
|
2021-07-28 19:10:09 -05:00
|
|
|
AppPreferences::Get()->MoveToCurrentWorkspace
|
2010-05-19 15:37:26 -05:00
|
|
|
= fToCurrentWorkspace->Value();
|
2010-05-19 13:05:30 -05:00
|
|
|
break;
|
2012-06-07 11:46:07 -05:00
|
|
|
case kRaiseOnMessageReceived:
|
2021-07-28 19:10:09 -05:00
|
|
|
AppPreferences::Get()->RaiseOnMessageReceived
|
2012-06-07 11:46:07 -05:00
|
|
|
= fRaiseOnMessageReceived->Value();
|
2012-03-08 18:35:02 -06:00
|
|
|
break;
|
2013-04-06 14:47:04 -05:00
|
|
|
case kMarkUnreadWindow:
|
2021-07-28 19:10:09 -05:00
|
|
|
AppPreferences::Get()->MarkUnreadWindow
|
2013-04-06 14:47:04 -05:00
|
|
|
= fMarkUnreadWindow->Value();
|
|
|
|
break;
|
2015-10-01 23:17:54 -05:00
|
|
|
case kDisablePrompt:
|
2021-07-28 19:10:09 -05:00
|
|
|
AppPreferences::Get()->DisableQuitConfirm
|
2015-10-01 23:17:54 -05:00
|
|
|
= fDisableQuitConfirm->Value();
|
|
|
|
break;
|
2010-05-19 13:05:30 -05:00
|
|
|
default:
|
|
|
|
BView::MessageReceived(message);
|
|
|
|
}
|
|
|
|
}
|