Author: pulkomandy Date: 2010-06-24 15:32:59 +0200 (Thu, 24 Jun 2010) New Revision: 37243 Changeset: http://dev.haiku-os.org/changeset/37243/haiku Modified: haiku/trunk/src/apps/deskbar/BarApp.cpp haiku/trunk/src/apps/deskbar/BarApp.h haiku/trunk/src/apps/deskbar/BeMenu.cpp haiku/trunk/src/apps/deskbar/PreferencesWindow.cpp haiku/trunk/src/apps/deskbar/PreferencesWindow.h haiku/trunk/src/apps/deskbar/StatusView.cpp haiku/trunk/src/apps/deskbar/TimeView.cpp haiku/trunk/src/apps/deskbar/TimeView.h haiku/trunk/src/kits/locale/Country.cpp Log: * 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. Modified: haiku/trunk/src/apps/deskbar/BarApp.cpp =================================================================== --- haiku/trunk/src/apps/deskbar/BarApp.cpp 2010-06-24 04:29:38 UTC (rev 37242) +++ haiku/trunk/src/apps/deskbar/BarApp.cpp 2010-06-24 13:32:59 UTC (rev 37243) @@ -192,7 +192,6 @@ fSettingsFile->Write(&fSettings.recentAppsCount, sizeof(int32)); fSettingsFile->Write(&fSettings.recentDocsCount, sizeof(int32)); fSettingsFile->Write(&fSettings.timeShowSeconds, sizeof(bool)); - fSettingsFile->Write(&fSettings.timeShowMil, sizeof(bool)); fSettingsFile->Write(&fSettings.recentFoldersCount, sizeof(int32)); fSettingsFile->Write(&fSettings.timeShowEuro, sizeof(bool)); fSettingsFile->Write(&fSettings.alwaysOnTop, sizeof(bool)); @@ -224,7 +223,6 @@ settings.recentAppsCount = 10; settings.recentDocsCount = 10; settings.timeShowSeconds = false; - settings.timeShowMil = false; settings.recentFoldersCount = 10; settings.timeShowEuro = false; settings.alwaysOnTop = false; @@ -276,7 +274,6 @@ } if (size >= kValidSettingsSize4) { fSettingsFile->Read(&settings.timeShowSeconds, sizeof(bool)); - fSettingsFile->Read(&settings.timeShowMil, sizeof(bool)); } if (size >= kValidSettingsSize5) fSettingsFile->Read(&settings.recentFoldersCount, Modified: haiku/trunk/src/apps/deskbar/BarApp.h =================================================================== --- haiku/trunk/src/apps/deskbar/BarApp.h 2010-06-24 04:29:38 UTC (rev 37242) +++ haiku/trunk/src/apps/deskbar/BarApp.h 2010-06-24 13:32:59 UTC (rev 37243) @@ -104,7 +104,6 @@ int32 recentAppsCount; // version 3 int32 recentDocsCount; bool timeShowSeconds; // version 4 - bool timeShowMil; int32 recentFoldersCount; // version 5 bool timeShowEuro; // version 6 bool alwaysOnTop; @@ -126,7 +125,7 @@ + sizeof(float); const uint32 kValidSettingsSize2 = sizeof(BPoint) + kValidSettingsSize1; 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 kValidSettingsSize6 = 2 * sizeof(bool) + kValidSettingsSize5; const uint32 kValidSettingsSize7 = sizeof(bool) + kValidSettingsSize6; Modified: haiku/trunk/src/apps/deskbar/BeMenu.cpp =================================================================== --- haiku/trunk/src/apps/deskbar/BeMenu.cpp 2010-06-24 04:29:38 UTC (rev 37242) +++ haiku/trunk/src/apps/deskbar/BeMenu.cpp 2010-06-24 13:32:59 UTC (rev 37243) @@ -371,7 +371,6 @@ case kConfigShow: case kAlwaysTop: case kShowSeconds: - case kMilTime: case kEuroDate: case kRebootSystem: case kSuspendSystem: Modified: haiku/trunk/src/apps/deskbar/PreferencesWindow.cpp =================================================================== --- haiku/trunk/src/apps/deskbar/PreferencesWindow.cpp 2010-06-24 04:29:38 UTC (rev 37242) +++ haiku/trunk/src/apps/deskbar/PreferencesWindow.cpp 2010-06-24 13:32:59 UTC (rev 37243) @@ -58,8 +58,6 @@ fAppsExpandNew = new BCheckBox(B_TRANSLATE("Expand new applications"), new BMessage(kExpandNewTeams)); - fClock24Hours = new BCheckBox(B_TRANSLATE("24 hour clock"), - new BMessage(kMilTime)); fClockSeconds = new BCheckBox(B_TRANSLATE("Show seconds"), new BMessage(kShowSeconds)); fClockEuropeanDate = new BCheckBox(B_TRANSLATE("European date"), @@ -124,13 +122,11 @@ TReplicantTray* replicantTray = barApp->BarView()->fReplicantTray; - fClock24Hours->SetValue(replicantTray->ShowingMiltime()); fClockSeconds->SetValue(replicantTray->ShowingSeconds()); fClockEuropeanDate->SetValue(replicantTray->ShowingEuroDate()); fClockFullDate->SetValue(replicantTray->ShowingFullDate()); bool showingClock = barApp->BarView()->ShowingClock(); - fClock24Hours->SetEnabled(showingClock); fClockSeconds->SetEnabled(showingClock); fClockEuropeanDate->SetEnabled(showingClock); fClockFullDate->SetEnabled(replicantTray->CanShowFullDate()); @@ -145,7 +141,6 @@ fAppsSortTrackerFirst->SetTarget(be_app); fAppsExpandNew->SetTarget(be_app); - fClock24Hours->SetTarget(replicantTray); fClockSeconds->SetTarget(replicantTray); fClockEuropeanDate->SetTarget(replicantTray); fClockFullDate->SetTarget(replicantTray); @@ -203,7 +198,6 @@ view = BLayoutBuilder::Group<>() .AddGroup(B_VERTICAL, 1) - .Add(fClock24Hours) .Add(fClockSeconds) .Add(fClockEuropeanDate) .Add(fClockFullDate) Modified: haiku/trunk/src/apps/deskbar/PreferencesWindow.h =================================================================== --- haiku/trunk/src/apps/deskbar/PreferencesWindow.h 2010-06-24 04:29:38 UTC (rev 37242) +++ haiku/trunk/src/apps/deskbar/PreferencesWindow.h 2010-06-24 13:32:59 UTC (rev 37243) @@ -52,7 +52,6 @@ BCheckBox* fAppsShowExpanders; BCheckBox* fAppsExpandNew; - BCheckBox* fClock24Hours; BCheckBox* fClockSeconds; BCheckBox* fClockEuropeanDate; BCheckBox* fClockFullDate; Modified: haiku/trunk/src/apps/deskbar/StatusView.cpp =================================================================== --- haiku/trunk/src/apps/deskbar/StatusView.cpp 2010-06-24 04:29:38 UTC (rev 37242) +++ haiku/trunk/src/apps/deskbar/StatusView.cpp 2010-06-24 13:32:59 UTC (rev 37243) @@ -199,7 +199,6 @@ desk_settings* settings = ((TBarApp*)be_app)->Settings(); settings->timeShowSeconds = fClock->ShowingSeconds(); - settings->timeShowMil = fClock->ShowingMilTime(); settings->timeShowEuro = fClock->ShowingEuroDate(); settings->timeFullDate = fClock->ShowingFullDate(); } @@ -216,15 +215,6 @@ bool -TReplicantTray::ShowingMiltime() -{ - if (fClock) - return fClock->ShowingMilTime(); - return false; -} - - -bool TReplicantTray::ShowingEuroDate() { if (fClock) @@ -261,8 +251,8 @@ desk_settings* settings = ((TBarApp*)be_app)->Settings(); fClock = new TTimeView(fMinimumTrayWidth, kMaxReplicantHeight - 1.0, - settings->timeShowSeconds, settings->timeShowMil, - settings->timeFullDate, settings->timeShowEuro, false); + settings->timeShowSeconds, settings->timeFullDate, + settings->timeShowEuro, false); AddChild(fClock); fClock->MoveTo(Bounds().right - fClock->Bounds().Width() - 1, 2); @@ -385,7 +375,6 @@ break; case kShowSeconds: - case kMilTime: case kEuroDate: case kFullDate: if (fClock != NULL) Modified: haiku/trunk/src/apps/deskbar/TimeView.cpp =================================================================== --- haiku/trunk/src/apps/deskbar/TimeView.cpp 2010-06-24 04:29:38 UTC (rev 37242) +++ haiku/trunk/src/apps/deskbar/TimeView.cpp 2010-06-24 13:32:59 UTC (rev 37243) @@ -38,8 +38,10 @@ #include <string.h> #include <Catalog.h> +#include <Country.h> #include <Debug.h> #include <Locale.h> +#include <LocaleRoster.h> #include <MenuItem.h> #include <MessageRunner.h> #include <PopUpMenu.h> @@ -72,7 +74,7 @@ #define B_TRANSLATE_CONTEXT "TimeView" 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_", B_FOLLOW_RIGHT | B_FOLLOW_TOP, @@ -80,7 +82,6 @@ fParent(NULL), fShowInterval(true), // ToDo: defaulting this to true until UI is in place fShowSeconds(showSeconds), - fMilTime(milTime), fFullDate(fullDate), fCanShowFullDate(false), fEuroDate(euroDate), @@ -104,7 +105,6 @@ { fTime = fLastTime = time(NULL); data->FindBool("seconds", &fShowSeconds); - data->FindBool("miltime", &fMilTime); data->FindBool("fulldate", &fFullDate); data->FindBool("eurodate", &fEuroDate); data->FindBool("interval", &fInterval); @@ -135,7 +135,6 @@ { BView::Archive(data, deep); data->AddBool("seconds", fShowSeconds); - data->AddBool("miltime", fMilTime); data->AddBool("fulldate", fFullDate); data->AddBool("eurodate", fEuroDate); data->AddBool("interval", fInterval); @@ -220,10 +219,6 @@ ShowSeconds(!ShowingSeconds()); break; - case kMilTime: - ShowMilTime(!ShowingMilTime()); - break; - case kEuroDate: ShowEuroDate(!ShowingEuroDate()); break; @@ -315,28 +310,18 @@ void TTimeView::GetCurrentTime() { - char tmp[64]; + // TODO : should this be another function ? 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; fMinute = time.tm_min; fHour = time.tm_hour; + + + BCountry* here; + be_locale_roster->GetDefaultCountry(&here); + + here->FormatTime(fTimeStr, 64, fTime, fShowSeconds); } @@ -466,14 +451,6 @@ void -TTimeView::ShowMilTime(bool on) -{ - fMilTime = on; - Update(); -} - - -void TTimeView::ShowDate(bool on) { fShowingDate = on; Modified: haiku/trunk/src/apps/deskbar/TimeView.h =================================================================== --- haiku/trunk/src/apps/deskbar/TimeView.h 2010-06-24 04:29:38 UTC (rev 37242) +++ haiku/trunk/src/apps/deskbar/TimeView.h 2010-06-24 13:32:59 UTC (rev 37243) @@ -54,7 +54,7 @@ class TTimeView : public BView { public: 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); TTimeView(BMessage* data); ~TTimeView(); @@ -76,8 +76,6 @@ bool ShowingSeconds() { return fShowSeconds; } void ShowSeconds(bool); - bool ShowingMilTime() { return fMilTime; } - void ShowMilTime(bool); bool ShowingDate() { return fShowingDate; } void ShowDate(bool); bool ShowingFullDate() { return fFullDate; } @@ -120,7 +118,6 @@ bool fShowInterval; bool fShowSeconds; - bool fMilTime; bool fShowingDate; bool fFullDate; bool fCanShowFullDate; Modified: haiku/trunk/src/kits/locale/Country.cpp =================================================================== --- haiku/trunk/src/kits/locale/Country.cpp 2010-06-24 04:29:38 UTC (rev 37242) +++ haiku/trunk/src/kits/locale/Country.cpp 2010-06-24 13:32:59 UTC (rev 37243) @@ -164,7 +164,7 @@ // short, medium, long, and full. Our bool parameter is not enough... icu_4_2::DateFormat* timeFormatter; timeFormatter = DateFormat::createTimeInstance( - longFormat ? DateFormat::FULL : DateFormat::SHORT, + longFormat ? DateFormat::MEDIUM : DateFormat::SHORT, *fICULocale); UnicodeString ICUString; ICUString = timeFormatter->format((UDate)time * 1000, ICUString);