From 0abdd9e0f96f4a9df9d71d999790afaca40a1c0b Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Wed, 28 Jul 2021 19:25:55 -0500 Subject: [PATCH] Save window's frame Fixes #51 --- application/preferences/AppPreferences.cpp | 4 ++++ application/preferences/AppPreferences.h | 3 +++ application/windows/MainWindow.cpp | 10 ++++------ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/application/preferences/AppPreferences.cpp b/application/preferences/AppPreferences.cpp index 9edeeee..9d4a589 100644 --- a/application/preferences/AppPreferences.cpp +++ b/application/preferences/AppPreferences.cpp @@ -45,6 +45,8 @@ AppPreferences::Load() DisableQuitConfirm = settings.GetBool("DisableQuitConfirm", false); IgnoreEmoticons = settings.GetBool("IgnoreEmoticons", true); HideOffline = settings.GetBool("HideOffline", false); + + MainWindowRect = settings.GetRect("MainWindowRect", BRect(0, 0, 600, 400)); } @@ -68,6 +70,8 @@ AppPreferences::Save() settings.AddBool("IgnoreEmoticons", IgnoreEmoticons); settings.AddBool("HideOffline", HideOffline); + settings.AddRect("MainWindowRect", MainWindowRect); + if (file.InitCheck() == B_OK) settings.Flatten(&file); } diff --git a/application/preferences/AppPreferences.h b/application/preferences/AppPreferences.h index 386842d..99d9e56 100644 --- a/application/preferences/AppPreferences.h +++ b/application/preferences/AppPreferences.h @@ -7,6 +7,7 @@ #ifndef _APP_PREFERENCES_H #define _APP_PREFERENCES_H +#include #include @@ -33,6 +34,8 @@ public: bool HideOffline; + BRect MainWindowRect; + private: const char* _PreferencesPath(); diff --git a/application/windows/MainWindow.cpp b/application/windows/MainWindow.cpp index 1afa6ca..81a2c98 100644 --- a/application/windows/MainWindow.cpp +++ b/application/windows/MainWindow.cpp @@ -46,8 +46,8 @@ const uint32 kLogin = 'LOGI'; MainWindow::MainWindow() : - BWindow(BRect(0, 0, 600, 400), B_TRANSLATE_SYSTEM_NAME(APP_NAME), - B_TITLED_WINDOW, 0), + BWindow(AppPreferences::Get()->MainWindowRect, + B_TRANSLATE_SYSTEM_NAME(APP_NAME), B_TITLED_WINDOW, 0), fWorkspaceChanged(false), fConversation(NULL), fRosterWindow(NULL), @@ -59,10 +59,6 @@ MainWindow::MainWindow() fServer = new Server(); AddFilter(fServer); - // Also through the editing filter (enter to send) - - CenterOnScreen(); - //TODO check for errors here ReplicantStatusView::InstallReplicant(); } @@ -90,6 +86,8 @@ MainWindow::QuitRequested() button_index = alert->Go(); } + AppPreferences::Get()->MainWindowRect = Frame(); + if(button_index == 0) { fServer->Quit(); AppPreferences::Get()->Save();