2012-03-13 17:57:04 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2010, Oliver Ruiz Dorantes. All rights reserved.
|
|
|
|
* Copyright 2012, Dario Casalinuovo. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
|
2021-07-19 09:54:27 -05:00
|
|
|
#include <Catalog.h>
|
2012-03-13 17:57:04 -05:00
|
|
|
#include <CheckBox.h>
|
|
|
|
#include <ControlLook.h>
|
|
|
|
#include <Deskbar.h>
|
|
|
|
#include <GroupLayout.h>
|
|
|
|
#include <GroupLayoutBuilder.h>
|
|
|
|
#include <StringView.h>
|
|
|
|
|
|
|
|
#include "AccountManager.h"
|
2021-06-20 12:44:20 -05:00
|
|
|
#include "ChatProtocol.h"
|
2012-03-13 17:57:04 -05:00
|
|
|
#include "PreferencesReplicant.h"
|
2021-06-20 12:44:20 -05:00
|
|
|
#include "AppPreferences.h"
|
2012-03-13 17:57:04 -05:00
|
|
|
#include "ProtocolManager.h"
|
|
|
|
#include "ProtocolSettings.h"
|
|
|
|
#include "MainWindow.h"
|
|
|
|
#include "ReplicantStatusView.h"
|
|
|
|
#include "TheApp.h"
|
|
|
|
|
2021-07-19 09:54:27 -05:00
|
|
|
|
|
|
|
#undef B_TRANSLATION_CONTEXT
|
|
|
|
#define B_TRANSLATION_CONTEXT "PreferencesReplicant"
|
|
|
|
|
|
|
|
|
2012-03-13 17:57:04 -05:00
|
|
|
const uint32 kDisableReplicant = 'DSrp';
|
|
|
|
const uint32 kPermanentReplicant ='PRpt';
|
2021-06-20 12:44:20 -05:00
|
|
|
const uint32 kHideDeskbar = 'HCtk';
|
2012-03-13 17:57:04 -05:00
|
|
|
|
|
|
|
|
|
|
|
PreferencesReplicant::PreferencesReplicant()
|
2021-07-19 09:54:27 -05:00
|
|
|
: BView(B_TRANSLATE("Replicant"), B_WILL_DRAW)
|
2012-03-13 17:57:04 -05:00
|
|
|
{
|
2012-03-24 18:54:58 -05:00
|
|
|
fReplicantString = new BStringView("ReplicantString",
|
2021-07-19 09:54:27 -05:00
|
|
|
B_TRANSLATE("Deskbar replicant"));
|
2012-03-24 18:54:58 -05:00
|
|
|
|
|
|
|
fReplicantString->SetExplicitAlignment(
|
|
|
|
BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
|
|
|
|
|
2012-03-13 17:57:04 -05:00
|
|
|
fReplicantString->SetFont(be_bold_font);
|
|
|
|
|
|
|
|
fDisableReplicant = new BCheckBox("DisableReplicant",
|
2021-07-19 09:54:27 -05:00
|
|
|
B_TRANSLATE("Disable deskbar replicant"),
|
|
|
|
new BMessage(kDisableReplicant));
|
2012-03-13 17:57:04 -05:00
|
|
|
|
2021-06-20 12:44:20 -05:00
|
|
|
if (!AppPreferences::Item()->HideDeskbar)
|
2013-07-31 15:34:52 -05:00
|
|
|
Looper()->PostMessage(new BMessage(kDisableReplicant));
|
|
|
|
|
2012-03-13 17:57:04 -05:00
|
|
|
fPermanentReplicant = new BCheckBox("PermanentReplicant",
|
2021-07-19 09:54:27 -05:00
|
|
|
B_TRANSLATE("Permanent deskbar replicant"), NULL);
|
2012-03-13 17:57:04 -05:00
|
|
|
fPermanentReplicant->SetEnabled(false);
|
|
|
|
|
2021-06-20 12:44:20 -05:00
|
|
|
fHideDeskbar = new BCheckBox("HideDeskbar",
|
2021-07-19 09:54:27 -05:00
|
|
|
B_TRANSLATE("Hide field in Deskbar"), new BMessage(kHideDeskbar));
|
2021-06-20 12:44:20 -05:00
|
|
|
fHideDeskbar->SetEnabled(false);
|
2012-03-13 17:57:04 -05:00
|
|
|
|
|
|
|
const float spacing = be_control_look->DefaultItemSpacing();
|
|
|
|
|
|
|
|
SetLayout(new BGroupLayout(B_HORIZONTAL, spacing));
|
|
|
|
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
|
|
|
.Add(fReplicantString)
|
|
|
|
.AddGroup(B_VERTICAL, spacing)
|
|
|
|
.Add(fDisableReplicant)
|
|
|
|
.Add(fPermanentReplicant)
|
2021-06-20 12:44:20 -05:00
|
|
|
.Add(fHideDeskbar)
|
2012-03-13 17:57:04 -05:00
|
|
|
.SetInsets(spacing * 2, spacing, spacing, spacing)
|
|
|
|
.End()
|
|
|
|
.AddGlue()
|
|
|
|
.SetInsets(spacing, spacing, spacing, spacing)
|
|
|
|
.TopView()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PreferencesReplicant::AttachedToWindow()
|
|
|
|
{
|
2021-06-20 12:44:20 -05:00
|
|
|
fHideDeskbar->SetTarget(this);
|
2012-03-13 17:57:04 -05:00
|
|
|
fDisableReplicant->SetTarget(this);
|
|
|
|
|
2021-06-20 12:44:20 -05:00
|
|
|
fHideDeskbar->SetValue(
|
|
|
|
AppPreferences::Item()->HideDeskbar);
|
2012-03-13 17:57:04 -05:00
|
|
|
fDisableReplicant->SetValue(
|
2021-06-20 12:44:20 -05:00
|
|
|
AppPreferences::Item()->DisableReplicant);
|
2012-03-13 17:57:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PreferencesReplicant::MessageReceived(BMessage* message)
|
|
|
|
{
|
|
|
|
switch (message->what) {
|
2021-06-20 12:44:20 -05:00
|
|
|
case kHideDeskbar:
|
|
|
|
AppPreferences::Item()->HideDeskbar
|
|
|
|
= fHideDeskbar->Value();
|
2012-03-13 17:57:04 -05:00
|
|
|
break;
|
|
|
|
case kDisableReplicant:
|
2021-06-20 12:44:20 -05:00
|
|
|
AppPreferences::Item()->DisableReplicant
|
2012-03-13 17:57:04 -05:00
|
|
|
= fDisableReplicant->Value();
|
|
|
|
|
|
|
|
if (fDisableReplicant->Value() == true)
|
|
|
|
ReplicantStatusView::RemoveReplicant();
|
|
|
|
else
|
|
|
|
ReplicantStatusView::InstallReplicant();
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BView::MessageReceived(message);
|
|
|
|
}
|
|
|
|
}
|