2 * Copyright 2008-2011, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Fredrik Modéen <fredrik@modeen.se>
15 /*static*/ Settings
Settings::sGlobalInstance
;
19 mpSettings::operator!=(const mpSettings
& other
) const
21 return autostart
!= other
.autostart
22 || closeWhenDonePlayingMovie
!= other
.closeWhenDonePlayingMovie
23 || closeWhenDonePlayingSound
!= other
.closeWhenDonePlayingSound
24 || loopMovie
!= other
.loopMovie
25 || loopSound
!= other
.loopSound
26 || useOverlays
!= other
.useOverlays
27 || scaleBilinear
!= other
.scaleBilinear
28 || scaleFullscreenControls
!= other
.scaleFullscreenControls
29 || subtitleSize
!= other
.subtitleSize
30 || subtitlePlacement
!= other
.subtitlePlacement
31 || backgroundMovieVolumeMode
!= other
.backgroundMovieVolumeMode
32 || filePanelFolder
!= other
.filePanelFolder
33 || audioPlayerWindowFrame
!= other
.audioPlayerWindowFrame
;
37 Settings::Settings(const char* filename
)
39 BLocker("settings lock"),
40 fSettingsMessage(B_USER_SETTINGS_DIRECTORY
, filename
)
42 // The settings are loaded from disk in the SettingsMessage constructor.
47 Settings::Get(mpSettings
& settings
) const
49 BAutolock
_(const_cast<Settings
*>(this));
51 settings
.autostart
= fSettingsMessage
.GetValue("autostart", true);
52 settings
.closeWhenDonePlayingMovie
53 = fSettingsMessage
.GetValue("closeWhenDonePlayingMovie", false);
54 settings
.closeWhenDonePlayingSound
55 = fSettingsMessage
.GetValue("closeWhenDonePlayingSound", false);
56 settings
.loopMovie
= fSettingsMessage
.GetValue("loopMovie", false);
57 settings
.loopSound
= fSettingsMessage
.GetValue("loopSound", false);
59 settings
.useOverlays
= fSettingsMessage
.GetValue("useOverlays", true);
60 settings
.scaleBilinear
= fSettingsMessage
.GetValue("scaleBilinear", true);
61 settings
.scaleFullscreenControls
62 = fSettingsMessage
.GetValue("scaleFullscreenControls", true);
65 = fSettingsMessage
.GetValue("subtitleSize",
66 (uint32
)mpSettings::SUBTITLE_SIZE_MEDIUM
);
67 settings
.subtitlePlacement
68 = fSettingsMessage
.GetValue("subtitlePlacement",
69 (uint32
)mpSettings::SUBTITLE_PLACEMENT_BOTTOM_OF_VIDEO
);
71 settings
.backgroundMovieVolumeMode
72 = fSettingsMessage
.GetValue("bgMovieVolumeMode",
73 (uint32
)mpSettings::BG_MOVIES_FULL_VOLUME
);
75 settings
.filePanelFolder
= FilePanelFolder();
76 settings
.audioPlayerWindowFrame
= AudioPlayerWindowFrame();
81 Settings::Update(const mpSettings
& settings
)
85 fSettingsMessage
.SetValue("autostart", settings
.autostart
);
86 fSettingsMessage
.SetValue("closeWhenDonePlayingMovie",
87 settings
.closeWhenDonePlayingMovie
);
88 fSettingsMessage
.SetValue("closeWhenDonePlayingSound",
89 settings
.closeWhenDonePlayingSound
);
90 fSettingsMessage
.SetValue("loopMovie", settings
.loopMovie
);
91 fSettingsMessage
.SetValue("loopSound", settings
.loopSound
);
93 fSettingsMessage
.SetValue("useOverlays", settings
.useOverlays
);
94 fSettingsMessage
.SetValue("scaleBilinear", settings
.scaleBilinear
);
95 fSettingsMessage
.SetValue("scaleFullscreenControls",
96 settings
.scaleFullscreenControls
);
98 fSettingsMessage
.SetValue("subtitleSize", settings
.subtitleSize
);
99 fSettingsMessage
.SetValue("subtitlePlacement", settings
.subtitlePlacement
);
101 fSettingsMessage
.SetValue("bgMovieVolumeMode",
102 settings
.backgroundMovieVolumeMode
);
104 fSettingsMessage
.SetValue("filePanelDirectory",
105 settings
.filePanelFolder
);
107 SetAudioPlayerWindowFrame(settings
.audioPlayerWindowFrame
);
114 Settings::FilePanelFolder() const
116 BAutolock
locker(const_cast<Settings
*>(this));
117 return fSettingsMessage
.GetValue("filePanelDirectory", entry_ref());
122 Settings::SetFilePanelFolder(const entry_ref
& ref
)
124 BAutolock
locker(this);
125 fSettingsMessage
.SetValue("filePanelDirectory", ref
);
130 Settings::AudioPlayerWindowFrame() const
132 BAutolock
locker(const_cast<Settings
*>(this));
133 return fSettingsMessage
.GetValue("audioPlayerWindowFrame", BRect());
138 Settings::SetAudioPlayerWindowFrame(BRect frame
)
140 BAutolock
locker(this);
141 fSettingsMessage
.SetValue("audioPlayerWindowFrame", frame
);
145 // #pragma mark - static
151 return &sGlobalInstance
;