diff --git a/AsuroTool/AsuroTool.cpp b/AsuroTool/AsuroTool.cpp index 56f8353..fffd825 100644 --- a/AsuroTool/AsuroTool.cpp +++ b/AsuroTool/AsuroTool.cpp @@ -420,7 +420,7 @@ ImVec2 timerWindow(DrawData& drawData, ApplicationData& appData) } ImGui::SameLine(); - ImGui::PushItemWidth(35.f); + ImGui::PushItemWidth(45.f); if (ImGui::InputFloat("##timer", &timerDisplayMinutes, 0, 0, "%.0fm")) { appData.settings.timerDuration = timerDisplayMinutes * 60.f; @@ -437,12 +437,20 @@ ImVec2 timerWindow(DrawData& drawData, ApplicationData& appData) char timeStr[32]; std::string timerText; - if (timerData.isTimerActive && timerData.timerHasNotified) + if (timerData.isTimerActive) { + if (timerData.timerHasNotified) + { formatTime(timerData.timerStartTimestamp + std::chrono::seconds((int)appData.settings.timerDuration), timeStr, sizeof(timeStr)); timerText = std::format("Ended at {}", timeStr); } else + { + formatTime(appData.timerData.timerStartTimestamp + std::chrono::seconds((int)appData.settings.timerDuration), timeStr, sizeof(timeStr)); + timerText = std::format("Ends at {}", timeStr); + } + } + else { formatTime(std::chrono::system_clock::now() + std::chrono::seconds((int)appData.settings.timerDuration), timeStr, sizeof(timeStr)); timerText = std::format("Ends at {}", timeStr); diff --git a/AsuroTool/Timer.cpp b/AsuroTool/Timer.cpp index 04853aa..2a66e0f 100644 --- a/AsuroTool/Timer.cpp +++ b/AsuroTool/Timer.cpp @@ -40,7 +40,7 @@ void updateTimer(ApplicationData& appData) timerData.isTimerActive = false; messageText = L"Timer does not repeat."; } - showToastNotification(&timerData.toastHandler, titleText.c_str(), messageText.c_str()); + showToastNotification(&timerData.toastHandler, titleText.c_str(), messageText.c_str(), appData.settings.timerRepeating ? appData.settings.timerRepeatDuration * 1000 : 0); } else { diff --git a/AsuroTool/WindowsShell.cpp b/AsuroTool/WindowsShell.cpp index fd9ff41..9773e1c 100644 --- a/AsuroTool/WindowsShell.cpp +++ b/AsuroTool/WindowsShell.cpp @@ -82,7 +82,7 @@ void initShell(DrawData& drawData) }); } -void showToastNotification(TimerToastHandler* handler, const wchar_t* title, const wchar_t* text) +void showToastNotification(TimerToastHandler* handler, const wchar_t* title, const wchar_t* text, UINT64 expiresInMs) { WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageAndText01); templ.setScenario(WinToastTemplate::Scenario::Alarm); @@ -91,7 +91,13 @@ void showToastNotification(TimerToastHandler* handler, const wchar_t* title, con templ.setAttributionText(text); templ.addAction(L"Stop"); templ.addAction(L"Dismiss"); - if (!WinToast::instance()->showToast(templ, handler)) { + if (expiresInMs > 0) + { + templ.setExpiration(expiresInMs); + } + + if (!WinToast::instance()->showToast(templ, handler)) + { OutputDebugString(L"Error: Could not launch toast!\n"); } } @@ -135,6 +141,14 @@ void TimerToastHandler::toastActivated() const void TimerToastHandler::toastActivated(int actionIndex) const { + if (actionIndex == 0) + { + gAppData->timerData.isTimerActive = false; + } + else if (actionIndex == 1) + { + + } } void TimerToastHandler::toastFailed() const diff --git a/AsuroTool/WindowsShell.h b/AsuroTool/WindowsShell.h index 75d0aab..374b219 100644 --- a/AsuroTool/WindowsShell.h +++ b/AsuroTool/WindowsShell.h @@ -15,7 +15,7 @@ struct TimerToastHandler : IWinToastHandler void initShell(DrawData& drawData); -void showToastNotification(TimerToastHandler* handler, const wchar_t* title, const wchar_t* text); +void showToastNotification(TimerToastHandler* handler, const wchar_t* title, const wchar_t* text, UINT64 expiresInMs = 0); void cleanupShell(DrawData& drawData);