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:
@@ -208,7 +208,7 @@ TBarApp::SaveSettings()
|
|||||||
storedSettings.AddBool("top", fSettings.top);
|
storedSettings.AddBool("top", fSettings.top);
|
||||||
storedSettings.AddInt32("state", fSettings.state);
|
storedSettings.AddInt32("state", fSettings.state);
|
||||||
storedSettings.AddFloat("width", fSettings.width);
|
storedSettings.AddFloat("width", fSettings.width);
|
||||||
|
storedSettings.AddBool("showClock", fSettings.showClock);
|
||||||
storedSettings.AddPoint("switcherLoc", fSettings.switcherLoc);
|
storedSettings.AddPoint("switcherLoc", fSettings.switcherLoc);
|
||||||
storedSettings.AddInt32("recentAppsCount", fSettings.recentAppsCount);
|
storedSettings.AddInt32("recentAppsCount", fSettings.recentAppsCount);
|
||||||
storedSettings.AddInt32("recentDocsCount", fSettings.recentDocsCount);
|
storedSettings.AddInt32("recentDocsCount", fSettings.recentDocsCount);
|
||||||
@@ -261,6 +261,7 @@ TBarApp::InitSettings()
|
|||||||
settings.top = true;
|
settings.top = true;
|
||||||
settings.state = kExpandoState;
|
settings.state = kExpandoState;
|
||||||
settings.width = 0;
|
settings.width = 0;
|
||||||
|
settings.showClock = true;
|
||||||
settings.switcherLoc = BPoint(5000, 5000);
|
settings.switcherLoc = BPoint(5000, 5000);
|
||||||
settings.recentAppsCount = 10;
|
settings.recentAppsCount = 10;
|
||||||
settings.recentDocsCount = 10;
|
settings.recentDocsCount = 10;
|
||||||
@@ -328,6 +329,10 @@ TBarApp::InitSettings()
|
|||||||
}
|
}
|
||||||
if (storedSettings.FindFloat("width", &settings.width) != B_OK)
|
if (storedSettings.FindFloat("width", &settings.width) != B_OK)
|
||||||
settings.width = 0;
|
settings.width = 0;
|
||||||
|
if (storedSettings.FindBool("showClock", &settings.showClock)
|
||||||
|
!= B_OK) {
|
||||||
|
settings.showClock = true;
|
||||||
|
}
|
||||||
if (storedSettings.FindPoint("switcherLoc", &settings.switcherLoc)
|
if (storedSettings.FindPoint("switcherLoc", &settings.switcherLoc)
|
||||||
!= B_OK) {
|
!= B_OK) {
|
||||||
settings.switcherLoc = BPoint(5000, 5000);
|
settings.switcherLoc = BPoint(5000, 5000);
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ struct desk_settings {
|
|||||||
bool top;
|
bool top;
|
||||||
uint32 state;
|
uint32 state;
|
||||||
float width;
|
float width;
|
||||||
|
bool showClock;
|
||||||
BPoint switcherLoc;
|
BPoint switcherLoc;
|
||||||
int32 recentAppsCount;
|
int32 recentAppsCount;
|
||||||
int32 recentDocsCount;
|
int32 recentDocsCount;
|
||||||
|
|||||||
@@ -174,15 +174,17 @@ TReplicantTray::AttachedToWindow()
|
|||||||
|
|
||||||
Window()->SetPulseRate(1000000);
|
Window()->SetPulseRate(1000000);
|
||||||
|
|
||||||
// Set clock settings
|
clock_settings* clock = ((TBarApp*)be_app)->ClockSettings();
|
||||||
clock_settings* settings = ((TBarApp*)be_app)->ClockSettings();
|
fTime->SetShowSeconds(clock->showSeconds);
|
||||||
fTime->SetShowSeconds(settings->showSeconds);
|
fTime->SetShowDayOfWeek(clock->showDayOfWeek);
|
||||||
fTime->SetShowDayOfWeek(settings->showDayOfWeek);
|
fTime->SetShowTimeZone(clock->showTimeZone);
|
||||||
fTime->SetShowTimeZone(settings->showTimeZone);
|
|
||||||
|
|
||||||
AddChild(fTime);
|
AddChild(fTime);
|
||||||
fTime->MoveTo(Bounds().right - fTime->Bounds().Width() - 1, 2);
|
fTime->MoveTo(Bounds().right - fTime->Bounds().Width() - 1, 2);
|
||||||
|
|
||||||
|
if (!((TBarApp*)be_app)->Settings()->showClock)
|
||||||
|
fTime->Hide();
|
||||||
|
|
||||||
#ifdef DB_ADDONS
|
#ifdef DB_ADDONS
|
||||||
// load addons and rehydrate archives
|
// load addons and rehydrate archives
|
||||||
#if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST)
|
#if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST)
|
||||||
@@ -439,10 +441,15 @@ TReplicantTray::ShowHideTime()
|
|||||||
RealignReplicants();
|
RealignReplicants();
|
||||||
AdjustPlacement();
|
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");
|
BMessenger messenger("application/x-vnd.Haiku-Time");
|
||||||
BMessage* message = new BMessage(kShowHideTime);
|
BMessage* message = new BMessage(kShowHideTime);
|
||||||
message->AddBool("showClock", !fTime->IsHidden());
|
message->AddBool("showClock", showClock);
|
||||||
messenger.SendMessage(message);
|
messenger.SendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user