Files
Upsilon/apps/usb_timer.cpp
Émilie Feral 6952c8a799 [apps] In USB timer, change color only when USB state has changed
Change-Id: I1ded3b149fd1987589566191f70d0ace992775f5
2017-04-24 17:36:31 +02:00

27 lines
744 B
C++

#include "usb_timer.h"
#include "global_preferences.h"
#include "apps_container.h"
USBTimer::USBTimer(AppsContainer * container) :
Timer(1),
m_container(container),
m_previousPluggedState(false)
{
}
void USBTimer::fire() {
if (Ion::USB::isPlugged()) {
if (!m_previousPluggedState && GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Activate) {
m_container->displayExamModePopUp(false, true);
}
KDColor LEDColor = Ion::Battery::isCharging() ? KDColorYellow : KDColorGreen;
Ion::LED::setColor(LEDColor);
m_previousPluggedState = true;
} else {
if (m_previousPluggedState) {
Ion::LED::setColor(KDColorBlack);
m_previousPluggedState = false;
}
}
}