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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <CheckBox.h>
|
|
|
|
#include <ControlLook.h>
|
|
|
|
#include <Deskbar.h>
|
|
|
|
#include <GroupLayout.h>
|
|
|
|
#include <GroupLayoutBuilder.h>
|
|
|
|
#include <StringView.h>
|
|
|
|
|
|
|
|
#include "AccountManager.h"
|
|
|
|
#include "CayaProtocol.h"
|
|
|
|
#include "PreferencesReplicant.h"
|
|
|
|
#include "CayaPreferences.h"
|
|
|
|
#include "ProtocolManager.h"
|
|
|
|
#include "ProtocolSettings.h"
|
|
|
|
#include "MainWindow.h"
|
|
|
|
#include "ReplicantStatusView.h"
|
|
|
|
#include "TheApp.h"
|
|
|
|
|
|
|
|
const uint32 kDisableReplicant = 'DSrp';
|
|
|
|
const uint32 kPermanentReplicant ='PRpt';
|
|
|
|
const uint32 kHideCayaDeskbar = 'HCtk';
|
|
|
|
|
|
|
|
|
|
|
|
PreferencesReplicant::PreferencesReplicant()
|
|
|
|
: BView("Replicant", B_WILL_DRAW)
|
|
|
|
{
|
2012-03-24 18:54:58 -05:00
|
|
|
fReplicantString = new BStringView("ReplicantString",
|
2013-07-31 15:34:52 -05:00
|
|
|
"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",
|
|
|
|
"Disable Deskbar replicant", new BMessage(kDisableReplicant));
|
|
|
|
|
2013-07-31 15:34:52 -05:00
|
|
|
if (!CayaPreferences::Item()->HideCayaDeskbar)
|
|
|
|
Looper()->PostMessage(new BMessage(kDisableReplicant));
|
|
|
|
|
2012-03-13 17:57:04 -05:00
|
|
|
fPermanentReplicant = new BCheckBox("PermanentReplicant",
|
|
|
|
"Permanent Deskbar Replicant", NULL);
|
|
|
|
fPermanentReplicant->SetEnabled(false);
|
|
|
|
|
|
|
|
fHideCayaDeskbar = new BCheckBox("HideCayaDeskbar",
|
|
|
|
"Hide Caya field in Deskbar", new BMessage(kHideCayaDeskbar));
|
|
|
|
fHideCayaDeskbar->SetEnabled(false);
|
|
|
|
|
|
|
|
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)
|
|
|
|
.Add(fHideCayaDeskbar)
|
|
|
|
.SetInsets(spacing * 2, spacing, spacing, spacing)
|
|
|
|
.End()
|
|
|
|
.AddGlue()
|
|
|
|
.SetInsets(spacing, spacing, spacing, spacing)
|
|
|
|
.TopView()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PreferencesReplicant::AttachedToWindow()
|
|
|
|
{
|
|
|
|
fHideCayaDeskbar->SetTarget(this);
|
|
|
|
fDisableReplicant->SetTarget(this);
|
|
|
|
|
|
|
|
fHideCayaDeskbar->SetValue(
|
|
|
|
CayaPreferences::Item()->HideCayaDeskbar);
|
|
|
|
fDisableReplicant->SetValue(
|
|
|
|
CayaPreferences::Item()->DisableReplicant);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PreferencesReplicant::MessageReceived(BMessage* message)
|
|
|
|
{
|
|
|
|
switch (message->what) {
|
|
|
|
case kHideCayaDeskbar:
|
|
|
|
CayaPreferences::Item()->HideCayaDeskbar
|
|
|
|
= fHideCayaDeskbar->Value();
|
|
|
|
break;
|
|
|
|
case kDisableReplicant:
|
|
|
|
CayaPreferences::Item()->DisableReplicant
|
|
|
|
= fDisableReplicant->Value();
|
|
|
|
|
|
|
|
if (fDisableReplicant->Value() == true)
|
|
|
|
ReplicantStatusView::RemoveReplicant();
|
|
|
|
else
|
|
|
|
ReplicantStatusView::InstallReplicant();
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BView::MessageReceived(message);
|
|
|
|
}
|
|
|
|
}
|