Skip to content

Commit

Permalink
Merge branch 'jb44852_deprecate_statefs' into 'master'
Browse files Browse the repository at this point in the history
Use systemsettings plugin for battery info

See merge request mer-core/buteo-mtp!26
  • Loading branch information
spiiroin committed Sep 26, 2019
2 parents 3521e47 + d704751 commit 558e775
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion mts/common.pri
@@ -1,2 +1,2 @@
CONFIG += link_pkgconfig
PKGCONFIG += contextkit-statefs
PKGCONFIG += systemsettings
2 changes: 2 additions & 0 deletions mts/mts.pro
@@ -1,3 +1,5 @@
include(common.pri)

QT += xml dbus
QT -= gui

Expand Down
21 changes: 9 additions & 12 deletions mts/platform/deviceinfo/deviceinfoprovider.cpp
Expand Up @@ -33,16 +33,16 @@
#include <QDeviceInfo>
#include <QTimer>
#include <ssudeviceinfo.h>
#include <contextproperty.h>
#include <batterystatus.h>
#include "trace.h"

using namespace meegomtp1dot0;

/**********************************************
* DeviceInfoProvider::DeviceInfoProvider
*********************************************/
DeviceInfoProvider::DeviceInfoProvider():
battery(new ContextProperty("Battery.ChargePercentage", this))
DeviceInfoProvider::DeviceInfoProvider()
: m_batteryStatus(new BatteryStatus(this))
{
QDeviceInfo di;

Expand All @@ -56,13 +56,8 @@ DeviceInfoProvider::DeviceInfoProvider():
m_manufacturer = di.manufacturer().isEmpty() ? m_manufacturer : di.manufacturer();
m_model = di.model().isEmpty() ? m_model : di.model();

connect(battery, SIGNAL(valueChanged()), this, SLOT(onBatteryPercentageChanged()));

// Initialize the battery charge value. Use idle callback because
// acting on the battery level information requires that the
// transport object setup has been finished and that is done
// (if at all) after setting up the device info provider.
QTimer::singleShot(0, this, SLOT(onBatteryPercentageChanged()));
connect(m_batteryStatus, &BatteryStatus::chargePercentageChanged,
this, &DeviceInfoProvider::onBatteryPercentageChanged);

if(m_newConfigFileWasCreated)
{
Expand All @@ -81,7 +76,9 @@ DeviceInfoProvider::~DeviceInfoProvider()
{
}

void DeviceInfoProvider::onBatteryPercentageChanged()
void DeviceInfoProvider::onBatteryPercentageChanged(int percentage)
{
setBatteryLevel(battery->value().toUInt());
if (percentage >= 0) {
setBatteryLevel(quint8(qMin(percentage, 255)));
}
}
6 changes: 3 additions & 3 deletions mts/platform/deviceinfo/deviceinfoprovider.h
Expand Up @@ -34,7 +34,7 @@

#include "deviceinfo.h"

class ContextProperty;
class BatteryStatus;

/// This class implements DeviceInfo for getting and setting device info and properties for an MTP session.

Expand All @@ -59,10 +59,10 @@ class DeviceInfoProvider : public DeviceInfo
~DeviceInfoProvider();

private:
ContextProperty *battery;
BatteryStatus *m_batteryStatus;

private slots:
void onBatteryPercentageChanged();
void onBatteryPercentageChanged(int percentage);
};
}

Expand Down
2 changes: 1 addition & 1 deletion rpm/buteo-mtp-qt5.spec
Expand Up @@ -21,7 +21,7 @@ BuildRequires: pkgconfig(mlite5)
# for the thumbnailer unit test
BuildRequires: pkgconfig(Qt5Gui)
BuildRequires: ssu-devel >= 0.37.9
BuildRequires: pkgconfig(contextkit-statefs) >= 0.2.7
BuildRequires: pkgconfig(systemsettings) >= 0.2.25
Requires: mtp-vendor-configuration
Requires: thumbnaild
Requires: libqt5sparql-tracker-direct
Expand Down

0 comments on commit 558e775

Please sign in to comment.