From a7aca18675a5d76b1281d055c1c0c027b8d90f81 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sun, 5 Mar 2006 20:42:38 +0000 Subject: [PATCH] Applied some Pomyk patches Originally committed to SVN as r209. --- core/automation_gui.cpp | 9 ++++- core/changelog.txt | 5 +++ core/dialog_search_replace.cpp | 70 +++++++++++++++++++++++++--------- core/dialog_search_replace.h | 9 ++++- core/frame_main_events.cpp | 20 +++++++--- core/options.cpp | 6 +++ core/subs_edit_box.cpp | 8 +++- 7 files changed, 99 insertions(+), 28 deletions(-) diff --git a/core/automation_gui.cpp b/core/automation_gui.cpp index af2717953..5b28b7c37 100644 --- a/core/automation_gui.cpp +++ b/core/automation_gui.cpp @@ -116,8 +116,11 @@ END_EVENT_TABLE() void DialogAutomationManager::OnCreate(wxCommandEvent &event) { - wxString sfnames = wxFileSelector(_("Create Automation script"), _T(""), _T("*.lua"), _T("lua"), _T("Automation Lua scripts (*.lua)|*.lua|All files (*.*)|*.*"), wxSAVE|wxOVERWRITE_PROMPT, this); + wxString path = Options.AsText(_T("Last open automation path")); + wxString sfnames = wxFileSelector(_("Create Automation script"), path, _T("*.lua"), _T("lua"), _T("Automation Lua scripts (*.lua)|*.lua|All files (*.*)|*.*"), wxSAVE|wxOVERWRITE_PROMPT, this); if (sfnames.empty()) return; + Options.SetText(_T("Last open automation path"), sfnames); + wxFileName sfname(sfnames); if (sfname.FileExists()) { @@ -162,8 +165,10 @@ void DialogAutomationManager::OnCreate(wxCommandEvent &event) void DialogAutomationManager::OnAdd(wxCommandEvent &event) { - wxString sfnames = wxFileSelector(_("Load Automation script"), _T(""), _T("*.lua"), _T("lua"), _T("Automation Lua scripts (*.lua)|*.lua|All files (*.*)|*.*"), wxOPEN|wxFILE_MUST_EXIST, this); + wxString path = Options.AsText(_T("Last open automation path")); + wxString sfnames = wxFileSelector(_("Load Automation script"), path, _T("*.lua"), _T("lua"), _T("Automation Lua scripts (*.lua)|*.lua|All files (*.*)|*.*"), wxOPEN|wxFILE_MUST_EXIST, this); if (sfnames.empty()) return; + Options.SetText(_T("Last open automation path"), sfnames); try { AutomationScriptFile *sfile = AutomationScriptFile::CreateFromFile(sfnames); diff --git a/core/changelog.txt b/core/changelog.txt index e8676a3c4..a7ba62713 100644 --- a/core/changelog.txt +++ b/core/changelog.txt @@ -57,6 +57,11 @@ Please visit http://aegisub.net to download latest version - Added option ("keep raw dialogue data", default false) that makes Aegisub use less RAM at a small performance cost when set to false. (AMZ) - The line timing extending in timing post-processor is now governed by the "timing processor adjascent bias" option (1.0 [default] = move end, 0.0 = move start, 0.5 = move to halfway point, etc) (AMZ) - Middle clicking the video seek bar and audio display will now focus them. (AMZ) +- Search and Replace dialogue made modeless. (Pomyk) +- Fixed bug related to moving elements up and down in File Export dialog. (Pomyk) +- Scrollbar and sliders in audio box can no longer receive focus. (Pomyk) +- Select lines dialog now has an option on how to deal with comment lines. (Pomyk) +- Last folder for all the file selection dialogs are now remembered in config.dat. (Pomyk) = 1.09 beta - 2006.01.16 =========================== diff --git a/core/dialog_search_replace.cpp b/core/dialog_search_replace.cpp index 6df385685..e73f64268 100644 --- a/core/dialog_search_replace.cpp +++ b/core/dialog_search_replace.cpp @@ -45,7 +45,8 @@ #include "options.h" #include "subs_edit_box.h" #include "video_display.h" - +#include "frame_main.h" +#include "main.h" /////////////// // Constructor @@ -79,7 +80,7 @@ DialogSearchReplace::DialogSearchReplace (wxWindow *parent,bool _hasReplace,wxSt CheckRegExp->SetValue(Options.AsBool(_T("Find RegExp"))); //CheckRegExp->Enable(false); CheckUpdateVideo->SetValue(Options.AsBool(_T("Find Update Video"))); - CheckUpdateVideo->Enable(Search.grid->video->loaded); +// CheckUpdateVideo->Enable(Search.grid->video->loaded); OptionsSizer->Add(CheckMatchCase,0,wxBOTTOM,5); OptionsSizer->Add(CheckRegExp,0,wxBOTTOM,5); OptionsSizer->Add(CheckUpdateVideo,0,wxBOTTOM,0); @@ -133,14 +134,23 @@ DialogSearchReplace::DialogSearchReplace (wxWindow *parent,bool _hasReplace,wxSt // Destructor DialogSearchReplace::~DialogSearchReplace() { // Save options + UpdateSettings(); +} + + +///////////////// +// Update search +void DialogSearchReplace::UpdateSettings() { + Search.isReg = CheckRegExp->IsChecked() && CheckRegExp->IsEnabled(); + Search.matchCase = CheckMatchCase->IsChecked(); + Search.updateVideo = CheckUpdateVideo->IsChecked() && CheckUpdateVideo->IsEnabled(); Options.SetBool(_T("Find Match Case"),CheckMatchCase->IsChecked()); Options.SetBool(_T("Find RegExp"),CheckRegExp->IsChecked()); Options.SetBool(_T("Find Update Video"),CheckUpdateVideo->IsChecked()); Options.SetInt(_T("Find Field"),Field->GetSelection()); Options.SetInt(_T("Find Affect"),Affect->GetSelection()); Options.Save(); -} - +} /////////////// // Event table @@ -149,21 +159,17 @@ BEGIN_EVENT_TABLE(DialogSearchReplace,wxDialog) EVT_BUTTON(BUTTON_FIND_NEXT,DialogSearchReplace::OnFindNext) EVT_BUTTON(BUTTON_REPLACE_NEXT,DialogSearchReplace::OnReplaceNext) EVT_BUTTON(BUTTON_REPLACE_ALL,DialogSearchReplace::OnReplaceAll) + EVT_SET_FOCUS(DialogSearchReplace::OnSetFocus) + EVT_KILL_FOCUS(DialogSearchReplace::OnKillFocus) END_EVENT_TABLE() - + ///////// // Close void DialogSearchReplace::OnClose (wxCommandEvent &event) { - // Update search - Search.isReg = CheckRegExp->IsChecked() && CheckRegExp->IsEnabled(); - Search.matchCase = CheckMatchCase->IsChecked(); - Search.updateVideo = CheckUpdateVideo->IsChecked() && CheckUpdateVideo->IsEnabled(); Search.OnDialogClose(); - - // Close - if (IsModal()) EndModal(0); - else Destroy(); + // Just hide + Show(false); } @@ -183,6 +189,12 @@ void DialogSearchReplace::OnFindNext (wxCommandEvent &event) { Search.affect = Affect->GetSelection(); Search.field = Field->GetSelection(); Search.FindNext(); + + if (hasReplace) { + wxString ReplaceWith = ReplaceEdit->GetValue(); + Search.ReplaceWith = ReplaceWith; + Options.AddToRecentList(ReplaceWith,_T("Recent replace")); + } // Add to history Options.AddToRecentList(LookFor,_T("Recent find")); @@ -261,6 +273,15 @@ void DialogSearchReplace::UpdateDropDowns() { } +void DialogSearchReplace::OnSetFocus (wxFocusEvent &event) { + Search.hasFocus = true; +} + +void DialogSearchReplace::OnKillFocus (wxFocusEvent &event) { + Search.hasFocus = false; +} + + /////////////////////// SearchReplaceEngine /////////////////////// /////////////// // Constructor @@ -500,11 +521,24 @@ void SearchReplaceEngine::OnDialogClose() { /////////////// // Open dialog void SearchReplaceEngine::OpenDialog (bool replace) { - DialogSearchReplace *diag; - if (replace) diag = new DialogSearchReplace(NULL,true,_("Replace")); - else diag = new DialogSearchReplace(NULL,false,_("Find")); - diag->ShowModal(); - delete diag; + static DialogSearchReplace *diag = NULL; + wxString title = replace? _("Replace") : _("Find"); + + // already opened + if (diag) { + // it's the right type so give focus + if(replace == hasReplace) { + diag->Show(); + diag->SetFocus(); // is needed? + return; + } + // wrong type - destroy and create the right one + diag->Destroy(); + } + // create new one + diag = new DialogSearchReplace(((AegisubApp*)wxTheApp)->frame,replace,title); + diag->Show(); + hasReplace = replace; } diff --git a/core/dialog_search_replace.h b/core/dialog_search_replace.h index 204a8162e..8d8a983f7 100644 --- a/core/dialog_search_replace.h +++ b/core/dialog_search_replace.h @@ -57,15 +57,17 @@ private: size_t replaceLen; bool Modified; bool LastWasFind; + bool hasReplace; wxString *GetText(int n,int field); - + public: SubtitlesGrid *grid; bool isReg; bool matchCase; bool updateVideo; bool CanContinue; + bool hasFocus; int field; int affect; wxString LookFor; @@ -79,6 +81,7 @@ public: void OnDialogClose(); SearchReplaceEngine(); + friend class DialogSearchReplace; }; // Instance @@ -103,11 +106,13 @@ private: void OnFindNext (wxCommandEvent &event); void OnReplaceNext (wxCommandEvent &event); void OnReplaceAll (wxCommandEvent &event); + void OnSetFocus (wxFocusEvent &event); + void OnKillFocus (wxFocusEvent &event); void UpdateDropDowns(); - public: DialogSearchReplace(wxWindow *parent,bool hasReplace,wxString name); ~DialogSearchReplace(); + void UpdateSettings(); DECLARE_EVENT_TABLE() }; diff --git a/core/frame_main_events.cpp b/core/frame_main_events.cpp index c20ce62fa..943494664 100644 --- a/core/frame_main_events.cpp +++ b/core/frame_main_events.cpp @@ -467,9 +467,11 @@ void FrameMain::OnSaveProjectAs(wxCommandEvent& WXUNUSED(event)) { ////////////// // Open video void FrameMain::OnOpenVideo(wxCommandEvent& WXUNUSED(event)) { - wxString filename = wxFileSelector(_("Open video file"),_T(""),_T(""),_T(""),_T("Recommended Formats (*.avi,*.avs,*.d2v)|*.avi;*.avs;*.d2v|Other supported formats (*.mkv,*.ogm,*.mp4,*.mpeg,*.mpg,*.vob)|*.mkv;*.ogm;*.mp4;*.mpeg;*.mpg;*.vob|All Files (*.*)|*.*"),wxOPEN | wxFILE_MUST_EXIST); + wxString path = Options.AsText(_T("Last open video path")); + wxString filename = wxFileSelector(_("Open video file"),path,_T(""),_T(""),_T("Recommended Formats (*.avi,*.avs,*.d2v)|*.avi;*.avs;*.d2v|Other supported formats (*.mkv,*.ogm,*.mp4,*.mpeg,*.mpg,*.vob)|*.mkv;*.ogm;*.mp4;*.mpeg;*.mpg;*.vob|All Files (*.*)|*.*"),wxOPEN | wxFILE_MUST_EXIST); if (!filename.empty()) { LoadVideo(filename); + Options.SetText(_T("Last open video path"), filename); } } @@ -484,9 +486,11 @@ void FrameMain::OnCloseVideo(wxCommandEvent& WXUNUSED(event)) { ////////////// // Open Audio void FrameMain::OnOpenAudio (wxCommandEvent& WXUNUSED(event)) { - wxString filename = wxFileSelector(_("Open audio file"),_T(""),_T(""),_T(""),_T("Audio Formats (*.wav,*.mp3,*.ogg,*.flac,*.mp4,*.ac3,*.aac,*.mka)|*.wav;*.mp3;*.ogg;*.flac;*.mp4;*.ac3;*.aac;*.mka|All files (*.*)|*.*"),wxOPEN | wxFILE_MUST_EXIST); + wxString path = Options.AsText(_T("Last open audio path")); + wxString filename = wxFileSelector(_("Open audio file"),path,_T(""),_T(""),_T("Audio Formats (*.wav,*.mp3,*.ogg,*.flac,*.mp4,*.ac3,*.aac,*.mka)|*.wav;*.mp3;*.ogg;*.flac;*.mp4;*.ac3;*.aac;*.mka|All files (*.*)|*.*"),wxOPEN | wxFILE_MUST_EXIST); if (!filename.empty()) { LoadAudio(filename); + Options.SetText(_T("Last open audio path"), filename); } } @@ -504,9 +508,11 @@ void FrameMain::OnCloseAudio (wxCommandEvent& WXUNUSED(event)) { ////////////////// // Open subtitles void FrameMain::OnOpenSubtitles(wxCommandEvent& WXUNUSED(event)) { - wxString filename = wxFileSelector(_("Open subtitles file"),_T(""),_T(""),_T(""),_T("All Supported Types (*.ass,*.ssa,*.srt,*.txt)|*.ass;*.ssa;*.srt;*.txt|Advanced Substation Alpha (*.ass)|*.ass|Substation Alpha (*.ssa)|*.ssa|SubRip (*.srt)|*.srt|Plain-text (*.txt)|*.txt"),wxOPEN | wxFILE_MUST_EXIST); + wxString path = Options.AsText(_T("Last open subtitles path")); + wxString filename = wxFileSelector(_("Open subtitles file"),path,_T(""),_T(""),_T("All Supported Types (*.ass,*.ssa,*.srt,*.txt)|*.ass;*.ssa;*.srt;*.txt|Advanced Substation Alpha (*.ass)|*.ass|Substation Alpha (*.ssa)|*.ssa|SubRip (*.srt)|*.srt|Plain-text (*.txt)|*.txt"),wxOPEN | wxFILE_MUST_EXIST); if (!filename.empty()) { LoadSubtitles(filename); + Options.SetText(_T("Last open subtitles path"), filename); } } @@ -516,14 +522,16 @@ void FrameMain::OnOpenSubtitles(wxCommandEvent& WXUNUSED(event)) { void FrameMain::OnOpenSubtitlesCharset(wxCommandEvent& WXUNUSED(event)) { // Initialize charsets wxArrayString choices = GetEncodings(); + wxString path = Options.AsText(_T("Last open subtitles path")); // Get options and load - wxString filename = wxFileSelector(_("Open subtitles file"),_T(""),_T(""),_T(""),_T("All Supported Types (*.ass,*.ssa,*.srt,*.txt)|*.ass;*.ssa;*.srt;*.txt|Advanced Substation Alpha (*.ass)|*.ass|Substation Alpha (*.ssa)|*.ssa|SubRip (*.srt)|*.srt|Plain-text (*.txt)|*.txt"),wxOPEN | wxFILE_MUST_EXIST); + wxString filename = wxFileSelector(_("Open subtitles file"),path,_T(""),_T(""),_T("All Supported Types (*.ass,*.ssa,*.srt,*.txt)|*.ass;*.ssa;*.srt;*.txt|Advanced Substation Alpha (*.ass)|*.ass|Substation Alpha (*.ssa)|*.ssa|SubRip (*.srt)|*.srt|Plain-text (*.txt)|*.txt"),wxOPEN | wxFILE_MUST_EXIST); if (!filename.empty()) { wxString charset = wxGetSingleChoice(_("Choose charset code:"), _("Charset"),choices,this,-1, -1,true,250,200); if (!charset.empty()) { LoadSubtitles(filename,charset); } + Options.SetText(_T("Last open subtitles path"), filename); } } @@ -571,9 +579,11 @@ void FrameMain::OnExportSubtitles(wxCommandEvent & WXUNUSED(event)) { ///////////////// // Open VFR tags void FrameMain::OnOpenVFR(wxCommandEvent &event) { - wxString filename = wxFileSelector(_("Open timecodes file"),_T(""),_T(""),_T(""),_T("All Supported Types (*.txt)|*.txt|All Files (*.*)|*.*"),wxOPEN | wxFILE_MUST_EXIST); + wxString path = Options.AsText(_T("Last open timecodes path")); + wxString filename = wxFileSelector(_("Open timecodes file"),path,_T(""),_T(""),_T("All Supported Types (*.txt)|*.txt|All Files (*.*)|*.*"),wxOPEN | wxFILE_MUST_EXIST); if (!filename.empty()) { LoadVFR(filename); + Options.SetText(_T("Last open timecodes path"), filename); } } diff --git a/core/options.cpp b/core/options.cpp index c6d9bfd57..0b57a39f7 100644 --- a/core/options.cpp +++ b/core/options.cpp @@ -232,6 +232,12 @@ void OptionsManager::LoadDefaults() { SetText(_T("Color Picker Recent"), _T("&H000000& &H0000FF& &H00FFFF& &H00FF00& &HFFFF00& &HFF0000& &HFF00FF& &HFFFFFF&")); SetInt(_T("Color Picker Mode"), 4); + + SetText(_T("Last open subtitles path"),_T("")); + SetText(_T("Last open video path"),_T("")); + SetText(_T("Last open audio path"),_T("")); + SetText(_T("Last open timecodes path"),_T("")); + SetText(_T("Last open automation path"),_T("")); } diff --git a/core/subs_edit_box.cpp b/core/subs_edit_box.cpp index fb0d52937..3580eaa58 100644 --- a/core/subs_edit_box.cpp +++ b/core/subs_edit_box.cpp @@ -55,6 +55,8 @@ #include "main.h" #include "frame_main.h" #include "utils.h" +#include "dialog_search_replace.h" + /////////////// @@ -275,7 +277,11 @@ void SubsEditBox::SetToLine(int n) { // Set video if (video->loaded) { - if (Options.AsBool(_T("Sync video with subs")) == true) { + wxString sync; + if (Search.hasFocus) sync = _T("Find update video"); + else sync = _T("Sync video with subs"); + + if (Options.AsBool(sync) == true) { video->Stop(); AssDialogue *cur = grid->GetDialogue(n); if (cur) video->JumpToFrame(VFR_Output.GetFrameAtTime(cur->Start.GetMS(),true));