* Moved the "Remove View" functionality into the popup menu of the ActivityView
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25025 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f374f0d9f1
commit
3f315b26d2
@ -22,6 +22,7 @@
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include "ActivityMonitor.h"
|
#include "ActivityMonitor.h"
|
||||||
|
#include "ActivityWindow.h"
|
||||||
#include "DataSource.h"
|
#include "DataSource.h"
|
||||||
#include "SystemInfo.h"
|
#include "SystemInfo.h"
|
||||||
#include "SystemInfoHandler.h"
|
#include "SystemInfoHandler.h"
|
||||||
@ -690,6 +691,15 @@ ActivityView::MouseDown(BPoint where)
|
|||||||
menu->SetTargetForItems(this);
|
menu->SetTargetForItems(this);
|
||||||
additionalMenu->SetTargetForItems(this);
|
additionalMenu->SetTargetForItems(this);
|
||||||
|
|
||||||
|
ActivityWindow* window = dynamic_cast<ActivityWindow*>(Window());
|
||||||
|
if (window != NULL && window->ActivityViewCount() > 1) {
|
||||||
|
menu->AddSeparatorItem();
|
||||||
|
BMessage* message = new BMessage(kMsgRemoveView);
|
||||||
|
message->AddPointer("view", this);
|
||||||
|
menu->AddItem(item = new BMenuItem("Remove View", message));
|
||||||
|
item->SetTarget(window);
|
||||||
|
}
|
||||||
|
|
||||||
ConvertToScreen(&where);
|
ConvertToScreen(&where);
|
||||||
menu->Go(where, true, false, true);
|
menu->Go(where, true, false, true);
|
||||||
|
|
||||||
|
@ -24,8 +24,7 @@
|
|||||||
#include "ActivityView.h"
|
#include "ActivityView.h"
|
||||||
|
|
||||||
|
|
||||||
const uint32 kMsgAddView = 'advw';
|
static const uint32 kMsgAddView = 'advw';
|
||||||
const uint32 kMsgRemoveView = 'rmvw';
|
|
||||||
|
|
||||||
|
|
||||||
ActivityWindow::ActivityWindow()
|
ActivityWindow::ActivityWindow()
|
||||||
@ -116,8 +115,6 @@ ActivityWindow::ActivityWindow()
|
|||||||
BMenuItem* item;
|
BMenuItem* item;
|
||||||
|
|
||||||
menu->AddItem(new BMenuItem("Add View", new BMessage(kMsgAddView)));
|
menu->AddItem(new BMenuItem("Add View", new BMessage(kMsgAddView)));
|
||||||
menu->AddItem(fRemoveItem = new BMenuItem("Remove View",
|
|
||||||
new BMessage(kMsgRemoveView)));
|
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
|
|
||||||
menu->AddItem(item = new BMenuItem("About ActivityMonitor" B_UTF8_ELLIPSIS,
|
menu->AddItem(item = new BMenuItem("About ActivityMonitor" B_UTF8_ELLIPSIS,
|
||||||
@ -128,8 +125,6 @@ ActivityWindow::ActivityWindow()
|
|||||||
menu->SetTargetForItems(this);
|
menu->SetTargetForItems(this);
|
||||||
item->SetTarget(be_app);
|
item->SetTarget(be_app);
|
||||||
menuBar->AddItem(menu);
|
menuBar->AddItem(menu);
|
||||||
|
|
||||||
_UpdateRemoveItem();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -205,14 +200,13 @@ ActivityWindow::_SaveSettings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
int32
|
||||||
ActivityWindow::_UpdateRemoveItem()
|
ActivityWindow::ActivityViewCount()
|
||||||
{
|
{
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
BView* view = fLayout->View();
|
return fLayout->View()->CountChildren();
|
||||||
int32 count = view->CountChildren();
|
#else
|
||||||
|
return 1;
|
||||||
fRemoveItem->SetEnabled(count >= 2);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,25 +247,20 @@ ActivityWindow::MessageReceived(BMessage* message)
|
|||||||
if (firstView != NULL)
|
if (firstView != NULL)
|
||||||
ResizeBy(0, firstView->Bounds().Height() + fLayout->Spacing());
|
ResizeBy(0, firstView->Bounds().Height() + fLayout->Spacing());
|
||||||
#endif
|
#endif
|
||||||
_UpdateRemoveItem();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case kMsgRemoveView:
|
case kMsgRemoveView:
|
||||||
{
|
{
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
BView* view = fLayout->View();
|
BView* view;
|
||||||
int32 count = view->CountChildren();
|
if (message->FindPointer("view", (void**)&view) != B_OK)
|
||||||
if (count == 1)
|
break;
|
||||||
return;
|
|
||||||
|
|
||||||
BView* last = view->ChildAt(count - 1);
|
view->RemoveSelf();
|
||||||
fLayout->RemoveView(last);
|
ResizeBy(0, -view->Bounds().Height() - fLayout->Spacing());
|
||||||
ResizeBy(0, -last->Bounds().Height() - fLayout->Spacing());
|
delete view;
|
||||||
delete last;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_UpdateRemoveItem();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,24 +16,27 @@ class ActivityView;
|
|||||||
|
|
||||||
class ActivityWindow : public BWindow {
|
class ActivityWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
ActivityWindow();
|
ActivityWindow();
|
||||||
virtual ~ActivityWindow();
|
virtual ~ActivityWindow();
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
|
int32 ActivityViewCount();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _OpenSettings(BFile& file, uint32 mode);
|
status_t _OpenSettings(BFile& file, uint32 mode);
|
||||||
status_t _LoadSettings(BMessage& settings);
|
status_t _LoadSettings(BMessage& settings);
|
||||||
status_t _SaveSettings();
|
status_t _SaveSettings();
|
||||||
|
|
||||||
void _UpdateRemoveItem();
|
void _UpdateRemoveItem();
|
||||||
void _MessageDropped(BMessage *message);
|
void _MessageDropped(BMessage *message);
|
||||||
|
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
BGroupLayout* fLayout;
|
BGroupLayout* fLayout;
|
||||||
#endif
|
#endif
|
||||||
BMenuItem* fRemoveItem;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const uint32 kMsgRemoveView = 'rmvw';
|
||||||
|
|
||||||
#endif // ACTIVITY_WINDOW_H
|
#endif // ACTIVITY_WINDOW_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user