Remove the "Full Date" setting and associated madness with respect to

the deskbar's current orientation. Instead, we now always show the full
date, but as a tooltip rather than switching the timeview's display
based on a mouse click.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39019 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent 2010-10-20 09:40:56 +00:00
parent 6f43fabafb
commit 9e9c8091e7
6 changed files with 12 additions and 112 deletions

View File

@ -60,9 +60,6 @@ PreferencesWindow::PreferencesWindow(BRect frame)
fClockSeconds = new BCheckBox(B_TRANSLATE("Show seconds"), fClockSeconds = new BCheckBox(B_TRANSLATE("Show seconds"),
new BMessage(kShowSeconds)); new BMessage(kShowSeconds));
fClockFullDate = new BCheckBox(B_TRANSLATE("Full date"),
new BMessage(kFullDate));
fWindowAlwaysOnTop = new BCheckBox(B_TRANSLATE("Always on top"), fWindowAlwaysOnTop = new BCheckBox(B_TRANSLATE("Always on top"),
new BMessage(kAlwaysTop)); new BMessage(kAlwaysTop));
fWindowAutoRaise = new BCheckBox(B_TRANSLATE("Auto-raise"), fWindowAutoRaise = new BCheckBox(B_TRANSLATE("Auto-raise"),
@ -121,11 +118,9 @@ PreferencesWindow::PreferencesWindow(BRect frame)
TReplicantTray* replicantTray = barApp->BarView()->fReplicantTray; TReplicantTray* replicantTray = barApp->BarView()->fReplicantTray;
fClockSeconds->SetValue(replicantTray->ShowingSeconds()); fClockSeconds->SetValue(replicantTray->ShowingSeconds());
fClockFullDate->SetValue(replicantTray->ShowingFullDate());
bool showingClock = barApp->BarView()->ShowingClock(); bool showingClock = barApp->BarView()->ShowingClock();
fClockSeconds->SetEnabled(showingClock); fClockSeconds->SetEnabled(showingClock);
fClockFullDate->SetEnabled(replicantTray->CanShowFullDate());
fWindowAlwaysOnTop->SetValue(appSettings->alwaysOnTop); fWindowAlwaysOnTop->SetValue(appSettings->alwaysOnTop);
fWindowAutoRaise->SetValue(appSettings->autoRaise); fWindowAutoRaise->SetValue(appSettings->autoRaise);
@ -138,7 +133,6 @@ PreferencesWindow::PreferencesWindow(BRect frame)
fAppsExpandNew->SetTarget(be_app); fAppsExpandNew->SetTarget(be_app);
fClockSeconds->SetTarget(replicantTray); fClockSeconds->SetTarget(replicantTray);
fClockFullDate->SetTarget(replicantTray);
fWindowAlwaysOnTop->SetTarget(be_app); fWindowAlwaysOnTop->SetTarget(be_app);
fWindowAutoRaise->SetTarget(be_app); fWindowAutoRaise->SetTarget(be_app);
@ -194,7 +188,6 @@ PreferencesWindow::PreferencesWindow(BRect frame)
view = BLayoutBuilder::Group<>() view = BLayoutBuilder::Group<>()
.AddGroup(B_VERTICAL, 1) .AddGroup(B_VERTICAL, 1)
.Add(fClockSeconds) .Add(fClockSeconds)
.Add(fClockFullDate)
.AddGlue() .AddGlue()
.SetInsets(10, 10, 10, 10) .SetInsets(10, 10, 10, 10)
.End() .End()

View File

@ -53,7 +53,6 @@ private:
BCheckBox* fAppsExpandNew; BCheckBox* fAppsExpandNew;
BCheckBox* fClockSeconds; BCheckBox* fClockSeconds;
BCheckBox* fClockFullDate;
BCheckBox* fWindowAlwaysOnTop; BCheckBox* fWindowAlwaysOnTop;
BCheckBox* fWindowAutoRaise; BCheckBox* fWindowAutoRaise;

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->timeFullDate = fClock->ShowingFullDate();
} }
} }
@ -213,24 +212,6 @@ TReplicantTray::ShowingSeconds()
} }
bool
TReplicantTray::ShowingFullDate()
{
if (fClock && CanShowFullDate())
return fClock->ShowingFullDate();
return false;
}
bool
TReplicantTray::CanShowFullDate()
{
if (fClock)
return fClock->CanShowFullDate();
return false;
}
void void
TReplicantTray::DealWithClock(bool showClock) TReplicantTray::DealWithClock(bool showClock)
{ {
@ -241,12 +222,11 @@ 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->timeFullDate, settings->timeShowSeconds,
false); false);
AddChild(fClock); AddChild(fClock);
fClock->MoveTo(Bounds().right - fClock->Bounds().Width() - 1, 2); fClock->MoveTo(Bounds().right - fClock->Bounds().Width() - 1, 2);
fClock->AllowFullDate(!IsMultiRow());
} }
} else { } else {
if (fClock) { if (fClock) {
@ -1387,11 +1367,6 @@ void
TReplicantTray::SetMultiRow(bool state) TReplicantTray::SetMultiRow(bool state)
{ {
fMultiRowMode = state; fMultiRowMode = state;
// in multi-row state, we only want the short date
if (fClock != NULL)
fClock->AllowFullDate(!state);
} }

View File

@ -113,8 +113,6 @@ public:
bool ShowingSeconds(void); bool ShowingSeconds(void);
bool ShowingMiltime(void); bool ShowingMiltime(void);
bool ShowingFullDate(void);
bool CanShowFullDate(void);
void RememberClockSettings(); void RememberClockSettings();
void DealWithClock(bool); void DealWithClock(bool);

View File

@ -68,7 +68,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 fullDate, bool) 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,
@ -76,14 +76,11 @@ 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),
fFullDate(fullDate),
fCanShowFullDate(false),
fMaxWidth(maxWidth), fMaxWidth(maxWidth),
fHeight(height), fHeight(height),
fOrientation(true), fOrientation(true),
fLongClickMessageRunner(NULL) fLongClickMessageRunner(NULL)
{ {
fShowingDate = false;
fTime = fLastTime = time(NULL); fTime = fLastTime = time(NULL);
fSeconds = fMinute = fHour = 0; fSeconds = fMinute = fHour = 0;
fLastTimeStr[0] = 0; fLastTimeStr[0] = 0;
@ -100,9 +97,7 @@ TTimeView::TTimeView(BMessage* data)
{ {
fTime = fLastTime = time(NULL); fTime = fLastTime = time(NULL);
data->FindBool("seconds", &fShowSeconds); data->FindBool("seconds", &fShowSeconds);
data->FindBool("fulldate", &fFullDate);
data->FindBool("interval", &fInterval); data->FindBool("interval", &fInterval);
fShowingDate = false;
fLocale = *be_locale; fLocale = *be_locale;
} }
@ -131,7 +126,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("fulldate", fFullDate);
data->AddBool("interval", fInterval); data->AddBool("interval", fInterval);
data->AddInt32("deskbar:private_align", B_ALIGN_RIGHT); data->AddInt32("deskbar:private_align", B_ALIGN_RIGHT);
@ -163,20 +157,13 @@ TTimeView::GetPreferredSize(float* width, float* height)
*height = fHeight; *height = fHeight;
GetCurrentTime(); GetCurrentTime();
GetCurrentDate();
// TODO: SetOrientation never gets called, fix that // TODO: SetOrientation never gets called, fix that
// When in vertical mode, we want to limit the width so that it can't // When in vertical mode, we want to limit the width so that it can't
// overlap the bevels in the parent view. // overlap the bevels in the parent view.
if (ShowingDate()) *width = fOrientation ?
*width = fOrientation ? min_c(fMaxWidth - kHMargin, kHMargin + StringWidth(fTimeStr))
min_c(fMaxWidth - kHMargin, kHMargin + StringWidth(fDateStr)) : kHMargin + StringWidth(fTimeStr);
: kHMargin + StringWidth(fDateStr);
else {
*width = fOrientation ?
min_c(fMaxWidth - kHMargin, kHMargin + StringWidth(fTimeStr))
: kHMargin + StringWidth(fTimeStr);
}
} }
@ -206,10 +193,6 @@ void
TTimeView::MessageReceived(BMessage* message) TTimeView::MessageReceived(BMessage* message)
{ {
switch (message->what) { switch (message->what) {
case kFullDate:
ShowFullDate(!ShowingFullDate());
break;
case kShowSeconds: case kShowSeconds:
ShowSeconds(!ShowingSeconds()); ShowSeconds(!ShowingSeconds());
break; break;
@ -314,7 +297,7 @@ TTimeView::GetCurrentDate()
{ {
char tmp[64]; char tmp[64];
fLocale.FormatDate(tmp, 64, fTime, fFullDate && CanShowFullDate()); fLocale.FormatDate(tmp, 64, fTime, true);
// remove leading 0 from date when month is less than 10 (MM/DD/YY) // 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) // or remove leading 0 from date when day is less than 10 (DD/MM/YY)
@ -336,10 +319,7 @@ TTimeView::Draw(BRect /*updateRect*/)
FillRect(Bounds()); FillRect(Bounds());
SetHighColor(0, 0, 0, 255); SetHighColor(0, 0, 0, 255);
if (fShowingDate) DrawString(fTimeStr, fTimeLocation);
DrawString(fDateStr, fDateLocation);
else
DrawString(fTimeStr, fTimeLocation);
PopState(); PopState();
} }
@ -358,11 +338,6 @@ TTimeView::MouseDown(BPoint point)
StartLongClickNotifier(point); StartLongClickNotifier(point);
} }
// flip to/from showing date or time
fShowingDate = !fShowingDate;
if (fShowingDate)
fLastTime = time(NULL);
// invalidate last time/date strings and call the pulse // invalidate last time/date strings and call the pulse
// method directly to change the display instantly // method directly to change the display instantly
fLastDateStr[0] = '\0'; fLastDateStr[0] = '\0';
@ -390,14 +365,12 @@ TTimeView::Pulse()
GetCurrentTime(); GetCurrentTime();
GetCurrentDate(); GetCurrentDate();
if ((!fShowingDate && strcmp(fTimeStr, fLastTimeStr) != 0) if (strcmp(fTimeStr, fLastTimeStr) != 0) {
|| (fShowingDate && strcmp(fDateStr, fLastDateStr) != 0)) {
// Update bounds when the size of the strings has changed // Update bounds when the size of the strings has changed
// For dates, Update() could be called two times in a row, // For dates, Update() could be called two times in a row,
// but that should only happen very rarely // but that should only happen very rarely
if ((!fShowingDate && fLastTimeStr[1] != fTimeStr[1] if ((fLastTimeStr[1] != fTimeStr[1]
&& (fLastTimeStr[1] == ':' || fTimeStr[1] == ':')) && (fLastTimeStr[1] == ':' || fTimeStr[1] == ':'))
|| (fShowingDate && strlen(fDateStr) != strlen(fLastDateStr))
|| !fLastTimeStr[0]) || !fLastTimeStr[0])
Update(); Update();
@ -406,11 +379,6 @@ TTimeView::Pulse()
fNeedToUpdate = true; fNeedToUpdate = true;
} }
if (fShowingDate && (fLastTime + 5 <= time(NULL))) {
fShowingDate = false;
Update(); // Needs to happen since size can change here
}
if (fNeedToUpdate) { if (fNeedToUpdate) {
fSeconds = ct->tm_sec; fSeconds = ct->tm_sec;
fMinute = ct->tm_min; fMinute = ct->tm_min;
@ -431,32 +399,6 @@ TTimeView::ShowSeconds(bool on)
} }
void
TTimeView::ShowDate(bool on)
{
fShowingDate = on;
Update();
}
void
TTimeView::ShowFullDate(bool on)
{
fFullDate = on;
Update();
}
void
TTimeView::AllowFullDate(bool allow)
{
fCanShowFullDate = allow;
if (allow != ShowingFullDate())
Update();
}
void void
TTimeView::Update() TTimeView::Update()
{ {
@ -464,6 +406,8 @@ TTimeView::Update()
GetCurrentTime(); GetCurrentTime();
GetCurrentDate(); GetCurrentDate();
SetToolTip(fDateStr);
ResizeToPreferred(); ResizeToPreferred();
CalculateTextPlacement(); CalculateTextPlacement();

View File

@ -55,7 +55,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 fullDate = false, bool showInterval = false); bool showInterval = false);
TTimeView(BMessage* data); TTimeView(BMessage* data);
~TTimeView(); ~TTimeView();
@ -76,12 +76,6 @@ class TTimeView : public BView {
bool ShowingSeconds() { return fShowSeconds; } bool ShowingSeconds() { return fShowSeconds; }
void ShowSeconds(bool); void ShowSeconds(bool);
bool ShowingDate() { return fShowingDate; }
void ShowDate(bool);
bool ShowingFullDate() { return fFullDate; }
void ShowFullDate(bool);
bool CanShowFullDate() const { return fCanShowFullDate; }
void AllowFullDate(bool);
void ShowCalendar(BPoint where); void ShowCalendar(BPoint where);
void StartLongClickNotifier(BPoint where); void StartLongClickNotifier(BPoint where);
void StopLongClickNotifier(); void StopLongClickNotifier();
@ -116,9 +110,6 @@ class TTimeView : public BView {
bool fShowInterval; bool fShowInterval;
bool fShowSeconds; bool fShowSeconds;
bool fShowingDate;
bool fFullDate;
bool fCanShowFullDate;
float fMaxWidth; float fMaxWidth;
float fHeight; float fHeight;