Save weights of main window's SplitViews

This commit is contained in:
Jaidyn Ann 2021-07-30 16:14:21 -05:00
parent ebc9d4041f
commit 7ec20a45ad
4 changed files with 18 additions and 3 deletions

View File

@ -46,6 +46,9 @@ AppPreferences::Load()
IgnoreEmoticons = settings.GetBool("IgnoreEmoticons", true); IgnoreEmoticons = settings.GetBool("IgnoreEmoticons", true);
HideOffline = settings.GetBool("HideOffline", false); HideOffline = settings.GetBool("HideOffline", false);
MainWindowListWeight = settings.GetFloat("MainWindowListWeight", 1);
MainWindowChatWeight = settings.GetFloat("MainWindowChatWeight", 5);
MainWindowRect = settings.GetRect("MainWindowRect", BRect(0, 0, 600, 400)); MainWindowRect = settings.GetRect("MainWindowRect", BRect(0, 0, 600, 400));
} }
@ -54,7 +57,7 @@ void
AppPreferences::Save() AppPreferences::Save()
{ {
const char* path = _PreferencesPath(); const char* path = _PreferencesPath();
BFile file(_PreferencesPath(), B_WRITE_ONLY); BFile file(_PreferencesPath(), B_WRITE_ONLY | B_CREATE_FILE);
BMessage settings; BMessage settings;
settings.AddBool("MoveToCurrentWorkpace", MoveToCurrentWorkspace); settings.AddBool("MoveToCurrentWorkpace", MoveToCurrentWorkspace);
@ -70,6 +73,9 @@ AppPreferences::Save()
settings.AddBool("IgnoreEmoticons", IgnoreEmoticons); settings.AddBool("IgnoreEmoticons", IgnoreEmoticons);
settings.AddBool("HideOffline", HideOffline); settings.AddBool("HideOffline", HideOffline);
settings.AddFloat("MainWindowListWeight", MainWindowListWeight);
settings.AddFloat("MainWindowChatWeight", MainWindowChatWeight);
settings.AddRect("MainWindowRect", MainWindowRect); settings.AddRect("MainWindowRect", MainWindowRect);
if (file.InitCheck() == B_OK) if (file.InitCheck() == B_OK)

View File

@ -34,6 +34,9 @@ public:
bool HideOffline; bool HideOffline;
float MainWindowListWeight;
float MainWindowChatWeight;
BRect MainWindowRect; BRect MainWindowRect;
private: private:

View File

@ -87,6 +87,8 @@ MainWindow::QuitRequested()
} }
AppPreferences::Get()->MainWindowRect = Frame(); AppPreferences::Get()->MainWindowRect = Frame();
AppPreferences::Get()->MainWindowListWeight = fSplitView->ItemWeight(0);
AppPreferences::Get()->MainWindowChatWeight = fSplitView->ItemWeight(1);
if(button_index == 0) { if(button_index == 0) {
fServer->Quit(); fServer->Quit();
@ -376,6 +378,9 @@ MainWindow::SetConversation(Conversation* chat)
chatMenu->AddItem(item); chatMenu->AddItem(item);
} }
} }
fSplitView->SetItemWeight(0, AppPreferences::Get()->MainWindowListWeight, true);
fSplitView->SetItemWeight(1, AppPreferences::Get()->MainWindowChatWeight, true);
} }
@ -411,6 +416,7 @@ MainWindow::_InitInterface()
// Left side of window, Roomlist + Status // Left side of window, Roomlist + Status
fListView = new ConversationListView("roomList"); fListView = new ConversationListView("roomList");
fStatusView = new StatusView("statusView"); fStatusView = new StatusView("statusView");
fSplitView = new BSplitView(B_HORIZONTAL, 0);
// Right-side of window, Chat + Textbox // Right-side of window, Chat + Textbox
fRightView = new BSplitView(B_VERTICAL, 0); fRightView = new BSplitView(B_VERTICAL, 0);
@ -420,7 +426,7 @@ MainWindow::_InitInterface()
.Add((fMenuBar = _CreateMenuBar())) .Add((fMenuBar = _CreateMenuBar()))
.AddGroup(B_HORIZONTAL) .AddGroup(B_HORIZONTAL)
.SetInsets(5, 5, 0, 10) .SetInsets(5, 5, 0, 10)
.AddSplit(B_HORIZONTAL, 0) .AddSplit(fSplitView)
.AddGroup(B_VERTICAL) .AddGroup(B_VERTICAL)
.Add(fListView, 1) .Add(fListView, 1)
.Add(fStatusView) .Add(fStatusView)

View File

@ -11,7 +11,6 @@
#include "Observer.h" #include "Observer.h"
//class BMenubar;
class BSplitView; class BSplitView;
class BTextView; class BTextView;
@ -66,6 +65,7 @@ private:
// Left panel, chat list // Left panel, chat list
ConversationListView* fListView; ConversationListView* fListView;
StatusView* fStatusView; StatusView* fStatusView;
BSplitView* fSplitView;
// Right panel, chat // Right panel, chat
BSplitView* fRightView; BSplitView* fRightView;