* Deskbar now uses localized time from locale kit. Thus the "24 hour

clock" setting is not needed anymore.
 * The locale kit now provide a less complete 'full' time format : hour 
minutes seconds, I don't think anyone cares much about the "UTC + 1" or 
other similar stuff.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37243 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adrien Destugues
2010-06-24 13:32:59 +00:00
parent fd9fa13896
commit 3fc995d101
9 changed files with 16 additions and 65 deletions
-3
View File
@@ -192,7 +192,6 @@ TBarApp::SaveSettings()
fSettingsFile->Write(&fSettings.recentAppsCount, sizeof(int32)); fSettingsFile->Write(&fSettings.recentAppsCount, sizeof(int32));
fSettingsFile->Write(&fSettings.recentDocsCount, sizeof(int32)); fSettingsFile->Write(&fSettings.recentDocsCount, sizeof(int32));
fSettingsFile->Write(&fSettings.timeShowSeconds, sizeof(bool)); fSettingsFile->Write(&fSettings.timeShowSeconds, sizeof(bool));
fSettingsFile->Write(&fSettings.timeShowMil, sizeof(bool));
fSettingsFile->Write(&fSettings.recentFoldersCount, sizeof(int32)); fSettingsFile->Write(&fSettings.recentFoldersCount, sizeof(int32));
fSettingsFile->Write(&fSettings.timeShowEuro, sizeof(bool)); fSettingsFile->Write(&fSettings.timeShowEuro, sizeof(bool));
fSettingsFile->Write(&fSettings.alwaysOnTop, sizeof(bool)); fSettingsFile->Write(&fSettings.alwaysOnTop, sizeof(bool));
@@ -224,7 +223,6 @@ TBarApp::InitSettings()
settings.recentAppsCount = 10; settings.recentAppsCount = 10;
settings.recentDocsCount = 10; settings.recentDocsCount = 10;
settings.timeShowSeconds = false; settings.timeShowSeconds = false;
settings.timeShowMil = false;
settings.recentFoldersCount = 10; settings.recentFoldersCount = 10;
settings.timeShowEuro = false; settings.timeShowEuro = false;
settings.alwaysOnTop = false; settings.alwaysOnTop = false;
@@ -276,7 +274,6 @@ TBarApp::InitSettings()
} }
if (size >= kValidSettingsSize4) { if (size >= kValidSettingsSize4) {
fSettingsFile->Read(&settings.timeShowSeconds, sizeof(bool)); fSettingsFile->Read(&settings.timeShowSeconds, sizeof(bool));
fSettingsFile->Read(&settings.timeShowMil, sizeof(bool));
} }
if (size >= kValidSettingsSize5) if (size >= kValidSettingsSize5)
fSettingsFile->Read(&settings.recentFoldersCount, fSettingsFile->Read(&settings.recentFoldersCount,
+1 -2
View File
@@ -104,7 +104,6 @@ struct desk_settings {
int32 recentAppsCount; // version 3 int32 recentAppsCount; // version 3
int32 recentDocsCount; int32 recentDocsCount;
bool timeShowSeconds; // version 4 bool timeShowSeconds; // version 4
bool timeShowMil;
int32 recentFoldersCount; // version 5 int32 recentFoldersCount; // version 5
bool timeShowEuro; // version 6 bool timeShowEuro; // version 6
bool alwaysOnTop; bool alwaysOnTop;
@@ -126,7 +125,7 @@ const uint32 kValidSettingsSize1 = 5 * sizeof(bool) + sizeof(uint32)
+ sizeof(float); + sizeof(float);
const uint32 kValidSettingsSize2 = sizeof(BPoint) + kValidSettingsSize1; const uint32 kValidSettingsSize2 = sizeof(BPoint) + kValidSettingsSize1;
const uint32 kValidSettingsSize3 = 2 * sizeof(int32) + kValidSettingsSize2; const uint32 kValidSettingsSize3 = 2 * sizeof(int32) + kValidSettingsSize2;
const uint32 kValidSettingsSize4 = 2 * sizeof(bool) + kValidSettingsSize3; const uint32 kValidSettingsSize4 = sizeof(bool) + kValidSettingsSize3;
const uint32 kValidSettingsSize5 = sizeof(int32) + kValidSettingsSize4; const uint32 kValidSettingsSize5 = sizeof(int32) + kValidSettingsSize4;
const uint32 kValidSettingsSize6 = 2 * sizeof(bool) + kValidSettingsSize5; const uint32 kValidSettingsSize6 = 2 * sizeof(bool) + kValidSettingsSize5;
const uint32 kValidSettingsSize7 = sizeof(bool) + kValidSettingsSize6; const uint32 kValidSettingsSize7 = sizeof(bool) + kValidSettingsSize6;
-1
View File
@@ -371,7 +371,6 @@ TBeMenu::ResetTargets()
case kConfigShow: case kConfigShow:
case kAlwaysTop: case kAlwaysTop:
case kShowSeconds: case kShowSeconds:
case kMilTime:
case kEuroDate: case kEuroDate:
case kRebootSystem: case kRebootSystem:
case kSuspendSystem: case kSuspendSystem:
-6
View File
@@ -58,8 +58,6 @@ PreferencesWindow::PreferencesWindow(BRect frame)
fAppsExpandNew = new BCheckBox(B_TRANSLATE("Expand new applications"), fAppsExpandNew = new BCheckBox(B_TRANSLATE("Expand new applications"),
new BMessage(kExpandNewTeams)); new BMessage(kExpandNewTeams));
fClock24Hours = new BCheckBox(B_TRANSLATE("24 hour clock"),
new BMessage(kMilTime));
fClockSeconds = new BCheckBox(B_TRANSLATE("Show seconds"), fClockSeconds = new BCheckBox(B_TRANSLATE("Show seconds"),
new BMessage(kShowSeconds)); new BMessage(kShowSeconds));
fClockEuropeanDate = new BCheckBox(B_TRANSLATE("European date"), fClockEuropeanDate = new BCheckBox(B_TRANSLATE("European date"),
@@ -124,13 +122,11 @@ PreferencesWindow::PreferencesWindow(BRect frame)
TReplicantTray* replicantTray = barApp->BarView()->fReplicantTray; TReplicantTray* replicantTray = barApp->BarView()->fReplicantTray;
fClock24Hours->SetValue(replicantTray->ShowingMiltime());
fClockSeconds->SetValue(replicantTray->ShowingSeconds()); fClockSeconds->SetValue(replicantTray->ShowingSeconds());
fClockEuropeanDate->SetValue(replicantTray->ShowingEuroDate()); fClockEuropeanDate->SetValue(replicantTray->ShowingEuroDate());
fClockFullDate->SetValue(replicantTray->ShowingFullDate()); fClockFullDate->SetValue(replicantTray->ShowingFullDate());
bool showingClock = barApp->BarView()->ShowingClock(); bool showingClock = barApp->BarView()->ShowingClock();
fClock24Hours->SetEnabled(showingClock);
fClockSeconds->SetEnabled(showingClock); fClockSeconds->SetEnabled(showingClock);
fClockEuropeanDate->SetEnabled(showingClock); fClockEuropeanDate->SetEnabled(showingClock);
fClockFullDate->SetEnabled(replicantTray->CanShowFullDate()); fClockFullDate->SetEnabled(replicantTray->CanShowFullDate());
@@ -145,7 +141,6 @@ PreferencesWindow::PreferencesWindow(BRect frame)
fAppsSortTrackerFirst->SetTarget(be_app); fAppsSortTrackerFirst->SetTarget(be_app);
fAppsExpandNew->SetTarget(be_app); fAppsExpandNew->SetTarget(be_app);
fClock24Hours->SetTarget(replicantTray);
fClockSeconds->SetTarget(replicantTray); fClockSeconds->SetTarget(replicantTray);
fClockEuropeanDate->SetTarget(replicantTray); fClockEuropeanDate->SetTarget(replicantTray);
fClockFullDate->SetTarget(replicantTray); fClockFullDate->SetTarget(replicantTray);
@@ -203,7 +198,6 @@ PreferencesWindow::PreferencesWindow(BRect frame)
view = BLayoutBuilder::Group<>() view = BLayoutBuilder::Group<>()
.AddGroup(B_VERTICAL, 1) .AddGroup(B_VERTICAL, 1)
.Add(fClock24Hours)
.Add(fClockSeconds) .Add(fClockSeconds)
.Add(fClockEuropeanDate) .Add(fClockEuropeanDate)
.Add(fClockFullDate) .Add(fClockFullDate)
-1
View File
@@ -52,7 +52,6 @@ private:
BCheckBox* fAppsShowExpanders; BCheckBox* fAppsShowExpanders;
BCheckBox* fAppsExpandNew; BCheckBox* fAppsExpandNew;
BCheckBox* fClock24Hours;
BCheckBox* fClockSeconds; BCheckBox* fClockSeconds;
BCheckBox* fClockEuropeanDate; BCheckBox* fClockEuropeanDate;
BCheckBox* fClockFullDate; BCheckBox* fClockFullDate;
+2 -13
View File
@@ -199,7 +199,6 @@ TReplicantTray::RememberClockSettings()
desk_settings* settings = ((TBarApp*)be_app)->Settings(); desk_settings* settings = ((TBarApp*)be_app)->Settings();
settings->timeShowSeconds = fClock->ShowingSeconds(); settings->timeShowSeconds = fClock->ShowingSeconds();
settings->timeShowMil = fClock->ShowingMilTime();
settings->timeShowEuro = fClock->ShowingEuroDate(); settings->timeShowEuro = fClock->ShowingEuroDate();
settings->timeFullDate = fClock->ShowingFullDate(); settings->timeFullDate = fClock->ShowingFullDate();
} }
@@ -215,15 +214,6 @@ TReplicantTray::ShowingSeconds()
} }
bool
TReplicantTray::ShowingMiltime()
{
if (fClock)
return fClock->ShowingMilTime();
return false;
}
bool bool
TReplicantTray::ShowingEuroDate() TReplicantTray::ShowingEuroDate()
{ {
@@ -261,8 +251,8 @@ TReplicantTray::DealWithClock(bool showClock)
desk_settings* settings = ((TBarApp*)be_app)->Settings(); desk_settings* settings = ((TBarApp*)be_app)->Settings();
fClock = new TTimeView(fMinimumTrayWidth, kMaxReplicantHeight - 1.0, fClock = new TTimeView(fMinimumTrayWidth, kMaxReplicantHeight - 1.0,
settings->timeShowSeconds, settings->timeShowMil, settings->timeShowSeconds, settings->timeFullDate,
settings->timeFullDate, settings->timeShowEuro, false); settings->timeShowEuro, false);
AddChild(fClock); AddChild(fClock);
fClock->MoveTo(Bounds().right - fClock->Bounds().Width() - 1, 2); fClock->MoveTo(Bounds().right - fClock->Bounds().Width() - 1, 2);
@@ -385,7 +375,6 @@ TReplicantTray::MessageReceived(BMessage* message)
break; break;
case kShowSeconds: case kShowSeconds:
case kMilTime:
case kEuroDate: case kEuroDate:
case kFullDate: case kFullDate:
if (fClock != NULL) if (fClock != NULL)
+11 -34
View File
@@ -38,8 +38,10 @@ All rights reserved.
#include <string.h> #include <string.h>
#include <Catalog.h> #include <Catalog.h>
#include <Country.h>
#include <Debug.h> #include <Debug.h>
#include <Locale.h> #include <Locale.h>
#include <LocaleRoster.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <MessageRunner.h> #include <MessageRunner.h>
#include <PopUpMenu.h> #include <PopUpMenu.h>
@@ -72,7 +74,7 @@ enum {
#define B_TRANSLATE_CONTEXT "TimeView" #define B_TRANSLATE_CONTEXT "TimeView"
TTimeView::TTimeView(float maxWidth, float height, bool showSeconds, TTimeView::TTimeView(float maxWidth, float height, bool showSeconds,
bool milTime, bool fullDate, bool euroDate, bool) bool fullDate, bool euroDate, bool)
: :
BView(BRect(-100,-100,-90,-90), "_deskbar_tv_", BView(BRect(-100,-100,-90,-90), "_deskbar_tv_",
B_FOLLOW_RIGHT | B_FOLLOW_TOP, B_FOLLOW_RIGHT | B_FOLLOW_TOP,
@@ -80,7 +82,6 @@ TTimeView::TTimeView(float maxWidth, float height, bool showSeconds,
fParent(NULL), fParent(NULL),
fShowInterval(true), // ToDo: defaulting this to true until UI is in place fShowInterval(true), // ToDo: defaulting this to true until UI is in place
fShowSeconds(showSeconds), fShowSeconds(showSeconds),
fMilTime(milTime),
fFullDate(fullDate), fFullDate(fullDate),
fCanShowFullDate(false), fCanShowFullDate(false),
fEuroDate(euroDate), fEuroDate(euroDate),
@@ -104,7 +105,6 @@ TTimeView::TTimeView(BMessage* data)
{ {
fTime = fLastTime = time(NULL); fTime = fLastTime = time(NULL);
data->FindBool("seconds", &fShowSeconds); data->FindBool("seconds", &fShowSeconds);
data->FindBool("miltime", &fMilTime);
data->FindBool("fulldate", &fFullDate); data->FindBool("fulldate", &fFullDate);
data->FindBool("eurodate", &fEuroDate); data->FindBool("eurodate", &fEuroDate);
data->FindBool("interval", &fInterval); data->FindBool("interval", &fInterval);
@@ -135,7 +135,6 @@ TTimeView::Archive(BMessage* data, bool deep) const
{ {
BView::Archive(data, deep); BView::Archive(data, deep);
data->AddBool("seconds", fShowSeconds); data->AddBool("seconds", fShowSeconds);
data->AddBool("miltime", fMilTime);
data->AddBool("fulldate", fFullDate); data->AddBool("fulldate", fFullDate);
data->AddBool("eurodate", fEuroDate); data->AddBool("eurodate", fEuroDate);
data->AddBool("interval", fInterval); data->AddBool("interval", fInterval);
@@ -220,10 +219,6 @@ TTimeView::MessageReceived(BMessage* message)
ShowSeconds(!ShowingSeconds()); ShowSeconds(!ShowingSeconds());
break; break;
case kMilTime:
ShowMilTime(!ShowingMilTime());
break;
case kEuroDate: case kEuroDate:
ShowEuroDate(!ShowingEuroDate()); ShowEuroDate(!ShowingEuroDate());
break; break;
@@ -315,28 +310,18 @@ TTimeView::StopLongClickNotifier()
void void
TTimeView::GetCurrentTime() TTimeView::GetCurrentTime()
{ {
char tmp[64]; // TODO : should this be another function ?
tm time = *localtime(&fTime); tm time = *localtime(&fTime);
if (fMilTime) {
strftime(tmp, 64, fShowSeconds ? "%H:%M:%S" : "%H:%M", &time);
} else {
if (fShowInterval)
strftime(tmp, 64, fShowSeconds ? "%I:%M:%S %p" : "%I:%M %p", &time);
else
strftime(tmp, 64, fShowSeconds ? "%I:%M:%S" : "%I:%M", &time);
}
// remove leading 0 from time when hour is less than 10
const char* str = tmp;
if (str[0] == '0')
str++;
strcpy(fTimeStr, str);
fSeconds = time.tm_sec; fSeconds = time.tm_sec;
fMinute = time.tm_min; fMinute = time.tm_min;
fHour = time.tm_hour; fHour = time.tm_hour;
BCountry* here;
be_locale_roster->GetDefaultCountry(&here);
here->FormatTime(fTimeStr, 64, fTime, fShowSeconds);
} }
@@ -465,14 +450,6 @@ TTimeView::ShowSeconds(bool on)
} }
void
TTimeView::ShowMilTime(bool on)
{
fMilTime = on;
Update();
}
void void
TTimeView::ShowDate(bool on) TTimeView::ShowDate(bool on)
{ {
+1 -4
View File
@@ -54,7 +54,7 @@ class _EXPORT TTimeView;
class TTimeView : public BView { class TTimeView : public BView {
public: public:
TTimeView(float maxWidth, float height, bool showSeconds = false, TTimeView(float maxWidth, float height, bool showSeconds = false,
bool milTime = false, bool fullDate = false, bool euroDate = false, bool fullDate = false, bool euroDate = false,
bool showInterval = false); bool showInterval = false);
TTimeView(BMessage* data); TTimeView(BMessage* data);
~TTimeView(); ~TTimeView();
@@ -76,8 +76,6 @@ class TTimeView : public BView {
bool ShowingSeconds() { return fShowSeconds; } bool ShowingSeconds() { return fShowSeconds; }
void ShowSeconds(bool); void ShowSeconds(bool);
bool ShowingMilTime() { return fMilTime; }
void ShowMilTime(bool);
bool ShowingDate() { return fShowingDate; } bool ShowingDate() { return fShowingDate; }
void ShowDate(bool); void ShowDate(bool);
bool ShowingFullDate() { return fFullDate; } bool ShowingFullDate() { return fFullDate; }
@@ -120,7 +118,6 @@ class TTimeView : public BView {
bool fShowInterval; bool fShowInterval;
bool fShowSeconds; bool fShowSeconds;
bool fMilTime;
bool fShowingDate; bool fShowingDate;
bool fFullDate; bool fFullDate;
bool fCanShowFullDate; bool fCanShowFullDate;
+1 -1
View File
@@ -164,7 +164,7 @@ BCountry::FormatTime(BString* string, time_t time, bool longFormat)
// short, medium, long, and full. Our bool parameter is not enough... // short, medium, long, and full. Our bool parameter is not enough...
icu_4_2::DateFormat* timeFormatter; icu_4_2::DateFormat* timeFormatter;
timeFormatter = DateFormat::createTimeInstance( timeFormatter = DateFormat::createTimeInstance(
longFormat ? DateFormat::FULL : DateFormat::SHORT, longFormat ? DateFormat::MEDIUM : DateFormat::SHORT,
*fICULocale); *fICULocale);
UnicodeString ICUString; UnicodeString ICUString;
ICUString = timeFormatter->format((UDate)time * 1000, ICUString); ICUString = timeFormatter->format((UDate)time * 1000, ICUString);