plugins/nightlight: Relax custom times constraints

Apparently the night light kcm allows to set the custom times so the
evening is earlier than the morning to handle extreme cases close to
the North and the South pole.

NightLightManager::updateTransitionTimings() should require no changes.

BUG: 489366
This commit is contained in:
Vlad Zahorodnii 2024-07-15 13:27:21 +03:00
parent d3bb8ceaae
commit 2adf962467

View file

@ -264,12 +264,8 @@ void NightLightManager::readConfig()
// fixed timings
QTime morning = QTime::fromString(settings->morningBeginFixed(), "hhmm");
QTime evening = QTime::fromString(settings->eveningBeginFixed(), "hhmm");
if (morning >= evening) {
morning = QTime(6, 0);
evening = QTime(18, 0);
}
const int dayDuration = morning.msecsTo(evening);
const int dayDuration = morning < evening ? morning.msecsTo(evening) : (MSC_DAY - evening.msecsTo(morning));
const int nightDuration = MSC_DAY - dayDuration;
const int maximumTransitionDuration = std::min(dayDuration, nightDuration);