Save window's frame

Fixes #51
This commit is contained in:
Jaidyn Ann 2021-07-28 19:25:55 -05:00
parent f038c492f7
commit 0abdd9e0f9
3 changed files with 11 additions and 6 deletions

View File

@ -45,6 +45,8 @@ AppPreferences::Load()
DisableQuitConfirm = settings.GetBool("DisableQuitConfirm", false); DisableQuitConfirm = settings.GetBool("DisableQuitConfirm", false);
IgnoreEmoticons = settings.GetBool("IgnoreEmoticons", true); IgnoreEmoticons = settings.GetBool("IgnoreEmoticons", true);
HideOffline = settings.GetBool("HideOffline", false); 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("IgnoreEmoticons", IgnoreEmoticons);
settings.AddBool("HideOffline", HideOffline); settings.AddBool("HideOffline", HideOffline);
settings.AddRect("MainWindowRect", MainWindowRect);
if (file.InitCheck() == B_OK) if (file.InitCheck() == B_OK)
settings.Flatten(&file); settings.Flatten(&file);
} }

View File

@ -7,6 +7,7 @@
#ifndef _APP_PREFERENCES_H #ifndef _APP_PREFERENCES_H
#define _APP_PREFERENCES_H #define _APP_PREFERENCES_H
#include <Rect.h>
#include <SupportDefs.h> #include <SupportDefs.h>
@ -33,6 +34,8 @@ public:
bool HideOffline; bool HideOffline;
BRect MainWindowRect;
private: private:
const char* _PreferencesPath(); const char* _PreferencesPath();

View File

@ -46,8 +46,8 @@ const uint32 kLogin = 'LOGI';
MainWindow::MainWindow() MainWindow::MainWindow()
: :
BWindow(BRect(0, 0, 600, 400), B_TRANSLATE_SYSTEM_NAME(APP_NAME), BWindow(AppPreferences::Get()->MainWindowRect,
B_TITLED_WINDOW, 0), B_TRANSLATE_SYSTEM_NAME(APP_NAME), B_TITLED_WINDOW, 0),
fWorkspaceChanged(false), fWorkspaceChanged(false),
fConversation(NULL), fConversation(NULL),
fRosterWindow(NULL), fRosterWindow(NULL),
@ -59,10 +59,6 @@ MainWindow::MainWindow()
fServer = new Server(); fServer = new Server();
AddFilter(fServer); AddFilter(fServer);
// Also through the editing filter (enter to send)
CenterOnScreen();
//TODO check for errors here //TODO check for errors here
ReplicantStatusView::InstallReplicant(); ReplicantStatusView::InstallReplicant();
} }
@ -90,6 +86,8 @@ MainWindow::QuitRequested()
button_index = alert->Go(); button_index = alert->Go();
} }
AppPreferences::Get()->MainWindowRect = Frame();
if(button_index == 0) { if(button_index == 0) {
fServer->Quit(); fServer->Quit();
AppPreferences::Get()->Save(); AppPreferences::Get()->Save();