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
|
#define StartupLog(a) LOG_I("frame_main/init") << a
|
||||||
#endif
|
#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
|
/// Handle files drag and dropped onto Aegisub
|
||||||
class AegisubFileDropTarget : public wxFileDropTarget {
|
class AegisubFileDropTarget : public wxFileDropTarget {
|
||||||
|
@ -190,11 +190,9 @@ FrameMain::FrameMain (wxArrayString args)
|
||||||
|
|
||||||
StartupLog("Set up Auto Save");
|
StartupLog("Set up Auto Save");
|
||||||
AutoSave.SetOwner(this, ID_APP_TIMER_AUTOSAVE);
|
AutoSave.SetOwner(this, ID_APP_TIMER_AUTOSAVE);
|
||||||
int time = OPT_GET("App/Auto/Save Every Seconds")->GetInt();
|
autosave_timer_changed(&AutoSave);
|
||||||
if (time > 0) {
|
OPT_SUB("App/Auto/Save", autosave_timer_changed, &AutoSave);
|
||||||
AutoSave.Start(time*1000);
|
OPT_SUB("App/Auto/Save Every Seconds", autosave_timer_changed, &AutoSave);
|
||||||
}
|
|
||||||
OPT_SUB("App/Auto/Save Every Seconds", autosave_timer_changed, &AutoSave, agi::signal::_1);
|
|
||||||
|
|
||||||
StartupLog("Set up drag/drop target");
|
StartupLog("Set up drag/drop target");
|
||||||
SetDropTarget(new AegisubFileDropTarget(this));
|
SetDropTarget(new AegisubFileDropTarget(this));
|
||||||
|
@ -513,14 +511,12 @@ bool FrameMain::LoadList(wxArrayString list) {
|
||||||
return subs.size() || audio.size() || video.size();
|
return subs.size() || audio.size() || video.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void autosave_timer_changed(wxTimer *timer, const agi::OptionValue &opt) {
|
static void autosave_timer_changed(wxTimer *timer) {
|
||||||
int freq = opt.GetInt();
|
int freq = OPT_GET("App/Auto/Save Every Seconds")->GetInt();
|
||||||
if (freq <= 0) {
|
if (freq > 0 && OPT_GET("App/Auto/Save")->GetBool())
|
||||||
timer->Stop();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
timer->Start(freq * 1000);
|
timer->Start(freq * 1000);
|
||||||
}
|
else
|
||||||
|
timer->Stop();
|
||||||
}
|
}
|
||||||
BEGIN_EVENT_TABLE(FrameMain, wxFrame)
|
BEGIN_EVENT_TABLE(FrameMain, wxFrame)
|
||||||
EVT_TIMER(ID_APP_TIMER_AUTOSAVE, FrameMain::OnAutoSave)
|
EVT_TIMER(ID_APP_TIMER_AUTOSAVE, FrameMain::OnAutoSave)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
"Backup" : true,
|
"Backup" : true,
|
||||||
"Check For Updates" : true,
|
"Check For Updates" : true,
|
||||||
"Load Linked Files" : 2,
|
"Load Linked Files" : 2,
|
||||||
|
"Save" : true,
|
||||||
"Save Every Seconds" : 60,
|
"Save Every Seconds" : 60,
|
||||||
"Save on Every Change" : false
|
"Save on Every Change" : false
|
||||||
},
|
},
|
||||||
|
|
|
@ -470,9 +470,9 @@ File_Associations::File_Associations(wxTreebook *book, Preferences *parent): Opt
|
||||||
/// Backup preferences page
|
/// Backup preferences page
|
||||||
Backup::Backup(wxTreebook *book, Preferences *parent): OptionPage(book, parent, _("Backup")) {
|
Backup::Backup(wxTreebook *book, Preferences *parent): OptionPage(book, parent, _("Backup")) {
|
||||||
wxFlexGridSizer *save = PageSizer(_("Automatic Save"));
|
wxFlexGridSizer *save = PageSizer(_("Automatic Save"));
|
||||||
OptionAdd(save, _("Enable"), "App/Auto/Backup");
|
OptionAdd(save, _("Enable"), "App/Auto/Save");
|
||||||
CellSkip(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");
|
OptionBrowse(save, _("Path"), "Path/Auto/Save");
|
||||||
OptionAdd(save, _("Autosave after every change"), "App/Auto/Save on Every Change");
|
OptionAdd(save, _("Autosave after every change"), "App/Auto/Save on Every Change");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue