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:
@@ -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(¬ifications, &NotificationService::leadReminderDue);
|
||||
QSignalSpy startSpy(¬ifications, &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"
|
||||
|
||||
Reference in New Issue
Block a user