Completed Team Monitor
Unimplemented : 4 seconds pressing reboot git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9515 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -675,7 +675,6 @@ KeyboardInputDevice::DeviceWatcher(void *arg)
|
|||||||
LOG("TeamMonitor called\n");
|
LOG("TeamMonitor called\n");
|
||||||
|
|
||||||
// show the team monitor
|
// show the team monitor
|
||||||
// argh we don't have one !
|
|
||||||
if (!dev->owner->fTMWindow)
|
if (!dev->owner->fTMWindow)
|
||||||
dev->owner->fTMWindow = new TMWindow();
|
dev->owner->fTMWindow = new TMWindow();
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,8 @@
|
|||||||
TMListItem::TMListItem(team_info &tinfo)
|
TMListItem::TMListItem(team_info &tinfo)
|
||||||
: BListItem(),
|
: BListItem(),
|
||||||
fInfo(tinfo),
|
fInfo(tinfo),
|
||||||
fIcon(BRect(0,0,15,15), B_CMAP8)
|
fIcon(BRect(0,0,15,15), B_CMAP8),
|
||||||
|
fLargeIcon(BRect(0,0,31,31), B_CMAP8)
|
||||||
{
|
{
|
||||||
SetHeight(16 + kITEM_MARGIN);
|
SetHeight(16 + kITEM_MARGIN);
|
||||||
|
|
||||||
@@ -35,6 +36,7 @@ TMListItem::TMListItem(team_info &tinfo)
|
|||||||
BNode node(info.name);
|
BNode node(info.name);
|
||||||
BNodeInfo nodeInfo(&node);
|
BNodeInfo nodeInfo(&node);
|
||||||
nodeInfo.GetTrackerIcon(&fIcon, B_MINI_ICON);
|
nodeInfo.GetTrackerIcon(&fIcon, B_MINI_ICON);
|
||||||
|
nodeInfo.GetTrackerIcon(&fLargeIcon, B_LARGE_ICON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,11 +30,13 @@ public:
|
|||||||
virtual void Update(BView *owner, const BFont *finfo);
|
virtual void Update(BView *owner, const BFont *finfo);
|
||||||
const team_info *GetInfo();
|
const team_info *GetInfo();
|
||||||
|
|
||||||
|
const BBitmap *LargeIcon() { return &fLargeIcon; };
|
||||||
|
const BPath *Path() { return &fPath; };
|
||||||
|
bool IsSystemServer();
|
||||||
bool fFound;
|
bool fFound;
|
||||||
private:
|
private:
|
||||||
bool IsSystemServer();
|
|
||||||
team_info fInfo;
|
team_info fInfo;
|
||||||
BBitmap fIcon;
|
BBitmap fIcon, fLargeIcon;
|
||||||
BPath fPath;
|
BPath fPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ const uint32 TM_FORCE_REBOOT = 'TMfr';
|
|||||||
const uint32 TM_KILL_APPLICATION = 'TMka';
|
const uint32 TM_KILL_APPLICATION = 'TMka';
|
||||||
const uint32 TM_SELECTED_TEAM = 'TMst';
|
const uint32 TM_SELECTED_TEAM = 'TMst';
|
||||||
|
|
||||||
|
extern "C" void _kshutdown_(long arg);
|
||||||
|
#define SHUTDOWN_HALT 0
|
||||||
|
#define SHUTDOWN_REBOOT 1
|
||||||
|
|
||||||
TMWindow::TMWindow()
|
TMWindow::TMWindow()
|
||||||
: BWindow(BRect(0,0,350,300), "Team Monitor",
|
: BWindow(BRect(0,0,350,300), "Team Monitor",
|
||||||
B_TITLED_WINDOW_LOOK, B_MODAL_ALL_WINDOW_FEEL,
|
B_TITLED_WINDOW_LOOK, B_MODAL_ALL_WINDOW_FEEL,
|
||||||
@@ -66,6 +70,12 @@ TMWindow::TMWindow()
|
|||||||
fBackground->AddChild(fKillApp);
|
fBackground->AddChild(fKillApp);
|
||||||
fKillApp->SetEnabled(false);
|
fKillApp->SetEnabled(false);
|
||||||
|
|
||||||
|
rect.top = rect.bottom + 10;
|
||||||
|
rect.bottom = rect.top + 65;
|
||||||
|
rect.right = rect.left + Bounds().right - 10;
|
||||||
|
fDescView = new TMDescView(rect);
|
||||||
|
fBackground->AddChild(fDescView);
|
||||||
|
|
||||||
BRect screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame());
|
BRect screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame());
|
||||||
BPoint pt;
|
BPoint pt;
|
||||||
pt.x = screenFrame.Width()/2 - Bounds().Width()/2;
|
pt.x = screenFrame.Width()/2 - Bounds().Width()/2;
|
||||||
@@ -90,6 +100,9 @@ TMWindow::MessageReceived(BMessage *msg)
|
|||||||
{
|
{
|
||||||
switch(msg->what)
|
switch(msg->what)
|
||||||
{
|
{
|
||||||
|
case TM_FORCE_REBOOT:
|
||||||
|
_kshutdown_(SHUTDOWN_REBOOT);
|
||||||
|
break;
|
||||||
case TM_KILL_APPLICATION: {
|
case TM_KILL_APPLICATION: {
|
||||||
TMListItem *item = (TMListItem*)fBackground->fListView->ItemAt(
|
TMListItem *item = (TMListItem*)fBackground->fListView->ItemAt(
|
||||||
fBackground->fListView->CurrentSelection());
|
fBackground->fListView->CurrentSelection());
|
||||||
@@ -97,8 +110,12 @@ TMWindow::MessageReceived(BMessage *msg)
|
|||||||
fKillApp->SetEnabled(false);
|
fKillApp->SetEnabled(false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TM_SELECTED_TEAM:
|
case TM_SELECTED_TEAM: {
|
||||||
fKillApp->SetEnabled(true);
|
fKillApp->SetEnabled(fBackground->fListView->CurrentSelection() >= 0);
|
||||||
|
TMListItem *item = (TMListItem*)fBackground->fListView->ItemAt(
|
||||||
|
fBackground->fListView->CurrentSelection());
|
||||||
|
fDescView->SetItem(item);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TM_CANCEL:
|
case TM_CANCEL:
|
||||||
Disable();
|
Disable();
|
||||||
@@ -126,14 +143,17 @@ TMWindow::Enable()
|
|||||||
{
|
{
|
||||||
SetPulseRate(1000000);
|
SetPulseRate(1000000);
|
||||||
|
|
||||||
if (IsHidden())
|
if (IsHidden()) {
|
||||||
|
PostMessage(B_PULSE);
|
||||||
Show();
|
Show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TMWindow::Disable()
|
TMWindow::Disable()
|
||||||
{
|
{
|
||||||
|
fBackground->fListView->DeselectAll();
|
||||||
SetPulseRate(0);
|
SetPulseRate(0);
|
||||||
Hide();
|
Hide();
|
||||||
}
|
}
|
||||||
@@ -201,3 +221,66 @@ TMBox::Pulse()
|
|||||||
|
|
||||||
fListView->Invalidate();
|
fListView->Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TMDescView::TMDescView(BRect rect)
|
||||||
|
: BBox(rect, "descview", B_FOLLOW_LEFT|B_FOLLOW_TOP, B_WILL_DRAW, B_NO_BORDER),
|
||||||
|
fItem(NULL)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TMDescView::Draw(BRect rect)
|
||||||
|
{
|
||||||
|
if (fItem) {
|
||||||
|
BRect frame(rect);
|
||||||
|
frame.OffsetBy(2,3);
|
||||||
|
frame.Set(frame.left, frame.top, frame.left+31, frame.top+31);
|
||||||
|
SetDrawingMode(B_OP_OVER);
|
||||||
|
DrawBitmap(fItem->LargeIcon(), frame);
|
||||||
|
SetDrawingMode(B_OP_COPY);
|
||||||
|
|
||||||
|
BFont font = be_plain_font;
|
||||||
|
font_height finfo;
|
||||||
|
font.GetHeight(&finfo);
|
||||||
|
SetFont(&font);
|
||||||
|
MovePenTo(frame.right+9, frame.top - 2 + ((frame.Height() - (finfo.ascent + finfo.descent + finfo.leading)) / 4) +
|
||||||
|
(finfo.ascent + finfo.descent) - 1);
|
||||||
|
DrawString(fItem->Path()->Path());
|
||||||
|
|
||||||
|
if (fItem->IsSystemServer()) {
|
||||||
|
MovePenTo(frame.right+9, frame.top + 1 + ((frame.Height() - (finfo.ascent + finfo.descent + finfo.leading)) *3 / 4) +
|
||||||
|
(finfo.ascent + finfo.descent) - 1);
|
||||||
|
DrawString("(This team is a component of the BeOS");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
BFont font = be_plain_font;
|
||||||
|
font_height finfo;
|
||||||
|
font.GetHeight(&finfo);
|
||||||
|
SetFont(&font);
|
||||||
|
BPoint point(rect.left+4, rect.top - 9 + ((rect.Height() - (finfo.ascent + finfo.descent + finfo.leading)) / 4) +
|
||||||
|
(finfo.ascent + finfo.descent) - 1);
|
||||||
|
MovePenTo(point);
|
||||||
|
DrawString("Select an application from the list above and click the \"Kill\" button in");
|
||||||
|
|
||||||
|
point.y += 13;
|
||||||
|
MovePenTo(point);
|
||||||
|
DrawString("order to close it.");
|
||||||
|
|
||||||
|
point.y += 26;
|
||||||
|
MovePenTo(point);
|
||||||
|
DrawString("Hold CONTROL+ALT+DELETE for 4 seconds to reboot.");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TMDescView::SetItem(TMListItem *item)
|
||||||
|
{
|
||||||
|
fItem = item;
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
#include "InputServerTypes.h"
|
#include "InputServerTypes.h"
|
||||||
|
#include "TMListItem.h"
|
||||||
|
|
||||||
class TMBox : public BBox {
|
class TMBox : public BBox {
|
||||||
public:
|
public:
|
||||||
@@ -33,6 +34,15 @@ public:
|
|||||||
BListView *fListView;
|
BListView *fListView;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TMDescView : public BBox {
|
||||||
|
public:
|
||||||
|
TMDescView(BRect bounds);
|
||||||
|
void Draw(BRect bounds);
|
||||||
|
void SetItem(TMListItem *item);
|
||||||
|
private:
|
||||||
|
TMListItem *fItem;
|
||||||
|
};
|
||||||
|
|
||||||
class TMWindow : public BWindow
|
class TMWindow : public BWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -48,6 +58,7 @@ private:
|
|||||||
|
|
||||||
BButton *fKillApp;
|
BButton *fKillApp;
|
||||||
TMBox *fBackground;
|
TMBox *fBackground;
|
||||||
|
TMDescView *fDescView;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user