* Move the GMT/Local radio box to the timezone tab
* As there is some extra space there, use it to display a hint on what the settings are useful for * Remove the huge and unclear tooltip that explained it before (that'd rather be part of the userguide) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43031 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
89a1a98bca
commit
c2f3ee3b7b
@ -183,7 +183,7 @@ TAnalogClock::MaxSize()
|
||||
BSize
|
||||
TAnalogClock::MinSize()
|
||||
{
|
||||
return BSize(0, 0);
|
||||
return BSize(64.f, 64.f);
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include <FindDirectory.h>
|
||||
#include <Message.h>
|
||||
#include <Path.h>
|
||||
#include <RadioButton.h>
|
||||
#include <StringView.h>
|
||||
#include <Window.h>
|
||||
|
||||
@ -48,12 +47,9 @@ using BPrivate::B_LOCAL_TIME;
|
||||
DateTimeView::DateTimeView(const char* name)
|
||||
:
|
||||
BGroupView(name, B_HORIZONTAL, 5),
|
||||
fGmtTime(NULL),
|
||||
fUseGmtTime(false),
|
||||
fInitialized(false),
|
||||
fSystemTimeAtStart(system_time())
|
||||
{
|
||||
_ReadRTCSettings();
|
||||
_InitView();
|
||||
|
||||
// record the current time to enable revert.
|
||||
@ -63,7 +59,6 @@ DateTimeView::DateTimeView(const char* name)
|
||||
|
||||
DateTimeView::~DateTimeView()
|
||||
{
|
||||
_WriteRTCSettings();
|
||||
}
|
||||
|
||||
|
||||
@ -110,11 +105,6 @@ DateTimeView::MessageReceived(BMessage* message)
|
||||
break;
|
||||
}
|
||||
|
||||
case kRTCUpdate:
|
||||
fUseGmtTime = fGmtTime->Value() == B_CONTROL_ON;
|
||||
_UpdateGmtSettings();
|
||||
break;
|
||||
|
||||
case kMsgRevert:
|
||||
_Revert();
|
||||
break;
|
||||
@ -125,6 +115,9 @@ DateTimeView::MessageReceived(BMessage* message)
|
||||
fClock->ChangeTimeFinished();
|
||||
break;
|
||||
|
||||
case kRTCUpdate:
|
||||
break;
|
||||
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
break;
|
||||
@ -135,15 +128,12 @@ DateTimeView::MessageReceived(BMessage* message)
|
||||
bool
|
||||
DateTimeView::CheckCanRevert()
|
||||
{
|
||||
// check GMT vs Local setting
|
||||
bool enable = fUseGmtTime != fOldUseGmtTime;
|
||||
|
||||
// check for changed time
|
||||
time_t unchangedNow = fTimeAtStart + _PrefletUptime();
|
||||
time_t changedNow;
|
||||
time(&changedNow);
|
||||
|
||||
return enable || (changedNow != unchangedNow);
|
||||
return changedNow != unchangedNow;
|
||||
}
|
||||
|
||||
|
||||
@ -153,14 +143,6 @@ DateTimeView::_Revert()
|
||||
// Set the clock and calendar as they were at launch time +
|
||||
// time elapsed since application launch.
|
||||
|
||||
fUseGmtTime = fOldUseGmtTime;
|
||||
_UpdateGmtSettings();
|
||||
|
||||
if (fUseGmtTime)
|
||||
fGmtTime->SetValue(B_CONTROL_ON);
|
||||
else
|
||||
fLocalTime->SetValue(B_CONTROL_ON);
|
||||
|
||||
time_t timeNow = fTimeAtStart + _PrefletUptime();
|
||||
struct tm result;
|
||||
struct tm* timeInfo;
|
||||
@ -201,26 +183,6 @@ DateTimeView::_InitView()
|
||||
BTime time(BTime::CurrentTime(B_LOCAL_TIME));
|
||||
fClock->SetTime(time.Hour(), time.Minute(), time.Second());
|
||||
|
||||
BStringView* text = new BStringView("clockSetTo",
|
||||
B_TRANSLATE("Hardware clock set to:"));
|
||||
text->SetToolTip(B_TRANSLATE(
|
||||
"This setting controls how Haiku will display your time based on how\n"
|
||||
"time is measured in the computer's hardware clock. Windows is usually\n"
|
||||
"set to local time, meaning the hardware clock is measured in the same\n"
|
||||
"time as the configured time zone. When this is set to GMT it means the\n"
|
||||
"hardware clock is measured based on GMT and Haiku will adjust the time\n"
|
||||
"it shows based on the configured time zone."));
|
||||
fLocalTime = new BRadioButton("localTime",
|
||||
B_TRANSLATE("Local time"), new BMessage(kRTCUpdate));
|
||||
fGmtTime = new BRadioButton("greenwichMeanTime",
|
||||
B_TRANSLATE("GMT"), new BMessage(kRTCUpdate));
|
||||
|
||||
if (fUseGmtTime)
|
||||
fGmtTime->SetValue(B_CONTROL_ON);
|
||||
else
|
||||
fLocalTime->SetValue(B_CONTROL_ON);
|
||||
fOldUseGmtTime = fUseGmtTime;
|
||||
|
||||
BBox* divider = new BBox(BRect(0, 0, 1, 1),
|
||||
B_EMPTY_STRING, B_FOLLOW_ALL_SIDES,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);
|
||||
@ -236,68 +198,11 @@ DateTimeView::_InitView()
|
||||
.AddGroup(B_VERTICAL, 0)
|
||||
.Add(fTimeEdit)
|
||||
.Add(fClock)
|
||||
.Add(text)
|
||||
.AddGroup(B_HORIZONTAL, kInset)
|
||||
.Add(fLocalTime)
|
||||
.Add(fGmtTime)
|
||||
.End()
|
||||
.End()
|
||||
.SetInsets(kInset, kInset, kInset, kInset);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DateTimeView::_ReadRTCSettings()
|
||||
{
|
||||
BPath path;
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
|
||||
return;
|
||||
|
||||
path.Append("RTC_time_settings");
|
||||
|
||||
BEntry entry(path.Path());
|
||||
if (entry.Exists()) {
|
||||
BFile file(&entry, B_READ_ONLY);
|
||||
if (file.InitCheck() == B_OK) {
|
||||
char buffer[6];
|
||||
file.Read(buffer, 6);
|
||||
if (strncmp(buffer, "gmt", 3) == 0)
|
||||
fUseGmtTime = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DateTimeView::_WriteRTCSettings()
|
||||
{
|
||||
BPath path;
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) != B_OK)
|
||||
return;
|
||||
|
||||
path.Append("RTC_time_settings");
|
||||
|
||||
BFile file(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY);
|
||||
if (file.InitCheck() == B_OK) {
|
||||
if (fUseGmtTime)
|
||||
file.Write("gmt", 3);
|
||||
else
|
||||
file.Write("local", 5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DateTimeView::_UpdateGmtSettings()
|
||||
{
|
||||
_WriteRTCSettings();
|
||||
|
||||
_NotifyClockSettingChanged();
|
||||
|
||||
_kern_set_real_time_clock_is_gmt(fUseGmtTime);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DateTimeView::_UpdateDateTime(BMessage* message)
|
||||
{
|
||||
@ -335,7 +240,6 @@ void
|
||||
DateTimeView::_NotifyClockSettingChanged()
|
||||
{
|
||||
BMessage msg(kMsgClockSettingChanged);
|
||||
msg.AddBool("UseGMT", fUseGmtTime);
|
||||
Window()->PostMessage(&msg);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
class TDateEdit;
|
||||
class TTimeEdit;
|
||||
class BRadioButton;
|
||||
class TAnalogClock;
|
||||
|
||||
|
||||
@ -41,23 +40,16 @@ public:
|
||||
|
||||
private:
|
||||
void _InitView();
|
||||
void _ReadRTCSettings();
|
||||
void _WriteRTCSettings();
|
||||
void _UpdateGmtSettings();
|
||||
void _UpdateDateTime(BMessage* message);
|
||||
void _NotifyClockSettingChanged();
|
||||
void _Revert();
|
||||
time_t _PrefletUptime() const;
|
||||
|
||||
BRadioButton* fLocalTime;
|
||||
BRadioButton* fGmtTime;
|
||||
TDateEdit* fDateEdit;
|
||||
TTimeEdit* fTimeEdit;
|
||||
BCalendarView* fCalendarView;
|
||||
TAnalogClock* fClock;
|
||||
|
||||
bool fUseGmtTime;
|
||||
bool fOldUseGmtTime;
|
||||
bool fInitialized;
|
||||
|
||||
time_t fTimeAtStart;
|
||||
|
@ -55,7 +55,7 @@ TTZDisplay::Draw(BRect)
|
||||
|
||||
BRect bounds = Bounds();
|
||||
FillRect(Bounds(), B_SOLID_LOW);
|
||||
|
||||
|
||||
font_height height;
|
||||
GetFontHeight(&height);
|
||||
float fontHeight = ceilf(height.descent + height.ascent +
|
||||
@ -164,5 +164,6 @@ TTZDisplay::_CalcPrefSize()
|
||||
StringWidth(" ") + StringWidth(fTime.String()) + padding);
|
||||
float secondLine = ceilf(StringWidth(fText.String()) + padding);
|
||||
size.width = firstLine > secondLine ? firstLine : secondLine;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include <String.h>
|
||||
#include <View.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
class TTZDisplay : public BView {
|
||||
|
@ -89,11 +89,8 @@ TTimeWindow::MessageReceived(BMessage* message)
|
||||
break;
|
||||
|
||||
case kMsgChange:
|
||||
_SetRevertStatus();
|
||||
break;
|
||||
|
||||
case kMsgClockSettingChanged:
|
||||
{
|
||||
_SetRevertStatus();
|
||||
bool useGMTTime = true;
|
||||
message->FindBool("UseGMT", &useGMTTime);
|
||||
if (useGMTTime) {
|
||||
@ -103,8 +100,12 @@ TTimeWindow::MessageReceived(BMessage* message)
|
||||
BMessage hide(H_HIDE_PREVIEW);
|
||||
fTimeZoneView->MessageReceived(&hide);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgClockSettingChanged:
|
||||
break;
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
break;
|
||||
|
@ -35,9 +35,11 @@
|
||||
#include <MutableLocaleRoster.h>
|
||||
#include <OutlineListView.h>
|
||||
#include <Path.h>
|
||||
#include <RadioButton.h>
|
||||
#include <ScrollView.h>
|
||||
#include <StorageDefs.h>
|
||||
#include <String.h>
|
||||
#include <StringView.h>
|
||||
#include <TimeZone.h>
|
||||
#include <ToolTip.h>
|
||||
#include <View.h>
|
||||
@ -80,11 +82,14 @@ private:
|
||||
TimeZoneView::TimeZoneView(const char* name)
|
||||
:
|
||||
BGroupView(name, B_HORIZONTAL, B_USE_DEFAULT_SPACING),
|
||||
fGmtTime(NULL),
|
||||
fToolTip(NULL),
|
||||
fUseGmtTime(false),
|
||||
fCurrentZoneItem(NULL),
|
||||
fOldZoneItem(NULL),
|
||||
fInitialized(false)
|
||||
{
|
||||
_ReadRTCSettings();
|
||||
_InitView();
|
||||
}
|
||||
|
||||
@ -92,7 +97,10 @@ TimeZoneView::TimeZoneView(const char* name)
|
||||
bool
|
||||
TimeZoneView::CheckCanRevert()
|
||||
{
|
||||
return fCurrentZoneItem != fOldZoneItem;
|
||||
// check GMT vs Local setting
|
||||
bool enable = fUseGmtTime != fOldUseGmtTime;
|
||||
|
||||
return enable || fCurrentZoneItem != fOldZoneItem;
|
||||
}
|
||||
|
||||
|
||||
@ -100,6 +108,7 @@ TimeZoneView::~TimeZoneView()
|
||||
{
|
||||
if (fToolTip != NULL)
|
||||
fToolTip->ReleaseReference();
|
||||
_WriteRTCSettings();
|
||||
}
|
||||
|
||||
|
||||
@ -158,7 +167,7 @@ TimeZoneView::MessageReceived(BMessage* message)
|
||||
case H_SET_TIME_ZONE:
|
||||
{
|
||||
_SetSystemTimeZone();
|
||||
Looper()->PostMessage(new BMessage(kMsgChange));
|
||||
_NotifyClockSettingChanged();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -177,6 +186,8 @@ TimeZoneView::MessageReceived(BMessage* message)
|
||||
break;
|
||||
|
||||
case kRTCUpdate:
|
||||
fUseGmtTime = fGmtTime->Value() == B_CONTROL_ON;
|
||||
_UpdateGmtSettings();
|
||||
_UpdateCurrent();
|
||||
_UpdatePreview();
|
||||
break;
|
||||
@ -248,6 +259,7 @@ TimeZoneView::_InitView()
|
||||
_BuildZoneMenu();
|
||||
BScrollView* scrollList = new BScrollView("scrollList", fZoneList,
|
||||
B_FRAME_EVENTS | B_WILL_DRAW, false, true);
|
||||
scrollList->SetExplicitMinSize(BSize(200, 0));
|
||||
|
||||
fCurrent = new TTZDisplay("currentTime", B_TRANSLATE("Current time:"));
|
||||
fPreview = new TTZDisplay("previewTime", B_TRANSLATE("Preview time:"));
|
||||
@ -258,6 +270,20 @@ TimeZoneView::_InitView()
|
||||
fSetZone->SetExplicitAlignment(
|
||||
BAlignment(B_ALIGN_RIGHT, B_ALIGN_BOTTOM));
|
||||
|
||||
BStringView* text = new BStringView("clockSetTo",
|
||||
B_TRANSLATE("Hardware clock set to:"));
|
||||
fLocalTime = new BRadioButton("localTime",
|
||||
B_TRANSLATE("Local time (Windows compatible)"), new BMessage(kRTCUpdate));
|
||||
fGmtTime = new BRadioButton("greenwichMeanTime",
|
||||
B_TRANSLATE("GMT (UNIX compatible)"), new BMessage(kRTCUpdate));
|
||||
|
||||
if (fUseGmtTime)
|
||||
fGmtTime->SetValue(B_CONTROL_ON);
|
||||
else
|
||||
fLocalTime->SetValue(B_CONTROL_ON);
|
||||
fOldUseGmtTime = fUseGmtTime;
|
||||
|
||||
|
||||
const float kInset = be_control_look->DefaultItemSpacing();
|
||||
BLayoutBuilder::Group<>(this)
|
||||
.Add(scrollList)
|
||||
@ -265,6 +291,11 @@ TimeZoneView::_InitView()
|
||||
.Add(fCurrent)
|
||||
.Add(fPreview)
|
||||
.AddGlue()
|
||||
.Add(text)
|
||||
.AddGroup(B_VERTICAL, kInset)
|
||||
.Add(fLocalTime)
|
||||
.Add(fGmtTime)
|
||||
.End()
|
||||
.Add(fSetZone)
|
||||
.End()
|
||||
.SetInsets(kInset, kInset, kInset, kInset);
|
||||
@ -463,6 +494,13 @@ TimeZoneView::_Revert()
|
||||
fZoneList->DeselectAll();
|
||||
fZoneList->ScrollToSelection();
|
||||
|
||||
fUseGmtTime = fOldUseGmtTime;
|
||||
if (fUseGmtTime)
|
||||
fGmtTime->SetValue(B_CONTROL_ON);
|
||||
else
|
||||
fLocalTime->SetValue(B_CONTROL_ON);
|
||||
|
||||
_UpdateGmtSettings();
|
||||
_SetSystemTimeZone();
|
||||
_UpdatePreview();
|
||||
_UpdateCurrent();
|
||||
@ -555,3 +593,65 @@ TimeZoneView::_FormatTime(const BTimeZone& timeZone)
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TimeZoneView::_ReadRTCSettings()
|
||||
{
|
||||
BPath path;
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
|
||||
return;
|
||||
|
||||
path.Append("RTC_time_settings");
|
||||
|
||||
BEntry entry(path.Path());
|
||||
if (entry.Exists()) {
|
||||
BFile file(&entry, B_READ_ONLY);
|
||||
if (file.InitCheck() == B_OK) {
|
||||
char buffer[6];
|
||||
file.Read(buffer, 6);
|
||||
if (strncmp(buffer, "gmt", 3) == 0)
|
||||
fUseGmtTime = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TimeZoneView::_WriteRTCSettings()
|
||||
{
|
||||
BPath path;
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) != B_OK)
|
||||
return;
|
||||
|
||||
path.Append("RTC_time_settings");
|
||||
|
||||
BFile file(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY);
|
||||
if (file.InitCheck() == B_OK) {
|
||||
if (fUseGmtTime)
|
||||
file.Write("gmt", 3);
|
||||
else
|
||||
file.Write("local", 5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TimeZoneView::_UpdateGmtSettings()
|
||||
{
|
||||
_WriteRTCSettings();
|
||||
|
||||
_NotifyClockSettingChanged();
|
||||
|
||||
_kern_set_real_time_clock_is_gmt(fUseGmtTime);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TimeZoneView::_NotifyClockSettingChanged()
|
||||
{
|
||||
BMessage msg(kMsgChange);
|
||||
msg.AddBool("UseGMT", fUseGmtTime);
|
||||
Window()->PostMessage(&msg);
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ class BButton;
|
||||
class BMessage;
|
||||
class BOutlineListView;
|
||||
class BPopUpMenu;
|
||||
class BRadioButton;
|
||||
class BTextToolTip;
|
||||
class BTimeZone;
|
||||
class TimeZoneListItem;
|
||||
@ -45,8 +46,13 @@ private:
|
||||
|
||||
void _UpdatePreview();
|
||||
void _UpdateCurrent();
|
||||
void _NotifyClockSettingChanged();
|
||||
BString _FormatTime(const BTimeZone& timeZone);
|
||||
|
||||
void _ReadRTCSettings();
|
||||
void _WriteRTCSettings();
|
||||
void _UpdateGmtSettings();
|
||||
|
||||
void _InitView();
|
||||
void _BuildZoneMenu();
|
||||
|
||||
@ -56,10 +62,14 @@ private:
|
||||
BButton* fSetZone;
|
||||
TTZDisplay* fCurrent;
|
||||
TTZDisplay* fPreview;
|
||||
BRadioButton* fLocalTime;
|
||||
BRadioButton* fGmtTime;
|
||||
|
||||
BTextToolTip* fToolTip;
|
||||
|
||||
int32 fLastUpdateMinute;
|
||||
bool fUseGmtTime;
|
||||
bool fOldUseGmtTime;
|
||||
|
||||
TimeZoneListItem* fCurrentZoneItem;
|
||||
TimeZoneListItem* fOldZoneItem;
|
||||
|
Loading…
Reference in New Issue
Block a user