mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-05-09 04:32:13 -05:00
fix repeat scheduling
This commit is contained in:
parent
be406ff353
commit
7f520b0f87
|
|
@ -348,7 +348,12 @@ void MacroScheduleEntryDialog::ApplyToEntry(MacroScheduleEntry &entry) const
|
|||
const QString macroName = _macroSel->currentText();
|
||||
entry.macro = macroName;
|
||||
|
||||
entry.startDateTime = _startDateTime->dateTime();
|
||||
const QDateTime newStartDateTime = _startDateTime->dateTime();
|
||||
const bool startChanged = (newStartDateTime != entry.startDateTime);
|
||||
entry.startDateTime = newStartDateTime;
|
||||
if (startChanged) {
|
||||
entry.FastForwardTo(QDateTime::currentDateTime());
|
||||
}
|
||||
|
||||
entry.hasEndDate = _hasEndDate->isChecked();
|
||||
if (entry.hasEndDate) {
|
||||
|
|
|
|||
|
|
@ -293,6 +293,38 @@ void MacroScheduleEntry::MarkTriggered(const QDateTime &now)
|
|||
lastTriggered = now;
|
||||
}
|
||||
|
||||
void MacroScheduleEntry::FastForwardTo(const QDateTime &now)
|
||||
{
|
||||
timesTriggered = 0;
|
||||
lastTriggered = QDateTime();
|
||||
|
||||
if (!startDateTime.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (repeatType == RepeatType::NONE) {
|
||||
// One-shot: count it as triggered if the start lies in the past.
|
||||
if (startDateTime <= now) {
|
||||
timesTriggered = 1;
|
||||
lastTriggered = startDateTime;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Repeating: walk intervals from startDateTime and count each one
|
||||
// that falls at or before 'now'.
|
||||
QDateTime t = startDateTime;
|
||||
while (t <= now) {
|
||||
++timesTriggered;
|
||||
lastTriggered = t;
|
||||
const QDateTime next = advanceFrom(t);
|
||||
if (!next.isValid()) {
|
||||
break;
|
||||
}
|
||||
t = next;
|
||||
}
|
||||
}
|
||||
|
||||
QString MacroScheduleEntry::GetRepeatDescription() const
|
||||
{
|
||||
if (repeatType == RepeatType::NONE) {
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ public:
|
|||
bool ShouldTrigger(const QDateTime &now) const;
|
||||
void MarkTriggered(const QDateTime &now);
|
||||
bool IsExpired() const;
|
||||
void FastForwardTo(const QDateTime &now);
|
||||
|
||||
QString GetSummary() const;
|
||||
QString GetRepeatDescription() const;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user