diff --git a/aegisub/src/ass_file.cpp b/aegisub/src/ass_file.cpp index c3ad498e8..b58a2cdd3 100644 --- a/aegisub/src/ass_file.cpp +++ b/aegisub/src/ass_file.cpp @@ -78,7 +78,7 @@ AssFile::~AssFile() { } /// @brief Load generic subs -void AssFile::Load(const wxString &_filename, wxString charset, bool addToRecent) { +void AssFile::Load(const wxString &_filename, wxString const& charset) { try { // Get proper format reader const SubtitleFormat *reader = SubtitleFormat::GetReader(_filename); @@ -113,23 +113,6 @@ void AssFile::Load(const wxString &_filename, wxString charset, bool addToRecent // Set general data loaded = true; filename = _filename; - StandardPaths::SetPathValue("?script", wxFileName(filename).GetPath()); - - // Save backup of file - if (CanSave() && OPT_GET("App/Auto/Backup")->GetBool()) { - wxFileName file(filename); - if (file.FileExists()) { - wxString path = lagi_wxString(OPT_GET("Path/Auto/Backup")->GetString()); - if (path.empty()) path = file.GetPath(); - wxFileName dstpath(StandardPaths::DecodePath(path + "/")); - if (!dstpath.DirExists()) - wxMkdir(dstpath.GetPath()); - - dstpath.SetFullName(file.GetName() + ".ORIGINAL." + file.GetExt()); - - wxCopyFile(file.GetFullPath(), dstpath.GetFullPath(), true); - } - } // Add comments and set vars AddComment(wxString("Script generated by Aegisub ") + GetAegisubLongVersionString()); @@ -143,8 +126,6 @@ void AssFile::Load(const wxString &_filename, wxString charset, bool addToRecent autosavedCommitId = savedCommitId = commitId + 1; Commit("", COMMIT_NEW); - // Add to recent - if (addToRecent) AddToRecent(filename); FileOpen(filename); } diff --git a/aegisub/src/ass_file.h b/aegisub/src/ass_file.h index 580d27be6..15daec490 100644 --- a/aegisub/src/ass_file.h +++ b/aegisub/src/ass_file.h @@ -122,8 +122,7 @@ public: /// @brief Load from a file /// @param file File name /// @param charset Character set of file or empty to autodetect - /// @param addToRecent Should the file be added to the MRU list? - void Load(const wxString &file,wxString charset="",bool addToRecent=true); + void Load(const wxString &file, wxString const& charset=""); /// @brief Save to a file /// @param file Path to save to diff --git a/aegisub/src/dialog_style_manager.cpp b/aegisub/src/dialog_style_manager.cpp index 4bb7c4491..9cb320a4e 100644 --- a/aegisub/src/dialog_style_manager.cpp +++ b/aegisub/src/dialog_style_manager.cpp @@ -598,7 +598,7 @@ void DialogStyleManager::OnCurrentImport() { AssFile temp; try { - temp.Load(filename, "", false); + temp.Load(filename); } catch (const char *err) { wxMessageBox(err, "Error", wxOK | wxICON_ERROR | wxCENTER, this); diff --git a/aegisub/src/frame_main.cpp b/aegisub/src/frame_main.cpp index 534ab953a..7aac9be37 100644 --- a/aegisub/src/frame_main.cpp +++ b/aegisub/src/frame_main.cpp @@ -408,7 +408,7 @@ void FrameMain::InitContents() { StartupLog("Leaving InitContents"); } -void FrameMain::LoadSubtitles(wxString filename,wxString charset) { +void FrameMain::LoadSubtitles(wxString const& filename, wxString const& charset) { if (context->ass->loaded) { if (TryToCloseSubs() == wxCANCEL) return; } @@ -416,7 +416,7 @@ void FrameMain::LoadSubtitles(wxString filename,wxString charset) { try { // Make sure that file isn't actually a timecode file try { - TextFileReader testSubs(filename,charset); + TextFileReader testSubs(filename, charset); wxString cur = testSubs.ReadLineFromFile(); if (cur.Left(10) == "# timecode") { context->videoController->LoadTimecodes(filename); @@ -428,7 +428,27 @@ void FrameMain::LoadSubtitles(wxString filename,wxString charset) { // safe to assume that it is in fact not a timecode file } - context->ass->Load(filename,charset); + context->ass->Load(filename, charset); + + wxFileName file(filename); + StandardPaths::SetPathValue("?script", file.GetPath()); + config::mru->Add("Subtitle", STD_STR(filename)); + OPT_SET("Path/Last/Subtitles")->SetString(STD_STR(file.GetPath())); + + // Save backup of file + if (context->ass->CanSave() && OPT_GET("App/Auto/Backup")->GetBool()) { + if (file.FileExists()) { + wxString path = lagi_wxString(OPT_GET("Path/Auto/Backup")->GetString()); + if (path.empty()) path = file.GetPath(); + wxFileName dstpath(StandardPaths::DecodePath(path + "/")); + if (!dstpath.DirExists()) + wxMkdir(dstpath.GetPath()); + + dstpath.SetFullName(file.GetName() + ".ORIGINAL." + file.GetExt()); + + wxCopyFile(file.GetFullPath(), dstpath.GetFullPath(), true); + } + } } catch (agi::FileNotFoundError const&) { wxMessageBox(filename + " not found.", "Error", wxOK | wxICON_ERROR | wxCENTER, this); diff --git a/aegisub/src/frame_main.h b/aegisub/src/frame_main.h index ce02865b8..ff243332d 100644 --- a/aegisub/src/frame_main.h +++ b/aegisub/src/frame_main.h @@ -146,7 +146,7 @@ public: /// @param enableCancel Should the user be able to cancel the close? int TryToCloseSubs(bool enableCancel=true); - void LoadSubtitles(wxString filename,wxString charset=""); + void LoadSubtitles(wxString const& filename, wxString const& charset=""); DECLARE_EVENT_TABLE() };