diff --git a/src/apps/haiku-depot/App.cpp b/src/apps/haiku-depot/App.cpp index 8b06aeeeb6..f31f3346e3 100644 --- a/src/apps/haiku-depot/App.cpp +++ b/src/apps/haiku-depot/App.cpp @@ -37,10 +37,12 @@ bool App::QuitRequested() { if (fMainWindow->LockLooperWithTimeout(1500000) == B_OK) { - BRect windowFrame = fMainWindow->Frame(); + BMessage windowSettings; + fMainWindow->StoreSettings(windowSettings); + fMainWindow->UnlockLooper(); - _StoreSettings(windowFrame); + _StoreSettings(windowSettings); } return true; @@ -60,7 +62,7 @@ App::ReadyToRun() make_sure_frame_is_on_screen(frame); - fMainWindow = new MainWindow(frame); + fMainWindow = new MainWindow(frame, settings); fMainWindow->Show(); } @@ -71,9 +73,11 @@ App::MessageReceived(BMessage* message) switch (message->what) { case MSG_MAIN_WINDOW_CLOSED: { - BRect windowFrame; - if (message->FindRect("window frame", &windowFrame) == B_OK) - _StoreSettings(windowFrame); + BMessage windowSettings; + if (message->FindMessage("window settings", + &windowSettings) == B_OK) { + _StoreSettings(windowSettings); + } Quit(); break; @@ -87,10 +91,8 @@ App::MessageReceived(BMessage* message) void -App::_StoreSettings(const BRect& windowFrame) +App::_StoreSettings(const BMessage& windowSettings) { - BMessage settings; - settings.AddRect("window frame", windowFrame); - save_settings(&settings, "main_settings", "HaikuDepot"); + save_settings(&windowSettings, "main_settings", "HaikuDepot"); } diff --git a/src/apps/haiku-depot/App.h b/src/apps/haiku-depot/App.h index b4ff240f84..b4ba3f0263 100644 --- a/src/apps/haiku-depot/App.h +++ b/src/apps/haiku-depot/App.h @@ -22,7 +22,7 @@ public: virtual void MessageReceived(BMessage* message); private: - void _StoreSettings(const BRect& windowFrame); + void _StoreSettings(const BMessage& windowSettings); MainWindow* fMainWindow; }; diff --git a/src/apps/haiku-depot/MainWindow.cpp b/src/apps/haiku-depot/MainWindow.cpp index d791aa4740..692c67ce15 100644 --- a/src/apps/haiku-depot/MainWindow.cpp +++ b/src/apps/haiku-depot/MainWindow.cpp @@ -72,7 +72,7 @@ struct RefreshWorkerParameters { }; -MainWindow::MainWindow(BRect frame) +MainWindow::MainWindow(BRect frame, const BMessage& settings) : BWindow(frame, B_TRANSLATE_SYSTEM_NAME("HaikuDepot"), B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, @@ -106,6 +106,11 @@ MainWindow::MainWindow(BRect frame) fSplitView->SetCollapsible(0, false); fSplitView->SetCollapsible(1, false); + // Restore settings + BMessage columnSettings; + if (settings.FindMessage("column settings", &columnSettings) == B_OK) + fPackageListView->LoadState(&columnSettings); + _StartRefreshWorker(); fPendingActionsSem = create_sem(0, "PendingPackageActions"); @@ -135,8 +140,12 @@ MainWindow::~MainWindow() bool MainWindow::QuitRequested() { + BMessage settings; + StoreSettings(settings); + BMessage message(MSG_MAIN_WINDOW_CLOSED); - message.AddRect("window frame", Frame()); + message.AddMessage("window settings", &settings); + be_app->PostMessage(&message); return true; @@ -229,6 +238,18 @@ MainWindow::MessageReceived(BMessage* message) } +void +MainWindow::StoreSettings(BMessage& settings) const +{ + settings.AddRect("window frame", Frame()); + + BMessage columnSettings; + fPackageListView->SaveState(&columnSettings); + + settings.AddMessage("column settings", &columnSettings); +} + + void MainWindow::PackageChanged(const PackageInfoEvent& event) { diff --git a/src/apps/haiku-depot/MainWindow.h b/src/apps/haiku-depot/MainWindow.h index 239f17cdc1..a72ff1ca4c 100644 --- a/src/apps/haiku-depot/MainWindow.h +++ b/src/apps/haiku-depot/MainWindow.h @@ -29,13 +29,16 @@ enum { class MainWindow : public BWindow, private PackageInfoListener, private PackageActionHandler { public: - MainWindow(BRect frame); + MainWindow(BRect frame, + const BMessage& settings); virtual ~MainWindow(); // BWindow interface virtual bool QuitRequested(); virtual void MessageReceived(BMessage* message); + void StoreSettings(BMessage& message) const; + private: // PackageInfoListener virtual void PackageChanged( diff --git a/src/apps/haiku-depot/support.cpp b/src/apps/haiku-depot/support.cpp index 4fb8dfc7bc..9287cd8696 100644 --- a/src/apps/haiku-depot/support.cpp +++ b/src/apps/haiku-depot/support.cpp @@ -46,7 +46,7 @@ load_settings(BMessage* message, const char* fileName, const char* folder) status_t -save_settings(BMessage* message, const char* fileName, const char* folder) +save_settings(const BMessage* message, const char* fileName, const char* folder) { if (message == NULL || fileName == NULL || fileName[0] == '\0') return B_BAD_VALUE; diff --git a/src/apps/haiku-depot/support.h b/src/apps/haiku-depot/support.h index ca3d23094b..1f45eb3019 100644 --- a/src/apps/haiku-depot/support.h +++ b/src/apps/haiku-depot/support.h @@ -17,7 +17,7 @@ class BWindow; status_t load_settings(BMessage* message, const char* fileName, const char* folder = NULL); -status_t save_settings(BMessage* message, const char* fileName, +status_t save_settings(const BMessage* message, const char* fileName, const char* folder = NULL); bool make_sure_frame_is_on_screen(BRect& frame, float borderWidth = 5.0f,