Add hooks to UserInterface to allow for saving/restoring of UI settings.
Make use of them as appopriate. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43121 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
3fa483ccda
commit
bbc851098d
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Copyright 2010, Rene Gollent, rene@gollent.com.
|
||||
* Copyright 2010-2011, Rene Gollent, rene@gollent.com.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
#include "TeamMemoryBlock.h"
|
||||
#include "TeamMemoryBlockManager.h"
|
||||
#include "TeamSettings.h"
|
||||
#include "TeamUISettings.h"
|
||||
#include "Tracing.h"
|
||||
#include "ValueNode.h"
|
||||
#include "ValueNodeContainer.h"
|
||||
@ -1370,13 +1371,12 @@ TeamDebugger::_LoadSettings()
|
||||
locker.Unlock();
|
||||
|
||||
// load the settings
|
||||
TeamSettings settings;
|
||||
if (fSettingsManager->LoadTeamSettings(teamName, settings) != B_OK)
|
||||
if (fSettingsManager->LoadTeamSettings(teamName, fTeamSettings) != B_OK)
|
||||
return;
|
||||
|
||||
// create the saved breakpoints
|
||||
for (int32 i = 0; const BreakpointSetting* breakpointSetting
|
||||
= settings.BreakpointAt(i); i++) {
|
||||
= fTeamSettings.BreakpointAt(i); i++) {
|
||||
if (breakpointSetting->GetFunctionID() == NULL)
|
||||
continue;
|
||||
|
||||
@ -1404,6 +1404,11 @@ TeamDebugger::_LoadSettings()
|
||||
fBreakpointManager->InstallUserBreakpoint(breakpoint,
|
||||
breakpointSetting->IsEnabled());
|
||||
}
|
||||
|
||||
const TeamUISettings* uiSettings = fTeamSettings.UISettingFor(
|
||||
fUserInterface->ID());
|
||||
if (uiSettings != NULL)
|
||||
fUserInterface->LoadSettings(uiSettings);
|
||||
}
|
||||
|
||||
|
||||
@ -1415,6 +1420,22 @@ TeamDebugger::_SaveSettings()
|
||||
TeamSettings settings;
|
||||
if (settings.SetTo(fTeam) != B_OK)
|
||||
return;
|
||||
|
||||
TeamUISettings* uiSettings = NULL;
|
||||
if (fUserInterface->SaveSettings(uiSettings) != B_OK)
|
||||
return;
|
||||
if (uiSettings != NULL)
|
||||
settings.AddUISettings(uiSettings);
|
||||
|
||||
// preserve the UI settings from our cached copy.
|
||||
for (int32 i = 0; i < fTeamSettings.CountUISettings(); i++) {
|
||||
const TeamUISettings* oldUISettings = fTeamSettings.UISettingAt(i);
|
||||
if (strcmp(oldUISettings->ID(), fUserInterface->ID()) != 0) {
|
||||
TeamUISettings* clonedSettings = oldUISettings->Clone();
|
||||
if (clonedSettings != NULL)
|
||||
settings.AddUISettings(clonedSettings);
|
||||
}
|
||||
}
|
||||
locker.Unlock();
|
||||
|
||||
// save the settings
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include "DebugEvent.h"
|
||||
#include "Team.h"
|
||||
#include "TeamSettings.h"
|
||||
#include "ThreadHandler.h"
|
||||
#include "UserInterface.h"
|
||||
#include "Worker.h"
|
||||
@ -155,6 +156,7 @@ private:
|
||||
UserInterface* fUserInterface;
|
||||
volatile bool fTerminating;
|
||||
bool fKillTeamOnQuit;
|
||||
TeamSettings fTeamSettings;
|
||||
};
|
||||
|
||||
|
||||
|
@ -100,7 +100,7 @@ TeamSettings::SetTo(const BMessage& archive)
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// add UI settings
|
||||
for (int32 i = 0; archive.FindMessage("uisettings", i, &childArchive)
|
||||
== B_OK; i++) {
|
||||
@ -111,7 +111,7 @@ TeamSettings::SetTo(const BMessage& archive)
|
||||
if (error != B_OK) {
|
||||
delete setting;
|
||||
return error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
@ -136,13 +136,13 @@ TeamSettings::WriteTo(BMessage& archive) const
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
for (int32 i = 0; TeamUISettings* uiSetting = fUISettings.ItemAt(i);
|
||||
i++) {
|
||||
error = uiSetting->WriteTo(childArchive);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
|
||||
error = archive.AddMessage("uisettings", &childArchive);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
@ -180,6 +180,29 @@ TeamSettings::UISettingAt(int32 index) const
|
||||
}
|
||||
|
||||
|
||||
const TeamUISettings*
|
||||
TeamSettings::UISettingFor(const char* id) const
|
||||
{
|
||||
for (int32 i = 0; i < fUISettings.CountItems(); i++) {
|
||||
TeamUISettings* settings = fUISettings.ItemAt(i);
|
||||
if (strcmp(settings->ID(), id) == 0)
|
||||
return settings;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
TeamSettings::AddUISettings(TeamUISettings* settings)
|
||||
{
|
||||
if (!fUISettings.AddItem(settings))
|
||||
return B_NO_MEMORY;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
TeamSettings&
|
||||
TeamSettings::operator=(const TeamSettings& other)
|
||||
{
|
||||
@ -221,7 +244,7 @@ TeamSettings::_Unset()
|
||||
i++) {
|
||||
delete breakpoint;
|
||||
}
|
||||
|
||||
|
||||
for (int32 i = 0; TeamUISettings* uiSetting = fUISettings.ItemAt(i); i++)
|
||||
delete uiSetting;
|
||||
|
||||
|
@ -32,9 +32,11 @@ public:
|
||||
|
||||
int32 CountBreakpoints() const;
|
||||
const BreakpointSetting* BreakpointAt(int32 index) const;
|
||||
|
||||
|
||||
int32 CountUISettings() const;
|
||||
const TeamUISettings* UISettingAt(int32 index) const;
|
||||
const TeamUISettings* UISettingFor(const char* id) const;
|
||||
status_t AddUISettings(TeamUISettings* settings);
|
||||
|
||||
TeamSettings& operator=(const TeamSettings& other);
|
||||
// throws std::bad_alloc
|
||||
|
@ -19,6 +19,7 @@ class FunctionInstance;
|
||||
class Image;
|
||||
class StackFrame;
|
||||
class Team;
|
||||
class TeamUISettings;
|
||||
class Thread;
|
||||
class TypeComponentPath;
|
||||
class UserBreakpoint;
|
||||
@ -39,6 +40,8 @@ class UserInterface : public BReferenceable {
|
||||
public:
|
||||
virtual ~UserInterface();
|
||||
|
||||
virtual const char* ID() const = 0;
|
||||
|
||||
virtual status_t Init(Team* team,
|
||||
UserInterfaceListener* listener) = 0;
|
||||
virtual void Show() = 0;
|
||||
@ -46,6 +49,11 @@ public:
|
||||
// shut down the UI *now* -- no more user
|
||||
// feedback
|
||||
|
||||
virtual status_t LoadSettings(const TeamUISettings* settings)
|
||||
= 0;
|
||||
virtual status_t SaveSettings(TeamUISettings*& settings)
|
||||
const = 0;
|
||||
|
||||
virtual void NotifyUser(const char* title,
|
||||
const char* message,
|
||||
user_notification_type type) = 0;
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Copyright 2011, Rene Gollent, rene@gollent.com.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@ -8,6 +9,7 @@
|
||||
|
||||
#include <Alert.h>
|
||||
|
||||
#include "GUITeamUISettings.h"
|
||||
#include "TeamWindow.h"
|
||||
#include "Tracing.h"
|
||||
|
||||
@ -26,6 +28,13 @@ GraphicalUserInterface::~GraphicalUserInterface()
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
GraphicalUserInterface::ID() const
|
||||
{
|
||||
return "GraphicalUserInterface";
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
GraphicalUserInterface::Init(Team* team, UserInterfaceListener* listener)
|
||||
{
|
||||
@ -58,6 +67,28 @@ GraphicalUserInterface::Terminate()
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
GraphicalUserInterface::LoadSettings(const TeamUISettings* settings)
|
||||
{
|
||||
// TODO: restore settings
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
GraphicalUserInterface::SaveSettings(TeamUISettings*& settings) const
|
||||
{
|
||||
settings = new(std::nothrow) GUITeamUISettings(ID());
|
||||
if (settings == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
// TODO: fill in settings
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GraphicalUserInterface::NotifyUser(const char* title, const char* message,
|
||||
user_notification_type type)
|
||||
|
@ -18,6 +18,8 @@ public:
|
||||
GraphicalUserInterface();
|
||||
virtual ~GraphicalUserInterface();
|
||||
|
||||
virtual const char* ID() const;
|
||||
|
||||
virtual status_t Init(Team* team,
|
||||
UserInterfaceListener* listener);
|
||||
virtual void Show();
|
||||
@ -25,6 +27,9 @@ public:
|
||||
// shut down the UI *now* -- no more user
|
||||
// feedback
|
||||
|
||||
virtual status_t LoadSettings(const TeamUISettings* settings);
|
||||
virtual status_t SaveSettings(TeamUISettings*& settings) const;
|
||||
|
||||
virtual void NotifyUser(const char* title,
|
||||
const char* message,
|
||||
user_notification_type type);
|
||||
|
Loading…
x
Reference in New Issue
Block a user