Skip to content

Commit

Permalink
Merge pull request #2147 from rrrapha/battery-bsd
Browse files Browse the repository at this point in the history
Add support for the battery widget on BSD systems (via upower)
  • Loading branch information
uklotzde authored Jun 8, 2019
2 parents 7b465cc + 227aaf7 commit e6dfe21
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions build/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ def configure(self, build, conf):
build.env.Append(LINKFLAGS='-framework IOKit')

class UPower(Dependence):
"""UPower is used to get battery measurements on Linux."""
"""UPower is used to get battery measurements on Linux and BSD."""
def configure(self, build, conf):
if not build.platform_is_linux:
if not build.platform_is_linux and not build.platform_is_bsd:
return
build.env.ParseConfig(
'pkg-config upower-glib --silence-errors --cflags --libs')
Expand Down
2 changes: 1 addition & 1 deletion build/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ def sources(self, build):
return ["src/util/battery/batterywindows.cpp"]
elif build.platform_is_osx:
return ["src/util/battery/batterymac.cpp"]
elif build.platform_is_linux:
elif build.platform_is_linux or build.platform_is_bsd:
return ["src/util/battery/batterylinux.cpp"]
else:
raise Exception('Battery support is not implemented for the target platform.')
Expand Down
12 changes: 6 additions & 6 deletions src/util/battery/battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
// Do not include platform-specific battery implementation unless we are built
// with battery support (__BATTERY__).
#ifdef __BATTERY__
#ifdef Q_OS_LINUX
#include "util/battery/batterylinux.h"
#elif defined(Q_OS_WIN)
#if defined(Q_OS_WIN)
#include "util/battery/batterywindows.h"
#elif defined(Q_OS_MAC)
#include "util/battery/batterymac.h"
#else
#include "util/battery/batterylinux.h"
#endif
#endif
#include "util/math.h"
Expand All @@ -31,12 +31,12 @@ Battery::~Battery() {

Battery* Battery::getBattery(QObject* parent) {
#ifdef __BATTERY__
#ifdef Q_OS_LINUX
return new BatteryLinux(parent);
#elif defined(Q_OS_WIN)
#if defined(Q_OS_WIN)
return new BatteryWindows(parent);
#elif defined(Q_OS_MAC)
return new BatteryMac(parent);
#else
return new BatteryLinux(parent);
#endif
#else
Q_UNUSED(parent);
Expand Down

0 comments on commit e6dfe21

Please sign in to comment.