save and restore menu and mouse settings, fixes bug 607
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17676 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -58,7 +58,6 @@ DesktopSettings::Private::_SetDefaults()
|
|||||||
strlcpy(fMenuInfo.f_family, fPlainFont.Family(), B_FONT_FAMILY_LENGTH);
|
strlcpy(fMenuInfo.f_family, fPlainFont.Family(), B_FONT_FAMILY_LENGTH);
|
||||||
strlcpy(fMenuInfo.f_style, fPlainFont.Style(), B_FONT_STYLE_LENGTH);
|
strlcpy(fMenuInfo.f_style, fPlainFont.Style(), B_FONT_STYLE_LENGTH);
|
||||||
fMenuInfo.font_size = fPlainFont.Size();
|
fMenuInfo.font_size = fPlainFont.Size();
|
||||||
// TODO:
|
|
||||||
fMenuInfo.background_color.set_to(216, 216, 216);
|
fMenuInfo.background_color.set_to(216, 216, 216);
|
||||||
|
|
||||||
// look of the separator (R5: (0, 1, 2), default 0)
|
// look of the separator (R5: (0, 1, 2), default 0)
|
||||||
@@ -163,6 +162,63 @@ DesktopSettings::Private::_Load()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// read mouse settings
|
||||||
|
|
||||||
|
path = basePath;
|
||||||
|
path.Append("mouse");
|
||||||
|
|
||||||
|
status = file.SetTo(path.Path(), B_READ_ONLY);
|
||||||
|
if (status == B_OK) {
|
||||||
|
BMessage settings;
|
||||||
|
status = settings.Unflatten(&file);
|
||||||
|
if (status == B_OK) {
|
||||||
|
int32 mode;
|
||||||
|
if (settings.FindInt32("mode", &mode) == B_OK) {
|
||||||
|
fMouseMode = (mode_mouse)mode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// read appearance settings
|
||||||
|
|
||||||
|
path = basePath;
|
||||||
|
path.Append("appearance");
|
||||||
|
|
||||||
|
status = file.SetTo(path.Path(), B_READ_ONLY);
|
||||||
|
if (status == B_OK) {
|
||||||
|
BMessage settings;
|
||||||
|
status = settings.Unflatten(&file);
|
||||||
|
if (status == B_OK) {
|
||||||
|
float fontSize;
|
||||||
|
if (settings.FindFloat("font size", &fontSize) == B_OK)
|
||||||
|
fMenuInfo.font_size = fontSize;
|
||||||
|
|
||||||
|
const char* fontFamily;
|
||||||
|
if (settings.FindString("font family", &fontFamily) == B_OK)
|
||||||
|
strlcpy(fMenuInfo.f_family, fontFamily, B_FONT_FAMILY_LENGTH);
|
||||||
|
|
||||||
|
const char* fontStyle;
|
||||||
|
if (settings.FindString("font style", &fontStyle) == B_OK)
|
||||||
|
strlcpy(fMenuInfo.f_style, fontStyle, B_FONT_STYLE_LENGTH);
|
||||||
|
|
||||||
|
rgb_color bgColor;
|
||||||
|
if (settings.FindInt32("bg color", (int32*)&bgColor) == B_OK)
|
||||||
|
fMenuInfo.background_color = bgColor;
|
||||||
|
|
||||||
|
int32 separator;
|
||||||
|
if (settings.FindInt32("separator", &separator) == B_OK)
|
||||||
|
fMenuInfo.separator = separator;
|
||||||
|
|
||||||
|
bool clickToOpen;
|
||||||
|
if (settings.FindBool("click to open", &clickToOpen) == B_OK)
|
||||||
|
fMenuInfo.click_to_open = clickToOpen;
|
||||||
|
|
||||||
|
bool triggersAlwaysShown;
|
||||||
|
if (settings.FindBool("triggers always shown", &triggersAlwaysShown) == B_OK)
|
||||||
|
fMenuInfo.triggers_always_shown = triggersAlwaysShown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,6 +274,41 @@ DesktopSettings::Private::Save(uint32 mask)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mask & kMouseSettings) {
|
||||||
|
BPath path(basePath);
|
||||||
|
if (path.Append("mouse") == B_OK) {
|
||||||
|
BMessage settings('asms');
|
||||||
|
settings.AddInt32("mode", (int32)fMouseMode);
|
||||||
|
|
||||||
|
BFile file;
|
||||||
|
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_READ_WRITE);
|
||||||
|
if (status == B_OK) {
|
||||||
|
status = settings.Flatten(&file, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mask & kAppearanceSettings) {
|
||||||
|
BPath path(basePath);
|
||||||
|
if (path.Append("appearance") == B_OK) {
|
||||||
|
BMessage settings('aslk');
|
||||||
|
settings.AddFloat("font size", fMenuInfo.font_size);
|
||||||
|
settings.AddString("font family", fMenuInfo.f_family);
|
||||||
|
settings.AddString("font style", fMenuInfo.f_style);
|
||||||
|
settings.AddInt32("bg color", (const int32&)fMenuInfo.background_color);
|
||||||
|
settings.AddInt32("separator", fMenuInfo.separator);
|
||||||
|
settings.AddBool("click to open", fMenuInfo.click_to_open);
|
||||||
|
settings.AddBool("triggers always shown", fMenuInfo.triggers_always_shown);
|
||||||
|
// TODO: more appearance settings
|
||||||
|
|
||||||
|
BFile file;
|
||||||
|
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_READ_WRITE);
|
||||||
|
if (status == B_OK) {
|
||||||
|
status = settings.Flatten(&file, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,6 +392,7 @@ void
|
|||||||
DesktopSettings::Private::SetMouseMode(const mode_mouse mode)
|
DesktopSettings::Private::SetMouseMode(const mode_mouse mode)
|
||||||
{
|
{
|
||||||
fMouseMode = mode;
|
fMouseMode = mode;
|
||||||
|
Save(kMouseSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ enum {
|
|||||||
kAllSettings = 0xff,
|
kAllSettings = 0xff,
|
||||||
kWorkspacesSettings = 0x01,
|
kWorkspacesSettings = 0x01,
|
||||||
kFontSettings = 0x02,
|
kFontSettings = 0x02,
|
||||||
kAppearanceSettings = 0x04
|
kAppearanceSettings = 0x04,
|
||||||
|
kMouseSettings = 0x08,
|
||||||
};
|
};
|
||||||
|
|
||||||
class DesktopSettings {
|
class DesktopSettings {
|
||||||
|
|||||||
Reference in New Issue
Block a user