Skip to content

Commit

Permalink
[mce-qt] Add battery related items. Fixes JB#44019
Browse files Browse the repository at this point in the history
Implements new Qt classes / QML items for tracking:

MceBatteryLevel:  Current charge percentage
MceBatteryStatus: Current status as Empty|Low|Ok|Full
MceCableState:    Whether charger cable is connected
MceChargerState:  Whether battery is getting charged
McePowerSaveMode: Whether PowerSaveMode is active

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Dec 13, 2018
1 parent 65d45f9 commit ec30bcd
Show file tree
Hide file tree
Showing 12 changed files with 1,142 additions and 1 deletion.
59 changes: 59 additions & 0 deletions lib/include/qmcebatterylevel.h
@@ -0,0 +1,59 @@
/*
* Copyright (C) 2016-2018 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Jolla Ltd nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* any official policies, either expressed or implied.
*/

#ifndef QMCE_BATTERYLEVEL_H_
#define QMCE_BATTERYLEVEL_H_

#include "qmcetypes.h"

class QMCE_EXPORT QMceBatteryLevel : public QObject
{
Q_OBJECT
Q_PROPERTY(bool valid READ valid NOTIFY validChanged)
Q_PROPERTY(int percent READ percent NOTIFY percentChanged)
public:
QMceBatteryLevel(QObject* aParent = NULL);
bool valid() const;
int percent() const;
Q_SIGNALS:
void validChanged();
void percentChanged();
private:
class Private;
Private* iPrivate;
};

#endif // QMCE_BATTERYLEVEL_H_
61 changes: 61 additions & 0 deletions lib/include/qmcebatterystatus.h
@@ -0,0 +1,61 @@
/*
* Copyright (C) 2016-2018 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Jolla Ltd nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* any official policies, either expressed or implied.
*/

#ifndef QMCE_BATTERYSTATUS_H_
#define QMCE_BATTERYSTATUS_H_

#include "qmcetypes.h"

class QMCE_EXPORT QMceBatteryStatus : public QObject
{
Q_OBJECT
Q_PROPERTY(bool valid READ valid NOTIFY validChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_ENUMS(Status)
public:
enum Status { Empty, Low, Ok, Full, };
QMceBatteryStatus(QObject* aParent = NULL);
bool valid() const;
Status status() const;
Q_SIGNALS:
void validChanged();
void statusChanged();
private:
class Private;
Private* iPrivate;
};

#endif // QMCE_BATTERYSTATUS_H_
59 changes: 59 additions & 0 deletions lib/include/qmcecablestate.h
@@ -0,0 +1,59 @@
/*
* Copyright (C) 2016-2018 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Jolla Ltd nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* any official policies, either expressed or implied.
*/

#ifndef QMCE_CABLESTATE_H_
#define QMCE_CABLESTATE_H_

#include "qmcetypes.h"

class QMCE_EXPORT QMceCableState : public QObject
{
Q_OBJECT
Q_PROPERTY(bool valid READ valid NOTIFY validChanged)
Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
public:
QMceCableState(QObject* aParent = NULL);
bool valid() const;
bool connected() const;
Q_SIGNALS:
void validChanged();
void connectedChanged();
private:
class Private;
Private* iPrivate;
};

#endif // QMCE_CABLESTATE_H_
59 changes: 59 additions & 0 deletions lib/include/qmcechargerstate.h
@@ -0,0 +1,59 @@
/*
* Copyright (C) 2016-2018 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Jolla Ltd nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* any official policies, either expressed or implied.
*/

#ifndef QMCE_CHARGERSTATE_H_
#define QMCE_CHARGERSTATE_H_

#include "qmcetypes.h"

class QMCE_EXPORT QMceChargerState : public QObject
{
Q_OBJECT
Q_PROPERTY(bool valid READ valid NOTIFY validChanged)
Q_PROPERTY(bool charging READ charging NOTIFY chargingChanged)
public:
QMceChargerState(QObject* aParent = NULL);
bool valid() const;
bool charging() const;
Q_SIGNALS:
void validChanged();
void chargingChanged();
private:
class Private;
Private* iPrivate;
};

#endif // QMCE_CHARGERSTATE_H_
59 changes: 59 additions & 0 deletions lib/include/qmcepowersavemode.h
@@ -0,0 +1,59 @@
/*
* Copyright (C) 2016-2018 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Jolla Ltd nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* any official policies, either expressed or implied.
*/

#ifndef QMCE_POWERSAVEMODE_H_
#define QMCE_POWERSAVEMODE_H_

#include "qmcetypes.h"

class QMCE_EXPORT QMcePowerSaveMode : public QObject
{
Q_OBJECT
Q_PROPERTY(bool valid READ valid NOTIFY validChanged)
Q_PROPERTY(bool active READ active NOTIFY activeChanged)
public:
QMcePowerSaveMode(QObject* aParent = NULL);
bool valid() const;
bool active() const;
Q_SIGNALS:
void validChanged();
void activeChanged();
private:
class Private;
Private* iPrivate;
};

#endif // QMCE_POWERSAVEMODE_H_
10 changes: 10 additions & 0 deletions lib/lib.pro
Expand Up @@ -21,12 +21,22 @@ XML_FILES += \
OTHER_FILES += $$XML_FILES

SOURCES += \
src/qmcebatterylevel.cpp \
src/qmcebatterystatus.cpp \
src/qmcecablestate.cpp \
src/qmcechargerstate.cpp \
src/qmcedisplay.cpp \
src/qmcepowersavemode.cpp \
src/qmceproxy.cpp \
src/qmcetklock.cpp

PUBLIC_HEADERS += \
include/qmcebatterylevel.h \
include/qmcebatterystatus.h \
include/qmcecablestate.h \
include/qmcechargerstate.h \
include/qmcedisplay.h \
include/qmcepowersavemode.h \
include/qmcetypes.h \
include/qmcetklock.h

Expand Down

0 comments on commit ec30bcd

Please sign in to comment.