Handle empty files better in the translation assistant

Originally committed to SVN as r6167.
This commit is contained in:
Thomas Goyne 2011-12-26 22:21:19 +00:00
parent 92254a9806
commit ae3895fb8e
3 changed files with 19 additions and 6 deletions

View file

@ -49,6 +49,7 @@
#include "../dialog_fonts_collector.h"
#include "../standard_paths.h" // tool_assdraw
#include "../video_context.h" // tool_font_collector
#include "../compat.h"
#include "../dialog_export.h"
#include "../dialog_resample.h"
#include "../dialog_selection.h"
@ -227,11 +228,17 @@ struct tool_translation_assistant : public Command {
void operator()(agi::Context *c) {
c->videoController->Stop();
try {
DialogTranslation d(c);
c->translationAssistant = &d;
d.ShowModal();
c->translationAssistant = 0;
}
catch (agi::Exception const& e) {
c->translationAssistant = 0;
wxMessageBox(lagi_wxString(e.GetChainedMessage()));
}
}
};
struct tool_translation_assistant_validator : public Command {

View file

@ -32,6 +32,7 @@
#include "ass_file.h"
#include "audio_controller.h"
#include "command/command.h"
#include "compat.h"
#include "help_button.h"
#include "libresrc/libresrc.h"
#include "persist_location.h"
@ -157,8 +158,10 @@ DialogTranslation::DialogTranslation(agi::Context *c)
Bind(wxEVT_KEY_DOWN, &DialogTranslation::OnKeyDown, this);
active_line->ParseASSTags();
if (bad_block(active_line->Blocks[0]))
NextBlock();
if (bad_block(active_line->Blocks[0])) {
if (!NextBlock())
throw NothingToTranslate(STD_STR(_("There is nothing to translate in the file.")));
}
else
UpdateDisplay();
}

View file

@ -24,6 +24,7 @@
#include <wx/dialog.h>
#endif
#include <libaegisub/exception.h>
#include <libaegisub/scoped_ptr.h>
namespace agi { struct Context; }
@ -71,4 +72,6 @@ public:
bool PrevBlock();
void Commit(bool next);
void InsertOriginal();
DEFINE_SIMPLE_EXCEPTION_NOINNER(NothingToTranslate, agi::Exception, "dialog/translation/nothing_to_translate");
};