2012-03-13 17:57:04 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2010, Oliver Ruiz Dorantes. All rights reserved.
|
|
|
|
* Copyright 2012, Dario Casalinuovo. All rights reserved.
|
2021-07-24 13:25:44 -05:00
|
|
|
* Copyright 2021, Jaidyn Levesque. All rights reserved.
|
2012-03-13 17:57:04 -05:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
|
2021-07-24 13:25:44 -05:00
|
|
|
#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>
|
2021-07-24 13:25:44 -05:00
|
|
|
#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
|
|
|
{
|
2021-07-24 13:25:44 -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-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
|
|
|
|
2021-07-24 13:25:44 -05:00
|
|
|
|
2012-03-13 17:57:04 -05:00
|
|
|
const float spacing = be_control_look->DefaultItemSpacing();
|
|
|
|
|
2021-07-24 13:25:44 -05:00
|
|
|
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()
|
2021-07-24 13:25:44 -05:00
|
|
|
.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(
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|