From 162de3ff6ca84569ae1e15bc5f76917e10577187 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Tue, 22 Apr 2014 18:16:32 +0000 Subject: [PATCH] [NEW_FEATURE] Automatic Backup System (in progress). git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1225 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/installer/nativeLang/chinese.xml | 2 +- PowerEditor/installer/nativeLang/english.xml | 3 ++- PowerEditor/installer/nativeLang/french.xml | 2 +- .../src/WinControls/Preference/preference.rc | 12 +++++----- .../WinControls/Preference/preferenceDlg.cpp | 22 ++++++++++++++----- 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/PowerEditor/installer/nativeLang/chinese.xml b/PowerEditor/installer/nativeLang/chinese.xml index 08fe8c82..31ba7794 100644 --- a/PowerEditor/installer/nativeLang/chinese.xml +++ b/PowerEditor/installer/nativeLang/chinese.xml @@ -719,6 +719,7 @@ + @@ -762,7 +763,6 @@ - diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 970fb50f..3c7b56bb 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -714,6 +714,8 @@ + + @@ -759,7 +761,6 @@ - diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index 117ef65b..ca4b8af6 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -733,6 +733,7 @@ + @@ -779,7 +780,6 @@ - diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index e721c1cc..f297fc5e 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -288,6 +288,12 @@ IDD_PREFERENCE_BACKUP_BOX DIALOGEX 0, 0, 455, 185 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN + GROUPBOX "Session snapshot and periodic backup",IDC_BACKUPDIR_RESTORESESSION_GRP_STATIC,79,1,289,59,BS_CENTER + CONTROL "Remember current session for next launch",IDC_CHECK_REMEMBERSESSION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,90,10,270,10 + CONTROL "Enable session snapshot and periodic backup",IDC_BACKUPDIR_RESTORESESSION_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,90,25,270,10 + EDITTEXT IDC_BACKUPDIR_RESTORESESSION_EDIT,164,40,21,14,ES_NUMBER + RTEXT "Backup in every",IDD_BACKUPDIR_RESTORESESSION_STATIC1,82,42,78,8 + LTEXT "seconds",IDD_BACKUPDIR_RESTORESESSION_STATIC2,190,42,66,8 GROUPBOX "Backup on save",IDC_BACKUPDIR_GRP_STATIC,79,69,289,110,BS_CENTER CONTROL "None",IDC_RADIO_BKNONE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,104,80,87,10 CONTROL "Simple backup",IDC_RADIO_BKSIMPLE,"Button",BS_AUTORADIOBUTTON,104,94,111,10 @@ -297,12 +303,6 @@ BEGIN RTEXT "Directory :",IDD_BACKUPDIR_STATIC,99,146,40,8 EDITTEXT IDC_BACKUPDIR_EDIT,146,144,179,14,ES_AUTOHSCROLL PUSHBUTTON "...",IDD_BACKUPDIR_BROWSE_BUTTON,332,144,16,14 - GROUPBOX "Session snapshot and periodic backup",IDC_BACKUPDIR_RESTORESESSION_GRP_STATIC,79,1,289,59,BS_CENTER - CONTROL "Remember current session for next launch",IDC_CHECK_REMEMBERSESSION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,90,10,270,10 - CONTROL "Enable session snapshot and periodic backup",IDC_BACKUPDIR_RESTORESESSION_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,90,25,270,10 - EDITTEXT IDC_BACKUPDIR_RESTORESESSION_EDIT,164,40,21,14,ES_NUMBER - RTEXT "Backup in every",IDD_BACKUPDIR_RESTORESESSION_STATIC1,82,42,78,8 - LTEXT "seconds",IDD_BACKUPDIR_RESTORESESSION_STATIC2,190,42,66,8 END IDD_PREFERENCE_AUTOCOMPLETION_BOX DIALOGEX 0, 0, 455, 185 diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index cdaf8213..6c4b1d98 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -828,7 +828,6 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) } ::SendDlgItemMessage(_hSelf, IDC_CHECK_MIN2SYSTRAY, BM_SETCHECK, nppGUI._isMinimizedToTray, 0); - ::SendDlgItemMessage(_hSelf, IDC_CHECK_REMEMBERSESSION, BM_SETCHECK, nppGUI._rememberLastSession, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_DETECTENCODING, BM_SETCHECK, nppGUI._detectEncoding, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_AUTOUPDATE, BM_SETCHECK, nppGUI._autoUpdateOpt._doAutoUpdate, 0); @@ -959,9 +958,6 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) nppGUI._isMinimizedToTray = isCheckedOrNot(wParam); return TRUE; - case IDC_CHECK_REMEMBERSESSION: - nppGUI._rememberLastSession = isCheckedOrNot(wParam); - return TRUE; case IDC_CHECK_DETECTENCODING: nppGUI._detectEncoding = isCheckedOrNot(wParam); return TRUE; @@ -2171,7 +2167,8 @@ BOOL CALLBACK BackupDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) { case WM_INITDIALOG : { - bool snapshotCheck = nppGUI._isSnapshotMode; + ::SendDlgItemMessage(_hSelf, IDC_CHECK_REMEMBERSESSION, BM_SETCHECK, nppGUI._rememberLastSession, 0); + bool snapshotCheck = nppGUI._rememberLastSession && nppGUI._isSnapshotMode; ::SendDlgItemMessage(_hSelf, IDC_BACKUPDIR_RESTORESESSION_CHECK, BM_SETCHECK, snapshotCheck?BST_CHECKED:BST_UNCHECKED, 0); int periodicBackupInSec = nppGUI._snapshotBackupTiming/1000; ::SetDlgItemInt(_hSelf, IDC_BACKUPDIR_RESTORESESSION_EDIT, periodicBackupInSec, FALSE); @@ -2257,6 +2254,17 @@ BOOL CALLBACK BackupDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) switch (wParam) { + case IDC_CHECK_REMEMBERSESSION: + { + nppGUI._rememberLastSession = isCheckedOrNot(IDC_CHECK_REMEMBERSESSION); + if (!nppGUI._rememberLastSession) + { + ::SendDlgItemMessage(_hSelf, IDC_BACKUPDIR_RESTORESESSION_CHECK, BM_SETCHECK, BST_UNCHECKED, 0); + ::SendMessage(_hSelf, WM_COMMAND, IDC_BACKUPDIR_RESTORESESSION_CHECK, 0); + } + updateBackupGUI(); + return TRUE; + } case IDC_BACKUPDIR_RESTORESESSION_CHECK: { nppGUI._isSnapshotMode = BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_BACKUPDIR_RESTORESESSION_CHECK, BM_GETCHECK, 0, 0); @@ -2315,7 +2323,9 @@ BOOL CALLBACK BackupDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) void BackupDlg::updateBackupGUI() { - bool isSnapshot = BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_BACKUPDIR_RESTORESESSION_CHECK, BM_GETCHECK, 0, 0); + bool rememberSession = isCheckedOrNot(IDC_CHECK_REMEMBERSESSION); + bool isSnapshot = isCheckedOrNot(IDC_BACKUPDIR_RESTORESESSION_CHECK); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_BACKUPDIR_RESTORESESSION_CHECK), rememberSession); ::EnableWindow(::GetDlgItem(_hSelf, IDD_BACKUPDIR_RESTORESESSION_STATIC1), isSnapshot); ::EnableWindow(::GetDlgItem(_hSelf, IDC_BACKUPDIR_RESTORESESSION_EDIT), isSnapshot); ::EnableWindow(::GetDlgItem(_hSelf, IDD_BACKUPDIR_RESTORESESSION_STATIC2), isSnapshot);