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
This commit is contained in:
parent
390cd3f7f9
commit
3722e64004
@ -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);
|
||||
|
@ -77,6 +77,7 @@ struct desk_settings {
|
||||
bool top;
|
||||
uint32 state;
|
||||
float width;
|
||||
bool showClock;
|
||||
BPoint switcherLoc;
|
||||
int32 recentAppsCount;
|
||||
int32 recentDocsCount;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user