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

103 lines
2.5 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.
* Copyright 2021, Jaidyn Levesque. All rights reserved.
2012-03-13 17:57:04 -05:00
* Distributed under the terms of the MIT License.
*/
#include "PreferencesReplicant.h"
#include <Box.h>
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 <LayoutBuilder.h>
2012-03-13 17:57:04 -05:00
2021-06-20 12:44:20 -05:00
#include "AppPreferences.h"
2012-03-13 17:57:04 -05:00
#include "ReplicantStatusView.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
{
BBox* replicantBox = new BBox("replicantBox");
replicantBox->SetLabel(B_TRANSLATE("Deskbar replicant"));
2012-03-13 17:57:04 -05:00
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-07-28 19:10:09 -05:00
if (!AppPreferences::Get()->HideDeskbar)
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
2012-03-13 17:57:04 -05:00
const float spacing = be_control_look->DefaultItemSpacing();
BLayoutBuilder::Group<>(replicantBox, B_VERTICAL)
.SetInsets(spacing, spacing * 2, spacing, spacing)
.Add(fDisableReplicant)
.Add(fPermanentReplicant)
.Add(fHideDeskbar)
.End();
BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(replicantBox)
2012-03-13 17:57:04 -05:00
.AddGlue()
.End();
2012-03-13 17:57:04 -05:00
}
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(
2021-07-28 19:10:09 -05:00
AppPreferences::Get()->HideDeskbar);
2012-03-13 17:57:04 -05:00
fDisableReplicant->SetValue(
2021-07-28 19:10:09 -05:00
AppPreferences::Get()->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:
2021-07-28 19:10:09 -05:00
AppPreferences::Get()->HideDeskbar
2021-06-20 12:44:20 -05:00
= fHideDeskbar->Value();
2012-03-13 17:57:04 -05:00
break;
case kDisableReplicant:
2021-07-28 19:10:09 -05:00
AppPreferences::Get()->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);
}
}