Save and restore the inspector window's frame + mode settings.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43155 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
548716773f
commit
787740e0f9
@ -19,6 +19,7 @@
|
||||
#include <ExpressionParser.h>
|
||||
|
||||
#include "Architecture.h"
|
||||
#include "GUITeamUISettings.h"
|
||||
#include "MemoryView.h"
|
||||
#include "MessageCodes.h"
|
||||
#include "Team.h"
|
||||
@ -265,7 +266,10 @@ InspectorWindow::MessageReceived(BMessage* msg)
|
||||
bool
|
||||
InspectorWindow::QuitRequested()
|
||||
{
|
||||
BMessenger(fTarget).SendMessage(MSG_INSPECTOR_WINDOW_CLOSED);
|
||||
BMessage settings(MSG_INSPECTOR_WINDOW_CLOSED);
|
||||
SaveSettings(&settings);
|
||||
|
||||
BMessenger(fTarget).SendMessage(&settings);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -281,3 +285,81 @@ InspectorWindow::MemoryBlockRetrieved(TeamMemoryBlock* block)
|
||||
fNextBlockButton->SetEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
InspectorWindow::LoadSettings(const GUITeamUISettings* settings)
|
||||
{
|
||||
BVariant value;
|
||||
if (settings->Value("inspectorWindowFrame", value) == B_OK) {
|
||||
BRect frameRect = value.ToRect();
|
||||
ResizeTo(frameRect.Width(), frameRect.Height());
|
||||
MoveTo(frameRect.left, frameRect.top);
|
||||
}
|
||||
|
||||
_LoadMenuFieldMode(fHexMode, "Hex", settings);
|
||||
_LoadMenuFieldMode(fEndianMode, "Endian", settings);
|
||||
_LoadMenuFieldMode(fTextMode, "Text", settings);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
InspectorWindow::SaveSettings(BMessage* settings)
|
||||
{
|
||||
status_t error = settings->AddRect("inspectorWindowFrame", Frame());
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
error = _SaveMenuFieldMode(fHexMode, "Hex", settings);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
error = _SaveMenuFieldMode(fEndianMode, "Endian", settings);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
error = _SaveMenuFieldMode(fTextMode, "Text", settings);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InspectorWindow::_LoadMenuFieldMode(BMenuField* field, const char* name,
|
||||
const GUITeamUISettings* settings)
|
||||
{
|
||||
BVariant value;
|
||||
BString fieldName;
|
||||
fieldName.SetToFormat("inspectorWindow%sMode", name);
|
||||
status_t error = settings->Value(fieldName.String(), value);
|
||||
if (error == B_OK) {
|
||||
BMenu* menu = field->Menu();
|
||||
for (int32 i = 0; i < menu->CountItems(); i++) {
|
||||
BInvoker* item = menu->ItemAt(i);
|
||||
if (item->Message()->FindInt32("mode") == value.ToInt32()) {
|
||||
item->Invoke();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
InspectorWindow::_SaveMenuFieldMode(BMenuField* field, const char* name,
|
||||
BMessage* settings)
|
||||
{
|
||||
BMenuItem* item = field->Menu()->FindMarked();
|
||||
if (item && item->Message()) {
|
||||
int32 mode = item->Message()->FindInt32("mode");
|
||||
BString fieldName;
|
||||
fieldName.SetToFormat("inspectorWindow%sMode", name);
|
||||
return settings->AddInt32(fieldName.String(), mode);
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ class BButton;
|
||||
class BMenuField;
|
||||
class BMessenger;
|
||||
class BTextControl;
|
||||
class GUITeamUISettings;
|
||||
class MemoryView;
|
||||
class Team;
|
||||
class UserInterfaceListener;
|
||||
@ -39,9 +40,20 @@ public:
|
||||
|
||||
virtual void MemoryBlockRetrieved(TeamMemoryBlock* block);
|
||||
|
||||
status_t LoadSettings(
|
||||
const GUITeamUISettings* settings);
|
||||
status_t SaveSettings(
|
||||
BMessage* settings);
|
||||
private:
|
||||
void _Init();
|
||||
|
||||
void _LoadMenuFieldMode(BMenuField* field,
|
||||
const char* name,
|
||||
const GUITeamUISettings* settings);
|
||||
status_t _SaveMenuFieldMode(BMenuField* field,
|
||||
const char* name,
|
||||
BMessage* settings);
|
||||
|
||||
private:
|
||||
UserInterfaceListener* fListener;
|
||||
BTextControl* fAddressInput;
|
||||
|
@ -219,8 +219,10 @@ TeamWindow::MessageReceived(BMessage* message)
|
||||
try {
|
||||
fInspectorWindow = InspectorWindow::Create(fTeam, fListener,
|
||||
this);
|
||||
if (fInspectorWindow != NULL)
|
||||
if (fInspectorWindow != NULL) {
|
||||
fInspectorWindow->LoadSettings(&fUISettings);
|
||||
fInspectorWindow->Show();
|
||||
}
|
||||
} catch (...) {
|
||||
// TODO: notify user
|
||||
}
|
||||
@ -228,7 +230,9 @@ TeamWindow::MessageReceived(BMessage* message)
|
||||
}
|
||||
case MSG_INSPECTOR_WINDOW_CLOSED:
|
||||
{
|
||||
_SaveInspectorSettings(CurrentMessage());
|
||||
fInspectorWindow = NULL;
|
||||
|
||||
}
|
||||
case B_REFS_RECEIVED:
|
||||
{
|
||||
@ -351,6 +355,8 @@ TeamWindow::LoadSettings(const GUITeamUISettings* settings)
|
||||
_LoadSplitSettings(fImageSplitView, "Image", settings);
|
||||
_LoadSplitSettings(fThreadSplitView, "Thread", settings);
|
||||
|
||||
fUISettings = *settings;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@ -358,6 +364,23 @@ TeamWindow::LoadSettings(const GUITeamUISettings* settings)
|
||||
status_t
|
||||
TeamWindow::SaveSettings(GUITeamUISettings* settings)
|
||||
{
|
||||
// save the settings from the cached copy first,
|
||||
// then overwrite them with our most current set
|
||||
// this is necessary in order to preserve the settings
|
||||
// of things like the inspector in case we haven't actually
|
||||
// invoked them at all in this session
|
||||
const BMessage& values = fUISettings.Values();
|
||||
char *name;
|
||||
type_code type;
|
||||
BVariant value;
|
||||
for (int32 i = 0; values.GetInfo(B_ANY_TYPE, i, &name, &type) == B_OK;
|
||||
i++) {
|
||||
if (value.SetFromMessage(values, name) == B_OK) {
|
||||
if (!settings->SetValue(name, value))
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
if (!settings->SetValue("teamWindowFrame", Frame()))
|
||||
return B_NO_MEMORY;
|
||||
|
||||
@ -1163,3 +1186,22 @@ TeamWindow::_SaveSplitSettings(BSplitView* view, const char* name,
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
TeamWindow::_SaveInspectorSettings(const BMessage* settings)
|
||||
{
|
||||
char *name;
|
||||
type_code type;
|
||||
BVariant value;
|
||||
|
||||
for (int32 i = 0; settings->GetInfo(B_ANY_TYPE, i, &name, &type) == B_OK;
|
||||
i++) {
|
||||
if (value.SetFromMessage(*settings, name) == B_OK) {
|
||||
if (!fUISettings.SetValue(name, value))
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include "BreakpointsView.h"
|
||||
#include "Function.h"
|
||||
#include "GUITeamUISettings.h"
|
||||
#include "ImageFunctionsView.h"
|
||||
#include "ImageListView.h"
|
||||
#include "SourceView.h"
|
||||
@ -27,7 +28,6 @@ class BMenuBar;
|
||||
class BSplitView;
|
||||
class BStringView;
|
||||
class BTabView;
|
||||
class GUITeamUISettings;
|
||||
class Image;
|
||||
class InspectorWindow;
|
||||
class RegistersView;
|
||||
@ -150,6 +150,8 @@ private:
|
||||
const char* name,
|
||||
GUITeamUISettings* settings);
|
||||
|
||||
status_t _SaveInspectorSettings(
|
||||
const BMessage* settings);
|
||||
private:
|
||||
::Team* fTeam;
|
||||
::Thread* fActiveThread;
|
||||
@ -182,6 +184,7 @@ private:
|
||||
BSplitView* fImageSplitView;
|
||||
BSplitView* fThreadSplitView;
|
||||
InspectorWindow* fInspectorWindow;
|
||||
GUITeamUISettings fUISettings;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user