timer fixes
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user