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
+3
View File
@@ -28,6 +28,7 @@ void TestConfig::defaultsAndRoundTrip()
QCOMPARE(settings.themePreference(), QStringLiteral("system"));
QCOMPARE(settings.micaEnabled(), false);
QCOMPARE(settings.snapMinutes(), 15);
QCOMPARE(settings.reminderLeadMinutes(), 10);
QCOMPARE(settings.trayHintShown(), false);
QCOMPARE(settings.aiConfig().baseUrl, QStringLiteral("https://api.openai.com/v1"));
QCOMPARE(settings.aiConfig().model, QStringLiteral("gpt-4o-mini"));
@@ -39,6 +40,7 @@ void TestConfig::defaultsAndRoundTrip()
settings.setThemePreference(QStringLiteral("dark"));
settings.setMicaEnabled(true);
settings.setSnapMinutes(30);
settings.setReminderLeadMinutes(30);
settings.setTrayHintShown(true);
settings.setCompactGeometry(QByteArray("compact-geometry"));
settings.setScheduleGeometry(QByteArray("schedule-geometry"));
@@ -63,6 +65,7 @@ void TestConfig::defaultsAndRoundTrip()
QCOMPARE(reloaded.themePreference(), QStringLiteral("dark"));
QCOMPARE(reloaded.micaEnabled(), true);
QCOMPARE(reloaded.snapMinutes(), 30);
QCOMPARE(reloaded.reminderLeadMinutes(), 30);
QCOMPARE(reloaded.trayHintShown(), true);
QCOMPARE(reloaded.compactGeometry(), QByteArray("compact-geometry"));
QCOMPARE(reloaded.scheduleGeometry(), QByteArray("schedule-geometry"));
+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"