diff --git a/src/preferences/time/TimeMessages.h b/src/preferences/time/TimeMessages.h index 101e659121..082a814cab 100644 --- a/src/preferences/time/TimeMessages.h +++ b/src/preferences/time/TimeMessages.h @@ -31,10 +31,6 @@ const uint32 H_TM_CHANGED = 'obTC'; // notice for user changes const uint32 H_USER_CHANGE = 'obUC'; -// notices to hide or show the time zone preview -const uint32 H_HIDE_PREVIEW = 'hipr'; -const uint32 H_SHOW_PREVIEW = 'shpr'; - // local/ gmt radiobuttons const uint32 kRTCUpdate = '_rtc'; diff --git a/src/preferences/time/TimeWindow.cpp b/src/preferences/time/TimeWindow.cpp index 13ed1995fc..63e0c75fea 100644 --- a/src/preferences/time/TimeWindow.cpp +++ b/src/preferences/time/TimeWindow.cpp @@ -89,19 +89,8 @@ TTimeWindow::MessageReceived(BMessage* message) break; case kMsgChange: - { _SetRevertStatus(); - bool useGMTTime = true; - message->FindBool("UseGMT", &useGMTTime); - if (useGMTTime) { - BMessage show(H_SHOW_PREVIEW); - fTimeZoneView->MessageReceived(&show); - } else { - BMessage hide(H_HIDE_PREVIEW); - fTimeZoneView->MessageReceived(&hide); - } break; - } case kMsgClockSettingChanged: break; diff --git a/src/preferences/time/ZoneView.cpp b/src/preferences/time/ZoneView.cpp index 734ed30498..90781f0625 100644 --- a/src/preferences/time/ZoneView.cpp +++ b/src/preferences/time/ZoneView.cpp @@ -171,16 +171,6 @@ TimeZoneView::MessageReceived(BMessage* message) break; } - case H_HIDE_PREVIEW: - fCurrent->Hide(); - fPreview->Hide(); - break; - - case H_SHOW_PREVIEW: - fCurrent->Show(); - fPreview->Show(); - break; - case kMsgRevert: _Revert(); break; @@ -281,6 +271,7 @@ TimeZoneView::_InitView() fGmtTime->SetValue(B_CONTROL_ON); else fLocalTime->SetValue(B_CONTROL_ON); + _ShowOrHidePreview(); fOldUseGmtTime = fUseGmtTime; @@ -288,14 +279,14 @@ TimeZoneView::_InitView() BLayoutBuilder::Group<>(this) .Add(scrollList) .AddGroup(B_VERTICAL, kInset) - .Add(fCurrent) - .Add(fPreview) - .AddGlue() .Add(text) .AddGroup(B_VERTICAL, kInset) .Add(fLocalTime) .Add(fGmtTime) .End() + .AddGlue() + .Add(fCurrent) + .Add(fPreview) .Add(fSetZone) .End() .SetInsets(kInset, kInset, kInset, kInset); @@ -499,6 +490,7 @@ TimeZoneView::_Revert() fGmtTime->SetValue(B_CONTROL_ON); else fLocalTime->SetValue(B_CONTROL_ON); + _ShowOrHidePreview(); _UpdateGmtSettings(); _SetSystemTimeZone(); @@ -641,17 +633,34 @@ TimeZoneView::_UpdateGmtSettings() { _WriteRTCSettings(); + _ShowOrHidePreview(); _NotifyClockSettingChanged(); _kern_set_real_time_clock_is_gmt(fUseGmtTime); } +void +TimeZoneView::_ShowOrHidePreview() +{ + if (fUseGmtTime) { + // Hardware clock uses GMT time, changing timezone will adjust the + // offset and we need to display a preview + fCurrent->Show(); + fPreview->Show(); + } else { + // Hardware clock uses local time, changing timezone will adjust the + // clock and there is no offset to manage, thus, no preview. + fCurrent->Hide(); + fPreview->Hide(); + } +} + + void TimeZoneView::_NotifyClockSettingChanged() { - BMessage msg(kMsgChange); - msg.AddBool("UseGMT", fUseGmtTime); + BMessage msg(kMsgClockSettingChanged); Window()->PostMessage(&msg); } diff --git a/src/preferences/time/ZoneView.h b/src/preferences/time/ZoneView.h index 9dc559b470..8d97decd65 100644 --- a/src/preferences/time/ZoneView.h +++ b/src/preferences/time/ZoneView.h @@ -52,6 +52,7 @@ private: void _ReadRTCSettings(); void _WriteRTCSettings(); void _UpdateGmtSettings(); + void _ShowOrHidePreview(); void _InitView(); void _BuildZoneMenu();