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:
@@ -19,6 +19,7 @@
|
|||||||
#include <ExpressionParser.h>
|
#include <ExpressionParser.h>
|
||||||
|
|
||||||
#include "Architecture.h"
|
#include "Architecture.h"
|
||||||
|
#include "GUITeamUISettings.h"
|
||||||
#include "MemoryView.h"
|
#include "MemoryView.h"
|
||||||
#include "MessageCodes.h"
|
#include "MessageCodes.h"
|
||||||
#include "Team.h"
|
#include "Team.h"
|
||||||
@@ -265,7 +266,10 @@ InspectorWindow::MessageReceived(BMessage* msg)
|
|||||||
bool
|
bool
|
||||||
InspectorWindow::QuitRequested()
|
InspectorWindow::QuitRequested()
|
||||||
{
|
{
|
||||||
BMessenger(fTarget).SendMessage(MSG_INSPECTOR_WINDOW_CLOSED);
|
BMessage settings(MSG_INSPECTOR_WINDOW_CLOSED);
|
||||||
|
SaveSettings(&settings);
|
||||||
|
|
||||||
|
BMessenger(fTarget).SendMessage(&settings);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,3 +285,81 @@ InspectorWindow::MemoryBlockRetrieved(TeamMemoryBlock* block)
|
|||||||
fNextBlockButton->SetEnabled(true);
|
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 BMenuField;
|
||||||
class BMessenger;
|
class BMessenger;
|
||||||
class BTextControl;
|
class BTextControl;
|
||||||
|
class GUITeamUISettings;
|
||||||
class MemoryView;
|
class MemoryView;
|
||||||
class Team;
|
class Team;
|
||||||
class UserInterfaceListener;
|
class UserInterfaceListener;
|
||||||
@@ -39,9 +40,20 @@ public:
|
|||||||
|
|
||||||
virtual void MemoryBlockRetrieved(TeamMemoryBlock* block);
|
virtual void MemoryBlockRetrieved(TeamMemoryBlock* block);
|
||||||
|
|
||||||
|
status_t LoadSettings(
|
||||||
|
const GUITeamUISettings* settings);
|
||||||
|
status_t SaveSettings(
|
||||||
|
BMessage* settings);
|
||||||
private:
|
private:
|
||||||
void _Init();
|
void _Init();
|
||||||
|
|
||||||
|
void _LoadMenuFieldMode(BMenuField* field,
|
||||||
|
const char* name,
|
||||||
|
const GUITeamUISettings* settings);
|
||||||
|
status_t _SaveMenuFieldMode(BMenuField* field,
|
||||||
|
const char* name,
|
||||||
|
BMessage* settings);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UserInterfaceListener* fListener;
|
UserInterfaceListener* fListener;
|
||||||
BTextControl* fAddressInput;
|
BTextControl* fAddressInput;
|
||||||
|
|||||||
@@ -219,8 +219,10 @@ TeamWindow::MessageReceived(BMessage* message)
|
|||||||
try {
|
try {
|
||||||
fInspectorWindow = InspectorWindow::Create(fTeam, fListener,
|
fInspectorWindow = InspectorWindow::Create(fTeam, fListener,
|
||||||
this);
|
this);
|
||||||
if (fInspectorWindow != NULL)
|
if (fInspectorWindow != NULL) {
|
||||||
|
fInspectorWindow->LoadSettings(&fUISettings);
|
||||||
fInspectorWindow->Show();
|
fInspectorWindow->Show();
|
||||||
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// TODO: notify user
|
// TODO: notify user
|
||||||
}
|
}
|
||||||
@@ -228,7 +230,9 @@ TeamWindow::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
case MSG_INSPECTOR_WINDOW_CLOSED:
|
case MSG_INSPECTOR_WINDOW_CLOSED:
|
||||||
{
|
{
|
||||||
|
_SaveInspectorSettings(CurrentMessage());
|
||||||
fInspectorWindow = NULL;
|
fInspectorWindow = NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
case B_REFS_RECEIVED:
|
case B_REFS_RECEIVED:
|
||||||
{
|
{
|
||||||
@@ -351,6 +355,8 @@ TeamWindow::LoadSettings(const GUITeamUISettings* settings)
|
|||||||
_LoadSplitSettings(fImageSplitView, "Image", settings);
|
_LoadSplitSettings(fImageSplitView, "Image", settings);
|
||||||
_LoadSplitSettings(fThreadSplitView, "Thread", settings);
|
_LoadSplitSettings(fThreadSplitView, "Thread", settings);
|
||||||
|
|
||||||
|
fUISettings = *settings;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,6 +364,23 @@ TeamWindow::LoadSettings(const GUITeamUISettings* settings)
|
|||||||
status_t
|
status_t
|
||||||
TeamWindow::SaveSettings(GUITeamUISettings* settings)
|
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()))
|
if (!settings->SetValue("teamWindowFrame", Frame()))
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
@@ -1163,3 +1186,22 @@ TeamWindow::_SaveSplitSettings(BSplitView* view, const char* name,
|
|||||||
|
|
||||||
return B_OK;
|
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 "BreakpointsView.h"
|
||||||
#include "Function.h"
|
#include "Function.h"
|
||||||
|
#include "GUITeamUISettings.h"
|
||||||
#include "ImageFunctionsView.h"
|
#include "ImageFunctionsView.h"
|
||||||
#include "ImageListView.h"
|
#include "ImageListView.h"
|
||||||
#include "SourceView.h"
|
#include "SourceView.h"
|
||||||
@@ -27,7 +28,6 @@ class BMenuBar;
|
|||||||
class BSplitView;
|
class BSplitView;
|
||||||
class BStringView;
|
class BStringView;
|
||||||
class BTabView;
|
class BTabView;
|
||||||
class GUITeamUISettings;
|
|
||||||
class Image;
|
class Image;
|
||||||
class InspectorWindow;
|
class InspectorWindow;
|
||||||
class RegistersView;
|
class RegistersView;
|
||||||
@@ -150,6 +150,8 @@ private:
|
|||||||
const char* name,
|
const char* name,
|
||||||
GUITeamUISettings* settings);
|
GUITeamUISettings* settings);
|
||||||
|
|
||||||
|
status_t _SaveInspectorSettings(
|
||||||
|
const BMessage* settings);
|
||||||
private:
|
private:
|
||||||
::Team* fTeam;
|
::Team* fTeam;
|
||||||
::Thread* fActiveThread;
|
::Thread* fActiveThread;
|
||||||
@@ -182,6 +184,7 @@ private:
|
|||||||
BSplitView* fImageSplitView;
|
BSplitView* fImageSplitView;
|
||||||
BSplitView* fThreadSplitView;
|
BSplitView* fThreadSplitView;
|
||||||
InspectorWindow* fInspectorWindow;
|
InspectorWindow* fInspectorWindow;
|
||||||
|
GUITeamUISettings fUISettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user