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

72 lines
1.6 KiB
C++
Raw Normal View History

/*
* Copyright 2010, Oliver Ruiz Dorantes. All rights reserved.
* Copyright 2012, Dario Casalinuovo. All rights reserved.
* Copyright 2021, Jaidyn Levesque. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "PreferencesChatWindow.h"
#include <Box.h>
2021-07-19 09:54:27 -05:00
#include <Catalog.h>
#include <CheckBox.h>
#include <ControlLook.h>
#include <LayoutBuilder.h>
2021-06-20 12:44:20 -05:00
#include "AppPreferences.h"
2021-07-19 09:54:27 -05:00
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "PreferencesChatWindow"
const uint32 kIgnoreEmoticons = 'CBhe';
PreferencesChatWindow::PreferencesChatWindow()
: BView(B_TRANSLATE("Chat view"), B_WILL_DRAW)
{
BBox* chatBox = new BBox("chatBox");
chatBox->SetLabel(B_TRANSLATE("Chat settings"));
fIgnoreEmoticons = new BCheckBox("IgnoreEmoticons",
B_TRANSLATE("Ignore emoticons"), new BMessage(kIgnoreEmoticons));
fIgnoreEmoticons->SetEnabled(true);
const float spacing = be_control_look->DefaultItemSpacing();
BLayoutBuilder::Group<>(chatBox, B_VERTICAL)
.SetInsets(spacing, spacing * 2, spacing, spacing)
.Add(fIgnoreEmoticons)
.End();
BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(chatBox)
.AddGlue()
.End();
}
void
PreferencesChatWindow::AttachedToWindow()
{
fIgnoreEmoticons->SetTarget(this);
fIgnoreEmoticons->SetValue(AppPreferences::Item()->IgnoreEmoticons);
}
void
PreferencesChatWindow::MessageReceived(BMessage* message)
{
switch (message->what) {
case kIgnoreEmoticons:
2021-06-20 12:44:20 -05:00
AppPreferences::Item()->IgnoreEmoticons
= fIgnoreEmoticons->Value();
break;
default:
BView::MessageReceived(message);
}
}