* 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 "ActivityMonitor.h"
|
||||
#include "ActivityWindow.h"
|
||||
#include "DataSource.h"
|
||||
#include "SystemInfo.h"
|
||||
#include "SystemInfoHandler.h"
|
||||
@ -690,6 +691,15 @@ ActivityView::MouseDown(BPoint where)
|
||||
menu->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);
|
||||
menu->Go(where, true, false, true);
|
||||
|
||||
|
@ -24,8 +24,7 @@
|
||||
#include "ActivityView.h"
|
||||
|
||||
|
||||
const uint32 kMsgAddView = 'advw';
|
||||
const uint32 kMsgRemoveView = 'rmvw';
|
||||
static const uint32 kMsgAddView = 'advw';
|
||||
|
||||
|
||||
ActivityWindow::ActivityWindow()
|
||||
@ -116,8 +115,6 @@ ActivityWindow::ActivityWindow()
|
||||
BMenuItem* item;
|
||||
|
||||
menu->AddItem(new BMenuItem("Add View", new BMessage(kMsgAddView)));
|
||||
menu->AddItem(fRemoveItem = new BMenuItem("Remove View",
|
||||
new BMessage(kMsgRemoveView)));
|
||||
menu->AddSeparatorItem();
|
||||
|
||||
menu->AddItem(item = new BMenuItem("About ActivityMonitor" B_UTF8_ELLIPSIS,
|
||||
@ -128,8 +125,6 @@ ActivityWindow::ActivityWindow()
|
||||
menu->SetTargetForItems(this);
|
||||
item->SetTarget(be_app);
|
||||
menuBar->AddItem(menu);
|
||||
|
||||
_UpdateRemoveItem();
|
||||
}
|
||||
|
||||
|
||||
@ -205,14 +200,13 @@ ActivityWindow::_SaveSettings()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ActivityWindow::_UpdateRemoveItem()
|
||||
int32
|
||||
ActivityWindow::ActivityViewCount()
|
||||
{
|
||||
#ifdef __HAIKU__
|
||||
BView* view = fLayout->View();
|
||||
int32 count = view->CountChildren();
|
||||
|
||||
fRemoveItem->SetEnabled(count >= 2);
|
||||
return fLayout->View()->CountChildren();
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -253,25 +247,20 @@ ActivityWindow::MessageReceived(BMessage* message)
|
||||
if (firstView != NULL)
|
||||
ResizeBy(0, firstView->Bounds().Height() + fLayout->Spacing());
|
||||
#endif
|
||||
_UpdateRemoveItem();
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgRemoveView:
|
||||
{
|
||||
#ifdef __HAIKU__
|
||||
BView* view = fLayout->View();
|
||||
int32 count = view->CountChildren();
|
||||
if (count == 1)
|
||||
return;
|
||||
BView* view;
|
||||
if (message->FindPointer("view", (void**)&view) != B_OK)
|
||||
break;
|
||||
|
||||
BView* last = view->ChildAt(count - 1);
|
||||
fLayout->RemoveView(last);
|
||||
ResizeBy(0, -last->Bounds().Height() - fLayout->Spacing());
|
||||
delete last;
|
||||
view->RemoveSelf();
|
||||
ResizeBy(0, -view->Bounds().Height() - fLayout->Spacing());
|
||||
delete view;
|
||||
#endif
|
||||
|
||||
_UpdateRemoveItem();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -16,24 +16,27 @@ class ActivityView;
|
||||
|
||||
class ActivityWindow : public BWindow {
|
||||
public:
|
||||
ActivityWindow();
|
||||
virtual ~ActivityWindow();
|
||||
ActivityWindow();
|
||||
virtual ~ActivityWindow();
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual bool QuitRequested();
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual bool QuitRequested();
|
||||
|
||||
int32 ActivityViewCount();
|
||||
|
||||
private:
|
||||
status_t _OpenSettings(BFile& file, uint32 mode);
|
||||
status_t _LoadSettings(BMessage& settings);
|
||||
status_t _SaveSettings();
|
||||
status_t _OpenSettings(BFile& file, uint32 mode);
|
||||
status_t _LoadSettings(BMessage& settings);
|
||||
status_t _SaveSettings();
|
||||
|
||||
void _UpdateRemoveItem();
|
||||
void _MessageDropped(BMessage *message);
|
||||
void _UpdateRemoveItem();
|
||||
void _MessageDropped(BMessage *message);
|
||||
|
||||
#ifdef __HAIKU__
|
||||
BGroupLayout* fLayout;
|
||||
#endif
|
||||
BMenuItem* fRemoveItem;
|
||||
};
|
||||
|
||||
static const uint32 kMsgRemoveView = 'rmvw';
|
||||
|
||||
#endif // ACTIVITY_WINDOW_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user