AboutView::AboutView() : BView("aboutview", B_WILL_DRAW | B_PULSE_NEEDED), fLastActionTime(system_time()), fScrollRunner(NULL) { // Begin Construction of System Information controls system_info systemInfo; get_system_info(&systemInfo); // Create all the various labels for system infomation // OS Version char string[1024]; strcpy(string, B_TRANSLATE("Unknown")); // the version is stored in the BEOS:APP_VERSION attribute of libbe.so BPath path; if (find_directory(B_BEOS_LIB_DIRECTORY, &path) == B_OK) { path.Append("libbe.so"); BAppFileInfo appFileInfo; version_info versionInfo; BFile file; if (file.SetTo(path.Path(), B_READ_ONLY) == B_OK && appFileInfo.SetTo(&file) == B_OK && appFileInfo.GetVersionInfo(&versionInfo, B_APP_VERSION_KIND) == B_OK && versionInfo.short_info[0] != '\0') strcpy(string, versionInfo.short_info); } // Add revision from uname() info utsname unameInfo; if (uname(&unameInfo) == 0) { long revision; if (sscanf(unameInfo.version, "r%ld", &revision) == 1) { char version[16]; snprintf(version, sizeof(version), "%ld", revision); strlcat(string, " (", sizeof(string)); strlcat(string, B_TRANSLATE("Revision"), sizeof(string)); strlcat(string, " ", sizeof(string)); strlcat(string, version, sizeof(string)); strlcat(string, ")", sizeof(string)); } } BStringView* versionView = new BStringView("ostext", string); versionView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); // GCC version BEntry gccFourHybrid("/boot/system/lib/gcc2/libstdc++.r4.so"); BEntry gccTwoHybrid("/boot/system/lib/gcc4/libsupc++.so"); if (gccFourHybrid.Exists() || gccTwoHybrid.Exists()) snprintf(string, sizeof(string), B_TRANSLATE("GCC %d Hybrid"), __GNUC__); else snprintf(string, sizeof(string), "GCC %d", __GNUC__); BStringView* gccView = new BStringView("gcctext", string); gccView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); // CPU count, type and clock speed char processorLabel[256]; if (systemInfo.cpu_count > 1) { snprintf(processorLabel, sizeof(processorLabel), B_TRANSLATE("%ld Processors:"), systemInfo.cpu_count); } else strlcpy(processorLabel, B_TRANSLATE("Processor:"), sizeof(processorLabel)); BString cpuType; cpuType << get_cpu_vendor_string(systemInfo.cpu_type) << " " << get_cpu_model_string(&systemInfo); BStringView* cpuView = new BStringView("cputext", cpuType.String()); cpuView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); int32 clockSpeed = get_rounded_cpu_speed(); if (clockSpeed < 1000) sprintf(string, B_TRANSLATE("%ld MHz"), clockSpeed); else sprintf(string, B_TRANSLATE("%.2f GHz"), clockSpeed / 1000.0f); BStringView* frequencyView = new BStringView("frequencytext", string); frequencyView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); // RAM BStringView *memSizeView = new BStringView("ramsizetext", MemSizeToString(string, sizeof(string), &systemInfo)); memSizeView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); fMemView = new BStringView("ramtext", MemUsageToString(string, sizeof(string), &systemInfo)); fMemView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); // Kernel build time/date snprintf(string, sizeof(string), "%s %s", systemInfo.kernel_build_date, systemInfo.kernel_build_time); BStringView* kernelView = new BStringView("kerneltext", string); kernelView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); // Uptime fUptimeView = new BTextView("uptimetext"); fUptimeView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fUptimeView->MakeEditable(false); fUptimeView->MakeSelectable(false); fUptimeView->SetWordWrap(true); fUptimeView->SetText(UptimeToString(string, sizeof(string))); const float offset = 5; SetLayout(new BGroupLayout(B_HORIZONTAL)); BLayoutBuilder::Group<>((BGroupLayout*)GetLayout()) .AddGroup(B_VERTICAL) .Add(new LogoView()) .AddGroup(B_VERTICAL) .Add(_CreateLabel("oslabel", B_TRANSLATE("Version:"))) .Add(versionView) .Add(gccView) .AddStrut(offset) .Add(_CreateLabel("cpulabel", processorLabel)) .Add(cpuView) .Add(frequencyView) .AddStrut(offset) .Add(_CreateLabel("memlabel", B_TRANSLATE("Memory:"))) .Add(memSizeView) .Add(fMemView) .AddStrut(offset) .Add(_CreateLabel("kernellabel", B_TRANSLATE("Kernel:"))) .Add(kernelView) .AddStrut(offset) .Add(_CreateLabel("uptimelabel", B_TRANSLATE("Time running:"))) .Add(fUptimeView) .SetInsets(5, 5, 5, 5) .End() // TODO: investigate: adding this causes the time to be cut //.AddGlue() .End() .Add(_CreateCreditsView()); float min = fMemView->MinSize().width * 1.1f; fCreditsView->SetExplicitMinSize(BSize(min, min)); }
InfoWin::InfoWin(BPoint leftTop, Controller* controller) : BWindow(BRect(leftTop.x, leftTop.y, leftTop.x + MIN_WIDTH - 1, leftTop.y + 300), B_TRANSLATE("File info"), B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_ZOOMABLE), fController(controller), fControllerObserver(new ControllerObserver(this, OBSERVE_FILE_CHANGES | OBSERVE_TRACK_CHANGES | OBSERVE_STAT_CHANGES)) { fIconView = new IconView("background", B_LARGE_ICON); fFilenameView = _CreateInfo("filename"); BFont bigFont(be_plain_font); bigFont.SetSize(bigFont.Size() * 1.5f); fFilenameView->SetFont(&bigFont); // Create info views BStringView* containerLabel = _CreateLabel("containerLabel", B_TRANSLATE("Container")); fContainerInfo = _CreateInfo("container"); fVideoSeparator = _CreateSeparator(); fVideoLabel = _CreateLabel("videoLabel", B_TRANSLATE("Video")); fVideoFormatInfo = _CreateInfo("videoFormat"); fVideoConfigInfo = _CreateInfo("videoConfig"); fDisplayModeLabel = _CreateLabel("displayModeLabel", B_TRANSLATE("Display mode")); fDisplayModeInfo = _CreateInfo("displayMode"); fAudioSeparator = _CreateSeparator(); fAudioLabel = _CreateLabel("audioLabel", B_TRANSLATE("Audio")); fAudioFormatInfo = _CreateInfo("audioFormat"); fAudioConfigInfo = _CreateInfo("audioConfig"); BStringView* durationLabel = _CreateLabel("durationLabel", B_TRANSLATE("Duration")); fDurationInfo = _CreateInfo("duration"); BStringView* locationLabel = _CreateLabel("locationLabel", B_TRANSLATE("Location")); fLocationInfo = _CreateInfo("location"); fCopyrightSeparator = _CreateSeparator(); fCopyrightLabel = _CreateLabel("copyrightLabel", B_TRANSLATE("Copyright")); fCopyrightInfo = _CreateInfo("copyright"); BLayoutBuilder::Group<>(this, B_VERTICAL) .SetInsets(B_USE_DEFAULT_SPACING) .AddGroup(B_HORIZONTAL) .Add(fIconView, 0) .Add(fFilenameView, 1) .End() .AddGrid(2, 13) .Add(containerLabel, 0, 0) .Add(fContainerInfo, 1, 0) .Add(fVideoSeparator, 0, 1) .Add(fVideoLabel, 0, 2) .Add(fVideoFormatInfo, 1, 2) .Add(fVideoConfigInfo, 1, 3) .Add(fDisplayModeLabel, 0, 4) .Add(fDisplayModeInfo, 1, 4) .Add(fAudioSeparator, 0, 5) .Add(fAudioLabel, 0, 6) .Add(fAudioFormatInfo, 1, 6) .Add(fAudioConfigInfo, 1, 7) .Add(_CreateSeparator(), 0, 8) .Add(durationLabel, 0, 9) .Add(fDurationInfo, 1, 9) .Add(_CreateSeparator(), 0, 10) .Add(locationLabel, 0, 11) .Add(fLocationInfo, 1, 11) .Add(fCopyrightSeparator, 0, 12) .Add(fCopyrightLabel, 0, 12) .Add(fCopyrightInfo, 1, 12) .SetColumnWeight(0, 0) .SetColumnWeight(1, 1) .SetSpacing(B_USE_DEFAULT_SPACING, 0) .SetExplicitMinSize(BSize(MIN_WIDTH, B_SIZE_UNSET)); fController->AddListener(fControllerObserver); Update(); UpdateSizeLimits(); // Move window on screen if needed BScreen screen(this); if (screen.Frame().bottom < Frame().bottom) MoveBy(0, screen.Frame().bottom - Frame().bottom); if (screen.Frame().right < Frame().right) MoveBy(0, screen.Frame().right - Frame().right); Show(); }