2012-03-24 09:56:00 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2012, Casalinuovo Dario. All rights reserved.
|
2021-07-28 19:10:09 -05:00
|
|
|
* Copyright 2021, Jaidyn Levesque <jadedctrl@teknik.io>
|
|
|
|
* All rights reserved. Distributed under the terms of the MIT license.
|
2012-03-24 09:56:00 -05:00
|
|
|
*/
|
|
|
|
|
2021-07-28 19:10:09 -05:00
|
|
|
#include "AppPreferences.h"
|
2012-03-24 09:56:00 -05:00
|
|
|
|
2021-07-28 19:10:09 -05:00
|
|
|
#include "Utils.h"
|
2012-03-24 09:56:00 -05:00
|
|
|
|
|
|
|
|
2021-07-28 19:10:09 -05:00
|
|
|
AppPreferences* AppPreferences::fInstance = NULL;
|
2012-03-24 09:56:00 -05:00
|
|
|
|
|
|
|
|
2021-07-28 19:10:09 -05:00
|
|
|
AppPreferences*
|
|
|
|
AppPreferences::Get()
|
2012-03-24 09:56:00 -05:00
|
|
|
{
|
2021-07-28 19:10:09 -05:00
|
|
|
if (fInstance == NULL) {
|
|
|
|
fInstance = new AppPreferences();
|
|
|
|
fInstance->Load();
|
|
|
|
}
|
|
|
|
return fInstance;
|
2012-03-24 09:56:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2021-07-28 19:10:09 -05:00
|
|
|
AppPreferences::Load()
|
2012-03-24 09:56:00 -05:00
|
|
|
{
|
2021-07-28 19:10:09 -05:00
|
|
|
const char* path = _PreferencesPath();
|
|
|
|
BFile file(_PreferencesPath(), B_READ_ONLY);
|
|
|
|
BMessage settings;
|
|
|
|
|
|
|
|
if (file.InitCheck() == B_OK)
|
|
|
|
settings.Unflatten(&file);
|
|
|
|
|
|
|
|
MoveToCurrentWorkspace = settings.GetBool("MoveToCurrentWorkpace", false);
|
|
|
|
RaiseOnMessageReceived = settings.GetBool("RaiseOnMessageReceived", false);
|
|
|
|
MarkUnreadWindow = settings.GetBool("MarkUnreadWindow", true);
|
|
|
|
NotifyProtocolStatus = settings.GetBool("NotifyProtocolStatus", true);
|
|
|
|
NotifyNewMessage = settings.GetBool("NotifyNewMessage", true);
|
|
|
|
NotifyContactStatus = settings.GetBool("NotifyContactStatus", false);
|
2021-08-18 18:28:53 -05:00
|
|
|
SoundOnMessageReceived = settings.GetBool("SoundOnMessageReceived", false);
|
|
|
|
SoundOnMention = settings.GetBool("SoundOnMention", true);
|
2021-07-28 19:10:09 -05:00
|
|
|
HideDeskbar = settings.GetBool("HideDeskbar", false);
|
|
|
|
DisableReplicant = settings.GetBool("DisableReplicant", true);
|
|
|
|
DisableQuitConfirm = settings.GetBool("DisableQuitConfirm", false);
|
|
|
|
IgnoreEmoticons = settings.GetBool("IgnoreEmoticons", true);
|
|
|
|
HideOffline = settings.GetBool("HideOffline", false);
|
2021-07-28 19:25:55 -05:00
|
|
|
|
2021-07-30 16:14:21 -05:00
|
|
|
MainWindowListWeight = settings.GetFloat("MainWindowListWeight", 1);
|
|
|
|
MainWindowChatWeight = settings.GetFloat("MainWindowChatWeight", 5);
|
|
|
|
|
2021-07-31 11:15:51 -05:00
|
|
|
ChatViewHorizChatWeight = settings.GetFloat("ChatViewHorizChatWeight", 8);
|
|
|
|
ChatViewHorizListWeight = settings.GetFloat("ChatViewHorizListWeight", 1);
|
|
|
|
ChatViewVertChatWeight = settings.GetFloat("ChatViewVertChatWeight", 20);
|
|
|
|
ChatViewVertSendWeight = settings.GetFloat("ChatViewVertSendWeight", 1);
|
|
|
|
|
2021-07-28 19:25:55 -05:00
|
|
|
MainWindowRect = settings.GetRect("MainWindowRect", BRect(0, 0, 600, 400));
|
2012-03-24 09:56:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2021-07-28 19:10:09 -05:00
|
|
|
AppPreferences::Save()
|
2012-03-24 09:56:00 -05:00
|
|
|
{
|
2021-07-28 19:10:09 -05:00
|
|
|
const char* path = _PreferencesPath();
|
2021-07-30 16:14:21 -05:00
|
|
|
BFile file(_PreferencesPath(), B_WRITE_ONLY | B_CREATE_FILE);
|
2021-07-28 19:10:09 -05:00
|
|
|
|
|
|
|
BMessage settings;
|
|
|
|
settings.AddBool("MoveToCurrentWorkpace", MoveToCurrentWorkspace);
|
|
|
|
settings.AddBool("RaiseOnMessageReceived", RaiseOnMessageReceived);
|
|
|
|
settings.AddBool("MarkUnreadWindow", MarkUnreadWindow);
|
|
|
|
settings.AddBool("NotifyProtocolStatus", NotifyProtocolStatus);
|
|
|
|
settings.AddBool("NotifyNewMessage", NotifyNewMessage);
|
|
|
|
settings.AddBool("NotifyContactStatus", NotifyContactStatus);
|
2021-08-18 18:28:53 -05:00
|
|
|
settings.AddBool("SoundOnMessageReceived", SoundOnMessageReceived);
|
|
|
|
settings.AddBool("SoundOnMention", SoundOnMention);
|
2021-07-28 19:10:09 -05:00
|
|
|
settings.AddBool("HideDeskbar", HideDeskbar);
|
|
|
|
settings.AddBool("DisableReplicant", DisableReplicant);
|
|
|
|
settings.AddBool("DisableQuitConfirm", DisableQuitConfirm);
|
|
|
|
settings.AddBool("IgnoreEmoticons", IgnoreEmoticons);
|
|
|
|
settings.AddBool("HideOffline", HideOffline);
|
|
|
|
|
2021-07-30 16:14:21 -05:00
|
|
|
settings.AddFloat("MainWindowListWeight", MainWindowListWeight);
|
|
|
|
settings.AddFloat("MainWindowChatWeight", MainWindowChatWeight);
|
|
|
|
|
2021-07-31 11:15:51 -05:00
|
|
|
settings.AddFloat("ChatViewHorizChatWeight", ChatViewHorizChatWeight);
|
|
|
|
settings.AddFloat("ChatViewHorizListWeight", ChatViewHorizListWeight);
|
|
|
|
settings.AddFloat("ChatViewVertChatWeight", ChatViewVertChatWeight);
|
|
|
|
settings.AddFloat("ChatViewVertSendWeight", ChatViewVertSendWeight);
|
|
|
|
|
2021-07-28 19:25:55 -05:00
|
|
|
settings.AddRect("MainWindowRect", MainWindowRect);
|
|
|
|
|
2021-07-28 19:10:09 -05:00
|
|
|
if (file.InitCheck() == B_OK)
|
|
|
|
settings.Flatten(&file);
|
2012-03-24 09:56:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char*
|
2021-07-28 19:10:09 -05:00
|
|
|
AppPreferences::_PreferencesPath()
|
2012-03-24 09:56:00 -05:00
|
|
|
{
|
2021-07-28 19:10:09 -05:00
|
|
|
BPath path(SettingsPath());
|
|
|
|
path.Append("preferences");
|
|
|
|
return path.Path();
|
2012-03-24 09:56:00 -05:00
|
|
|
}
|