From 995e85e9e63553576fc285d937d4abbad369e7e4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 6 Nov 2024 21:38:39 +0300 Subject: =?UTF-8?q?fixes=20#4776=20(Notes=20&=20Reminders:=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=B8=D1=82=D1=8C=20=D0=B1=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D1=88=D0=B5=20=D0=B2=D0=B0=D1=80=D0=B8=D0=B0=D0=BD=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=BF=D0=BE=D0=B2=D1=82=D0=BE=D1=80=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=BF=D0=BE=D0=BC=D0=B8=D0=BD=D0=B0=D0=BD=D0=B8=D1=8F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/NotesAndReminders/src/reminders.cpp | 70 ++++++++++++++++++++++------- plugins/NotesAndReminders/src/resource.h | 2 +- 2 files changed, 54 insertions(+), 18 deletions(-) (limited to 'plugins/NotesAndReminders/src') diff --git a/plugins/NotesAndReminders/src/reminders.cpp b/plugins/NotesAndReminders/src/reminders.cpp index caec286b2e..a4853349ea 100644 --- a/plugins/NotesAndReminders/src/reminders.cpp +++ b/plugins/NotesAndReminders/src/reminders.cpp @@ -17,6 +17,11 @@ static void RemoveReminderSystemEvent(struct REMINDERDATA *p); +enum REPEAT +{ + NONE = 0, DAILY = 1, WEEKLY = 2, MONTHLY = 3 +}; + struct REMINDERDATA : public MZeroedObject { HWND handle; @@ -26,8 +31,8 @@ struct REMINDERDATA : public MZeroedObject UINT RepeatSound; UINT RepeatSoundTTL; int SoundSel; // -1 if sound disabled + int RepeatMode; bool bVisible; - bool bRepeat; bool bSystemEventQueued; REMINDERDATA() @@ -153,8 +158,8 @@ void JustSaveReminders(void) szValue.Format("X%u:%I64x", pReminder->uid, pReminder->When / FILETIME_TICKS_PER_SEC); // repeat - if (pReminder->bRepeat) - szValue.AppendFormat("\033""%u:%u", DATATAG_REPEAT, (int)pReminder->bRepeat); + if (pReminder->RepeatMode) + szValue.AppendFormat("\033""%u:%u", DATATAG_REPEAT, pReminder->RepeatMode); // sound repeat if (pReminder->RepeatSound) @@ -232,7 +237,7 @@ static bool LoadReminder(char *Value) break; case DATATAG_REPEAT: - TempRem->bRepeat = strtol(TVal, nullptr, 10) != 0; + TempRem->RepeatMode = strtol(TVal, nullptr, 10) != 0; break; } } @@ -1095,7 +1100,7 @@ public: cmbRemindAgainIn.OnKillFocus = Callback(this, &CReminderNotifyDlg::onKillFocus_RemindAgain); btnDismiss.OnClick = Callback(this, &CReminderNotifyDlg::onClick_Dismiss); - btnCreateNote.OnClick = Callback(this, &CReminderNotifyDlg::onClick_None); + btnCreateNote.OnClick = Callback(this, &CReminderNotifyDlg::onClick_CreateNote); btnRemindAgain.OnClick = Callback(this, &CReminderNotifyDlg::onClick_RemindAgain); } @@ -1116,11 +1121,10 @@ public: chkAfter.SetState(true); chkOnDate.SetState(false); - if (m_pReminder->bRepeat) { + if (m_pReminder->RepeatMode) { chkOnDate.Hide(); chkAfter.Disable(); cmbRemindAgainIn.Disable(); - cmbRemindAgainIn.SetCurSel(16); } edtText.SendMsg(EM_LIMITTEXT, MAX_REMINDER_LEN, 0); @@ -1205,7 +1209,31 @@ public: ULONGLONG li; SystemTimeToFileTime(&tm, (FILETIME*)&li); - int TT = cmbRemindAgainIn.GetCurData() * 60; + int TT; + switch (m_pReminder->RepeatMode) { + case REPEAT::DAILY: + TT = 24 * 60 * 60; + break; + case REPEAT::WEEKLY: + TT = 7 * 24 * 60 * 60; + break; + case REPEAT::MONTHLY: + { SYSTEMTIME tm2 = tm; + if (tm2.wMonth == 12) + tm2.wYear++, tm2.wMonth = 1; + else + tm2.wMonth++; + + ULONGLONG li2; + SystemTimeToFileTime(&tm2, (FILETIME *)&li2); + TT = int((li2 - li) / FILETIME_TICKS_PER_SEC); + } + break; + default: + TT = cmbRemindAgainIn.GetCurData() * 60; + break; + } + if (TT >= 24 * 3600) { // selection is 1 day or more, take daylight saving boundaries into consideration // (ie. 24 hour might actually be 23 or 25, in order for reminder to pop up at the @@ -1229,7 +1257,7 @@ public: } // reset When from the current time - if (!m_pReminder->bRepeat) + if (!m_pReminder->RepeatMode) m_pReminder->When = li; m_pReminder->When += (TT * FILETIME_TICKS_PER_SEC); } @@ -1253,7 +1281,7 @@ public: Close(); } - void onClick_None(CCtrlButton*) + void onClick_CreateNote(CCtrlButton*) { // create note from reminder NewNote(0, 0, -1, -1, ptrW(edtText.GetText()), nullptr, TRUE, TRUE, 0); @@ -1288,8 +1316,7 @@ class CReminderFormDlg : public CReminderBaseDlg REMINDERDATA *m_pReminder; CCtrlEdit edtText; - CCtrlCheck chkRepeat; - CCtrlCombo cmbSound, cmbRepeatSnd; + CCtrlCombo cmbMode, cmbSound, cmbRepeatSnd; CCtrlButton btnAdd, btnView, btnPlaySound; public: @@ -1300,7 +1327,7 @@ public: btnView(this, IDC_VIEWREMINDERS), btnPlaySound(this, IDC_BTN_PLAYSOUND), edtText(this, IDC_REMINDER), - chkRepeat(this, IDC_CHECK_REPEAT), + cmbMode(this, IDC_REPEAT_MODE), cmbSound(this, IDC_COMBO_SOUND), cmbRepeatSnd(this, IDC_COMBO_REPEATSND) { @@ -1313,18 +1340,27 @@ public: bool OnInitDialog() override { - SYSTEMTIME tm; + // populate repeat mode combo + cmbMode.AddString(TranslateT("Don't repeat"), REPEAT::NONE); + cmbMode.AddString(TranslateT("Repeat daily"), REPEAT::DAILY); + cmbMode.AddString(TranslateT("Repeat weekly"), REPEAT::WEEKLY); + cmbMode.AddString(TranslateT("Repeat monthly"), REPEAT::MONTHLY); + SYSTEMTIME tm; + // opening the edit reminder dialog (uses same dialog resource as add reminder) if (m_pReminder) { - // opening the edit reminder dialog (uses same dialog resource as add reminder) SetWindowText(m_hwnd, TranslateT("Reminder")); SetDlgItemText(m_hwnd, IDC_ADDREMINDER, TranslateT("&Update Reminder")); btnView.Hide(); + cmbMode.SetCurSel(m_pReminder->RepeatMode); + m_savedLi = m_pReminder->When; FileTimeToSystemTime((FILETIME*)&m_savedLi, &tm); } else { + cmbMode.SetCurSel(0); + GetSystemTime(&tm); SystemTimeToFileTime(&tm, (FILETIME*)&m_savedLi); } @@ -1435,7 +1471,7 @@ public: TempRem->uid = CreateUid(); SystemTimeToFileTime(&Date, (FILETIME*)&TempRem->When); TempRem->wszText = ptrW(edtText.GetText()); - TempRem->bRepeat = chkRepeat.GetState(); + TempRem->RepeatMode = cmbMode.GetCurData(); TempRem->SoundSel = cmbSound.GetCurData(); TempRem->RepeatSound = TempRem->SoundSel < 0 ? 0 : (UINT)RepeatSound; InsertReminder(TempRem); @@ -1446,7 +1482,7 @@ public: SystemTimeToFileTime(&Date, (FILETIME*)&m_pReminder->When); m_pReminder->wszText = ptrW(edtText.GetText()); - m_pReminder->bRepeat = chkRepeat.GetState(); + m_pReminder->RepeatMode = cmbMode.GetCurData(); m_pReminder->SoundSel = cmbSound.GetCurData(); m_pReminder->RepeatSound = m_pReminder->SoundSel < 0 ? 0 : (UINT)RepeatSound; diff --git a/plugins/NotesAndReminders/src/resource.h b/plugins/NotesAndReminders/src/resource.h index 851851b473..a0ef9bd712 100644 --- a/plugins/NotesAndReminders/src/resource.h +++ b/plugins/NotesAndReminders/src/resource.h @@ -52,7 +52,7 @@ #define IDC_BTN_PLAYSOUND 1030 #define IDC_EDIT_ALTBROWSER 1031 #define IDC_BTN_BROWSEBROWSER 1032 -#define IDC_CHECK_REPEAT 1033 +#define IDC_REPEAT_MODE 1033 #define IDC_LISTREMINDERS_HEADER 1034 #define IDC_EDIT1 1034 #define IDC_FILTER 1034 -- cgit v1.2.3