2011-07-27 07:36:15 +02:00
|
|
|
// Copyright (c) 2011, Thomas Goyne <plorkyeran@aegisub.org>
|
2006-01-16 22:02:54 +01:00
|
|
|
//
|
2011-07-27 07:36:15 +02:00
|
|
|
// Permission to use, copy, modify, and distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice appear in all copies.
|
2006-01-16 22:02:54 +01:00
|
|
|
//
|
2011-07-27 07:36:15 +02:00
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
2006-01-16 22:02:54 +01:00
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
|
|
|
|
|
|
|
/// @file dialog_translation.cpp
|
|
|
|
/// @brief Translation Assistant dialogue box and logic
|
|
|
|
/// @ingroup tools_ui
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
#include "dialog_translation.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
|
2011-01-16 08:17:08 +01:00
|
|
|
#include "include/aegisub/context.h"
|
2011-01-05 19:40:37 +01:00
|
|
|
#include "include/aegisub/hotkey.h"
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
#include "ass_dialogue.h"
|
|
|
|
#include "ass_file.h"
|
2011-07-27 07:36:15 +02:00
|
|
|
#include "command/command.h"
|
2011-12-26 23:21:19 +01:00
|
|
|
#include "compat.h"
|
2014-05-29 17:28:37 +02:00
|
|
|
#include "format.h"
|
2008-01-13 23:25:26 +01:00
|
|
|
#include "help_button.h"
|
2009-07-24 02:08:25 +02:00
|
|
|
#include "libresrc/libresrc.h"
|
2018-03-27 21:07:37 +02:00
|
|
|
#include "options.h"
|
2011-07-27 07:36:15 +02:00
|
|
|
#include "persist_location.h"
|
2014-05-22 01:23:28 +02:00
|
|
|
#include "project.h"
|
2012-03-13 00:34:45 +01:00
|
|
|
#include "subs_edit_ctrl.h"
|
2010-12-08 04:36:10 +01:00
|
|
|
#include "selection_controller.h"
|
2014-05-22 01:23:28 +02:00
|
|
|
#include "video_controller.h"
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2014-04-23 22:53:24 +02:00
|
|
|
#include <libaegisub/make_unique.h>
|
2013-06-10 15:58:13 +02:00
|
|
|
|
2012-12-30 00:53:56 +01:00
|
|
|
#include <boost/algorithm/string/classification.hpp>
|
|
|
|
#include <boost/algorithm/string/predicate.hpp>
|
2014-05-30 21:39:39 +02:00
|
|
|
#include <boost/algorithm/string/replace.hpp>
|
2012-12-30 00:53:56 +01:00
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
#include <wx/checkbox.h>
|
2011-07-27 19:21:39 +02:00
|
|
|
#include <wx/msgdlg.h>
|
|
|
|
#include <wx/sizer.h>
|
2011-07-27 07:36:15 +02:00
|
|
|
#include <wx/settings.h>
|
|
|
|
#include <wx/stattext.h>
|
2014-05-30 21:39:39 +02:00
|
|
|
#include <wx/stc/stc.h>
|
2011-07-27 07:36:15 +02:00
|
|
|
|
2012-03-13 00:35:20 +01:00
|
|
|
static void add_hotkey(wxSizer *sizer, wxWindow *parent, const char *command, wxString const& text) {
|
|
|
|
sizer->Add(new wxStaticText(parent, -1, text));
|
2013-01-04 16:01:50 +01:00
|
|
|
sizer->Add(new wxStaticText(parent, -1, to_wx(hotkey::get_hotkey_str_first("Translation Assistant", command))));
|
2011-07-27 07:36:15 +02:00
|
|
|
}
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2011-12-26 23:21:14 +01:00
|
|
|
// Skip over override blocks, comments, and whitespace between blocks
|
2014-04-14 19:58:46 +02:00
|
|
|
static bool bad_block(std::unique_ptr<AssDialogueBlock> &block) {
|
2018-03-27 21:07:37 +02:00
|
|
|
bool is_whitespace = boost::all(block->GetText(), boost::is_space());
|
|
|
|
return block->GetType() != AssBlockType::PLAIN || (is_whitespace && OPT_GET("Tool/Translation Assistant/Skip Whitespace")->GetBool());
|
2011-12-26 23:21:14 +01:00
|
|
|
}
|
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
DialogTranslation::DialogTranslation(agi::Context *c)
|
2012-03-13 00:34:45 +01:00
|
|
|
: wxDialog(c->parent, -1, _("Translation Assistant"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX)
|
2011-07-27 07:36:15 +02:00
|
|
|
, c(c)
|
2012-03-13 00:34:54 +01:00
|
|
|
, file_change_connection(c->ass->AddCommitListener(&DialogTranslation::OnExternalCommit, this))
|
2012-10-05 05:22:54 +02:00
|
|
|
, active_line_connection(c->selectionController->AddActiveLineListener(&DialogTranslation::OnActiveLineChanged, this))
|
2011-07-27 07:36:15 +02:00
|
|
|
, active_line(c->selectionController->GetActiveLine())
|
2014-03-07 18:02:24 +01:00
|
|
|
, line_count(c->ass->Events.size())
|
2006-01-16 22:02:54 +01:00
|
|
|
{
|
2012-04-03 22:40:24 +02:00
|
|
|
SetIcon(GETICON(translation_toolbutton_16));
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
wxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
wxSizer *translation_sizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
{
|
|
|
|
wxSizer *original_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Original"));
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
line_number_display = new wxStaticText(this, -1, "");
|
|
|
|
original_box->Add(line_number_display, 0, wxBOTTOM, 5);
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2014-05-30 21:39:39 +02:00
|
|
|
original_text = new wxStyledTextCtrl(this, -1, wxDefaultPosition, wxSize(320, 80));
|
2011-07-27 07:36:15 +02:00
|
|
|
original_text->SetWrapMode(wxSTC_WRAP_WORD);
|
|
|
|
original_text->SetMarginWidth(1, 0);
|
|
|
|
original_text->StyleSetForeground(1, wxColour(10, 60, 200));
|
|
|
|
original_text->SetReadOnly(true);
|
|
|
|
original_box->Add(original_text, 1, wxEXPAND, 0);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
translation_sizer->Add(original_box, 1, wxEXPAND, 0);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
{
|
2013-11-21 18:13:36 +01:00
|
|
|
translated_text = new SubsTextEditCtrl(this, wxSize(320, 80), 0, nullptr);
|
2011-07-27 07:36:15 +02:00
|
|
|
translated_text->SetWrapMode(wxSTC_WRAP_WORD);
|
|
|
|
translated_text->SetMarginWidth(1, 0);
|
|
|
|
translated_text->SetFocus();
|
2012-04-27 21:07:49 +02:00
|
|
|
translated_text->Bind(wxEVT_CHAR_HOOK, &DialogTranslation::OnKeyDown, this);
|
2014-01-11 16:47:19 +01:00
|
|
|
translated_text->CmdKeyAssign(wxSTC_KEY_RETURN, wxSTC_SCMOD_SHIFT, wxSTC_CMD_NEWLINE);
|
2011-07-27 07:36:15 +02:00
|
|
|
|
|
|
|
wxSizer *translated_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Translation"));
|
|
|
|
translated_box->Add(translated_text, 1, wxEXPAND, 0);
|
|
|
|
translation_sizer->Add(translated_box, 1, wxTOP|wxEXPAND, 5);
|
|
|
|
}
|
|
|
|
main_sizer->Add(translation_sizer, 1, wxALL | wxEXPAND, 5);
|
|
|
|
|
|
|
|
wxSizer *right_box = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
{
|
|
|
|
wxSizer *hotkey_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Keys"));
|
|
|
|
|
|
|
|
wxSizer *hotkey_grid = new wxGridSizer(2, 0, 5);
|
2012-03-13 00:35:20 +01:00
|
|
|
add_hotkey(hotkey_grid, this, "tool/translation_assistant/commit", _("Accept changes"));
|
|
|
|
add_hotkey(hotkey_grid, this, "tool/translation_assistant/preview", _("Preview changes"));
|
|
|
|
add_hotkey(hotkey_grid, this, "tool/translation_assistant/prev", _("Previous line"));
|
|
|
|
add_hotkey(hotkey_grid, this, "tool/translation_assistant/next", _("Next line"));
|
|
|
|
add_hotkey(hotkey_grid, this, "tool/translation_assistant/insert_original", _("Insert original"));
|
|
|
|
add_hotkey(hotkey_grid, this, "video/play/line", _("Play video"));
|
|
|
|
add_hotkey(hotkey_grid, this, "audio/play/selection", _("Play audio"));
|
|
|
|
add_hotkey(hotkey_grid, this, "edit/line/delete", _("Delete line"));
|
2011-07-27 07:36:15 +02:00
|
|
|
hotkey_box->Add(hotkey_grid, 0, wxEXPAND, 0);
|
|
|
|
|
2011-11-18 19:49:09 +01:00
|
|
|
seek_video = new wxCheckBox(this, -1, _("Enable &preview"));
|
2011-07-27 07:36:15 +02:00
|
|
|
seek_video->SetValue(true);
|
|
|
|
hotkey_box->Add(seek_video, 0, wxTOP, 5);
|
|
|
|
|
|
|
|
right_box->Add(hotkey_box, 1, wxRIGHT | wxEXPAND, 5);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
{
|
|
|
|
wxStaticBoxSizer *actions_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Actions"));
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2011-11-18 19:49:09 +01:00
|
|
|
wxButton *play_audio = new wxButton(this, -1, _("Play &Audio"));
|
2014-05-22 01:23:28 +02:00
|
|
|
play_audio->Enable(!!c->project->AudioProvider());
|
2013-12-12 03:25:13 +01:00
|
|
|
play_audio->Bind(wxEVT_BUTTON, &DialogTranslation::OnPlayAudioButton, this);
|
2011-07-27 07:36:15 +02:00
|
|
|
actions_box->Add(play_audio, 0, wxALL, 5);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2011-11-18 19:49:09 +01:00
|
|
|
wxButton *play_video = new wxButton(this, -1, _("Play &Video"));
|
2014-05-22 01:23:28 +02:00
|
|
|
play_video->Enable(!!c->project->VideoProvider());
|
2013-12-12 03:25:13 +01:00
|
|
|
play_video->Bind(wxEVT_BUTTON, &DialogTranslation::OnPlayVideoButton, this);
|
2011-07-27 07:36:15 +02:00
|
|
|
actions_box->Add(play_video, 0, wxLEFT | wxRIGHT | wxBOTTOM, 5);
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
right_box->Add(actions_box, 0);
|
|
|
|
}
|
|
|
|
main_sizer->Add(right_box, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, 5);
|
|
|
|
|
|
|
|
{
|
2013-11-21 18:13:36 +01:00
|
|
|
auto standard_buttons = new wxStdDialogButtonSizer();
|
2011-07-27 07:36:15 +02:00
|
|
|
standard_buttons->AddButton(new wxButton(this, wxID_CANCEL));
|
|
|
|
standard_buttons->AddButton(new HelpButton(this, "Translation Assistant"));
|
|
|
|
standard_buttons->Realize();
|
|
|
|
main_sizer->Add(standard_buttons, 0, wxALIGN_RIGHT | wxLEFT | wxBOTTOM | wxRIGHT, 5);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2011-12-26 23:21:14 +01:00
|
|
|
SetSizerAndFit(main_sizer);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2014-04-23 22:53:24 +02:00
|
|
|
persist = agi::make_unique<PersistLocation>(this, "Tool/Translation Assistant");
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
Bind(wxEVT_KEY_DOWN, &DialogTranslation::OnKeyDown, this);
|
2011-12-26 23:21:14 +01:00
|
|
|
|
2012-12-02 19:24:49 +01:00
|
|
|
blocks = active_line->ParseTags();
|
|
|
|
if (bad_block(blocks[0])) {
|
2011-12-26 23:21:19 +01:00
|
|
|
if (!NextBlock())
|
2014-06-11 00:12:12 +02:00
|
|
|
throw NothingToTranslate();
|
2011-12-26 23:21:19 +01:00
|
|
|
}
|
2011-12-26 23:21:14 +01:00
|
|
|
else
|
|
|
|
UpdateDisplay();
|
2012-03-13 00:34:54 +01:00
|
|
|
}
|
|
|
|
|
2014-05-30 21:39:39 +02:00
|
|
|
DialogTranslation::~DialogTranslation() { }
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2012-03-13 00:34:54 +01:00
|
|
|
void DialogTranslation::OnActiveLineChanged(AssDialogue *new_line) {
|
|
|
|
if (switching_lines) return;
|
|
|
|
|
|
|
|
active_line = new_line;
|
2012-12-02 19:24:49 +01:00
|
|
|
blocks = active_line->ParseTags();
|
2012-03-13 00:34:54 +01:00
|
|
|
cur_block = 0;
|
|
|
|
|
2012-12-02 19:24:49 +01:00
|
|
|
if (bad_block(blocks[cur_block]) && !NextBlock()) {
|
2012-03-13 00:34:54 +01:00
|
|
|
wxMessageBox(_("No more lines to translate."));
|
|
|
|
EndModal(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DialogTranslation::OnExternalCommit(int commit_type) {
|
|
|
|
if (commit_type == AssFile::COMMIT_NEW || commit_type & AssFile::COMMIT_DIAG_ADDREM) {
|
2014-03-07 18:02:24 +01:00
|
|
|
line_count = c->ass->Events.size();
|
2014-05-29 17:28:37 +02:00
|
|
|
line_number_display->SetLabel(fmt_tl("Current line: %d/%d", active_line->Row + 1, line_count));
|
2012-03-13 00:34:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (commit_type & AssFile::COMMIT_DIAG_TEXT)
|
|
|
|
OnActiveLineChanged(active_line);
|
|
|
|
}
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
bool DialogTranslation::NextBlock() {
|
2012-03-13 00:34:54 +01:00
|
|
|
switching_lines = true;
|
2011-07-27 07:36:15 +02:00
|
|
|
do {
|
2012-12-02 19:24:49 +01:00
|
|
|
if (cur_block == blocks.size() - 1) {
|
2011-07-27 07:36:15 +02:00
|
|
|
c->selectionController->NextLine();
|
|
|
|
AssDialogue *new_line = c->selectionController->GetActiveLine();
|
|
|
|
if (active_line == new_line || !new_line) return false;
|
|
|
|
|
|
|
|
active_line = new_line;
|
2012-12-02 19:24:49 +01:00
|
|
|
blocks = active_line->ParseTags();
|
2011-07-27 07:36:15 +02:00
|
|
|
cur_block = 0;
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
2011-07-27 07:36:15 +02:00
|
|
|
else
|
|
|
|
++cur_block;
|
2012-12-02 19:24:49 +01:00
|
|
|
} while (bad_block(blocks[cur_block]));
|
2012-03-13 00:34:54 +01:00
|
|
|
switching_lines = false;
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
UpdateDisplay();
|
|
|
|
return true;
|
|
|
|
}
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
bool DialogTranslation::PrevBlock() {
|
2012-03-13 00:34:54 +01:00
|
|
|
switching_lines = true;
|
2011-07-27 07:36:15 +02:00
|
|
|
do {
|
|
|
|
if (cur_block == 0) {
|
|
|
|
c->selectionController->PrevLine();
|
|
|
|
AssDialogue *new_line = c->selectionController->GetActiveLine();
|
|
|
|
if (active_line == new_line || !new_line) return false;
|
|
|
|
|
|
|
|
active_line = new_line;
|
2012-12-02 19:24:49 +01:00
|
|
|
blocks = active_line->ParseTags();
|
|
|
|
cur_block = blocks.size() - 1;
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
2011-07-27 07:36:15 +02:00
|
|
|
else
|
|
|
|
--cur_block;
|
2012-12-02 19:24:49 +01:00
|
|
|
} while (bad_block(blocks[cur_block]));
|
2012-03-13 00:34:54 +01:00
|
|
|
switching_lines = false;
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
UpdateDisplay();
|
|
|
|
return true;
|
|
|
|
}
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
void DialogTranslation::UpdateDisplay() {
|
2014-05-29 17:28:37 +02:00
|
|
|
line_number_display->SetLabel(fmt_tl("Current line: %d/%d", active_line->Row, line_count));
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
original_text->SetReadOnly(false);
|
|
|
|
original_text->ClearAll();
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2012-11-04 04:53:03 +01:00
|
|
|
size_t i = 0;
|
2012-12-02 19:24:49 +01:00
|
|
|
for (auto& block : blocks) {
|
2014-04-14 19:58:46 +02:00
|
|
|
if (block->GetType() == AssBlockType::PLAIN) {
|
2013-07-12 05:18:41 +02:00
|
|
|
int initial_pos = original_text->GetLength();
|
2014-04-14 19:58:46 +02:00
|
|
|
original_text->AppendTextRaw(block->GetText().c_str());
|
2011-07-27 07:36:15 +02:00
|
|
|
if (i == cur_block) {
|
2020-11-22 19:17:19 +01:00
|
|
|
#if wxVERSION_NUMBER >= 3100
|
|
|
|
original_text->StartStyling(initial_pos);
|
|
|
|
#else
|
|
|
|
original_text->StartStyling(initial_pos, 255);
|
|
|
|
#endif
|
2014-05-30 21:39:39 +02:00
|
|
|
original_text->SetStyling(block->GetText().size(), 1);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
}
|
2012-12-30 18:04:43 +01:00
|
|
|
else
|
2014-04-14 19:58:46 +02:00
|
|
|
original_text->AppendTextRaw(block->GetText().c_str());
|
2012-11-04 04:53:03 +01:00
|
|
|
++i;
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
original_text->SetReadOnly(true);
|
2007-07-16 05:17:11 +02:00
|
|
|
|
2011-12-22 22:28:51 +01:00
|
|
|
if (seek_video->IsChecked()) c->videoController->JumpToTime(active_line->Start);
|
2008-03-07 00:21:03 +01:00
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
translated_text->ClearAll();
|
|
|
|
translated_text->SetFocus();
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
void DialogTranslation::Commit(bool next) {
|
2014-05-30 21:39:39 +02:00
|
|
|
std::string new_value = translated_text->GetTextRaw().data();
|
|
|
|
boost::replace_all(new_value, "\r\n", "\\N");
|
|
|
|
boost::replace_all(new_value, "\r", "\\N");
|
|
|
|
boost::replace_all(new_value, "\n", "\\N");
|
|
|
|
*blocks[cur_block] = AssDialogueBlockPlain(new_value);
|
2012-12-02 19:24:49 +01:00
|
|
|
active_line->UpdateText(blocks);
|
2012-03-13 00:34:54 +01:00
|
|
|
|
|
|
|
file_change_connection.Block();
|
2011-09-15 07:16:32 +02:00
|
|
|
c->ass->Commit(_("translation assistant"), AssFile::COMMIT_DIAG_TEXT);
|
2012-03-13 00:34:54 +01:00
|
|
|
file_change_connection.Unblock();
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
if (next) {
|
|
|
|
if (!NextBlock()) {
|
|
|
|
wxMessageBox(_("No more lines to translate."));
|
|
|
|
EndModal(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
UpdateDisplay();
|
|
|
|
}
|
2008-05-09 05:43:47 +02:00
|
|
|
}
|
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
void DialogTranslation::InsertOriginal() {
|
2014-05-30 21:39:39 +02:00
|
|
|
auto const& text = blocks[cur_block]->GetText();
|
|
|
|
translated_text->AddTextRaw(text.data(), text.size());
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
void DialogTranslation::OnKeyDown(wxKeyEvent &evt) {
|
2012-03-13 00:34:34 +01:00
|
|
|
hotkey::check("Translation Assistant", c, evt);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
void DialogTranslation::OnPlayVideoButton(wxCommandEvent &) {
|
|
|
|
c->videoController->PlayLine();
|
|
|
|
translated_text->SetFocus();
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2011-07-27 07:36:15 +02:00
|
|
|
void DialogTranslation::OnPlayAudioButton(wxCommandEvent &) {
|
|
|
|
cmd::call("audio/play/selection", c);
|
|
|
|
translated_text->SetFocus();
|
|
|
|
}
|