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:
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||||
* Copyright 2010, Rene Gollent, [email protected].
|
* Copyright 2010-2011, Rene Gollent, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -40,6 +40,7 @@
|
|||||||
#include "TeamMemoryBlock.h"
|
#include "TeamMemoryBlock.h"
|
||||||
#include "TeamMemoryBlockManager.h"
|
#include "TeamMemoryBlockManager.h"
|
||||||
#include "TeamSettings.h"
|
#include "TeamSettings.h"
|
||||||
|
#include "TeamUISettings.h"
|
||||||
#include "Tracing.h"
|
#include "Tracing.h"
|
||||||
#include "ValueNode.h"
|
#include "ValueNode.h"
|
||||||
#include "ValueNodeContainer.h"
|
#include "ValueNodeContainer.h"
|
||||||
@@ -1370,13 +1371,12 @@ TeamDebugger::_LoadSettings()
|
|||||||
locker.Unlock();
|
locker.Unlock();
|
||||||
|
|
||||||
// load the settings
|
// load the settings
|
||||||
TeamSettings settings;
|
if (fSettingsManager->LoadTeamSettings(teamName, fTeamSettings) != B_OK)
|
||||||
if (fSettingsManager->LoadTeamSettings(teamName, settings) != B_OK)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// create the saved breakpoints
|
// create the saved breakpoints
|
||||||
for (int32 i = 0; const BreakpointSetting* breakpointSetting
|
for (int32 i = 0; const BreakpointSetting* breakpointSetting
|
||||||
= settings.BreakpointAt(i); i++) {
|
= fTeamSettings.BreakpointAt(i); i++) {
|
||||||
if (breakpointSetting->GetFunctionID() == NULL)
|
if (breakpointSetting->GetFunctionID() == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -1404,6 +1404,11 @@ TeamDebugger::_LoadSettings()
|
|||||||
fBreakpointManager->InstallUserBreakpoint(breakpoint,
|
fBreakpointManager->InstallUserBreakpoint(breakpoint,
|
||||||
breakpointSetting->IsEnabled());
|
breakpointSetting->IsEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const TeamUISettings* uiSettings = fTeamSettings.UISettingFor(
|
||||||
|
fUserInterface->ID());
|
||||||
|
if (uiSettings != NULL)
|
||||||
|
fUserInterface->LoadSettings(uiSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1415,6 +1420,22 @@ TeamDebugger::_SaveSettings()
|
|||||||
TeamSettings settings;
|
TeamSettings settings;
|
||||||
if (settings.SetTo(fTeam) != B_OK)
|
if (settings.SetTo(fTeam) != B_OK)
|
||||||
return;
|
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();
|
locker.Unlock();
|
||||||
|
|
||||||
// save the settings
|
// save the settings
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "DebugEvent.h"
|
#include "DebugEvent.h"
|
||||||
#include "Team.h"
|
#include "Team.h"
|
||||||
|
#include "TeamSettings.h"
|
||||||
#include "ThreadHandler.h"
|
#include "ThreadHandler.h"
|
||||||
#include "UserInterface.h"
|
#include "UserInterface.h"
|
||||||
#include "Worker.h"
|
#include "Worker.h"
|
||||||
@@ -155,6 +156,7 @@ private:
|
|||||||
UserInterface* fUserInterface;
|
UserInterface* fUserInterface;
|
||||||
volatile bool fTerminating;
|
volatile bool fTerminating;
|
||||||
bool fKillTeamOnQuit;
|
bool fKillTeamOnQuit;
|
||||||
|
TeamSettings fTeamSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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&
|
||||||
TeamSettings::operator=(const TeamSettings& other)
|
TeamSettings::operator=(const TeamSettings& other)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ public:
|
|||||||
|
|
||||||
int32 CountUISettings() const;
|
int32 CountUISettings() const;
|
||||||
const TeamUISettings* UISettingAt(int32 index) const;
|
const TeamUISettings* UISettingAt(int32 index) const;
|
||||||
|
const TeamUISettings* UISettingFor(const char* id) const;
|
||||||
|
status_t AddUISettings(TeamUISettings* settings);
|
||||||
|
|
||||||
TeamSettings& operator=(const TeamSettings& other);
|
TeamSettings& operator=(const TeamSettings& other);
|
||||||
// throws std::bad_alloc
|
// throws std::bad_alloc
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class FunctionInstance;
|
|||||||
class Image;
|
class Image;
|
||||||
class StackFrame;
|
class StackFrame;
|
||||||
class Team;
|
class Team;
|
||||||
|
class TeamUISettings;
|
||||||
class Thread;
|
class Thread;
|
||||||
class TypeComponentPath;
|
class TypeComponentPath;
|
||||||
class UserBreakpoint;
|
class UserBreakpoint;
|
||||||
@@ -39,6 +40,8 @@ class UserInterface : public BReferenceable {
|
|||||||
public:
|
public:
|
||||||
virtual ~UserInterface();
|
virtual ~UserInterface();
|
||||||
|
|
||||||
|
virtual const char* ID() const = 0;
|
||||||
|
|
||||||
virtual status_t Init(Team* team,
|
virtual status_t Init(Team* team,
|
||||||
UserInterfaceListener* listener) = 0;
|
UserInterfaceListener* listener) = 0;
|
||||||
virtual void Show() = 0;
|
virtual void Show() = 0;
|
||||||
@@ -46,6 +49,11 @@ public:
|
|||||||
// shut down the UI *now* -- no more user
|
// shut down the UI *now* -- no more user
|
||||||
// feedback
|
// feedback
|
||||||
|
|
||||||
|
virtual status_t LoadSettings(const TeamUISettings* settings)
|
||||||
|
= 0;
|
||||||
|
virtual status_t SaveSettings(TeamUISettings*& settings)
|
||||||
|
const = 0;
|
||||||
|
|
||||||
virtual void NotifyUser(const char* title,
|
virtual void NotifyUser(const char* title,
|
||||||
const char* message,
|
const char* message,
|
||||||
user_notification_type type) = 0;
|
user_notification_type type) = 0;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||||
|
* Copyright 2011, Rene Gollent, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -8,6 +9,7 @@
|
|||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
|
|
||||||
|
#include "GUITeamUISettings.h"
|
||||||
#include "TeamWindow.h"
|
#include "TeamWindow.h"
|
||||||
#include "Tracing.h"
|
#include "Tracing.h"
|
||||||
|
|
||||||
@@ -26,6 +28,13 @@ GraphicalUserInterface::~GraphicalUserInterface()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char*
|
||||||
|
GraphicalUserInterface::ID() const
|
||||||
|
{
|
||||||
|
return "GraphicalUserInterface";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
GraphicalUserInterface::Init(Team* team, UserInterfaceListener* listener)
|
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
|
void
|
||||||
GraphicalUserInterface::NotifyUser(const char* title, const char* message,
|
GraphicalUserInterface::NotifyUser(const char* title, const char* message,
|
||||||
user_notification_type type)
|
user_notification_type type)
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ public:
|
|||||||
GraphicalUserInterface();
|
GraphicalUserInterface();
|
||||||
virtual ~GraphicalUserInterface();
|
virtual ~GraphicalUserInterface();
|
||||||
|
|
||||||
|
virtual const char* ID() const;
|
||||||
|
|
||||||
virtual status_t Init(Team* team,
|
virtual status_t Init(Team* team,
|
||||||
UserInterfaceListener* listener);
|
UserInterfaceListener* listener);
|
||||||
virtual void Show();
|
virtual void Show();
|
||||||
@@ -25,6 +27,9 @@ public:
|
|||||||
// shut down the UI *now* -- no more user
|
// shut down the UI *now* -- no more user
|
||||||
// feedback
|
// feedback
|
||||||
|
|
||||||
|
virtual status_t LoadSettings(const TeamUISettings* settings);
|
||||||
|
virtual status_t SaveSettings(TeamUISettings*& settings) const;
|
||||||
|
|
||||||
virtual void NotifyUser(const char* title,
|
virtual void NotifyUser(const char* title,
|
||||||
const char* message,
|
const char* message,
|
||||||
user_notification_type type);
|
user_notification_type type);
|
||||||
|
|||||||
Reference in New Issue
Block a user