From a249cfcc3515be78f2c1c2cbeb152c7542b7416a Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 20 Jan 2012 01:04:24 +0000 Subject: [PATCH] Add an option to disable autosave as setting the interval to zero isn't very obvious Originally committed to SVN as r6318. --- aegisub/src/frame_main.cpp | 22 +++++++++------------- aegisub/src/libresrc/default_config.json | 1 + aegisub/src/preferences.cpp | 4 ++-- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/aegisub/src/frame_main.cpp b/aegisub/src/frame_main.cpp index 43234cb6f..ea398cab0 100644 --- a/aegisub/src/frame_main.cpp +++ b/aegisub/src/frame_main.cpp @@ -90,7 +90,7 @@ enum { #define StartupLog(a) LOG_I("frame_main/init") << a #endif -static void autosave_timer_changed(wxTimer *timer, const agi::OptionValue &opt); +static void autosave_timer_changed(wxTimer *timer); /// Handle files drag and dropped onto Aegisub class AegisubFileDropTarget : public wxFileDropTarget { @@ -190,11 +190,9 @@ FrameMain::FrameMain (wxArrayString args) StartupLog("Set up Auto Save"); AutoSave.SetOwner(this, ID_APP_TIMER_AUTOSAVE); - int time = OPT_GET("App/Auto/Save Every Seconds")->GetInt(); - if (time > 0) { - AutoSave.Start(time*1000); - } - OPT_SUB("App/Auto/Save Every Seconds", autosave_timer_changed, &AutoSave, agi::signal::_1); + autosave_timer_changed(&AutoSave); + OPT_SUB("App/Auto/Save", autosave_timer_changed, &AutoSave); + OPT_SUB("App/Auto/Save Every Seconds", autosave_timer_changed, &AutoSave); StartupLog("Set up drag/drop target"); SetDropTarget(new AegisubFileDropTarget(this)); @@ -513,14 +511,12 @@ bool FrameMain::LoadList(wxArrayString list) { return subs.size() || audio.size() || video.size(); } -static void autosave_timer_changed(wxTimer *timer, const agi::OptionValue &opt) { - int freq = opt.GetInt(); - if (freq <= 0) { - timer->Stop(); - } - else { +static void autosave_timer_changed(wxTimer *timer) { + int freq = OPT_GET("App/Auto/Save Every Seconds")->GetInt(); + if (freq > 0 && OPT_GET("App/Auto/Save")->GetBool()) timer->Start(freq * 1000); - } + else + timer->Stop(); } BEGIN_EVENT_TABLE(FrameMain, wxFrame) EVT_TIMER(ID_APP_TIMER_AUTOSAVE, FrameMain::OnAutoSave) diff --git a/aegisub/src/libresrc/default_config.json b/aegisub/src/libresrc/default_config.json index 5c5f8d155..9af6fbaae 100644 --- a/aegisub/src/libresrc/default_config.json +++ b/aegisub/src/libresrc/default_config.json @@ -4,6 +4,7 @@ "Backup" : true, "Check For Updates" : true, "Load Linked Files" : 2, + "Save" : true, "Save Every Seconds" : 60, "Save on Every Change" : false }, diff --git a/aegisub/src/preferences.cpp b/aegisub/src/preferences.cpp index 3231a8767..ba25ca78a 100644 --- a/aegisub/src/preferences.cpp +++ b/aegisub/src/preferences.cpp @@ -470,9 +470,9 @@ File_Associations::File_Associations(wxTreebook *book, Preferences *parent): Opt /// Backup preferences page Backup::Backup(wxTreebook *book, Preferences *parent): OptionPage(book, parent, _("Backup")) { wxFlexGridSizer *save = PageSizer(_("Automatic Save")); - OptionAdd(save, _("Enable"), "App/Auto/Backup"); + OptionAdd(save, _("Enable"), "App/Auto/Save"); CellSkip(save); - OptionAdd(save, _("Interval in seconds"), "App/Auto/Save Every Seconds"); + OptionAdd(save, _("Interval in seconds"), "App/Auto/Save Every Seconds", 1); OptionBrowse(save, _("Path"), "Path/Auto/Save"); OptionAdd(save, _("Autosave after every change"), "App/Auto/Save on Every Change");