Remove the "update video" box from the find dialog

It hasn't worked for a few years and doesn't really make any sense with
how committing works now.
This commit is contained in:
Thomas Goyne 2013-01-10 20:45:59 -08:00
parent 76d93f0036
commit 4334514c78
5 changed files with 23 additions and 65 deletions

View File

@ -34,6 +34,20 @@
#include "config.h" #include "config.h"
#include "dialog_search_replace.h"
#include "ass_dialogue.h"
#include "ass_file.h"
#include "compat.h"
#include "include/aegisub/context.h"
#include "options.h"
#include "selection_controller.h"
#include "text_selection_controller.h"
#include "subs_grid.h"
#include "utils.h"
#include <libaegisub/of_type_adaptor.h>
#include <functional> #include <functional>
#include <wx/button.h> #include <wx/button.h>
@ -43,21 +57,6 @@
#include <wx/stattext.h> #include <wx/stattext.h>
#include <wx/string.h> #include <wx/string.h>
#include "ass_dialogue.h"
#include "ass_file.h"
#include "command/command.h"
#include "compat.h"
#include "dialog_search_replace.h"
#include "include/aegisub/context.h"
#include "options.h"
#include "selection_controller.h"
#include "text_selection_controller.h"
#include "subs_edit_ctrl.h"
#include "subs_grid.h"
#include "video_context.h"
#include <libaegisub/of_type_adaptor.h>
enum { enum {
BUTTON_FIND_NEXT, BUTTON_FIND_NEXT,
BUTTON_REPLACE_NEXT, BUTTON_REPLACE_NEXT,
@ -88,26 +87,16 @@ DialogSearchReplace::DialogSearchReplace(agi::Context* c, bool withReplace)
wxSizer *OptionsSizer = new wxBoxSizer(wxVERTICAL); wxSizer *OptionsSizer = new wxBoxSizer(wxVERTICAL);
CheckMatchCase = new wxCheckBox(this,CHECK_MATCH_CASE,_("&Match case")); CheckMatchCase = new wxCheckBox(this,CHECK_MATCH_CASE,_("&Match case"));
CheckRegExp = new wxCheckBox(this,CHECK_MATCH_CASE,_("&Use regular expressions")); CheckRegExp = new wxCheckBox(this,CHECK_MATCH_CASE,_("&Use regular expressions"));
CheckUpdateVideo = new wxCheckBox(this,CHECK_UPDATE_VIDEO,_("Update &Video"));
CheckMatchCase->SetValue(OPT_GET("Tool/Search Replace/Match Case")->GetBool()); CheckMatchCase->SetValue(OPT_GET("Tool/Search Replace/Match Case")->GetBool());
CheckRegExp->SetValue(OPT_GET("Tool/Search Replace/RegExp")->GetBool()); CheckRegExp->SetValue(OPT_GET("Tool/Search Replace/RegExp")->GetBool());
CheckUpdateVideo->SetValue(OPT_GET("Tool/Search Replace/Video Update")->GetBool());
CheckUpdateVideo->Enable(c->videoController->IsLoaded());
OptionsSizer->Add(CheckMatchCase,0,wxBOTTOM,5); OptionsSizer->Add(CheckMatchCase,0,wxBOTTOM,5);
OptionsSizer->Add(CheckRegExp,0,wxBOTTOM,5); OptionsSizer->Add(CheckRegExp,0,wxBOTTOM,5);
OptionsSizer->Add(CheckUpdateVideo,0,wxBOTTOM,0);
// Limits sizer // Limits sizer
wxArrayString field; wxString field[] = { _("Text"), _("Style"), _("Actor"), _("Effect") };
field.Add(_("Text")); wxString affect[] = { _("All rows"), _("Selected rows") };
field.Add(_("Style")); Field = new wxRadioBox(this,-1,_("In Field"),wxDefaultPosition,wxDefaultSize,countof(field), field);
field.Add(_("Actor")); Affect = new wxRadioBox(this,-1,_("Limit to"),wxDefaultPosition,wxDefaultSize,countof(affect), affect);
field.Add(_("Effect"));
wxArrayString affect;
affect.Add(_("All rows"));
affect.Add(_("Selected rows"));
Field = new wxRadioBox(this,-1,_("In Field"),wxDefaultPosition,wxDefaultSize,field);
Affect = new wxRadioBox(this,-1,_("Limit to"),wxDefaultPosition,wxDefaultSize,affect);
wxSizer *LimitSizer = new wxBoxSizer(wxHORIZONTAL); wxSizer *LimitSizer = new wxBoxSizer(wxHORIZONTAL);
LimitSizer->Add(Field,1,wxEXPAND | wxRIGHT,5); LimitSizer->Add(Field,1,wxEXPAND | wxRIGHT,5);
LimitSizer->Add(Affect,0,wxEXPAND | wxRIGHT,0); LimitSizer->Add(Affect,0,wxEXPAND | wxRIGHT,0);
@ -154,10 +143,8 @@ DialogSearchReplace::~DialogSearchReplace() {
void DialogSearchReplace::UpdateSettings() { void DialogSearchReplace::UpdateSettings() {
Search.isReg = CheckRegExp->IsChecked() && CheckRegExp->IsEnabled(); Search.isReg = CheckRegExp->IsChecked() && CheckRegExp->IsEnabled();
Search.matchCase = CheckMatchCase->IsChecked(); Search.matchCase = CheckMatchCase->IsChecked();
Search.updateVideo = CheckUpdateVideo->IsChecked() && CheckUpdateVideo->IsEnabled();
OPT_SET("Tool/Search Replace/Match Case")->SetBool(CheckMatchCase->IsChecked()); OPT_SET("Tool/Search Replace/Match Case")->SetBool(CheckMatchCase->IsChecked());
OPT_SET("Tool/Search Replace/RegExp")->SetBool(CheckRegExp->IsChecked()); OPT_SET("Tool/Search Replace/RegExp")->SetBool(CheckRegExp->IsChecked());
OPT_SET("Tool/Search Replace/Video Update")->SetBool(CheckUpdateVideo->IsChecked());
OPT_SET("Tool/Search Replace/Field")->SetInt(Field->GetSelection()); OPT_SET("Tool/Search Replace/Field")->SetInt(Field->GetSelection());
OPT_SET("Tool/Search Replace/Affect")->SetInt(Affect->GetSelection()); OPT_SET("Tool/Search Replace/Affect")->SetInt(Affect->GetSelection());
} }
@ -172,7 +159,6 @@ void DialogSearchReplace::FindReplace(int mode) {
// Setup // Setup
Search.isReg = CheckRegExp->IsChecked() && CheckRegExp->IsEnabled(); Search.isReg = CheckRegExp->IsChecked() && CheckRegExp->IsEnabled();
Search.matchCase = CheckMatchCase->IsChecked(); Search.matchCase = CheckMatchCase->IsChecked();
Search.updateVideo = CheckUpdateVideo->IsChecked() && CheckUpdateVideo->IsEnabled();
Search.LookFor = LookFor; Search.LookFor = LookFor;
Search.CanContinue = true; Search.CanContinue = true;
Search.affect = Affect->GetSelection(); Search.affect = Affect->GetSelection();
@ -225,12 +211,10 @@ SearchReplaceEngine::SearchReplaceEngine()
, pos(0) , pos(0)
, matchLen(0) , matchLen(0)
, replaceLen(0) , replaceLen(0)
, Modified(0)
, LastWasFind(true) , LastWasFind(true)
, hasReplace(false) , hasReplace(false)
, isReg(false) , isReg(false)
, matchCase(false) , matchCase(false)
, updateVideo(false)
, CanContinue(false) , CanContinue(false)
, hasFocus(false) , hasFocus(false)
, field(0) , field(0)
@ -263,7 +247,6 @@ void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
// if selection has changed reset values // if selection has changed reset values
if (firstLine != curLine) { if (firstLine != curLine) {
curLine = firstLine; curLine = firstLine;
Modified = false;
LastWasFind = true; LastWasFind = true;
pos = 0; pos = 0;
matchLen = 0; matchLen = 0;
@ -328,9 +311,9 @@ void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
// Found // Found
if (found) { if (found) {
// If replacing if (!DoReplace)
if (DoReplace) { replaceLen = matchLen;
// Replace with regular expressions else {
if (isReg) { if (isReg) {
wxString toReplace = Text->get().Mid(pos,matchLen); wxString toReplace = Text->get().Mid(pos,matchLen);
wxRegEx regex(LookFor,regFlags); wxRegEx regex(LookFor,regFlags);
@ -338,22 +321,14 @@ void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
*Text = Text->get().Left(pos) + toReplace + Text->get().Mid(pos+matchLen); *Text = Text->get().Left(pos) + toReplace + Text->get().Mid(pos+matchLen);
replaceLen = toReplace.Length(); replaceLen = toReplace.Length();
} }
// Normal replace
else { else {
*Text = Text->get().Left(pos) + ReplaceWith + Text->get().Mid(pos+matchLen); *Text = Text->get().Left(pos) + ReplaceWith + Text->get().Mid(pos+matchLen);
replaceLen = ReplaceWith.Length(); replaceLen = ReplaceWith.Length();
} }
// Commit
context->ass->Commit(_("replace"), AssFile::COMMIT_DIAG_TEXT); context->ass->Commit(_("replace"), AssFile::COMMIT_DIAG_TEXT);
} }
else {
replaceLen = matchLen;
}
// Select
context->subsGrid->SelectRow(curLine,false); context->subsGrid->SelectRow(curLine,false);
context->subsGrid->MakeCellVisible(curLine,0); context->subsGrid->MakeCellVisible(curLine,0);
if (field == 0) { if (field == 0) {
@ -361,19 +336,12 @@ void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
context->textSelectionController->SetSelection(pos, pos + replaceLen); context->textSelectionController->SetSelection(pos, pos + replaceLen);
} }
// Update video
if (updateVideo) {
cmd::call("video/jump/start", context);
}
else if (DoReplace) Modified = true;
// hAx to prevent double match on style/actor // hAx to prevent double match on style/actor
if (field != 0) replaceLen = 99999; if (field != 0) replaceLen = 99999;
} }
LastWasFind = !DoReplace; LastWasFind = !DoReplace;
} }
/// @brief Replace all instances
void SearchReplaceEngine::ReplaceAll() { void SearchReplaceEngine::ReplaceAll() {
size_t count = 0; size_t count = 0;
@ -457,7 +425,6 @@ void SearchReplaceEngine::OnDialogOpen() {
if (sels.Count() > 0) curLine = sels[0]; if (sels.Count() > 0) curLine = sels[0];
// Reset values // Reset values
Modified = false;
LastWasFind = true; LastWasFind = true;
pos = 0; pos = 0;
matchLen = 0; matchLen = 0;

View File

@ -46,12 +46,10 @@ class SearchReplaceEngine {
size_t pos; size_t pos;
size_t matchLen; size_t matchLen;
size_t replaceLen; size_t replaceLen;
bool Modified;
bool LastWasFind; bool LastWasFind;
bool hasReplace; bool hasReplace;
bool isReg; bool isReg;
bool matchCase; bool matchCase;
bool updateVideo;
bool CanContinue; bool CanContinue;
bool hasFocus; bool hasFocus;
int field; int field;

View File

@ -463,7 +463,6 @@
"Field" : 0, "Field" : 0,
"Match Case" : false, "Match Case" : false,
"RegExp" : false, "RegExp" : false,
"Video Update" : false
}, },
"Select Lines" : { "Select Lines" : {
"Action" : 0, "Action" : 0,

View File

@ -463,7 +463,6 @@
"Field" : 0, "Field" : 0,
"Match Case" : false, "Match Case" : false,
"RegExp" : false, "RegExp" : false,
"Video Update" : false
}, },
"Select Lines" : { "Select Lines" : {
"Action" : 0, "Action" : 0,

View File

@ -53,7 +53,6 @@
#include "ass_file.h" #include "ass_file.h"
#include "command/command.h" #include "command/command.h"
#include "compat.h" #include "compat.h"
#include "dialog_search_replace.h"
#include "include/aegisub/context.h" #include "include/aegisub/context.h"
#include "include/aegisub/hotkey.h" #include "include/aegisub/hotkey.h"
#include "libresrc/libresrc.h" #include "libresrc/libresrc.h"
@ -345,11 +344,7 @@ void SubsEditBox::OnActiveLineChanged(AssDialogue *new_line) {
/// @todo VideoContext should be doing this /// @todo VideoContext should be doing this
if (c->videoController->IsLoaded()) { if (c->videoController->IsLoaded()) {
bool sync; if (OPT_GET("Video/Subtitle Sync")->GetBool()) {
if (Search.HasFocus()) sync = OPT_GET("Tool/Search Replace/Video Update")->GetBool();
else sync = OPT_GET("Video/Subtitle Sync")->GetBool();
if (sync) {
c->videoController->Stop(); c->videoController->Stop();
c->videoController->JumpToTime(line->Start); c->videoController->JumpToTime(line->Start);
} }