* Remove "date & time" view from tracker settings, since it will soon use the locale kit settings.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37929 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -719,357 +719,6 @@ WindowsSettingsView::IsRevertable() const
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
TimeFormatSettingsView::TimeFormatSettingsView(BRect rect)
|
|
||||||
: SettingsView(rect, "WindowsSettingsView")
|
|
||||||
{
|
|
||||||
rect.OffsetTo(B_ORIGIN);
|
|
||||||
|
|
||||||
font_height fontHeight;
|
|
||||||
be_bold_font->GetHeight(&fontHeight);
|
|
||||||
|
|
||||||
rect.bottom = ceilf(fontHeight.ascent + fontHeight.descent) + 10;
|
|
||||||
BBox *clockBox = new BBox(rect, "Clock");
|
|
||||||
clockBox->SetLabel(B_TRANSLATE("Clock"));
|
|
||||||
AddChild(clockBox);
|
|
||||||
|
|
||||||
rect.left = 8;
|
|
||||||
rect.top = rect.bottom - 8;
|
|
||||||
f24HrRadioButton = new BRadioButton(rect, "",
|
|
||||||
B_TRANSLATE("24 hour"),
|
|
||||||
new BMessage(kSettingsContentsModified));
|
|
||||||
f24HrRadioButton->ResizeToPreferred();
|
|
||||||
clockBox->AddChild(f24HrRadioButton);
|
|
||||||
|
|
||||||
const float itemSpacing = f24HrRadioButton->Bounds().Height() + kItemExtraSpacing;
|
|
||||||
rect.OffsetBy(0, itemSpacing);
|
|
||||||
|
|
||||||
f12HrRadioButton = new BRadioButton(rect, "",
|
|
||||||
B_TRANSLATE("12 hour"),
|
|
||||||
new BMessage(kSettingsContentsModified));
|
|
||||||
f12HrRadioButton->ResizeToPreferred();
|
|
||||||
clockBox->AddChild(f12HrRadioButton);
|
|
||||||
|
|
||||||
float width = max_c(f12HrRadioButton->Frame().right, f24HrRadioButton->Frame().right) + 8.0f;
|
|
||||||
clockBox->ResizeTo(width, clockBox->Bounds().Height()
|
|
||||||
+ 3 * f12HrRadioButton->Frame().Height());
|
|
||||||
|
|
||||||
rect = clockBox->Frame();
|
|
||||||
rect.OffsetBy(rect.Width() + 8, 0);
|
|
||||||
BBox *dateFormatBox = new BBox(rect, "Date order");
|
|
||||||
dateFormatBox->SetLabel(B_TRANSLATE("Date order"));
|
|
||||||
AddChild(dateFormatBox);
|
|
||||||
|
|
||||||
rect = f24HrRadioButton->Frame();
|
|
||||||
fYMDRadioButton = new BRadioButton(rect, "",
|
|
||||||
B_TRANSLATE("Year-month-day"),
|
|
||||||
new BMessage(kSettingsContentsModified));
|
|
||||||
fYMDRadioButton->ResizeToPreferred();
|
|
||||||
dateFormatBox->AddChild(fYMDRadioButton);
|
|
||||||
|
|
||||||
rect.OffsetBy(0, itemSpacing);
|
|
||||||
|
|
||||||
fDMYRadioButton = new BRadioButton(rect, "",
|
|
||||||
B_TRANSLATE("Day-month-year"),
|
|
||||||
new BMessage(kSettingsContentsModified));
|
|
||||||
fDMYRadioButton->ResizeToPreferred();
|
|
||||||
dateFormatBox->AddChild(fDMYRadioButton);
|
|
||||||
|
|
||||||
rect.OffsetBy(0, itemSpacing);
|
|
||||||
|
|
||||||
fMDYRadioButton = new BRadioButton(rect, "",
|
|
||||||
B_TRANSLATE("Month-day-year"),
|
|
||||||
new BMessage(kSettingsContentsModified));
|
|
||||||
fMDYRadioButton->ResizeToPreferred();
|
|
||||||
dateFormatBox->AddChild(fMDYRadioButton);
|
|
||||||
|
|
||||||
dateFormatBox->ResizeTo(fYMDRadioButton->Bounds().Width() + 16,
|
|
||||||
dateFormatBox->Bounds().Height());
|
|
||||||
|
|
||||||
BPopUpMenu *menu = new BPopUpMenu("Separator");
|
|
||||||
menu->AddItem(new BMenuItem(B_TRANSLATE("None"),
|
|
||||||
new BMessage(kSettingsContentsModified)));
|
|
||||||
menu->AddItem(new BMenuItem(B_TRANSLATE("Space"),
|
|
||||||
new BMessage(kSettingsContentsModified)));
|
|
||||||
menu->AddItem(new BMenuItem("-", new BMessage(kSettingsContentsModified)));
|
|
||||||
menu->AddItem(new BMenuItem("/", new BMessage(kSettingsContentsModified)));
|
|
||||||
menu->AddItem(new BMenuItem("\\", new BMessage(kSettingsContentsModified)));
|
|
||||||
menu->AddItem(new BMenuItem(".", new BMessage(kSettingsContentsModified)));
|
|
||||||
|
|
||||||
rect.left = 0;
|
|
||||||
rect.top = clockBox->Frame().bottom + 8;
|
|
||||||
rect.right = Bounds().Width() - 8;
|
|
||||||
rect.bottom = rect.top + itemSpacing;
|
|
||||||
fSeparatorMenuField = new BMenuField(rect, "Separator", "Separator:", menu);
|
|
||||||
fSeparatorMenuField->SetDivider(fSeparatorMenuField->StringWidth(fSeparatorMenuField->Label()) + 8.0f);
|
|
||||||
fSeparatorMenuField->SetAlignment(B_ALIGN_LEFT);
|
|
||||||
fSeparatorMenuField->ResizeToPreferred();
|
|
||||||
AddChild(fSeparatorMenuField);
|
|
||||||
|
|
||||||
rect.OffsetBy(0, itemSpacing + 10);
|
|
||||||
|
|
||||||
BStringView* exampleView = new BStringView(rect, "", B_TRANSLATE("Examples:"));
|
|
||||||
exampleView->ResizeToPreferred();
|
|
||||||
AddChild(exampleView);
|
|
||||||
|
|
||||||
rect.OffsetBy(0, itemSpacing);
|
|
||||||
|
|
||||||
fLongDateExampleView = new BStringView(rect, "", "");
|
|
||||||
fLongDateExampleView->ResizeToPreferred();
|
|
||||||
AddChild(fLongDateExampleView);
|
|
||||||
|
|
||||||
rect.OffsetBy(0, itemSpacing);
|
|
||||||
|
|
||||||
fShortDateExampleView = new BStringView(rect, "", "");
|
|
||||||
fShortDateExampleView->ResizeToPreferred();
|
|
||||||
AddChild(fShortDateExampleView);
|
|
||||||
|
|
||||||
_UpdateExamples();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TimeFormatSettingsView::GetPreferredSize(float *_width, float *_height)
|
|
||||||
{
|
|
||||||
if (_width != NULL) {
|
|
||||||
BView* view = fMDYRadioButton->Parent();
|
|
||||||
if (view != NULL)
|
|
||||||
*_width = view->Frame().right;
|
|
||||||
else
|
|
||||||
*_width = Bounds().Width();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_height != NULL)
|
|
||||||
*_height = fShortDateExampleView->Frame().bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TimeFormatSettingsView::AttachedToWindow()
|
|
||||||
{
|
|
||||||
f24HrRadioButton->SetTarget(this);
|
|
||||||
f12HrRadioButton->SetTarget(this);
|
|
||||||
fYMDRadioButton->SetTarget(this);
|
|
||||||
fDMYRadioButton->SetTarget(this);
|
|
||||||
fMDYRadioButton->SetTarget(this);
|
|
||||||
|
|
||||||
fSeparatorMenuField->Menu()->SetTargetForItems(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TimeFormatSettingsView::MessageReceived(BMessage *message)
|
|
||||||
{
|
|
||||||
TTracker *tracker = dynamic_cast<TTracker *>(be_app);
|
|
||||||
if (!tracker)
|
|
||||||
return;
|
|
||||||
TrackerSettings settings;
|
|
||||||
|
|
||||||
switch (message->what) {
|
|
||||||
case kSettingsContentsModified:
|
|
||||||
{
|
|
||||||
int32 separator = 0;
|
|
||||||
BMenuItem *item = fSeparatorMenuField->Menu()->FindMarked();
|
|
||||||
if (item) {
|
|
||||||
separator = fSeparatorMenuField->Menu()->IndexOf(item);
|
|
||||||
if (separator >= 0)
|
|
||||||
settings.SetTimeFormatSeparator((FormatSeparator)separator);
|
|
||||||
}
|
|
||||||
|
|
||||||
DateOrder format =
|
|
||||||
fYMDRadioButton->Value() ? kYMDFormat :
|
|
||||||
fDMYRadioButton->Value() ? kDMYFormat : kMDYFormat;
|
|
||||||
|
|
||||||
settings.SetDateOrderFormat(format);
|
|
||||||
settings.SetClockTo24Hr(f24HrRadioButton->Value() == 1);
|
|
||||||
|
|
||||||
// Make the notification message and send it to the tracker:
|
|
||||||
BMessage notificationMessage;
|
|
||||||
notificationMessage.AddInt32("TimeFormatSeparator", separator);
|
|
||||||
notificationMessage.AddInt32("DateOrderFormat", format);
|
|
||||||
notificationMessage.AddBool("24HrClock", f24HrRadioButton->Value() == 1);
|
|
||||||
tracker->SendNotices(kDateFormatChanged, ¬ificationMessage);
|
|
||||||
|
|
||||||
_UpdateExamples();
|
|
||||||
|
|
||||||
Window()->PostMessage(kSettingsContentsModified);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
_inherited::MessageReceived(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TimeFormatSettingsView::SetDefaults()
|
|
||||||
{
|
|
||||||
TrackerSettings settings;
|
|
||||||
|
|
||||||
settings.SetTimeFormatSeparator(kSlashSeparator);
|
|
||||||
settings.SetDateOrderFormat(kMDYFormat);
|
|
||||||
settings.SetClockTo24Hr(false);
|
|
||||||
|
|
||||||
ShowCurrentSettings();
|
|
||||||
_SendNotices();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
TimeFormatSettingsView::IsDefaultable() const
|
|
||||||
{
|
|
||||||
TrackerSettings settings;
|
|
||||||
|
|
||||||
return settings.TimeFormatSeparator() != kSlashSeparator
|
|
||||||
|| settings.DateOrderFormat() != kMDYFormat
|
|
||||||
|| settings.ClockIs24Hr() != false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TimeFormatSettingsView::Revert()
|
|
||||||
{
|
|
||||||
TrackerSettings settings;
|
|
||||||
|
|
||||||
settings.SetTimeFormatSeparator(fSeparator);
|
|
||||||
settings.SetDateOrderFormat(fFormat);
|
|
||||||
settings.SetClockTo24Hr(f24HrClock);
|
|
||||||
|
|
||||||
ShowCurrentSettings();
|
|
||||||
_SendNotices();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TimeFormatSettingsView::_SendNotices()
|
|
||||||
{
|
|
||||||
TTracker *tracker = dynamic_cast<TTracker *>(be_app);
|
|
||||||
if (!tracker)
|
|
||||||
return;
|
|
||||||
|
|
||||||
TrackerSettings settings;
|
|
||||||
|
|
||||||
// Make the notification message and send it to the tracker:
|
|
||||||
BMessage notificationMessage;
|
|
||||||
notificationMessage.AddInt32("TimeFormatSeparator", (int32)settings.TimeFormatSeparator());
|
|
||||||
notificationMessage.AddInt32("DateOrderFormat", (int32)settings.DateOrderFormat());
|
|
||||||
notificationMessage.AddBool("24HrClock", settings.ClockIs24Hr());
|
|
||||||
tracker->SendNotices(kDateFormatChanged, ¬ificationMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TimeFormatSettingsView::ShowCurrentSettings()
|
|
||||||
{
|
|
||||||
TrackerSettings settings;
|
|
||||||
|
|
||||||
f24HrRadioButton->SetValue(settings.ClockIs24Hr());
|
|
||||||
f12HrRadioButton->SetValue(!settings.ClockIs24Hr());
|
|
||||||
|
|
||||||
switch (settings.DateOrderFormat()) {
|
|
||||||
case kYMDFormat:
|
|
||||||
fYMDRadioButton->SetValue(1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kMDYFormat:
|
|
||||||
fMDYRadioButton->SetValue(1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
case kDMYFormat:
|
|
||||||
fDMYRadioButton->SetValue(1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
FormatSeparator separator = settings.TimeFormatSeparator();
|
|
||||||
|
|
||||||
if (separator >= kNoSeparator && separator < kSeparatorsEnd)
|
|
||||||
fSeparatorMenuField->Menu()->ItemAt((int32)separator)->SetMarked(true);
|
|
||||||
|
|
||||||
_UpdateExamples();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TimeFormatSettingsView::RecordRevertSettings()
|
|
||||||
{
|
|
||||||
TrackerSettings settings;
|
|
||||||
|
|
||||||
f24HrClock = settings.ClockIs24Hr();
|
|
||||||
fSeparator = settings.TimeFormatSeparator();
|
|
||||||
fFormat = settings.DateOrderFormat();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
TimeFormatSettingsView::IsRevertable() const
|
|
||||||
{
|
|
||||||
FormatSeparator separator;
|
|
||||||
|
|
||||||
BMenuItem *item = fSeparatorMenuField->Menu()->FindMarked();
|
|
||||||
if (item) {
|
|
||||||
int32 index = fSeparatorMenuField->Menu()->IndexOf(item);
|
|
||||||
if (index >= 0)
|
|
||||||
separator = (FormatSeparator)index;
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
} else
|
|
||||||
return true;
|
|
||||||
|
|
||||||
DateOrder format =
|
|
||||||
fYMDRadioButton->Value() ? kYMDFormat :
|
|
||||||
(fDMYRadioButton->Value() ? kDMYFormat : kMDYFormat);
|
|
||||||
|
|
||||||
return f24HrClock != (f24HrRadioButton->Value() > 0)
|
|
||||||
|| separator != fSeparator
|
|
||||||
|| format != fFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TimeFormatSettingsView::_UpdateExamples()
|
|
||||||
{
|
|
||||||
time_t timeValue = (time_t)time(NULL);
|
|
||||||
tm timeData;
|
|
||||||
localtime_r(&timeValue, &timeData);
|
|
||||||
BString timeFormat = "Internal Error!";
|
|
||||||
char buffer[256];
|
|
||||||
|
|
||||||
FormatSeparator separator;
|
|
||||||
|
|
||||||
BMenuItem *item = fSeparatorMenuField->Menu()->FindMarked();
|
|
||||||
if (item) {
|
|
||||||
int32 index = fSeparatorMenuField->Menu()->IndexOf(item);
|
|
||||||
if (index >= 0)
|
|
||||||
separator = (FormatSeparator)index;
|
|
||||||
else
|
|
||||||
separator = kSlashSeparator;
|
|
||||||
} else
|
|
||||||
separator = kSlashSeparator;
|
|
||||||
|
|
||||||
DateOrder order =
|
|
||||||
fYMDRadioButton->Value() ? kYMDFormat :
|
|
||||||
(fDMYRadioButton->Value() ? kDMYFormat : kMDYFormat);
|
|
||||||
|
|
||||||
bool clockIs24hr = (f24HrRadioButton->Value() > 0);
|
|
||||||
|
|
||||||
TimeFormat(timeFormat, 0, separator, order, clockIs24hr);
|
|
||||||
strftime(buffer, 256, timeFormat.String(), &timeData);
|
|
||||||
|
|
||||||
fLongDateExampleView->SetText(buffer);
|
|
||||||
fLongDateExampleView->ResizeToPreferred();
|
|
||||||
|
|
||||||
TimeFormat(timeFormat, 4, separator, order, clockIs24hr);
|
|
||||||
strftime(buffer, 256, timeFormat.String(), &timeData);
|
|
||||||
|
|
||||||
fShortDateExampleView->SetText(buffer);
|
|
||||||
fShortDateExampleView->ResizeToPreferred();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
|
||||||
|
|
||||||
|
|
||||||
SpaceBarSettingsView::SpaceBarSettingsView(BRect rect)
|
SpaceBarSettingsView::SpaceBarSettingsView(BRect rect)
|
||||||
: SettingsView(rect, "SpaceBarSettingsView")
|
: SettingsView(rect, "SpaceBarSettingsView")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -134,44 +134,6 @@ class WindowsSettingsView : public SettingsView {
|
|||||||
typedef SettingsView _inherited;
|
typedef SettingsView _inherited;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TimeFormatSettingsView : public SettingsView {
|
|
||||||
public:
|
|
||||||
TimeFormatSettingsView(BRect frame);
|
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage *message);
|
|
||||||
virtual void AttachedToWindow();
|
|
||||||
virtual void GetPreferredSize(float *_width, float *_height);
|
|
||||||
|
|
||||||
virtual void SetDefaults();
|
|
||||||
virtual bool IsDefaultable() const;
|
|
||||||
virtual void Revert();
|
|
||||||
virtual void ShowCurrentSettings();
|
|
||||||
virtual void RecordRevertSettings();
|
|
||||||
virtual bool IsRevertable() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void _UpdateExamples();
|
|
||||||
void _SendNotices();
|
|
||||||
|
|
||||||
BRadioButton *f24HrRadioButton;
|
|
||||||
BRadioButton *f12HrRadioButton;
|
|
||||||
|
|
||||||
BRadioButton *fYMDRadioButton;
|
|
||||||
BRadioButton *fDMYRadioButton;
|
|
||||||
BRadioButton *fMDYRadioButton;
|
|
||||||
|
|
||||||
BMenuField *fSeparatorMenuField;
|
|
||||||
|
|
||||||
BStringView *fLongDateExampleView;
|
|
||||||
BStringView *fShortDateExampleView;
|
|
||||||
|
|
||||||
bool f24HrClock;
|
|
||||||
|
|
||||||
FormatSeparator fSeparator;
|
|
||||||
DateOrder fFormat;
|
|
||||||
|
|
||||||
typedef SettingsView _inherited;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SpaceBarSettingsView : public SettingsView {
|
class SpaceBarSettingsView : public SettingsView {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -120,8 +120,6 @@ TrackerSettingsWindow::TrackerSettingsWindow()
|
|||||||
new DesktopSettingsView(rect)));
|
new DesktopSettingsView(rect)));
|
||||||
fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Windows"),
|
fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Windows"),
|
||||||
new WindowsSettingsView(rect)));
|
new WindowsSettingsView(rect)));
|
||||||
fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Date & Time"),
|
|
||||||
new TimeFormatSettingsView(rect)));
|
|
||||||
fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Trash"),
|
fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Trash"),
|
||||||
new TrashSettingsView(rect)));
|
new TrashSettingsView(rect)));
|
||||||
fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Volume icons"),
|
fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Volume icons"),
|
||||||
|
|||||||
Reference in New Issue
Block a user