From 0c971b1900421d10ba1f998e41a996c6d0a7a2e2 Mon Sep 17 00:00:00 2001
From: Guillermo Bonvehi <gbonvehi@gmail.com>
Date: Fri, 3 Jan 2014 09:01:45 +0000
Subject: [PATCH] Fix #5285 Aesthetic bug in Mail app
---
src/apps/mail/Header.cpp | 72 +++++++++++++++++++++++++++++++++---------------
1 file changed, 50 insertions(+), 22 deletions(-)
diff --git a/src/apps/mail/Header.cpp b/src/apps/mail/Header.cpp
index 485c7e6..96bf850 100644
a
|
b
|
of their respective holders. All rights reserved.
|
52 | 52 | #include <MenuBar.h> |
53 | 53 | #include <MenuField.h> |
54 | 54 | #include <MenuItem.h> |
| 55 | #include <ObjectList.h> |
55 | 56 | #include <PopUpMenu.h> |
56 | 57 | #include <Query.h> |
57 | 58 | #include <String.h> |
… |
… |
THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
|
159 | 160 | BMenuField* field; |
160 | 161 | BMessage* msg; |
161 | 162 | |
162 | | float x = StringWidth( /* The longest title string in the header area */ |
163 | | B_TRANSLATE("Attachments: ")) + 9; |
| 163 | BString kAttachments(B_TRANSLATE("Attachments: ")); |
| 164 | BString kDecoding(B_TRANSLATE("Decoding:")); |
| 165 | BString kFrom(B_TRANSLATE("From:")); |
| 166 | BString kTo(B_TRANSLATE("To:")); |
| 167 | BString kEncoding(B_TRANSLATE("Encoding:")); |
| 168 | BString kAccount(B_TRANSLATE("Account:")); |
| 169 | BString kCc(B_TRANSLATE("Cc:")); |
| 170 | BString kSubject(B_TRANSLATE("Subject:")); |
| 171 | BString kBcc(B_TRANSLATE("Bcc:")); |
| 172 | |
| 173 | BObjectList<BString> kToCompare; |
| 174 | kToCompare.AddItem(&kAttachments); |
| 175 | kToCompare.AddItem(&kDecoding); |
| 176 | kToCompare.AddItem(&kFrom); |
| 177 | kToCompare.AddItem(&kTo); |
| 178 | kToCompare.AddItem(&kEncoding); |
| 179 | kToCompare.AddItem(&kAccount); |
| 180 | kToCompare.AddItem(&kCc); |
| 181 | kToCompare.AddItem(&kSubject); |
| 182 | kToCompare.AddItem(&kBcc); |
| 183 | |
| 184 | float x = 0; |
| 185 | // Get the longest translated string's width to use when calculating |
| 186 | // horizontal positions |
| 187 | for(int i = 0; i < kToCompare.CountItems(); ++i) { |
| 188 | float stringWidth = StringWidth(kToCompare.ItemAt(i)->String()) + 9; |
| 189 | if (stringWidth > x) |
| 190 | x = stringWidth; |
| 191 | } |
164 | 192 | float y = TO_FIELD_V; |
165 | | |
| 193 | |
166 | 194 | BMenuBar* dummy = new BMenuBar(BRect(0, 0, 100, 15), "Dummy"); |
167 | 195 | AddChild(dummy); |
168 | 196 | float width, menuBarHeight; |
… |
… |
THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
|
249 | 277 | if (fIncoming && !resending) { |
250 | 278 | // Set up the character set pop-up menu on the right of "To" box. |
251 | 279 | r.Set (windowRect.Width() - widestCharacterSet - |
252 | | StringWidth (B_TRANSLATE("Decoding:")) - 2 * SEPARATOR_MARGIN, |
| 280 | StringWidth (kDecoding.String()) - 2 * SEPARATOR_MARGIN, |
253 | 281 | y - 2, windowRect.Width() - SEPARATOR_MARGIN, |
254 | 282 | y + menuFieldHeight); |
255 | | field = new BMenuField (r, "decoding", B_TRANSLATE("Decoding:"), |
| 283 | field = new BMenuField (r, "decoding", kDecoding.String(), |
256 | 284 | fEncodingMenu, true /* fixedSize */, |
257 | 285 | B_FOLLOW_TOP | B_FOLLOW_RIGHT, |
258 | 286 | B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); |
259 | | field->SetDivider(field->StringWidth(B_TRANSLATE("Decoding:")) + 5); |
| 287 | field->SetDivider(field->StringWidth(kDecoding.String()) + 5); |
260 | 288 | AddChild(field); |
261 | 289 | r.Set(SEPARATOR_MARGIN, y, |
262 | 290 | field->Frame().left - SEPARATOR_MARGIN, y + menuFieldHeight); |
263 | | sprintf(string, B_TRANSLATE("From:")); |
| 291 | sprintf(string, kFrom.String()); |
264 | 292 | } else { |
265 | 293 | r.Set(x - 12, y, windowRect.Width() - SEPARATOR_MARGIN, |
266 | 294 | y + menuFieldHeight); |
… |
… |
THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
|
288 | 316 | if (!fIncoming || resending) { |
289 | 317 | r.right = r.left - 5; |
290 | 318 | r.left = r.right - ceilf(be_plain_font->StringWidth( |
291 | | B_TRANSLATE("To:")) + 25); |
| 319 | kTo.String()) + 25); |
292 | 320 | r.top -= 1; |
293 | | fToMenu = new QPopupMenu(B_TRANSLATE("To:")); |
| 321 | fToMenu = new QPopupMenu(kTo.String()); |
294 | 322 | field = new BMenuField(r, "", "", fToMenu, true, |
295 | 323 | B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); |
296 | 324 | field->SetDivider(0.0); |
… |
… |
THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
|
302 | 330 | if (!fIncoming || resending) { |
303 | 331 | // Put the character set box on the right of the From field. |
304 | 332 | r.Set(windowRect.Width() - widestCharacterSet - |
305 | | StringWidth(B_TRANSLATE("Encoding:")) - 2 * SEPARATOR_MARGIN, |
| 333 | StringWidth(kEncoding.String()) - 2 * SEPARATOR_MARGIN, |
306 | 334 | y - 2, windowRect.Width() - SEPARATOR_MARGIN, y + menuFieldHeight); |
307 | 335 | BMenuField* encodingField = new BMenuField(r, "encoding", |
308 | | B_TRANSLATE("Encoding:"), fEncodingMenu, true /* fixedSize */, |
| 336 | kEncoding.String(), fEncodingMenu, true /* fixedSize */, |
309 | 337 | B_FOLLOW_TOP | B_FOLLOW_RIGHT, |
310 | 338 | B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); |
311 | 339 | encodingField->SetDivider(encodingField->StringWidth( |
312 | | B_TRANSLATE("Encoding:")) + 5); |
| 340 | kEncoding.String()) + 5); |
313 | 341 | AddChild(encodingField); |
314 | 342 | |
315 | 343 | field = encodingField; |
… |
… |
THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
|
359 | 387 | |
360 | 388 | r.Set(SEPARATOR_MARGIN, y - 2, |
361 | 389 | field->Frame().left - SEPARATOR_MARGIN, y + menuFieldHeight); |
362 | | field = new BMenuField(r, "account", B_TRANSLATE("From:"), |
| 390 | field = new BMenuField(r, "account", kFrom.String(), |
363 | 391 | fAccountMenu, true /* fixedSize */, |
364 | 392 | B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT, |
365 | 393 | B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); |
… |
… |
THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
|
375 | 403 | windowRect.Width() - SEPARATOR_MARGIN, y + menuFieldHeight); |
376 | 404 | if (account) |
377 | 405 | r.right -= SEPARATOR_MARGIN + ACCOUNT_FIELD_WIDTH; |
378 | | fAccountTo = new TTextControl(r, B_TRANSLATE("To:"), NULL, fIncoming, |
| 406 | fAccountTo = new TTextControl(r, kTo.String(), NULL, fIncoming, |
379 | 407 | false, B_FOLLOW_LEFT_RIGHT); |
380 | 408 | fAccountTo->SetEnabled(false); |
381 | 409 | fAccountTo->SetDivider(x - 12 - SEPARATOR_MARGIN); |
… |
… |
THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
|
384 | 412 | |
385 | 413 | if (account) { |
386 | 414 | r.left = r.right + 6; r.right = windowRect.Width() - SEPARATOR_MARGIN; |
387 | | fAccount = new TTextControl(r, B_TRANSLATE("Account:"), NULL, |
| 415 | fAccount = new TTextControl(r, kAccount.String(), NULL, |
388 | 416 | fIncoming, false, B_FOLLOW_RIGHT | B_FOLLOW_TOP); |
389 | 417 | fAccount->SetEnabled(false); |
390 | 418 | AddChild(fAccount); |
… |
… |
THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
|
397 | 425 | r.Set(SEPARATOR_MARGIN, y, |
398 | 426 | windowRect.Width() - SEPARATOR_MARGIN, y + menuFieldHeight); |
399 | 427 | y += controlHeight; |
400 | | fCc = new TTextControl(r, B_TRANSLATE("Cc:"), |
| 428 | fCc = new TTextControl(r, kCc.String(), |
401 | 429 | NULL, fIncoming, false, B_FOLLOW_LEFT_RIGHT); |
402 | 430 | fCc->SetEnabled(false); |
403 | 431 | fCc->SetDivider(x - 12 - SEPARATOR_MARGIN); |
… |
… |
THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
|
409 | 437 | r.Set(SEPARATOR_MARGIN, y, |
410 | 438 | windowRect.Width() - SEPARATOR_MARGIN, y + menuFieldHeight); |
411 | 439 | y += controlHeight; |
412 | | fSubject = new TTextControl(r, B_TRANSLATE("Subject:"), |
| 440 | fSubject = new TTextControl(r, kSubject.String(), |
413 | 441 | new BMessage(SUBJECT_FIELD),fIncoming, false, B_FOLLOW_LEFT_RIGHT); |
414 | 442 | AddChild(fSubject); |
415 | 443 | (msg = new BMessage(FIELD_CHANGED))->AddInt32("bitmask", FIELD_SUBJECT); |
… |
… |
THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
|
433 | 461 | |
434 | 462 | r.right = r.left - 5; |
435 | 463 | r.left = r.right - ceilf(be_plain_font->StringWidth( |
436 | | B_TRANSLATE("Cc:")) + 25); |
| 464 | kCc.String()) + 25); |
437 | 465 | r.top -= 1; |
438 | | fCcMenu = new QPopupMenu(B_TRANSLATE("Cc:")); |
| 466 | fCcMenu = new QPopupMenu(kCc.String()); |
439 | 467 | field = new BMenuField(r, "", "", fCcMenu, true, |
440 | 468 | B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); |
441 | 469 | |
… |
… |
THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
|
443 | 471 | field->SetEnabled(true); |
444 | 472 | AddChild(field); |
445 | 473 | |
446 | | r.Set(BCC_FIELD_H + be_plain_font->StringWidth(B_TRANSLATE("Bcc:")), y, |
| 474 | r.Set(BCC_FIELD_H + be_plain_font->StringWidth(kBcc.String()), y, |
447 | 475 | windowRect.Width() - SEPARATOR_MARGIN, y + menuFieldHeight); |
448 | 476 | y += controlHeight; |
449 | 477 | fBcc = new TTextControl(r, "", new BMessage(BCC_FIELD), |
… |
… |
THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
|
457 | 485 | |
458 | 486 | r.right = r.left - 5; |
459 | 487 | r.left = r.right - ceilf(be_plain_font->StringWidth( |
460 | | B_TRANSLATE("Bcc:")) + 25); |
| 488 | kBcc.String()) + 25); |
461 | 489 | r.top -= 1; |
462 | | fBccMenu = new QPopupMenu(B_TRANSLATE("Bcc:")); |
| 490 | fBccMenu = new QPopupMenu(kBcc.String()); |
463 | 491 | field = new BMenuField(r, "", "", fBccMenu, true, |
464 | 492 | B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); |
465 | 493 | field->SetDivider(0.0); |