Remember the last used file panel folder. Also remember the folder even
if the user cancled the file panel. Some improvements to the SettingsMessage and some more helpful comments here and there. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27986 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
43450d12d7
commit
ac6b0fc9d2
@ -33,6 +33,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "EventQueue.h"
|
||||
#include "Settings.h"
|
||||
#include "SettingsWindow.h"
|
||||
|
||||
|
||||
@ -56,6 +57,8 @@ MainApp::MainApp()
|
||||
fMediaServerRunning(false),
|
||||
fMediaAddOnServerRunning(false)
|
||||
{
|
||||
mpSettings settings = Settings::CurrentSettings();
|
||||
fLastFilePanelFolder = settings.filePanelFolder;
|
||||
}
|
||||
|
||||
|
||||
@ -76,6 +79,11 @@ MainApp::QuitRequested()
|
||||
fSettingsWindow->Quit();
|
||||
fSettingsWindow = NULL;
|
||||
|
||||
// store the current file panel ref in the global settings
|
||||
mpSettings settings = Settings::CurrentSettings();
|
||||
settings.filePanelFolder = fLastFilePanelFolder;
|
||||
Settings::Default()->SaveSettings(settings);
|
||||
|
||||
return BApplication::QuitRequested();
|
||||
}
|
||||
|
||||
@ -260,6 +268,18 @@ MainApp::MessageReceived(BMessage* message)
|
||||
case M_SAVE_PANEL_RESULT:
|
||||
_HandleSavePanelResult(message);
|
||||
break;
|
||||
case B_CANCEL: {
|
||||
// The user canceled a file panel, but store at least the current
|
||||
// file panel folder.
|
||||
uint32 oldWhat;
|
||||
if (message->FindInt32("old_what", (int32*)&oldWhat) != B_OK)
|
||||
break;
|
||||
if (oldWhat == M_OPEN_PANEL_RESULT && fOpenFilePanel != NULL)
|
||||
fOpenFilePanel->GetPanelDirectory(&fLastFilePanelFolder);
|
||||
else if (oldWhat == M_SAVE_PANEL_RESULT && fSaveFilePanel != NULL)
|
||||
fSaveFilePanel->GetPanelDirectory(&fLastFilePanelFolder);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BApplication::MessageReceived(message);
|
||||
|
@ -21,14 +21,16 @@ mpSettings::operator!=(const mpSettings& other) const
|
||||
|| loopSound != other.loopSound
|
||||
|| useOverlays != other.useOverlays
|
||||
|| scaleBilinear != other.scaleBilinear
|
||||
|| backgroundMovieVolumeMode != other.backgroundMovieVolumeMode;
|
||||
|| backgroundMovieVolumeMode != other.backgroundMovieVolumeMode
|
||||
|| filePanelFolder != other.filePanelFolder;
|
||||
}
|
||||
|
||||
|
||||
Settings::Settings(const char* filename)
|
||||
: BLocker("settings lock"),
|
||||
fSettingsMessage(B_USER_CONFIG_DIRECTORY, filename)
|
||||
fSettingsMessage(B_USER_SETTINGS_DIRECTORY, filename)
|
||||
{
|
||||
// The settings are loaded from disk in the SettingsMessage constructor.
|
||||
}
|
||||
|
||||
|
||||
@ -51,6 +53,11 @@ Settings::LoadSettings(mpSettings& settings) const
|
||||
settings.backgroundMovieVolumeMode
|
||||
= fSettingsMessage.GetValue("bgMovieVolumeMode",
|
||||
(uint32)mpSettings::BG_MOVIES_FULL_VOLUME);
|
||||
|
||||
entry_ref defaultFilePanelFolder;
|
||||
// an "unset" entry_ref
|
||||
settings.filePanelFolder = fSettingsMessage.GetValue(
|
||||
"filePanelDirectory", defaultFilePanelFolder);
|
||||
}
|
||||
|
||||
|
||||
@ -73,6 +80,9 @@ Settings::SaveSettings(const mpSettings& settings)
|
||||
fSettingsMessage.SetValue("bgMovieVolumeMode",
|
||||
settings.backgroundMovieVolumeMode);
|
||||
|
||||
fSettingsMessage.SetValue("filePanelDirectory",
|
||||
settings.filePanelFolder);
|
||||
|
||||
// Save at this point, although saving is also done on destruction,
|
||||
// this will make sure the settings are saved even when the player
|
||||
// crashes.
|
||||
|
@ -9,30 +9,32 @@
|
||||
#ifndef SETTINGS_H
|
||||
#define SETTINGS_H
|
||||
|
||||
#include <Entry.h>
|
||||
#include <Locker.h>
|
||||
|
||||
#include "Notifier.h"
|
||||
#include "SettingsMessage.h"
|
||||
|
||||
struct mpSettings {
|
||||
bool autostart;
|
||||
bool closeWhenDonePlayingMovie;
|
||||
bool closeWhenDonePlayingSound;
|
||||
bool loopMovie;
|
||||
bool loopSound;
|
||||
bool useOverlays;
|
||||
bool scaleBilinear;
|
||||
enum {
|
||||
BG_MOVIES_FULL_VOLUME = 0,
|
||||
BG_MOVIES_HALF_VLUME = 1,
|
||||
BG_MOVIES_MUTED = 2
|
||||
};
|
||||
uint32 backgroundMovieVolumeMode;
|
||||
|
||||
bool operator!=(const mpSettings& other) const;
|
||||
bool autostart;
|
||||
bool closeWhenDonePlayingMovie;
|
||||
bool closeWhenDonePlayingSound;
|
||||
bool loopMovie;
|
||||
bool loopSound;
|
||||
bool useOverlays;
|
||||
bool scaleBilinear;
|
||||
enum {
|
||||
BG_MOVIES_FULL_VOLUME = 0,
|
||||
BG_MOVIES_HALF_VLUME = 1,
|
||||
BG_MOVIES_MUTED = 2
|
||||
};
|
||||
uint32 backgroundMovieVolumeMode;
|
||||
entry_ref filePanelFolder;
|
||||
|
||||
bool operator!=(const mpSettings& other) const;
|
||||
};
|
||||
|
||||
#define SETTINGS_FILENAME "MediaPlayerSettings"
|
||||
#define SETTINGS_FILENAME "MediaPlayer"
|
||||
|
||||
class Settings : public BLocker, public Notifier {
|
||||
public:
|
||||
|
@ -276,6 +276,9 @@ SettingsWindow::~SettingsWindow()
|
||||
void
|
||||
SettingsWindow::Show()
|
||||
{
|
||||
// The Settings that we want to be able to revert to is the state at which
|
||||
// the SettingsWindow was shown. So the current settings are stored in
|
||||
// fLastSettings.
|
||||
Settings::Default()->LoadSettings(fLastSettings);
|
||||
fSettings = fLastSettings;
|
||||
AdoptSettings();
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "SettingsMessage.h"
|
||||
|
||||
#include <Entry.h>
|
||||
#include <File.h>
|
||||
#include <String.h>
|
||||
|
||||
@ -158,7 +159,7 @@ SettingsMessage::SetValue(const char* name, const BString& value)
|
||||
|
||||
|
||||
status_t
|
||||
SettingsMessage::SetValue(const char* name, BPoint value)
|
||||
SettingsMessage::SetValue(const char* name, const BPoint& value)
|
||||
{
|
||||
if (ReplacePoint(name, value) == B_OK)
|
||||
return B_OK;
|
||||
@ -167,7 +168,7 @@ SettingsMessage::SetValue(const char* name, BPoint value)
|
||||
|
||||
|
||||
status_t
|
||||
SettingsMessage::SetValue(const char* name, BRect value)
|
||||
SettingsMessage::SetValue(const char* name, const BRect& value)
|
||||
{
|
||||
if (ReplaceRect(name, value) == B_OK)
|
||||
return B_OK;
|
||||
@ -175,6 +176,15 @@ SettingsMessage::SetValue(const char* name, BRect value)
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
SettingsMessage::SetValue(const char* name, const entry_ref& value)
|
||||
{
|
||||
if (ReplaceRef(name, &value) == B_OK)
|
||||
return B_OK;
|
||||
return AddRef(name, &value);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
SettingsMessage::SetValue(const char* name, const BMessage* value)
|
||||
{
|
||||
@ -305,6 +315,16 @@ SettingsMessage::GetValue(const char* name, BRect defaultValue) const
|
||||
}
|
||||
|
||||
|
||||
entry_ref
|
||||
SettingsMessage::GetValue(const char* name, const entry_ref& defaultValue) const
|
||||
{
|
||||
entry_ref value;
|
||||
if (FindRef(name, &value) != B_OK)
|
||||
return defaultValue;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
BMessage
|
||||
SettingsMessage::GetValue(const char* name, const BMessage& defaultValue) const
|
||||
{
|
||||
|
@ -36,8 +36,9 @@ public:
|
||||
const char* value);
|
||||
status_t SetValue(const char* name,
|
||||
const BString& value);
|
||||
status_t SetValue(const char *name, BPoint value);
|
||||
status_t SetValue(const char* name, BRect value);
|
||||
status_t SetValue(const char *name, const BPoint& value);
|
||||
status_t SetValue(const char* name, const BRect& value);
|
||||
status_t SetValue(const char* name, const entry_ref& value);
|
||||
status_t SetValue(const char* name,
|
||||
const BMessage* value);
|
||||
status_t SetValue(const char* name,
|
||||
@ -65,6 +66,8 @@ public:
|
||||
BPoint defaultValue) const;
|
||||
BRect GetValue(const char* name,
|
||||
BRect defaultValue) const;
|
||||
entry_ref GetValue(const char* name,
|
||||
const entry_ref& defaultValue) const;
|
||||
BMessage GetValue(const char* name,
|
||||
const BMessage& defaultValue) const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user