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);
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);
}

View File

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

View File

@ -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();