From 7ec20a45ad1b1654dccc3cf685ef89c8e1909a07 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Fri, 30 Jul 2021 16:14:21 -0500 Subject: [PATCH] Save weights of main window's SplitViews --- application/preferences/AppPreferences.cpp | 8 +++++++- application/preferences/AppPreferences.h | 3 +++ application/windows/MainWindow.cpp | 8 +++++++- application/windows/MainWindow.h | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/application/preferences/AppPreferences.cpp b/application/preferences/AppPreferences.cpp index 9d4a589..ccd3670 100644 --- a/application/preferences/AppPreferences.cpp +++ b/application/preferences/AppPreferences.cpp @@ -46,6 +46,9 @@ AppPreferences::Load() IgnoreEmoticons = settings.GetBool("IgnoreEmoticons", true); HideOffline = settings.GetBool("HideOffline", false); + MainWindowListWeight = settings.GetFloat("MainWindowListWeight", 1); + MainWindowChatWeight = settings.GetFloat("MainWindowChatWeight", 5); + MainWindowRect = settings.GetRect("MainWindowRect", BRect(0, 0, 600, 400)); } @@ -54,7 +57,7 @@ void AppPreferences::Save() { const char* path = _PreferencesPath(); - BFile file(_PreferencesPath(), B_WRITE_ONLY); + BFile file(_PreferencesPath(), B_WRITE_ONLY | B_CREATE_FILE); BMessage settings; settings.AddBool("MoveToCurrentWorkpace", MoveToCurrentWorkspace); @@ -70,6 +73,9 @@ AppPreferences::Save() settings.AddBool("IgnoreEmoticons", IgnoreEmoticons); settings.AddBool("HideOffline", HideOffline); + settings.AddFloat("MainWindowListWeight", MainWindowListWeight); + settings.AddFloat("MainWindowChatWeight", MainWindowChatWeight); + settings.AddRect("MainWindowRect", MainWindowRect); if (file.InitCheck() == B_OK) diff --git a/application/preferences/AppPreferences.h b/application/preferences/AppPreferences.h index 99d9e56..30bae19 100644 --- a/application/preferences/AppPreferences.h +++ b/application/preferences/AppPreferences.h @@ -34,6 +34,9 @@ public: bool HideOffline; + float MainWindowListWeight; + float MainWindowChatWeight; + BRect MainWindowRect; private: diff --git a/application/windows/MainWindow.cpp b/application/windows/MainWindow.cpp index efa867c..ab0bf64 100644 --- a/application/windows/MainWindow.cpp +++ b/application/windows/MainWindow.cpp @@ -87,6 +87,8 @@ MainWindow::QuitRequested() } AppPreferences::Get()->MainWindowRect = Frame(); + AppPreferences::Get()->MainWindowListWeight = fSplitView->ItemWeight(0); + AppPreferences::Get()->MainWindowChatWeight = fSplitView->ItemWeight(1); if(button_index == 0) { fServer->Quit(); @@ -376,6 +378,9 @@ MainWindow::SetConversation(Conversation* chat) 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 fListView = new ConversationListView("roomList"); fStatusView = new StatusView("statusView"); + fSplitView = new BSplitView(B_HORIZONTAL, 0); // Right-side of window, Chat + Textbox fRightView = new BSplitView(B_VERTICAL, 0); @@ -420,7 +426,7 @@ MainWindow::_InitInterface() .Add((fMenuBar = _CreateMenuBar())) .AddGroup(B_HORIZONTAL) .SetInsets(5, 5, 0, 10) - .AddSplit(B_HORIZONTAL, 0) + .AddSplit(fSplitView) .AddGroup(B_VERTICAL) .Add(fListView, 1) .Add(fStatusView) diff --git a/application/windows/MainWindow.h b/application/windows/MainWindow.h index fae141a..847efcb 100644 --- a/application/windows/MainWindow.h +++ b/application/windows/MainWindow.h @@ -11,7 +11,6 @@ #include "Observer.h" -//class BMenubar; class BSplitView; class BTextView; @@ -66,6 +65,7 @@ private: // Left panel, chat list ConversationListView* fListView; StatusView* fStatusView; + BSplitView* fSplitView; // Right panel, chat BSplitView* fRightView;