Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

Commit

Permalink
Save state of "show original"
Browse files Browse the repository at this point in the history
  • Loading branch information
wangqr committed May 18, 2020
1 parent b854fef commit 8ae50e9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/libresrc/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@
"Syntax" : true
},
"Provider" : "libass",
"Show Original": false,
"Time Edit" : {
"Insert Mode" : true
}
Expand Down
21 changes: 17 additions & 4 deletions src/subs_edit_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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()));
}

Expand Down
1 change: 1 addition & 0 deletions src/subs_edit_box.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 8ae50e9

Please sign in to comment.