Skip to content

Commit

Permalink
refactor(battery): make use of std::chrono::milliseconds for update i…
Browse files Browse the repository at this point in the history
…nterval
  • Loading branch information
Swiftb0y committed Aug 20, 2023
1 parent 824bd1e commit 77b0fd9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/util/battery/battery.cpp
@@ -1,5 +1,7 @@
#include "util/battery/battery.h"

#include <chrono>

#include "moc_battery.cpp"

// Do not include platform-specific battery implementation unless we are built
Expand All @@ -15,8 +17,9 @@
#endif
#include "util/math.h"

// interval (in ms) of the timer which calls update()
constexpr int kBatteryUpdateIntervalMS = 5000;
using namespace std::chrono_literals;
// interval of the timer which calls update()
static constexpr std::chrono::milliseconds kBatteryUpdateInterval = 5000ms;

Battery::Battery(QObject* parent)
: QObject(parent),
Expand All @@ -25,7 +28,7 @@ Battery::Battery(QObject* parent)
m_iMinutesLeft(0),
m_timer(this) {
connect(&m_timer, &QTimer::timeout, this, &Battery::update);
m_timer.start(kBatteryUpdateIntervalMS);
m_timer.start(kBatteryUpdateInterval);
}

Battery* Battery::getBattery(QObject* parent) {
Expand Down

0 comments on commit 77b0fd9

Please sign in to comment.