* Introduce a new method in BCountry to get the first day of week (monday or sunday)

* Localize date in deskbar properly, and use the new API to show the calendar. The "show european date" checkbox is now gone.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37344 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adrien Destugues
2010-07-02 17:15:55 +00:00
parent 38319af892
commit 2f0eb7b11e
13 changed files with 40 additions and 65 deletions
+2
View File
@@ -49,6 +49,8 @@ class BCountry {
const char* DateSeparator() const;
const char* TimeSeparator() const;
int StartOfWeek();
// numbers
virtual void FormatNumber(char* string, size_t maxSize, double value);
-3
View File
@@ -192,7 +192,6 @@ TBarApp::SaveSettings()
fSettingsFile->Write(&fSettings.recentDocsCount, sizeof(int32));
fSettingsFile->Write(&fSettings.timeShowSeconds, sizeof(bool));
fSettingsFile->Write(&fSettings.recentFoldersCount, sizeof(int32));
fSettingsFile->Write(&fSettings.timeShowEuro, sizeof(bool));
fSettingsFile->Write(&fSettings.alwaysOnTop, sizeof(bool));
fSettingsFile->Write(&fSettings.timeFullDate, sizeof(bool));
fSettingsFile->Write(&fSettings.trackerAlwaysFirst, sizeof(bool));
@@ -223,7 +222,6 @@ TBarApp::InitSettings()
settings.recentDocsCount = 10;
settings.timeShowSeconds = false;
settings.recentFoldersCount = 10;
settings.timeShowEuro = false;
settings.alwaysOnTop = false;
settings.timeFullDate = false;
settings.trackerAlwaysFirst = false;
@@ -278,7 +276,6 @@ TBarApp::InitSettings()
fSettingsFile->Read(&settings.recentFoldersCount,
sizeof(int32));
if (size >= kValidSettingsSize6) {
fSettingsFile->Read(&settings.timeShowEuro, sizeof(bool));
fSettingsFile->Read(&settings.alwaysOnTop, sizeof(bool));
}
if (size >= kValidSettingsSize7)
+2 -3
View File
@@ -105,8 +105,7 @@ struct desk_settings {
int32 recentDocsCount;
bool timeShowSeconds; // version 4
int32 recentFoldersCount; // version 5
bool timeShowEuro; // version 6
bool alwaysOnTop;
bool alwaysOnTop; // version 6
bool timeFullDate; // version 7
bool trackerAlwaysFirst; // version 8
bool sortRunningApps;
@@ -127,7 +126,7 @@ const uint32 kValidSettingsSize2 = sizeof(BPoint) + kValidSettingsSize1;
const uint32 kValidSettingsSize3 = 2 * sizeof(int32) + kValidSettingsSize2;
const uint32 kValidSettingsSize4 = sizeof(bool) + kValidSettingsSize3;
const uint32 kValidSettingsSize5 = sizeof(int32) + kValidSettingsSize4;
const uint32 kValidSettingsSize6 = 2 * sizeof(bool) + kValidSettingsSize5;
const uint32 kValidSettingsSize6 = sizeof(bool) + kValidSettingsSize5;
const uint32 kValidSettingsSize7 = sizeof(bool) + kValidSettingsSize6;
const uint32 kValidSettingsSize8 = 2 * sizeof(bool) + kValidSettingsSize7;
const uint32 kValidSettingsSize9 = 2 * sizeof(bool) + kValidSettingsSize8;
-1
View File
@@ -371,7 +371,6 @@ TBeMenu::ResetTargets()
case kConfigShow:
case kAlwaysTop:
case kShowSeconds:
case kEuroDate:
case kRebootSystem:
case kSuspendSystem:
case kShutdownSystem:
+8 -2
View File
@@ -12,6 +12,8 @@
#include <GroupLayout.h>
#include <GroupLayoutBuilder.h>
#include <GroupView.h>
#include <Locale.h>
#include <LocaleRoster.h>
#include <Screen.h>
#include <SpaceLayoutItem.h>
#include <String.h>
@@ -77,7 +79,7 @@ enum {
};
CalendarMenuWindow::CalendarMenuWindow(BPoint where, bool euroDate)
CalendarMenuWindow::CalendarMenuWindow(BPoint where)
:
BWindow(BRect(0.0, 0.0, 100.0, 130.0), "", B_BORDERED_WINDOW,
B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS | B_CLOSE_ON_ESCAPE
@@ -87,6 +89,10 @@ CalendarMenuWindow::CalendarMenuWindow(BPoint where, bool euroDate)
fCalendarView(NULL),
fSuppressFirstClose(true)
{
BCountry* here;
be_locale_roster->GetDefaultCountry(&here);
BPrivate::week_start startOfWeek = /*here->StartOfWeek()*/ B_WEEK_START_MONDAY;
RemoveShortcut('H', B_COMMAND_KEY | B_CONTROL_KEY);
AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
@@ -97,7 +103,7 @@ CalendarMenuWindow::CalendarMenuWindow(BPoint where, bool euroDate)
fMonthLabel->SetFontSize(10.0);
fCalendarView = new BCalendarView(Bounds(), "calendar",
euroDate ? B_WEEK_START_MONDAY : B_WEEK_START_SUNDAY, B_FOLLOW_ALL);
startOfWeek, B_FOLLOW_ALL);
fCalendarView->SetInvocationMessage(new BMessage(kInvokationMessage));
fCalendarView->SetFontSize(10.0);
+1 -1
View File
@@ -22,7 +22,7 @@ using BPrivate::BCalendarView;
class CalendarMenuWindow : public BWindow {
public:
CalendarMenuWindow(BPoint where, bool euroDate);
CalendarMenuWindow(BPoint where);
virtual ~CalendarMenuWindow();
virtual void Show();
-6
View File
@@ -60,8 +60,6 @@ PreferencesWindow::PreferencesWindow(BRect frame)
fClockSeconds = new BCheckBox(B_TRANSLATE("Show seconds"),
new BMessage(kShowSeconds));
fClockEuropeanDate = new BCheckBox(B_TRANSLATE("European date"),
new BMessage(kEuroDate));
fClockFullDate = new BCheckBox(B_TRANSLATE("Full date"),
new BMessage(kFullDate));
@@ -123,12 +121,10 @@ PreferencesWindow::PreferencesWindow(BRect frame)
TReplicantTray* replicantTray = barApp->BarView()->fReplicantTray;
fClockSeconds->SetValue(replicantTray->ShowingSeconds());
fClockEuropeanDate->SetValue(replicantTray->ShowingEuroDate());
fClockFullDate->SetValue(replicantTray->ShowingFullDate());
bool showingClock = barApp->BarView()->ShowingClock();
fClockSeconds->SetEnabled(showingClock);
fClockEuropeanDate->SetEnabled(showingClock);
fClockFullDate->SetEnabled(replicantTray->CanShowFullDate());
fWindowAlwaysOnTop->SetValue(appSettings->alwaysOnTop);
@@ -142,7 +138,6 @@ PreferencesWindow::PreferencesWindow(BRect frame)
fAppsExpandNew->SetTarget(be_app);
fClockSeconds->SetTarget(replicantTray);
fClockEuropeanDate->SetTarget(replicantTray);
fClockFullDate->SetTarget(replicantTray);
fWindowAlwaysOnTop->SetTarget(be_app);
@@ -199,7 +194,6 @@ PreferencesWindow::PreferencesWindow(BRect frame)
view = BLayoutBuilder::Group<>()
.AddGroup(B_VERTICAL, 1)
.Add(fClockSeconds)
.Add(fClockEuropeanDate)
.Add(fClockFullDate)
.AddGlue()
.SetInsets(10, 10, 10, 10)
-1
View File
@@ -53,7 +53,6 @@ private:
BCheckBox* fAppsExpandNew;
BCheckBox* fClockSeconds;
BCheckBox* fClockEuropeanDate;
BCheckBox* fClockFullDate;
BCheckBox* fWindowAlwaysOnTop;
+1 -12
View File
@@ -199,7 +199,6 @@ TReplicantTray::RememberClockSettings()
desk_settings* settings = ((TBarApp*)be_app)->Settings();
settings->timeShowSeconds = fClock->ShowingSeconds();
settings->timeShowEuro = fClock->ShowingEuroDate();
settings->timeFullDate = fClock->ShowingFullDate();
}
}
@@ -214,15 +213,6 @@ TReplicantTray::ShowingSeconds()
}
bool
TReplicantTray::ShowingEuroDate()
{
if (fClock)
return fClock->ShowingEuroDate();
return false;
}
bool
TReplicantTray::ShowingFullDate()
{
@@ -252,7 +242,7 @@ TReplicantTray::DealWithClock(bool showClock)
fClock = new TTimeView(fMinimumTrayWidth, kMaxReplicantHeight - 1.0,
settings->timeShowSeconds, settings->timeFullDate,
settings->timeShowEuro, false);
false);
AddChild(fClock);
fClock->MoveTo(Bounds().right - fClock->Bounds().Width() - 1, 2);
@@ -375,7 +365,6 @@ TReplicantTray::MessageReceived(BMessage* message)
break;
case kShowSeconds:
case kEuroDate:
case kFullDate:
if (fClock != NULL)
Window()->PostMessage(message, fClock);
-1
View File
@@ -113,7 +113,6 @@ public:
bool ShowingSeconds(void);
bool ShowingMiltime(void);
bool ShowingEuroDate(void);
bool ShowingFullDate(void);
bool CanShowFullDate(void);
+3 -29
View File
@@ -52,11 +52,6 @@ All rights reserved.
#include "CalendarMenuWindow.h"
const char* kShortDateFormat = "%m/%d/%y";
const char* kShortEuroDateFormat = "%d/%m/%y";
const char* kLongDateFormat = "%a, %B %d, %Y";
const char* kLongEuroDateFormat = "%a, %d %B, %Y";
static const char* const kMinString = "99:99 AM";
static const float kHMargin = 2.0;
@@ -74,7 +69,7 @@ enum {
#define B_TRANSLATE_CONTEXT "TimeView"
TTimeView::TTimeView(float maxWidth, float height, bool showSeconds,
bool fullDate, bool euroDate, bool)
bool fullDate, bool)
:
BView(BRect(-100,-100,-90,-90), "_deskbar_tv_",
B_FOLLOW_RIGHT | B_FOLLOW_TOP,
@@ -84,7 +79,6 @@ TTimeView::TTimeView(float maxWidth, float height, bool showSeconds,
fShowSeconds(showSeconds),
fFullDate(fullDate),
fCanShowFullDate(false),
fEuroDate(euroDate),
fMaxWidth(maxWidth),
fHeight(height),
fOrientation(true),
@@ -108,7 +102,6 @@ TTimeView::TTimeView(BMessage* data)
fTime = fLastTime = time(NULL);
data->FindBool("seconds", &fShowSeconds);
data->FindBool("fulldate", &fFullDate);
data->FindBool("eurodate", &fEuroDate);
data->FindBool("interval", &fInterval);
fShowingDate = false;
@@ -140,7 +133,6 @@ TTimeView::Archive(BMessage* data, bool deep) const
BView::Archive(data, deep);
data->AddBool("seconds", fShowSeconds);
data->AddBool("fulldate", fFullDate);
data->AddBool("eurodate", fEuroDate);
data->AddBool("interval", fInterval);
data->AddInt32("deskbar:private_align", B_ALIGN_RIGHT);
@@ -223,10 +215,6 @@ TTimeView::MessageReceived(BMessage* message)
ShowSeconds(!ShowingSeconds());
break;
case kEuroDate:
ShowEuroDate(!ShowingEuroDate());
break;
case kChangeClock:
// launch the time prefs app
be_roster->Launch("application/x-vnd.Haiku-Time");
@@ -279,7 +267,7 @@ TTimeView::ShowCalendar(BPoint where)
if (where.y >= BScreen().Frame().bottom)
where.y -= (Bounds().Height() + 4.0);
CalendarMenuWindow* window = new CalendarMenuWindow(where, fEuroDate);
CalendarMenuWindow* window = new CalendarMenuWindow(where);
fCalendarWindow = BMessenger(window);
window->Show();
@@ -329,14 +317,8 @@ void
TTimeView::GetCurrentDate()
{
char tmp[64];
tm time = *localtime(&fTime);
if (fFullDate && CanShowFullDate())
strftime(tmp, 64, fEuroDate ? kLongEuroDateFormat : kLongDateFormat,
&time);
else
strftime(tmp, 64, fEuroDate ? kShortEuroDateFormat : kShortDateFormat,
&time);
fHere->FormatDate(tmp, 64, fTime, fFullDate && CanShowFullDate());
// remove leading 0 from date when month is less than 10 (MM/DD/YY)
// or remove leading 0 from date when day is less than 10 (DD/MM/YY)
@@ -466,14 +448,6 @@ TTimeView::ShowFullDate(bool on)
}
void
TTimeView::ShowEuroDate(bool on)
{
fEuroDate = on;
Update();
}
void
TTimeView::AllowFullDate(bool allow)
{
+1 -6
View File
@@ -42,7 +42,6 @@ All rights reserved.
const uint32 kShowSeconds = 'ShSc';
const uint32 kFullDate = 'FDat';
const uint32 kEuroDate = 'EDat';
class BCountry;
class BMessageRunner;
@@ -55,8 +54,7 @@ class _EXPORT TTimeView;
class TTimeView : public BView {
public:
TTimeView(float maxWidth, float height, bool showSeconds = false,
bool fullDate = false, bool euroDate = false,
bool showInterval = false);
bool fullDate = false, bool showInterval = false);
TTimeView(BMessage* data);
~TTimeView();
@@ -83,8 +81,6 @@ class TTimeView : public BView {
void ShowFullDate(bool);
bool CanShowFullDate() const { return fCanShowFullDate; }
void AllowFullDate(bool);
bool ShowingEuroDate() {return fEuroDate; }
void ShowEuroDate(bool);
void ShowCalendar(BPoint where);
void StartLongClickNotifier(BPoint where);
void StopLongClickNotifier();
@@ -122,7 +118,6 @@ class TTimeView : public BView {
bool fShowingDate;
bool fFullDate;
bool fCanShowFullDate;
bool fEuroDate;
float fMaxWidth;
float fHeight;
+22
View File
@@ -9,6 +9,7 @@
#include <assert.h>
#include <CalendarView.h>
#include <IconUtils.h>
#include <Resources.h>
#include <String.h>
@@ -24,6 +25,10 @@
#include <stdarg.h>
using BPrivate::B_WEEK_START_MONDAY;
using BPrivate::B_WEEK_START_SUNDAY;
const char* gStrings[] = {
// date/time format
"",
@@ -231,6 +236,23 @@ BCountry::TimeFormat(BString& format, bool longFormat) const
}
int
BCountry::StartOfWeek()
{
UErrorCode err = U_ZERO_ERROR;
Calendar* c = Calendar::createInstance(*fICULocale, err);
if (err == U_ZERO_ERROR && c->getFirstDayOfWeek(err) == UCAL_SUNDAY) {
delete c;
return B_WEEK_START_SUNDAY;
} else {
delete c;
// Might be another day, but BeAPI will not handle it
return B_WEEK_START_MONDAY;
}
}
// TODO find how to get it from ICU (setting it is ok, we use the pattern-string
// for that)
// Or remove this function ?