@@ -42,6 +42,37 @@ namespace {
4242 }
4343 return QIcon (QPixmap::fromImage (img));
4444 }
45+
46+ #ifdef _WIN32
47+ // CloudStore registry path for Night Light state
48+ // QSettings::NativeFormat reads directly from Windows registry
49+ bool isNightLightActive ()
50+ {
51+ QSettings reg (
52+ " HKEY_CURRENT_USER\\ Software\\ Microsoft\\ Windows\\ CurrentVersion\\ CloudStore\\ Store\\ Cache\\ DefaultAccount\\ "
53+ " $$windows.data.bluelightreduction.bluelightreductionstate\\ Current" ,
54+ QSettings::NativeFormat
55+ );
56+ QByteArray data = reg.value (" Data" ).toByteArray ();
57+ if (data.isEmpty ())
58+ return false ;
59+
60+ // Search for "isEnabled" UTF-16LE pattern in the serialized blob
61+ QByteArray pattern = QByteArrayLiteral (" \x69\x00\x73\x00\x45\x00\x6e\x00\x61\x00\x62\x00\x6c\x00\x65\x00\x64\x00 " );
62+ int idx = data.indexOf (pattern);
63+ if (idx < 0 )
64+ return false ;
65+
66+ // After the key, search for VT_BOOL (0x0b) followed by the bool value
67+ int searchEnd = qMin (idx + pattern.size () + 64 , data.size () - 4 );
68+ for (int j = idx + pattern.size (); j < searchEnd; ++j)
69+ {
70+ if (data[j] == ' \x0b ' )
71+ return (data[j + 4 ] == ' \x01 ' );
72+ }
73+ return false ;
74+ }
75+ #endif
4576}
4677
4778SysTray::SysTray (HyperionDaemon* hyperiond)
@@ -438,6 +469,13 @@ void SysTray::handleInstanceStarted(quint8 instance)
438469 _trayMenu->insertAction (_settingsAction, _firstInstanceAction);
439470
440471 updateStartupSourceIndicator ();
472+
473+ #ifdef _WIN32
474+ if (!isNightLightActive ())
475+ {
476+ emit signalEvent (Event::Suspend);
477+ }
478+ #endif
441479 }
442480 else
443481 {
0 commit comments