Chat-O-Matic/application/preferences/PreferencesReplicant.cpp

107 lines
2.6 KiB
C++
Raw Normal View History

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"
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"
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()
: BView("Replicant", B_WILL_DRAW)
{
fReplicantString = new BStringView("ReplicantString",
"Deskbar Replicant");
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));
2021-06-20 12:44:20 -05:00
if (!AppPreferences::Item()->HideDeskbar)
Looper()->PostMessage(new BMessage(kDisableReplicant));
2012-03-13 17:57:04 -05:00
fPermanentReplicant = new BCheckBox("PermanentReplicant",
"Permanent Deskbar Replicant", NULL);
fPermanentReplicant->SetEnabled(false);
2021-06-20 12:44:20 -05:00
fHideDeskbar = new BCheckBox("HideDeskbar",
"Hide field in Deskbar", new BMessage(kHideDeskbar));
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);
}
}