Teammonitor: Add 'Open Terminal' button

* Add a button to open a Terminal to the left of the Cancel button.
  The ALT+OPT+T combo is a bit hidden, as mentioned in #16243.

* After opening a Terminal, close the Team Monitor. Being a modal
  window, the user would have to close it manually anyway to be able
  to use the Terminal.

* Remove the unneeded instructions how to use the Quit and Kill buttons.
  Now we can use a simple BStringView and avoid most of the font style
  complications.

* Put some weight on the scroll view, so it's the only view getting
  taller when vertically resize the window.

Change-Id: I4a58033c0ce9b36a0e714f9bdd5c5542bca30849
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2906
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Humdinger 2020-06-12 07:54:35 +02:00 committed by waddlesplash
parent bbc0611099
commit f29b420144

View File

@ -1,5 +1,5 @@
/*
* Copyright 2004-2008, Haiku.
* Copyright 2004-2020, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -27,8 +27,8 @@
#include <Screen.h>
#include <SpaceLayoutItem.h>
#include <String.h>
#include <StringFormat.h>
#include <StringView.h>
#include <TextView.h>
#include <syscalls.h>
#include <tracker_private.h>
@ -125,9 +125,8 @@ private:
int32 fSeconds;
BMessageRunner* fRebootRunner;
IconView* fIconView;
const char* fInfoString;
BCardLayout* fLayout;
BTextView* fInfoTextView;
BStringView* fInfoTextView;
BStringView* fTeamName;
BStringView* fSysComponent;
@ -188,12 +187,15 @@ TeamMonitorWindow::TeamMonitorWindow()
fRestartButton = new BButton("restart", B_TRANSLATE("Restart the desktop"),
new BMessage(TM_RESTART_DESKTOP));
BButton* openTerminal = new BButton("terminal",
B_TRANSLATE("Open Terminal"), new BMessage(kMsgLaunchTerminal));
fCancelButton = new BButton("cancel", B_TRANSLATE("Cancel"),
new BMessage(TM_CANCEL));
SetDefaultButton(fCancelButton);
BGroupLayoutBuilder(layout)
.Add(scrollView)
.Add(scrollView, 10)
.AddGroup(B_HORIZONTAL)
.SetInsets(0, 0, 0, 0)
.Add(fKillButton)
@ -207,6 +209,7 @@ TeamMonitorWindow::TeamMonitorWindow()
.AddGlue()
.Add(fRestartButton)
.AddGlue(inset)
.Add(openTerminal)
.Add(fCancelButton);
CenterOnScreen();
@ -273,6 +276,7 @@ TeamMonitorWindow::MessageReceived(BMessage* msg)
case kMsgLaunchTerminal:
be_roster->Launch("application/x-vnd.Haiku-Terminal");
PostMessage(B_QUIT_REQUESTED);
break;
case TM_FORCE_REBOOT:
@ -576,12 +580,6 @@ TeamDescriptionView::TeamDescriptionView()
fSeconds(4),
fRebootRunner(NULL)
{
fInfoString = B_TRANSLATE(
"Select an application from the list above and click one of "
"the buttons 'Kill application' and 'Quit application' "
"in order to close it.\n\n"
"Hold CONTROL+ALT+DELETE for %ld seconds to reboot.");
fTeamName = new BStringView("team name", "team name");
fTeamName->SetTruncation(B_TRUNCATE_BEGINNING);
fTeamName->SetExplicitSize(BSize(StringWidth("x") * 60, B_SIZE_UNSET));
@ -591,13 +589,9 @@ TeamDescriptionView::TeamDescriptionView()
"If the application will not quit you may have to kill it."));
fQuitOverdue->SetFont(be_bold_font);
fInfoTextView = new BTextView("info text");
fInfoTextView = new BStringView("info text", "");
fInfoTextView->SetLowUIColor(B_PANEL_BACKGROUND_COLOR);
fInfoTextView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
BGroupView* infoGroup = new BGroupView(B_VERTICAL);
BGroupLayoutBuilder(infoGroup)
.Add(fInfoTextView)
.AddGlue();
fIconView = new IconView();
fIconView->SetExplicitAlignment(
@ -608,7 +602,6 @@ TeamDescriptionView::TeamDescriptionView()
BGridLayout* layout = new BGridLayout();
teamPropertiesView->SetLayout(layout);
BLayoutBuilder::Grid<>(layout)
.SetInsets(0)
.SetSpacing(B_USE_ITEM_SPACING, 0)
@ -623,14 +616,9 @@ TeamDescriptionView::TeamDescriptionView()
fLayout = new BCardLayout();
SetLayout(fLayout);
fLayout->AddView(infoGroup);
fLayout->AddView(fInfoTextView);
fLayout->AddView(teamPropertiesView);
infoGroup->SetExplicitMinSize(BSize(StringWidth("x") * 70, B_SIZE_UNSET));
fInfoTextView->SetExplicitSize(BSize(B_SIZE_UNSET, be_plain_font->Size() * 7.2));
fInfoTextView->MakeEditable(false);
fInfoTextView->MakeSelectable(false);
SetItem(NULL);
}
@ -686,24 +674,21 @@ TeamDescriptionView::SetItem(TeamListItem* item)
if (item == NULL) {
if (fInfoTextView != NULL) {
int32 styleStart = 0;
int32 styleEnd = 0;
BString text;
BFont font;
fInfoTextView->GetFont(&font);
font.SetFace(B_REGULAR_FACE);
text.SetToFormat(fInfoString, fSeconds);
fInfoTextView->SetText(text);
if (fRebootRunner != NULL && fSeconds < 4) {
styleStart = text.FindLast('\n');
styleEnd = text.Length();
}
if (styleStart != styleEnd) {
BFont font;
fInfoTextView->GetFont(&font);
if (fRebootRunner != NULL && fSeconds < 4)
font.SetFace(B_BOLD_FACE);
fInfoTextView->SetStylable(true);
fInfoTextView->SetFontAndColor(styleStart, styleEnd, &font);
}
fInfoTextView->SetFont(&font);
static BStringFormat format(B_TRANSLATE("{0, plural,"
"one{Hold CONTROL+ALT+DELETE for # second to reboot.}"
"other{Hold CONTROL+ALT+DELETE for # seconds to reboot.}}"));
BString text;
format.Format(text, fSeconds);
fInfoTextView->SetText(text);
}
} else {
fTeamName->SetText(item->Path()->Path());