summaryrefslogtreecommitdiff
path: root/plugins/NotesAndReminders
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/NotesAndReminders')
-rw-r--r--plugins/NotesAndReminders/res/resource.rc2
-rw-r--r--plugins/NotesAndReminders/src/options.cpp5
-rw-r--r--plugins/NotesAndReminders/src/reminders.cpp145
-rw-r--r--plugins/NotesAndReminders/src/resource.h1
-rw-r--r--plugins/NotesAndReminders/src/stdafx.cxx2
5 files changed, 79 insertions, 76 deletions
diff --git a/plugins/NotesAndReminders/res/resource.rc b/plugins/NotesAndReminders/res/resource.rc
index 994629c5be..da8ba04b57 100644
--- a/plugins/NotesAndReminders/res/resource.rc
+++ b/plugins/NotesAndReminders/res/resource.rc
@@ -104,7 +104,7 @@ BEGIN
LTEXT "Use Sound",IDC_STATIC,31,185,90,8,0,WS_EX_RIGHT
COMBOBOX IDC_COMBO_SOUND,126,182,90,81,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "",IDC_BTN_PLAYSOUND,220,183,13,12,BS_ICON
- DEFPUSHBUTTON "&Add Reminder",IDC_ADDREMINDER,158,6,76,14
+ DEFPUSHBUTTON "&Add Reminder",IDOK,158,6,76,14
PUSHBUTTON "&Close",IDCANCEL,158,23,76,14
PUSHBUTTON "&View Reminders",IDC_VIEWREMINDERS,158,40,76,14
END
diff --git a/plugins/NotesAndReminders/src/options.cpp b/plugins/NotesAndReminders/src/options.cpp
index 3142a15eb9..a085181e33 100644
--- a/plugins/NotesAndReminders/src/options.cpp
+++ b/plugins/NotesAndReminders/src/options.cpp
@@ -299,13 +299,14 @@ public:
void onClick_Browse(CCtrlButton*)
{
- wchar_t s[MAX_PATH];
+ wchar_t s[MAX_PATH], wszFilter[MAX_PATH];
GetDlgItemText(m_hwnd, IDC_EDIT_ALTBROWSER, s, _countof(s));
+ mir_snwprintf(wszFilter, L"%s%c*.exe%c%s%c*.*%c", TranslateT("Executable Files"), 0, 0, TranslateT("All Files"), 0, 0);
OPENFILENAME ofn = {0};
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
ofn.hwndOwner = m_hwnd;
- ofn.lpstrFilter = TranslateT("Executable Files\0*.exe\0All Files\0*.*\0\0");
+ ofn.lpstrFilter = wszFilter;
ofn.lpstrFile = s;
ofn.nMaxFile = _countof(s);
ofn.lpstrTitle = TranslateT("Select Executable");
diff --git a/plugins/NotesAndReminders/src/reminders.cpp b/plugins/NotesAndReminders/src/reminders.cpp
index a4853349ea..14837e440f 100644
--- a/plugins/NotesAndReminders/src/reminders.cpp
+++ b/plugins/NotesAndReminders/src/reminders.cpp
@@ -15,6 +15,11 @@
/////////////////////////////////////////////////////////////////////////////////////////
+static int date2int(const SYSTEMTIME &t)
+{
+ return (t.wYear * 1000 + t.wMonth) * 100 + t.wDay;
+}
+
static void RemoveReminderSystemEvent(struct REMINDERDATA *p);
enum REPEAT
@@ -122,7 +127,7 @@ static void RemoveReminderSystemEvent(REMINDERDATA *p)
if (!pev)
break;
- if ((ULONG)pev->lParam == p->uid && !pev->hContact && pev->pszService && !mir_strcmp(pev->pszService, MODULENAME"/OpenTriggeredReminder")) {
+ if ((ULONG)pev->lParam == p->uid && !pev->hContact && !mir_strcmp(pev->pszService, MODULENAME"/OpenTriggeredReminder")) {
if (!Clist_RemoveEvent(pev->hContact, pev->hDbEvent)) {
p->bSystemEventQueued = false;
if (QueuedReminderCount)
@@ -237,7 +242,7 @@ static bool LoadReminder(char *Value)
break;
case DATATAG_REPEAT:
- TempRem->RepeatMode = strtol(TVal, nullptr, 10) != 0;
+ TempRem->RepeatMode = strtol(TVal, nullptr, 10);
break;
}
}
@@ -704,31 +709,37 @@ protected:
FileTimeToSystemTime((FILETIME*)&savedLi, &pDate);
}
- return true;
}
+ else {
+ // user entered a custom value
+ wchar_t buf[32];
+ cmbTime.GetText(buf, _countof(buf));
- // user entered a custom value
- wchar_t buf[32];
- cmbTime.GetText(buf, _countof(buf));
+ int h, m;
+ if (!ParseTime(buf, &h, &m, FALSE, m_bRelativeCombo)) {
+ MessageBoxW(m_hwnd, TranslateT("The specified time is invalid."), _A2W(SECTIONNAME), MB_OK | MB_ICONWARNING);
+ return false;
+ }
- int h, m;
- if (!ParseTime(buf, &h, &m, FALSE, m_bRelativeCombo)) {
- MessageBox(cmbTime.GetParent()->GetHwnd(), TranslateT("The specified time is invalid."), _A2W(SECTIONNAME), MB_OK | MB_ICONWARNING);
- return false;
- }
+ // absolute time (on pDate)
+ if (ReformatTimeInput(savedLi, h, m, &pDate, nullptr))
+ return false;
- // absolute time (on pDate)
- if (ReformatTimeInput(savedLi, h, m, &pDate, nullptr))
- return false;
+ SYSTEMTIME tm;
+ GetSystemTime(&tm);
+ bool bTomorrow = date2int(tm) >= date2int(pDate) && (h * 60 + m) < (pDate.wHour * 60 + pDate.wMinute);
- pDate.wHour = h;
- pDate.wMinute = m;
- pDate.wSecond = 0;
- pDate.wMilliseconds = 0;
+ pDate.wHour = h;
+ pDate.wMinute = m;
+ pDate.wSecond = 0;
+ pDate.wMilliseconds = 0;
- ULONGLONG li;
- TzLocalSTToFileTime(&pDate, (FILETIME*)&li);
- FileTimeToSystemTime((FILETIME*)&li, &pDate);
+ ULONGLONG li;
+ TzLocalSTToFileTime(&pDate, (FILETIME *)&li);
+ if (bTomorrow)
+ li += (ULONGLONG)(24 * 3600) * FILETIME_TICKS_PER_SEC;
+ FileTimeToSystemTime((FILETIME *)&li, &pDate);
+ }
return true;
}
@@ -751,6 +762,14 @@ protected:
mir_subclassWindow(m_date.GetHwnd(), DatePickerWndProc);
}
+ void PopulateRepeatCombo(CCtrlCombo &ctrl)
+ {
+ ctrl.AddString(TranslateT("Don't repeat"), REPEAT::NONE);
+ ctrl.AddString(TranslateT("Repeat daily"), REPEAT::DAILY);
+ ctrl.AddString(TranslateT("Repeat weekly"), REPEAT::WEEKLY);
+ ctrl.AddString(TranslateT("Repeat monthly"), REPEAT::MONTHLY);
+ }
+
///////////////////////////////////////////////////////////////////////////////////////
// NOTE: may seem like a bit excessive time converstion and handling, but this is
// done in order to gracefully handle crossing daylight saving boundaries
@@ -840,8 +859,6 @@ protected:
// add from +1 to +23.5 (in half hour steps) if crossing daylight saving boundary it may be 22.5 or 24.5 hours
for (int i = 0; i < 50; i++) {
- UINT dt;
-
FileTimeToTzLocalST((FILETIME *)&li, &tm2);
if (i > 40) {
@@ -858,11 +875,8 @@ protected:
// icq-style display 1.0, 1.5 etc. hours even though that isn't accurate due to rounding
//mir_snwprintf(s, L"%02d:%02d (%d.%d %s)", (UINT)tm2.wHour, (UINT)tm2.wMinute, 1+(i>>1), (i&1) ? 5 : 0, lpszHours);
// display delta time more accurately to match reformatting (that icq doesn't do)
- dt = (UINT)((li / MinutesToFileTime) - (ref / MinutesToFileTime));
- if (dt < 60)
- mir_snwprintf(s, L"%02d:%02d (%d %s)", (UINT)tm2.wHour, (UINT)tm2.wMinute, dt, TranslateT("Minutes"));
- else
- mir_snwprintf(s, L"%02d:%02d (%d.%d %s)", (UINT)tm2.wHour, (UINT)tm2.wMinute, dt / 60, ((dt % 60) * 10) / 60, TranslateT("Hours"));
+ unsigned dt = (UINT)((li / MinutesToFileTime) - (ref / MinutesToFileTime));
+ mir_snwprintf(s, L"%02d:%02d", (UINT)tm2.wHour, (UINT)tm2.wMinute);
cmbTime.AddString(s, dt * 60);
li += 30ll * MinutesToFileTime;
@@ -878,6 +892,8 @@ protected:
int ReformatTimeInput(ULONGLONG savedLi, int h, int m, const SYSTEMTIME *pDateLocal, ULONGLONG *triggerRelUtcOut = nullptr)
{
+ wchar_t buf[64];
+
if (h < 0) {
// time value is an offset ('m' holds the offset in minutes)
if (m_bRelativeCombo) {
@@ -898,14 +914,8 @@ protected:
if (triggerRelUtcOut)
*triggerRelUtcOut = li;
- wchar_t buf[64];
- UINT dt = (UINT)((li / MinutesToFileTime) - (ref / MinutesToFileTime));
- if (dt < 60)
- mir_snwprintf(buf, L"%02d:%02d (%d %s)", h, m, dt, TranslateT("Minutes"));
- else
- mir_snwprintf(buf, L"%02d:%02d (%d.%d %s)", h, m, dt / 60, ((dt % 60) * 10) / 60, TranslateT("Hours"));
-
// search for preset
+ mir_snwprintf(buf, L"%02d:%02d", h, m);
int n = cmbTime.FindString(buf);
if (n != -1) {
cmbTime.SetCurSel(n);
@@ -921,7 +931,6 @@ protected:
}
// search for preset first
- wchar_t buf[64];
mir_snwprintf(buf, L"%02d:%02d", h, m);
int n = cmbTime.FindString(buf);
if (n != -1) {
@@ -983,7 +992,7 @@ protected:
// due to ending up at an undesired time (this way the user immediately notices something was wrong)
cmbTime.SetCurSel(0);
invalid_dst:
- MessageBox(cmbTime.GetParent()->GetHwnd(),
+ MessageBoxW(m_hwnd,
TranslateT("The specified time is invalid due to begin of daylight saving (summer time)."),
_A2W(SECTIONNAME), MB_OK | MB_ICONWARNING);
return 1;
@@ -993,11 +1002,7 @@ output_result:
if (triggerRelUtcOut)
*triggerRelUtcOut = li;
- UINT dt = (UINT)((li / MinutesToFileTime) - (ref / MinutesToFileTime));
- if (dt < 60)
- mir_snwprintf(buf, L"%02d:%02d (%d %s)", h, m, dt, TranslateT("Minutes"));
- else
- mir_snwprintf(buf, L"%02d:%02d (%d.%d %s)", h, m, dt / 60, ((dt % 60) * 10) / 60, TranslateT("Hours"));
+ mir_snwprintf(buf, L"%02d:%02d", h, m);
}
else {
// absolute time (00:00 to 23:59), clean up time to make sure it's not inside "missing" hour (will be rounded downward)
@@ -1115,17 +1120,21 @@ public:
BringWindowToTop(m_hwnd);
- PopulateTimeOffsetCombo();
-
- cmbRemindAgainIn.SetCurSel(0);
- chkAfter.SetState(true);
- chkOnDate.SetState(false);
-
if (m_pReminder->RepeatMode) {
chkOnDate.Hide();
chkAfter.Disable();
cmbRemindAgainIn.Disable();
+
+ PopulateRepeatCombo(cmbRemindAgainIn);
+ cmbRemindAgainIn.SetCurSel(m_pReminder->RepeatMode);
}
+ else {
+ PopulateTimeOffsetCombo();
+
+ cmbRemindAgainIn.SetCurSel(0);
+ chkOnDate.SetState(false);
+ }
+ chkAfter.SetState(true);
edtText.SendMsg(EM_LIMITTEXT, MAX_REMINDER_LEN, 0);
@@ -1317,13 +1326,12 @@ class CReminderFormDlg : public CReminderBaseDlg
CCtrlEdit edtText;
CCtrlCombo cmbMode, cmbSound, cmbRepeatSnd;
- CCtrlButton btnAdd, btnView, btnPlaySound;
+ CCtrlButton btnView, btnPlaySound;
public:
CReminderFormDlg(REMINDERDATA *pReminder = nullptr) :
CSuper(IDD_ADDREMINDER),
m_pReminder(pReminder),
- btnAdd(this, IDC_ADDREMINDER),
btnView(this, IDC_VIEWREMINDERS),
btnPlaySound(this, IDC_BTN_PLAYSOUND),
edtText(this, IDC_REMINDER),
@@ -1331,7 +1339,6 @@ public:
cmbSound(this, IDC_COMBO_SOUND),
cmbRepeatSnd(this, IDC_COMBO_REPEATSND)
{
- btnAdd.OnClick = Callback(this, &CReminderFormDlg::onClick_Add);
btnView.OnClick = Callback(this, &CReminderFormDlg::onClick_View);
btnPlaySound.OnClick = Callback(this, &CReminderFormDlg::onClick_PlaySound);
@@ -1341,16 +1348,13 @@ public:
bool OnInitDialog() override
{
// 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);
+ PopulateRepeatCombo(cmbMode);
SYSTEMTIME tm;
// opening the edit reminder dialog (uses same dialog resource as add reminder)
if (m_pReminder) {
SetWindowText(m_hwnd, TranslateT("Reminder"));
- SetDlgItemText(m_hwnd, IDC_ADDREMINDER, TranslateT("&Update Reminder"));
+ SetDlgItemText(m_hwnd, IDOK, TranslateT("&Update Reminder"));
btnView.Hide();
cmbMode.SetCurSel(m_pReminder->RepeatMode);
@@ -1440,25 +1444,18 @@ public:
}
if (m_pReminder)
- SetFocus(GetDlgItem(m_hwnd, IDC_ADDREMINDER));
+ SetFocus(GetDlgItem(m_hwnd, IDOK));
else
SetFocus(edtText.GetHwnd());
return true;
}
- void OnDestroy() override
- {
- bNewReminderVisible = false;
- if (m_pReminder)
- m_pReminder->bVisible = false;
- }
-
- void onClick_Add(CCtrlButton*)
+ bool OnApply() override
{
SYSTEMTIME Date;
m_date.GetTime(&Date);
if (!GetTriggerTime(m_savedLi, Date))
- return;
+ return false;
int RepeatSound = cmbRepeatSnd.GetCurData();
if (RepeatSound == -1)
@@ -1496,8 +1493,14 @@ public:
edtText.SetTextA("");
JustSaveReminders();
NotifyList();
- if (bClose)
- Close();
+ return bClose;
+ }
+
+ void OnDestroy() override
+ {
+ bNewReminderVisible = false;
+ if (m_pReminder)
+ m_pReminder->bVisible = false;
}
void onClick_View(CCtrlButton*)
@@ -1790,7 +1793,7 @@ public:
break;
case ID_CONTEXTMENUREMINDER_DELETEALL:
- if (arReminders.getCount() && IDOK == MessageBox(m_hwnd, TranslateT("Are you sure you want to delete all reminders?"), _A2W(SECTIONNAME), MB_OKCANCEL)) {
+ if (arReminders.getCount() && IDOK == MessageBoxW(m_hwnd, TranslateT("Are you sure you want to delete all reminders?"), _A2W(SECTIONNAME), MB_OKCANCEL)) {
SetDlgItemTextA(m_hwnd, IDC_REMINDERDATA, "");
DeleteReminders();
RefreshList();
@@ -1799,7 +1802,7 @@ public:
case ID_CONTEXTMENUREMINDER_DELETE:
idx = m_list.GetSelectionMark();
- if (idx != -1 && IDOK == MessageBox(m_hwnd, TranslateT("Are you sure you want to delete this reminder?"), _A2W(SECTIONNAME), MB_OKCANCEL)) {
+ if (idx != -1 && IDOK == MessageBoxW(m_hwnd, TranslateT("Are you sure you want to delete this reminder?"), _A2W(SECTIONNAME), MB_OKCANCEL)) {
SetDlgItemTextA(m_hwnd, IDC_REMINDERDATA, "");
DeleteReminder(getData(idx));
JustSaveReminders();
@@ -1917,7 +1920,7 @@ INT_PTR PluginMenuCommandViewReminders(WPARAM, LPARAM)
INT_PTR PluginMenuCommandDeleteReminders(WPARAM, LPARAM)
{
if (arReminders.getCount())
- if (IDOK == MessageBox(nullptr, TranslateT("Are you sure you want to delete all reminders?"), TranslateT(SECTIONNAME), MB_OKCANCEL))
+ if (IDOK == MessageBoxW(nullptr, TranslateT("Are you sure you want to delete all reminders?"), TranslateT(SECTIONNAME), MB_OKCANCEL))
DeleteReminders();
return 0;
}
diff --git a/plugins/NotesAndReminders/src/resource.h b/plugins/NotesAndReminders/src/resource.h
index a0ef9bd712..d3fbe4161c 100644
--- a/plugins/NotesAndReminders/src/resource.h
+++ b/plugins/NotesAndReminders/src/resource.h
@@ -24,7 +24,6 @@
#define IDC_DISMISS 1001
#define IDC_REMINDERDATA 1001
#define IDC_REMINDAGAIN 1002
-#define IDC_ADDREMINDER 1002
#define IDC_ADDNEWREMINDER 1002
#define IDC_REMINDAGAININ 1003
#define IDC_AFTER 1004
diff --git a/plugins/NotesAndReminders/src/stdafx.cxx b/plugins/NotesAndReminders/src/stdafx.cxx
index 13f28e1314..f111565f38 100644
--- a/plugins/NotesAndReminders/src/stdafx.cxx
+++ b/plugins/NotesAndReminders/src/stdafx.cxx
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2012-24 Miranda NG team (https://miranda-ng.org)
+Copyright (C) 2012-25 Miranda NG team (https://miranda-ng.org)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License