Added a "defaults" button to options dialog.

Originally committed to SVN as r1092.
This commit is contained in:
Rodrigo Braz Monteiro 2007-04-18 04:03:22 +00:00
parent 0c7b674e55
commit 9dcb9d7884
4 changed files with 42 additions and 27 deletions

View file

@ -61,6 +61,14 @@
#include "browse_button.h"
///////
// IDs
enum {
BUTTON_DEFAULTS = 2500,
HOTKEY_LIST
};
///////////////
// Constructor
DialogOptions::DialogOptions(wxWindow *parent)
@ -351,7 +359,7 @@ DialogOptions::DialogOptions(wxWindow *parent)
wxControl *control;
// First sizer
videoSizer3->Add(new wxStaticText(videoPage,-1,_("Check video resolution on open: ")),0,wxALIGN_CENTER_VERTICAL | wxRIGHT,10);
videoSizer3->Add(new wxStaticText(videoPage,-1,_("Match video resolution on open: ")),0,wxALIGN_CENTER_VERTICAL | wxRIGHT,10);
wxString choices1[3] = { _("Never"), _("Ask"), _("Always") };
control = new wxComboBox(videoPage,-1,_T(""),wxDefaultPosition,wxDefaultSize,3,choices1,wxCB_READONLY | wxCB_DROPDOWN);
Bind(control,_T("Video check script res"));
@ -626,7 +634,7 @@ DialogOptions::DialogOptions(wxWindow *parent)
wxStaticText *text = new wxStaticText(hotkeysPage,-1,_("List of all hotkeys (shortcuts) available in Aegisub.\nDouble click on any item to reassign it."),wxDefaultPosition,wxSize(150,-1));
// List of shortcuts
Shortcuts = new wxListView(hotkeysPage,Hotkey_List,wxDefaultPosition,wxSize(250,150),wxLC_REPORT | wxLC_SINGLE_SEL);
Shortcuts = new wxListView(hotkeysPage,HOTKEY_LIST,wxDefaultPosition,wxSize(250,150),wxLC_REPORT | wxLC_SINGLE_SEL);
Shortcuts->InsertColumn(0,_("Function"),wxLIST_FORMAT_LEFT,200);
Shortcuts->InsertColumn(1,_("Key"),wxLIST_FORMAT_LEFT,120);
@ -663,12 +671,12 @@ DialogOptions::DialogOptions(wxWindow *parent)
#endif
// Buttons Sizer
//wxStdDialogButtonSizer *buttonSizer = static_cast<wxStdDialogButtonSizer*>(CreateButtonSizer(wxOK|wxCANCEL));
wxStdDialogButtonSizer *buttonSizer = new wxStdDialogButtonSizer();
buttonSizer->AddButton(new wxButton(this,wxID_OK));
buttonSizer->AddButton(new wxButton(this,wxID_CANCEL));
buttonSizer->AddButton(new wxButton(this,wxID_APPLY));
buttonSizer->Realize();
wxSizer *buttonSizer = new wxBoxSizer(wxHORIZONTAL);
buttonSizer->Add(new wxButton(this,BUTTON_DEFAULTS,_("Defaults")),0);
buttonSizer->AddStretchSpacer(1);
buttonSizer->Add(new wxButton(this,wxID_OK),0,wxRIGHT,5);
buttonSizer->Add(new wxButton(this,wxID_CANCEL),0,wxRIGHT,5);
buttonSizer->Add(new wxButton(this,wxID_APPLY),0);
// Main Sizer
wxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
@ -706,7 +714,8 @@ BEGIN_EVENT_TABLE(DialogOptions,wxDialog)
EVT_BUTTON(wxID_OK,DialogOptions::OnOK)
EVT_BUTTON(wxID_CANCEL,DialogOptions::OnCancel)
EVT_BUTTON(wxID_APPLY,DialogOptions::OnApply)
EVT_LIST_ITEM_ACTIVATED (Hotkey_List,DialogOptions::OnEditHotkey)
EVT_BUTTON(BUTTON_DEFAULTS,DialogOptions::OnDefaults)
EVT_LIST_ITEM_ACTIVATED (HOTKEY_LIST,DialogOptions::OnEditHotkey)
END_EVENT_TABLE()
@ -758,6 +767,17 @@ void DialogOptions::OnCancel(wxCommandEvent &event) {
}
////////////////////
// Restore defaults
void DialogOptions::OnDefaults(wxCommandEvent &event) {
int result = wxMessageBox(_("Are you sure that you want to restore the defaults? All your settings will be overriden."),_("Restore defaults?"),wxYES_NO);
if (result == wxYES) {
Options.LoadDefaults(true);
Options.Save();
ReadFromOptions();
}
}
////////////////////
// Write to options

View file

@ -90,6 +90,7 @@ private:
void OnOK(wxCommandEvent &event);
void OnCancel(wxCommandEvent &event);
void OnApply(wxCommandEvent &event);
void OnDefaults(wxCommandEvent &event);
void OnEditHotkey(wxListEvent &event);
public:
@ -127,10 +128,3 @@ private:
public:
DialogInputHotkey(HotkeyType *key,wxString name);
};
///////
// IDs
enum {
Hotkey_List = 2500
};

View file

@ -73,7 +73,7 @@ void OptionsManager::Clear() {
///////////////////////
// Load default values
void OptionsManager::LoadDefaults() {
void OptionsManager::LoadDefaults(bool onlyDefaults) {
///// PUBLIC //////
// Here go the options that can be edited by the options menu
@ -139,15 +139,6 @@ void OptionsManager::LoadDefaults() {
SetModificationType(MOD_VIDEO);
SetBool(_T("Show keyframes on video slider"),true);
// Dummy video defaults
SetModificationType(MOD_AUTOMATIC);
SetInt(_T("Video Dummy Last Width"), 640);
SetInt(_T("Video Dummy Last Height"), 480);
SetColour(_T("Video Dummy Last Colour"), wxColour(47, 163, 254));
SetFloat(_T("Video Dummy Last FPS"), 23.976);
SetInt(_T("Video Dummy Last Length"), 40000);
SetBool(_T("Video Dummy Pattern"), false);
// Video Provider (Advanced)
SetModificationType(MOD_VIDEO_RELOAD);
SetInt(_T("Avisynth MemoryMax"),64);
@ -264,9 +255,19 @@ void OptionsManager::LoadDefaults() {
SetModificationType(MOD_OFF);
// Only defaults?
if (onlyDefaults) return;
///// INTERNAL //////
// Options that are set by the program itself
SetInt(_T("Video Dummy Last Width"), 640);
SetInt(_T("Video Dummy Last Height"), 480);
SetColour(_T("Video Dummy Last Colour"), wxColour(47, 163, 254));
SetFloat(_T("Video Dummy Last FPS"), 23.976);
SetInt(_T("Video Dummy Last Length"), 40000);
SetBool(_T("Video Dummy Pattern"), false);
SetInt(_T("Locale Code"),-1);
SetBool(_T("Sync video with subs"),true);
SetText(_T("Spell checker language"),_T("en_US"));

View file

@ -79,7 +79,7 @@ public:
void SetFile(wxString file);
void Save();
void Load();
void LoadDefaults();
void LoadDefaults(bool onlyDefaults=false);
void AddToRecentList (wxString entry,wxString list);
wxArrayString GetRecentList (wxString list);