xref: /haiku/src/apps/mediaplayer/settings/SettingsWindow.cpp (revision ffa42ceaf70ce92d06e2f838e531ebad9e6a5aa3)
14d3ebaccSStephan Aßmus /*
2a178983dSAxel Dörfler  * Copyright 2008-2011, Haiku, Inc. All rights reserved.
34d3ebaccSStephan Aßmus  * Distributed under the terms of the MIT License.
44d3ebaccSStephan Aßmus  *
54d3ebaccSStephan Aßmus  * Authors:
64d3ebaccSStephan Aßmus  *		Fredrik Modéen <fredrik@modeen.se>
7c5f8afb9SStephan Aßmus  *		Stephan Aßmus <superstippi@gmx.de>
84d3ebaccSStephan Aßmus  */
94d3ebaccSStephan Aßmus 
10e65a6eb2SStephan Aßmus 
114d3ebaccSStephan Aßmus #include "SettingsWindow.h"
124d3ebaccSStephan Aßmus 
134d3ebaccSStephan Aßmus #include <stdio.h>
144d3ebaccSStephan Aßmus 
154d3ebaccSStephan Aßmus #include <Box.h>
164d3ebaccSStephan Aßmus #include <Button.h>
17238df8fbSAdrien Destugues #include <Catalog.h>
18b6d5916aSStephan Aßmus #include <CheckBox.h>
19108d2173SHumdinger #include <ControlLook.h>
205dcd3cd1SHannah Boneß #include <LayoutBuilder.h>
21238df8fbSAdrien Destugues #include <Locale.h>
22e65a6eb2SStephan Aßmus #include <OptionPopUp.h>
2326e9cdb7SStephan Aßmus #include <SpaceLayoutItem.h>
24b6d5916aSStephan Aßmus #include <String.h>
25b6d5916aSStephan Aßmus #include <StringView.h>
26b6d5916aSStephan Aßmus #include <RadioButton.h>
27b6d5916aSStephan Aßmus #include <View.h>
2826e9cdb7SStephan Aßmus 
29e65a6eb2SStephan Aßmus 
30546208a5SOliver Tappe #undef B_TRANSLATION_CONTEXT
31546208a5SOliver Tappe #define B_TRANSLATION_CONTEXT "MediaPlayer-SettingsWindow"
32238df8fbSAdrien Destugues 
33238df8fbSAdrien Destugues 
344d3ebaccSStephan Aßmus enum {
35e65a6eb2SStephan Aßmus 	M_SETTINGS_CHANGED = 0x3000,
3626e9cdb7SStephan Aßmus 
374d3ebaccSStephan Aßmus 	M_SETTINGS_SAVE,
384d3ebaccSStephan Aßmus 	M_SETTINGS_CANCEL,
3926e9cdb7SStephan Aßmus 	M_SETTINGS_REVERT
404d3ebaccSStephan Aßmus };
414d3ebaccSStephan Aßmus 
42e65a6eb2SStephan Aßmus 
SettingsWindow(BRect frame)434d3ebaccSStephan Aßmus SettingsWindow::SettingsWindow(BRect frame)
44e65a6eb2SStephan Aßmus  	:
45238df8fbSAdrien Destugues  	BWindow(frame, B_TRANSLATE("MediaPlayer settings"), B_FLOATING_WINDOW_LOOK,
468e542736SDancsó Róbert  		B_FLOATING_ALL_WINDOW_FEEL,
4726e9cdb7SStephan Aßmus  		B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE
4826e9cdb7SStephan Aßmus  			| B_AUTO_UPDATE_SIZE_LIMITS)
494d3ebaccSStephan Aßmus {
50108d2173SHumdinger 	const float kSpacing = be_control_look->DefaultItemSpacing();
51108d2173SHumdinger 
5226e9cdb7SStephan Aßmus 	BBox* settingsBox = new BBox(B_PLAIN_BORDER, NULL);
53108d2173SHumdinger 	BGroupLayout* settingsLayout = new BGroupLayout(B_VERTICAL, kSpacing / 2);
5426e9cdb7SStephan Aßmus 	settingsBox->SetLayout(settingsLayout);
5526e9cdb7SStephan Aßmus 	BBox* buttonBox = new BBox(B_PLAIN_BORDER, NULL);
56108d2173SHumdinger 	BGroupLayout* buttonLayout = new BGroupLayout(B_HORIZONTAL, kSpacing / 2);
5726e9cdb7SStephan Aßmus 	buttonBox->SetLayout(buttonLayout);
5826e9cdb7SStephan Aßmus 
5926e9cdb7SStephan Aßmus 	BStringView* playModeLabel = new BStringView("stringViewPlayMode",
60238df8fbSAdrien Destugues 		B_TRANSLATE("Play mode"));
6126e9cdb7SStephan Aßmus 	BStringView* viewOptionsLabel = new BStringView("stringViewViewOpions",
62238df8fbSAdrien Destugues 		B_TRANSLATE("View options"));
6326e9cdb7SStephan Aßmus 	BStringView* bgMoviesModeLabel = new BStringView("stringViewPlayBackg",
6461698f2dSPhilippe Houdoin 		B_TRANSLATE("Volume of background clips"));
6526e9cdb7SStephan Aßmus 	BAlignment alignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER);
6626e9cdb7SStephan Aßmus 	playModeLabel->SetExplicitAlignment(alignment);
6726e9cdb7SStephan Aßmus 	playModeLabel->SetFont(be_bold_font);
6826e9cdb7SStephan Aßmus 	viewOptionsLabel->SetExplicitAlignment(alignment);
6926e9cdb7SStephan Aßmus 	viewOptionsLabel->SetFont(be_bold_font);
7026e9cdb7SStephan Aßmus 	bgMoviesModeLabel->SetExplicitAlignment(alignment);
7126e9cdb7SStephan Aßmus 	bgMoviesModeLabel->SetFont(be_bold_font);
7226e9cdb7SStephan Aßmus 
7326e9cdb7SStephan Aßmus 	fAutostartCB = new BCheckBox("chkboxAutostart",
74238df8fbSAdrien Destugues 		B_TRANSLATE("Automatically start playing"),
75238df8fbSAdrien Destugues 		new BMessage(M_SETTINGS_CHANGED));
7626e9cdb7SStephan Aßmus 
7726e9cdb7SStephan Aßmus 	fCloseWindowMoviesCB = new BCheckBox("chkBoxCloseWindowMovies",
78329daa44SJoachim Seemer 		B_TRANSLATE("Close window after playing video"),
79e65a6eb2SStephan Aßmus 		new BMessage(M_SETTINGS_CHANGED));
8026e9cdb7SStephan Aßmus 	fCloseWindowSoundsCB = new BCheckBox("chkBoxCloseWindowSounds",
81329daa44SJoachim Seemer 		B_TRANSLATE("Close window after playing audio"),
82e65a6eb2SStephan Aßmus 		new BMessage(M_SETTINGS_CHANGED));
8326e9cdb7SStephan Aßmus 
8426e9cdb7SStephan Aßmus 	fLoopMoviesCB = new BCheckBox("chkBoxLoopMovie",
85329daa44SJoachim Seemer 		B_TRANSLATE("Loop video"),
86238df8fbSAdrien Destugues 		new BMessage(M_SETTINGS_CHANGED));
8726e9cdb7SStephan Aßmus 	fLoopSoundsCB = new BCheckBox("chkBoxLoopSounds",
88329daa44SJoachim Seemer 		B_TRANSLATE("Loop audio"),
89238df8fbSAdrien Destugues 		new BMessage(M_SETTINGS_CHANGED));
9026e9cdb7SStephan Aßmus 
9126e9cdb7SStephan Aßmus 	fUseOverlaysCB = new BCheckBox("chkBoxUseOverlays",
92238df8fbSAdrien Destugues 		B_TRANSLATE("Use hardware video overlays if available"),
93e65a6eb2SStephan Aßmus 		new BMessage(M_SETTINGS_CHANGED));
9426e9cdb7SStephan Aßmus 	fScaleBilinearCB = new BCheckBox("chkBoxScaleBilinear",
95238df8fbSAdrien Destugues 		B_TRANSLATE("Scale movies smoothly (non-overlay mode)"),
96e65a6eb2SStephan Aßmus 		new BMessage(M_SETTINGS_CHANGED));
9726e9cdb7SStephan Aßmus 
98341ea11eSStephan Aßmus 	fScaleFullscreenControlsCB = new BCheckBox("chkBoxScaleControls",
99329daa44SJoachim Seemer 		B_TRANSLATE("Scale controls in full screen mode"),
100e65a6eb2SStephan Aßmus 		new BMessage(M_SETTINGS_CHANGED));
101e65a6eb2SStephan Aßmus 
1023248de3dSJulien Lepiller 	fResumeOP = new BOptionPopUp("resume",
1033248de3dSJulien Lepiller 		B_TRANSLATE("Resume:"), new BMessage(M_SETTINGS_CHANGED));
1043248de3dSJulien Lepiller 	fResumeOP->AddOption(
1053248de3dSJulien Lepiller 		B_TRANSLATE("never"), mpSettings::RESUME_NEVER);
1063248de3dSJulien Lepiller 	fResumeOP->AddOption(
1073248de3dSJulien Lepiller 		B_TRANSLATE("ask every time"), mpSettings::RESUME_ASK);
1083248de3dSJulien Lepiller 	fResumeOP->AddOption(
1093248de3dSJulien Lepiller 		B_TRANSLATE("always"), mpSettings::RESUME_ALWAYS);
1103248de3dSJulien Lepiller 
111e65a6eb2SStephan Aßmus 	fSubtitleSizeOP = new BOptionPopUp("subtitleSize",
11261698f2dSPhilippe Houdoin 		B_TRANSLATE("Subtitle size:"), new BMessage(M_SETTINGS_CHANGED));
113238df8fbSAdrien Destugues 	fSubtitleSizeOP->AddOption(
114238df8fbSAdrien Destugues 		B_TRANSLATE("Small"), mpSettings::SUBTITLE_SIZE_SMALL);
115238df8fbSAdrien Destugues 	fSubtitleSizeOP->AddOption(
116238df8fbSAdrien Destugues 		B_TRANSLATE("Medium"), mpSettings::SUBTITLE_SIZE_MEDIUM);
117238df8fbSAdrien Destugues 	fSubtitleSizeOP->AddOption(
118238df8fbSAdrien Destugues 		B_TRANSLATE("Large"), mpSettings::SUBTITLE_SIZE_LARGE);
119e65a6eb2SStephan Aßmus 
120e65a6eb2SStephan Aßmus 	fSubtitlePlacementOP = new BOptionPopUp("subtitlePlacement",
12161698f2dSPhilippe Houdoin 		B_TRANSLATE("Subtitle placement:"), new BMessage(M_SETTINGS_CHANGED));
122238df8fbSAdrien Destugues 	fSubtitlePlacementOP->AddOption(B_TRANSLATE("Bottom of video"),
123e65a6eb2SStephan Aßmus 		mpSettings::SUBTITLE_PLACEMENT_BOTTOM_OF_VIDEO);
124238df8fbSAdrien Destugues 	fSubtitlePlacementOP->AddOption(B_TRANSLATE("Bottom of screen"),
125e65a6eb2SStephan Aßmus 		mpSettings::SUBTITLE_PLACEMENT_BOTTOM_OF_SCREEN);
126341ea11eSStephan Aßmus 
12726e9cdb7SStephan Aßmus 	fFullVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume",
128238df8fbSAdrien Destugues 		B_TRANSLATE("Full volume"), new BMessage(M_SETTINGS_CHANGED));
12926e9cdb7SStephan Aßmus 
13026e9cdb7SStephan Aßmus 	fHalfVolumeBGMoviesRB = new BRadioButton("rdbtnhalfvolume",
131238df8fbSAdrien Destugues 		B_TRANSLATE("Low volume"), new BMessage(M_SETTINGS_CHANGED));
13226e9cdb7SStephan Aßmus 
13326e9cdb7SStephan Aßmus 	fMutedVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume",
134238df8fbSAdrien Destugues 		B_TRANSLATE("Muted"), new BMessage(M_SETTINGS_CHANGED));
13526e9cdb7SStephan Aßmus 
136238df8fbSAdrien Destugues 	fRevertB = new BButton("revert", B_TRANSLATE("Revert"),
13726e9cdb7SStephan Aßmus 		new BMessage(M_SETTINGS_REVERT));
13826e9cdb7SStephan Aßmus 
139238df8fbSAdrien Destugues 	BButton* cancelButton = new BButton("cancel", B_TRANSLATE("Cancel"),
14026e9cdb7SStephan Aßmus 		new BMessage(M_SETTINGS_CANCEL));
14126e9cdb7SStephan Aßmus 
142238df8fbSAdrien Destugues 	BButton* okButton = new BButton("ok", B_TRANSLATE("OK"),
14326e9cdb7SStephan Aßmus 		new BMessage(M_SETTINGS_SAVE));
14426e9cdb7SStephan Aßmus 	okButton->MakeDefault(true);
14526e9cdb7SStephan Aßmus 
14626e9cdb7SStephan Aßmus 	// Build the layout
1473007aa00SRene Gollent 	BGroupLayout* volumeGroup;
1483007aa00SRene Gollent 	BGroupLayout* startGroup;
1493007aa00SRene Gollent 	BGroupLayout* playGroup;
150*ffa42ceaSCalisto Mathias 	BGroupLayout* controlsGroup;
151*ffa42ceaSCalisto Mathias 
1525dcd3cd1SHannah Boneß 	BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
1535dcd3cd1SHannah Boneß 		.AddGroup(settingsLayout)
154d0ac6099SHumdinger 			.SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING,
155d0ac6099SHumdinger 				B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING)
15626e9cdb7SStephan Aßmus 			.Add(playModeLabel)
1575dcd3cd1SHannah Boneß 			.AddGroup(B_HORIZONTAL, 0)
1583007aa00SRene Gollent 				.GetLayout(&playGroup)
1593007aa00SRene Gollent 				.AddStrut(10)
1605dcd3cd1SHannah Boneß 				.AddGroup(B_VERTICAL, 0)
1613007aa00SRene Gollent 					.GetLayout(&startGroup)
16226e9cdb7SStephan Aßmus 					.Add(fAutostartCB)
163*ffa42ceaSCalisto Mathias 					.AddGroup(B_HORIZONTAL,0)
164*ffa42ceaSCalisto Mathias 						.Add(BSpaceLayoutItem::CreateHorizontalStrut(kSpacing*1.9))
165*ffa42ceaSCalisto Mathias 						.AddGroup(B_VERTICAL,0)
166*ffa42ceaSCalisto Mathias 							.GetLayout(&controlsGroup)
167*ffa42ceaSCalisto Mathias 							.Add(fCloseWindowMoviesCB)
168*ffa42ceaSCalisto Mathias 							.Add(fCloseWindowSoundsCB)
169*ffa42ceaSCalisto Mathias 						.End()
1705dcd3cd1SHannah Boneß 					.End()
17126e9cdb7SStephan Aßmus 					.Add(fLoopMoviesCB)
17226e9cdb7SStephan Aßmus 					.Add(fLoopSoundsCB)
1733248de3dSJulien Lepiller 					.Add(fResumeOP)
1745dcd3cd1SHannah Boneß 				.End()
1755dcd3cd1SHannah Boneß 			.End()
176108d2173SHumdinger 			.AddStrut(kSpacing)
17726e9cdb7SStephan Aßmus 
17826e9cdb7SStephan Aßmus 			.Add(viewOptionsLabel)
1795dcd3cd1SHannah Boneß 			.AddGroup(B_HORIZONTAL, 0)
1805dcd3cd1SHannah Boneß 				.AddStrut(10)
1815dcd3cd1SHannah Boneß 				.AddGroup(B_VERTICAL, 0)
18226e9cdb7SStephan Aßmus 					.Add(fUseOverlaysCB)
18326e9cdb7SStephan Aßmus 					.Add(fScaleBilinearCB)
184341ea11eSStephan Aßmus 					.Add(fScaleFullscreenControlsCB)
185e65a6eb2SStephan Aßmus 					.Add(fSubtitleSizeOP)
186e65a6eb2SStephan Aßmus 					.Add(fSubtitlePlacementOP)
1875dcd3cd1SHannah Boneß 				.End()
1885dcd3cd1SHannah Boneß 			.End()
189108d2173SHumdinger 			.AddStrut(kSpacing)
19026e9cdb7SStephan Aßmus 
19126e9cdb7SStephan Aßmus 			.Add(bgMoviesModeLabel)
1925dcd3cd1SHannah Boneß 			.AddGroup(B_HORIZONTAL, 0)
1935dcd3cd1SHannah Boneß 				.AddStrut(10)
1945dcd3cd1SHannah Boneß 				.AddGroup(B_VERTICAL, 0)
1953007aa00SRene Gollent 					.GetLayout(&volumeGroup)
19626e9cdb7SStephan Aßmus 					.Add(fFullVolumeBGMoviesRB)
19726e9cdb7SStephan Aßmus 					.Add(fHalfVolumeBGMoviesRB)
19826e9cdb7SStephan Aßmus 					.Add(fMutedVolumeBGMoviesRB)
1995dcd3cd1SHannah Boneß 				.End()
2005dcd3cd1SHannah Boneß 			.End()
201108d2173SHumdinger 			.AddStrut(kSpacing)
2025dcd3cd1SHannah Boneß 		.End()
2035dcd3cd1SHannah Boneß 		.AddGroup(buttonLayout)
204d0ac6099SHumdinger 			.SetInsets(B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING,
205d0ac6099SHumdinger 				B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING)
206613ecaf5SStephan Aßmus 			.Add(fRevertB)
20726e9cdb7SStephan Aßmus 			.AddGlue()
20826e9cdb7SStephan Aßmus 			.Add(cancelButton)
2095dcd3cd1SHannah Boneß 			.Add(okButton);
2103007aa00SRene Gollent 
2113007aa00SRene Gollent 	startGroup->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
2123007aa00SRene Gollent 	playGroup->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
2133007aa00SRene Gollent 	volumeGroup->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
214*ffa42ceaSCalisto Mathias 	controlsGroup->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
2154d3ebaccSStephan Aßmus }
2164d3ebaccSStephan Aßmus 
2174d3ebaccSStephan Aßmus 
~SettingsWindow()2184d3ebaccSStephan Aßmus SettingsWindow::~SettingsWindow()
2194d3ebaccSStephan Aßmus {
2204d3ebaccSStephan Aßmus }
2214d3ebaccSStephan Aßmus 
2224d3ebaccSStephan Aßmus 
2234d3ebaccSStephan Aßmus void
Show()22426e9cdb7SStephan Aßmus SettingsWindow::Show()
2254d3ebaccSStephan Aßmus {
226ac6b0fc9SStephan Aßmus 	// The Settings that we want to be able to revert to is the state at which
227ac6b0fc9SStephan Aßmus 	// the SettingsWindow was shown. So the current settings are stored in
228ac6b0fc9SStephan Aßmus 	// fLastSettings.
229a178983dSAxel Dörfler 	Settings::Default()->Get(fLastSettings);
23026e9cdb7SStephan Aßmus 	fSettings = fLastSettings;
23126e9cdb7SStephan Aßmus 	AdoptSettings();
23226e9cdb7SStephan Aßmus 
23326e9cdb7SStephan Aßmus 	BWindow::Show();
2344d3ebaccSStephan Aßmus }
2354d3ebaccSStephan Aßmus 
2364d3ebaccSStephan Aßmus 
2374d3ebaccSStephan Aßmus bool
QuitRequested()2384d3ebaccSStephan Aßmus SettingsWindow::QuitRequested()
2394d3ebaccSStephan Aßmus {
2404d3ebaccSStephan Aßmus 	Hide();
2414d3ebaccSStephan Aßmus 	return false;
2424d3ebaccSStephan Aßmus }
2434d3ebaccSStephan Aßmus 
2444d3ebaccSStephan Aßmus 
2454d3ebaccSStephan Aßmus void
MessageReceived(BMessage * message)2464d3ebaccSStephan Aßmus SettingsWindow::MessageReceived(BMessage* message)
2474d3ebaccSStephan Aßmus {
2484d3ebaccSStephan Aßmus 	switch (message->what) {
249e65a6eb2SStephan Aßmus 		case M_SETTINGS_CHANGED:
25026e9cdb7SStephan Aßmus 			ApplySettings();
25126e9cdb7SStephan Aßmus 			break;
25226e9cdb7SStephan Aßmus 
2534d3ebaccSStephan Aßmus 		case B_KEY_DOWN:
2544d3ebaccSStephan Aßmus 			int32 index;
25526e9cdb7SStephan Aßmus 			if (message->FindInt32("key", &index) == B_OK && index == 1)
2564d3ebaccSStephan Aßmus 				PostMessage(B_QUIT_REQUESTED);
2574d3ebaccSStephan Aßmus 			break;
25826e9cdb7SStephan Aßmus 
25926e9cdb7SStephan Aßmus 		case M_SETTINGS_REVERT:
26026e9cdb7SStephan Aßmus 			Revert();
26126e9cdb7SStephan Aßmus 			break;
26226e9cdb7SStephan Aßmus 
2634d3ebaccSStephan Aßmus 		case M_SETTINGS_CANCEL:
26426e9cdb7SStephan Aßmus 			Revert();
26526e9cdb7SStephan Aßmus 			// fall through
26626e9cdb7SStephan Aßmus 		case M_SETTINGS_SAVE:
2674d3ebaccSStephan Aßmus 			PostMessage(B_QUIT_REQUESTED);
2684d3ebaccSStephan Aßmus 			break;
26926e9cdb7SStephan Aßmus 
2704d3ebaccSStephan Aßmus 		default:
2714d3ebaccSStephan Aßmus 			BWindow::MessageReceived(message);
2724d3ebaccSStephan Aßmus 			break;
2734d3ebaccSStephan Aßmus 	}
2744d3ebaccSStephan Aßmus }
27526e9cdb7SStephan Aßmus 
27626e9cdb7SStephan Aßmus 
27726e9cdb7SStephan Aßmus void
AdoptSettings()27826e9cdb7SStephan Aßmus SettingsWindow::AdoptSettings()
27926e9cdb7SStephan Aßmus {
28026e9cdb7SStephan Aßmus 	fAutostartCB->SetValue(fSettings.autostart);
28126e9cdb7SStephan Aßmus 	fCloseWindowMoviesCB->SetValue(fSettings.closeWhenDonePlayingMovie);
28226e9cdb7SStephan Aßmus 	fCloseWindowSoundsCB->SetValue(fSettings.closeWhenDonePlayingSound);
28326e9cdb7SStephan Aßmus 	fLoopMoviesCB->SetValue(fSettings.loopMovie);
28426e9cdb7SStephan Aßmus 	fLoopSoundsCB->SetValue(fSettings.loopSound);
28526e9cdb7SStephan Aßmus 
28626e9cdb7SStephan Aßmus 	fUseOverlaysCB->SetValue(fSettings.useOverlays);
28726e9cdb7SStephan Aßmus 	fScaleBilinearCB->SetValue(fSettings.scaleBilinear);
288341ea11eSStephan Aßmus 	fScaleFullscreenControlsCB->SetValue(fSettings.scaleFullscreenControls);
28926e9cdb7SStephan Aßmus 
2903248de3dSJulien Lepiller 	fResumeOP->SetValue(fSettings.resume);
291e65a6eb2SStephan Aßmus 	fSubtitleSizeOP->SetValue(fSettings.subtitleSize);
292e65a6eb2SStephan Aßmus 	fSubtitlePlacementOP->SetValue(fSettings.subtitlePlacement);
293e65a6eb2SStephan Aßmus 
29426e9cdb7SStephan Aßmus 	fFullVolumeBGMoviesRB->SetValue(fSettings.backgroundMovieVolumeMode
29526e9cdb7SStephan Aßmus 		== mpSettings::BG_MOVIES_FULL_VOLUME);
29626e9cdb7SStephan Aßmus 	fHalfVolumeBGMoviesRB->SetValue(fSettings.backgroundMovieVolumeMode
29726e9cdb7SStephan Aßmus 		== mpSettings::BG_MOVIES_HALF_VLUME);
29826e9cdb7SStephan Aßmus 	fMutedVolumeBGMoviesRB->SetValue(fSettings.backgroundMovieVolumeMode
29926e9cdb7SStephan Aßmus 		== mpSettings::BG_MOVIES_MUTED);
300613ecaf5SStephan Aßmus 
301613ecaf5SStephan Aßmus 	fRevertB->SetEnabled(IsRevertable());
30226e9cdb7SStephan Aßmus }
30326e9cdb7SStephan Aßmus 
30426e9cdb7SStephan Aßmus 
30526e9cdb7SStephan Aßmus void
ApplySettings()30626e9cdb7SStephan Aßmus SettingsWindow::ApplySettings()
30726e9cdb7SStephan Aßmus {
30826e9cdb7SStephan Aßmus 	fSettings.autostart = fAutostartCB->Value() == B_CONTROL_ON;
30926e9cdb7SStephan Aßmus 	fSettings.closeWhenDonePlayingMovie
31026e9cdb7SStephan Aßmus 		= fCloseWindowMoviesCB->Value() == B_CONTROL_ON;
31126e9cdb7SStephan Aßmus 	fSettings.closeWhenDonePlayingSound
31226e9cdb7SStephan Aßmus 		= fCloseWindowSoundsCB->Value() == B_CONTROL_ON;
31326e9cdb7SStephan Aßmus 	fSettings.loopMovie = fLoopMoviesCB->Value() == B_CONTROL_ON;
31426e9cdb7SStephan Aßmus 	fSettings.loopSound = fLoopSoundsCB->Value() == B_CONTROL_ON;
31526e9cdb7SStephan Aßmus 
31626e9cdb7SStephan Aßmus 	fSettings.useOverlays = fUseOverlaysCB->Value() == B_CONTROL_ON;
31726e9cdb7SStephan Aßmus 	fSettings.scaleBilinear = fScaleBilinearCB->Value() == B_CONTROL_ON;
318341ea11eSStephan Aßmus 	fSettings.scaleFullscreenControls
319341ea11eSStephan Aßmus 		= fScaleFullscreenControlsCB->Value() == B_CONTROL_ON;
32026e9cdb7SStephan Aßmus 
3213248de3dSJulien Lepiller 	fSettings.resume = fResumeOP->Value();
322e65a6eb2SStephan Aßmus 	fSettings.subtitleSize = fSubtitleSizeOP->Value();
323e65a6eb2SStephan Aßmus 	fSettings.subtitlePlacement = fSubtitlePlacementOP->Value();
324e65a6eb2SStephan Aßmus 
32526e9cdb7SStephan Aßmus 	if (fFullVolumeBGMoviesRB->Value() == B_CONTROL_ON) {
32626e9cdb7SStephan Aßmus 		fSettings.backgroundMovieVolumeMode
32726e9cdb7SStephan Aßmus 			= mpSettings::BG_MOVIES_FULL_VOLUME;
32826e9cdb7SStephan Aßmus 	} else if (fHalfVolumeBGMoviesRB->Value() == B_CONTROL_ON) {
32926e9cdb7SStephan Aßmus 		fSettings.backgroundMovieVolumeMode
33026e9cdb7SStephan Aßmus 			= mpSettings::BG_MOVIES_HALF_VLUME;
33126e9cdb7SStephan Aßmus 	} else if (fMutedVolumeBGMoviesRB->Value() == B_CONTROL_ON) {
33226e9cdb7SStephan Aßmus 		fSettings.backgroundMovieVolumeMode
33326e9cdb7SStephan Aßmus 			= mpSettings::BG_MOVIES_MUTED;
33426e9cdb7SStephan Aßmus 	}
33526e9cdb7SStephan Aßmus 
336a178983dSAxel Dörfler 	Settings::Default()->Update(fSettings);
337613ecaf5SStephan Aßmus 
338613ecaf5SStephan Aßmus 	fRevertB->SetEnabled(IsRevertable());
33926e9cdb7SStephan Aßmus }
34026e9cdb7SStephan Aßmus 
34126e9cdb7SStephan Aßmus 
34226e9cdb7SStephan Aßmus void
Revert()34326e9cdb7SStephan Aßmus SettingsWindow::Revert()
34426e9cdb7SStephan Aßmus {
34526e9cdb7SStephan Aßmus 	fSettings = fLastSettings;
34626e9cdb7SStephan Aßmus 	AdoptSettings();
347a178983dSAxel Dörfler 	Settings::Default()->Update(fSettings);
34826e9cdb7SStephan Aßmus }
34926e9cdb7SStephan Aßmus 
350613ecaf5SStephan Aßmus 
351613ecaf5SStephan Aßmus bool
IsRevertable() const352613ecaf5SStephan Aßmus SettingsWindow::IsRevertable() const
353613ecaf5SStephan Aßmus {
354613ecaf5SStephan Aßmus 	return fSettings != fLastSettings;
355613ecaf5SStephan Aßmus }
356613ecaf5SStephan Aßmus 
357