Save state of "show original"

Fix wangqr/Aegisub#41
This commit is contained in:
wangqr 2020-05-17 23:36:52 -04:00
parent 5e71125825
commit 333f928019
3 changed files with 19 additions and 4 deletions

View File

@ -390,6 +390,7 @@
"Syntax" : true
},
"Provider" : "libass",
"Show Original": false,
"Time Edit" : {
"Insert Mode" : true
}

View File

@ -258,6 +258,12 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context)
context->textSelectionController->SetControl(edit_ctrl);
edit_ctrl->SetFocus();
bool show_original = OPT_GET("Subtitle/Show Original")->GetBool();
if (show_original) {
split_box->SetValue(true);
DoOnSplit(true);
}
}
SubsEditBox::~SubsEditBox() {
@ -604,15 +610,22 @@ void SubsEditBox::SetControlsState(bool state) {
}
void SubsEditBox::OnSplit(wxCommandEvent&) {
bool show_original = split_box->IsChecked();
DoOnSplit(show_original);
OPT_SET("Subtitle/Show Original")->SetBool(show_original);
}
void SubsEditBox::DoOnSplit(bool show_original) {
Freeze();
GetSizer()->Show(secondary_editor, split_box->IsChecked());
GetSizer()->Show(bottom_sizer, split_box->IsChecked());
GetSizer()->Show(secondary_editor, show_original);
GetSizer()->Show(bottom_sizer, show_original);
Fit();
SetMinSize(GetSize());
GetParent()->GetSizer()->Layout();
wxSizer* parent_sizer = GetParent()->GetSizer();
if (parent_sizer) parent_sizer->Layout();
Thaw();
if (split_box->IsChecked())
if (show_original)
secondary_editor->SetValue(to_wx(c->initialLineState->GetInitialText()));
}

View File

@ -152,6 +152,7 @@ class SubsEditBox final : public wxPanel {
void OnEffectChange(wxCommandEvent &);
void OnSize(wxSizeEvent &event);
void OnSplit(wxCommandEvent&);
void DoOnSplit(bool show_original);
void SetPlaceholderCtrl(wxControl *ctrl, wxString const& value);