hrev45280 adds 1 changeset to branch 'master' old head: 390cd3f7f99c10edef0242c72bd84ef229d5b59e new head: 3722e6400443ac3a57b255188898dab89a5a9aa4 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=3722e64+%5E390cd3f ---------------------------------------------------------------------------- 3722e64: Store and read show/hide clock setting on disk. So that the setting will persist across reboots. This is a Deskbar setting, not a "clock" setting. Theoretically someday if we make it so you can replace the clock with a different clock widget we still want to store whether or not to show the clock widget as a Deskbar setting. Fixes #9456 [ John Scipione <jscipione@xxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev45280 Commit: 3722e6400443ac3a57b255188898dab89a5a9aa4 URL: http://cgit.haiku-os.org/haiku/commit/?id=3722e64 Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Feb 13 22:52:01 2013 UTC Ticket: https://dev.haiku-os.org/ticket/9456 ---------------------------------------------------------------------------- 3 files changed, 21 insertions(+), 8 deletions(-) src/apps/deskbar/BarApp.cpp | 7 ++++++- src/apps/deskbar/BarApp.h | 1 + src/apps/deskbar/StatusView.cpp | 21 ++++++++++++++------- ---------------------------------------------------------------------------- diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp index 9c12a27..afb2451 100644 --- a/src/apps/deskbar/BarApp.cpp +++ b/src/apps/deskbar/BarApp.cpp @@ -208,7 +208,7 @@ TBarApp::SaveSettings() storedSettings.AddBool("top", fSettings.top); storedSettings.AddInt32("state", fSettings.state); storedSettings.AddFloat("width", fSettings.width); - + storedSettings.AddBool("showClock", fSettings.showClock); storedSettings.AddPoint("switcherLoc", fSettings.switcherLoc); storedSettings.AddInt32("recentAppsCount", fSettings.recentAppsCount); storedSettings.AddInt32("recentDocsCount", fSettings.recentDocsCount); @@ -261,6 +261,7 @@ TBarApp::InitSettings() settings.top = true; settings.state = kExpandoState; settings.width = 0; + settings.showClock = true; settings.switcherLoc = BPoint(5000, 5000); settings.recentAppsCount = 10; settings.recentDocsCount = 10; @@ -328,6 +329,10 @@ TBarApp::InitSettings() } if (storedSettings.FindFloat("width", &settings.width) != B_OK) settings.width = 0; + if (storedSettings.FindBool("showClock", &settings.showClock) + != B_OK) { + settings.showClock = true; + } if (storedSettings.FindPoint("switcherLoc", &settings.switcherLoc) != B_OK) { settings.switcherLoc = BPoint(5000, 5000); diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h index 86535da..40ece97 100644 --- a/src/apps/deskbar/BarApp.h +++ b/src/apps/deskbar/BarApp.h @@ -77,6 +77,7 @@ struct desk_settings { bool top; uint32 state; float width; + bool showClock; BPoint switcherLoc; int32 recentAppsCount; int32 recentDocsCount; diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp index b9e6976..947773f 100644 --- a/src/apps/deskbar/StatusView.cpp +++ b/src/apps/deskbar/StatusView.cpp @@ -174,15 +174,17 @@ TReplicantTray::AttachedToWindow() Window()->SetPulseRate(1000000); - // Set clock settings - clock_settings* settings = ((TBarApp*)be_app)->ClockSettings(); - fTime->SetShowSeconds(settings->showSeconds); - fTime->SetShowDayOfWeek(settings->showDayOfWeek); - fTime->SetShowTimeZone(settings->showTimeZone); + clock_settings* clock = ((TBarApp*)be_app)->ClockSettings(); + fTime->SetShowSeconds(clock->showSeconds); + fTime->SetShowDayOfWeek(clock->showDayOfWeek); + fTime->SetShowTimeZone(clock->showTimeZone); AddChild(fTime); fTime->MoveTo(Bounds().right - fTime->Bounds().Width() - 1, 2); + if (!((TBarApp*)be_app)->Settings()->showClock) + fTime->Hide(); + #ifdef DB_ADDONS // load addons and rehydrate archives #if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) @@ -439,10 +441,15 @@ TReplicantTray::ShowHideTime() RealignReplicants(); AdjustPlacement(); - // message Time preferences to update it's show time setting + bool showClock = !fTime->IsHidden(); + + // Update showClock setting that gets saved to disk on quit + ((TBarApp*)be_app)->Settings()->showClock = showClock; + + // Send a message to Time preferences telling it to update BMessenger messenger("application/x-vnd.Haiku-Time"); BMessage* message = new BMessage(kShowHideTime); - message->AddBool("showClock", !fTime->IsHidden()); + message->AddBool("showClock", showClock); messenger.SendMessage(message); }