feat: add desktop start and native reminders

- Notify at schedule start and optionally N minutes before\n- Add reminder lead setting and TOML persistence\n- Use Linux DBus native notifications with action handling\n- Focus the matching block when a notification is clicked\n- Keep overdue reminders and update validation docs/screenshots
This commit is contained in:
Misaki
2026-10-26 21:16:07 +08:00
parent 121e66d527
commit 795f9730f8
23 changed files with 465 additions and 6 deletions
+35
View File
@@ -28,6 +28,7 @@ private slots:
void energyProfileLearnsFromHistory();
void searchFindsSchedules();
void createsRecurringSchedules();
void startAndLeadReminders();
};
namespace
@@ -439,5 +440,39 @@ void TestServices::createsRecurringSchedules()
QVERIFY(!error.isEmpty());
}
void TestServices::startAndLeadReminders()
{
Context context;
QVERIFY(context.open());
const QDateTime now = QDateTime::currentDateTime();
QString error;
QVERIFY(context.service->createBlock(QStringLiteral("即将开始"),
now.addSecs(5 * 60),
now.addSecs(65 * 60),
&error));
QVERIFY(context.service->createBlock(QStringLiteral("已经开始"),
now.addSecs(-5 * 60),
now.addSecs(55 * 60),
&error));
NotificationService notifications(*context.service);
QSignalSpy leadSpy(&notifications, &NotificationService::leadReminderDue);
QSignalSpy startSpy(&notifications, &NotificationService::startReminderDue);
notifications.checkNow();
QCOMPARE(leadSpy.count(), 1);
QCOMPARE(startSpy.count(), 1);
QCOMPARE(leadSpy.first().at(0).value<ScheduleItem>().task.title, QStringLiteral("即将开始"));
QCOMPARE(leadSpy.first().at(1).toInt(), 10);
QCOMPARE(startSpy.first().at(0).value<ScheduleItem>().task.title, QStringLiteral("已经开始"));
notifications.checkNow();
QCOMPARE(leadSpy.count(), 1);
QCOMPARE(startSpy.count(), 1);
notifications.setLeadMinutes(0);
QCOMPARE(leadSpy.count(), 1);
}
QTEST_GUILESS_MAIN(TestServices)
#include "test_services.moc"