AboutSystem: Style updates

No functional change intended.

Change-Id: I0e5f0160f9caacd0e27161ac2c1450ea4d2f16e1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5510
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: nephele <nep@packageloss.eu>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
John Scipione 2022-07-29 21:40:51 -04:00
parent 652a775f28
commit 81e5700a39

View File

@ -109,6 +109,9 @@ static const char* kRalinkFirmware = B_TRANSLATE_MARK("Ralink WiFi Firmware");
#endif #endif
// #pragma mark - TranslationComparator function
static int static int
TranslationComparator(const void* left, const void* right) TranslationComparator(const void* left, const void* right)
{ {
@ -138,6 +141,9 @@ TranslationComparator(const void* left, const void* right)
} }
// #pragma mark - class definitions
class AboutApp : public BApplication { class AboutApp : public BApplication {
public: public:
AboutApp(); AboutApp();
@ -200,9 +206,8 @@ public:
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void AllAttached(); virtual void AllAttached();
virtual void Pulse(); virtual void Pulse();
virtual void MessageReceived(BMessage* message);
virtual void MessageReceived(BMessage* msg); virtual void MouseDown(BPoint where);
virtual void MouseDown(BPoint point);
void AddCopyrightEntry(const char* name, void AddCopyrightEntry(const char* name,
const char* text, const char* text,
@ -252,16 +257,17 @@ private:
}; };
// #pragma mark - // #pragma mark - AboutApp
AboutApp::AboutApp() AboutApp::AboutApp()
: BApplication("application/x-vnd.Haiku-About") :
BApplication("application/x-vnd.Haiku-About")
{ {
B_TRANSLATE_MARK_SYSTEM_NAME_VOID("AboutSystem"); B_TRANSLATE_MARK_SYSTEM_NAME_VOID("AboutSystem");
AboutWindow *window = new(std::nothrow) AboutWindow(); AboutWindow* window = new(std::nothrow) AboutWindow();
if (window) if (window != NULL)
window->Show(); window->Show();
} }
@ -279,11 +285,12 @@ AboutApp::MessageReceived(BMessage* message)
} }
// #pragma mark - // #pragma mark - AboutWindow
AboutWindow::AboutWindow() AboutWindow::AboutWindow()
: BWindow(BRect(0, 0, 500, 300), B_TRANSLATE("About this system"), :
BWindow(BRect(0, 0, 500, 300), B_TRANSLATE("About this system"),
B_TITLED_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_ZOOMABLE) B_TITLED_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_ZOOMABLE)
{ {
SetLayout(new BGroupLayout(B_VERTICAL)); SetLayout(new BGroupLayout(B_VERTICAL));
@ -311,9 +318,10 @@ AboutWindow::QuitRequested()
LogoView::LogoView() LogoView::LogoView()
: BView("logo", B_WILL_DRAW) :
BView("logo", B_WILL_DRAW),
fLogo(BTranslationUtils::GetBitmap(B_PNG_FORMAT, "logo.png"))
{ {
fLogo = BTranslationUtils::GetBitmap(B_PNG_FORMAT, "logo.png");
SetViewColor(255, 255, 255); SetViewColor(255, 255, 255);
} }
@ -347,10 +355,10 @@ LogoView::MaxSize()
void void
LogoView::Draw(BRect updateRect) LogoView::Draw(BRect updateRect)
{ {
if (fLogo != NULL) { if (fLogo == NULL)
DrawBitmap(fLogo, return;
BPoint((Bounds().Width() - fLogo->Bounds().Width()) / 2, 0));
} DrawBitmap(fLogo, BPoint((Bounds().Width() - fLogo->Bounds().Width()) / 2, 0));
} }
@ -358,8 +366,9 @@ LogoView::Draw(BRect updateRect)
CropView::CropView(BView* target, int32 left, int32 top, int32 right, CropView::CropView(BView* target, int32 left, int32 top, int32 right,
int32 bottom) int32 bottom)
: BView("crop view", 0), :
BView("crop view", 0),
fTarget(target), fTarget(target),
fCropLeft(left), fCropLeft(left),
fCropTop(top), fCropTop(top),
@ -427,7 +436,8 @@ CropView::DoLayout()
#define B_TRANSLATION_CONTEXT "AboutView" #define B_TRANSLATION_CONTEXT "AboutView"
AboutView::AboutView() AboutView::AboutView()
: BView("aboutview", B_WILL_DRAW | B_PULSE_NEEDED), :
BView("aboutview", B_WILL_DRAW | B_PULSE_NEEDED),
fLastActionTime(system_time()), fLastActionTime(system_time()),
fScrollRunner(NULL) fScrollRunner(NULL)
{ {
@ -654,13 +664,13 @@ AboutView::AllAttached()
void void
AboutView::MouseDown(BPoint point) AboutView::MouseDown(BPoint where)
{ {
BRect r(92, 26, 105, 31); BRect rect(92, 26, 105, 31);
if (r.Contains(point)) if (rect.Contains(where))
BMessenger(this).SendMessage('eegg'); BMessenger(this).SendMessage('eegg');
if (Bounds().Contains(point)) { if (Bounds().Contains(where)) {
fLastActionTime = system_time(); fLastActionTime = system_time();
delete fScrollRunner; delete fScrollRunner;
fScrollRunner = NULL; fScrollRunner = NULL;
@ -686,23 +696,23 @@ AboutView::Pulse()
void void
AboutView::MessageReceived(BMessage* msg) AboutView::MessageReceived(BMessage* message)
{ {
switch (msg->what) { switch (message->what) {
case B_COLORS_UPDATED: case B_COLORS_UPDATED:
{ {
if (msg->HasColor(ui_color_name(B_PANEL_TEXT_COLOR))) if (message->HasColor(ui_color_name(B_PANEL_TEXT_COLOR)))
_AdjustTextColors(); _AdjustTextColors();
break; break;
} }
case SCROLL_CREDITS_VIEW: case SCROLL_CREDITS_VIEW:
{ {
BScrollBar* scrollBar = BScrollBar* scrollBar = fCreditsView->ScrollBar(B_VERTICAL);
fCreditsView->ScrollBar(B_VERTICAL);
if (scrollBar == NULL) if (scrollBar == NULL)
break; break;
float max, min; float min;
float max;
scrollBar->GetRange(&min, &max); scrollBar->GetRange(&min, &max);
if (scrollBar->Value() < max) if (scrollBar->Value() < max)
fCreditsView->ScrollBy(0, 1); fCreditsView->ScrollBy(0, 1);
@ -718,7 +728,7 @@ AboutView::MessageReceived(BMessage* msg)
} }
default: default:
BView::MessageReceived(msg); BView::MessageReceived(message);
break; break;
} }
} }
@ -829,8 +839,9 @@ AboutView::PickRandomHaiku()
return; return;
char* buff = (char*)malloc((size_t)st.st_size + 1); char* buff = (char*)malloc((size_t)st.st_size + 1);
if (!buff) if (buff == NULL)
return; return;
buff[(size_t)st.st_size] = '\0'; buff[(size_t)st.st_size] = '\0';
BList haikuList; BList haikuList;
if (fortunes.Read(buff, (size_t)st.st_size) == (ssize_t)st.st_size) { if (fortunes.Read(buff, (size_t)st.st_size) == (ssize_t)st.st_size) {
@ -847,6 +858,7 @@ AboutView::PickRandomHaiku()
} }
} }
free(buff); free(buff);
if (haikuList.CountItems() < 1) if (haikuList.CountItems() < 1)
return; return;
@ -859,9 +871,8 @@ AboutView::PickRandomHaiku()
fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &fTextColor); fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &fTextColor);
fCreditsView->Insert(s->String()); fCreditsView->Insert(s->String());
fCreditsView->Insert("\n"); fCreditsView->Insert("\n");
while ((s = (BString*)haikuList.RemoveItem((int32)0))) { while ((s = (BString*)haikuList.RemoveItem((int32)0)))
delete s; delete s;
}
} }
@ -1075,7 +1086,6 @@ AboutView::_CreateCreditsView()
fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &fHaikuGreenColor); fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &fHaikuGreenColor);
fCreditsView->Insert(B_TRANSLATE("\nCopyrights\n\n")); fCreditsView->Insert(B_TRANSLATE("\nCopyrights\n\n"));
// Haiku license // Haiku license
BString haikuLicense = B_TRANSLATE_COMMENT("The code that is unique to " BString haikuLicense = B_TRANSLATE_COMMENT("The code that is unique to "
"Haiku, especially the kernel and all code that applications may link " "Haiku, especially the kernel and all code that applications may link "
@ -1642,11 +1652,14 @@ UptimeToString(char string[], size_t size)
} }
// #pragma mark - main
int int
main() main()
{ {
AboutApp app; AboutApp app;
app.Run(); app.Run();
return 0; return 0;
} }