Add an option to disable autosave as setting the interval to zero isn't very obvious
Originally committed to SVN as r6318.
This commit is contained in:
parent
6e09fb1abf
commit
a249cfcc35
3 changed files with 12 additions and 15 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
},
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
Loading…
Reference in a new issue