[app] Don't keep display on when battery is low

To avoid completely discharging the battery if the reader falls asleep
This commit is contained in:
Slava Monich 2023-05-21 04:27:16 +03:00
parent d99bc12146
commit 34c10653eb
4 changed files with 17 additions and 11 deletions

View file

@ -25,10 +25,10 @@ CONFIG(debug, debug|release) {
}
# Directories
FBREADER_DIR = $$_PRO_FILE_PWD_/../fbreader
FRIBIDI_DIR = $$_PRO_FILE_PWD_/../fribidi
LINEBREAK_DIR = $$_PRO_FILE_PWD_/../linebreak
HARBOUR_LIB_DIR = $$_PRO_FILE_PWD_/../harbour-lib
FBREADER_DIR = ../fbreader
FRIBIDI_DIR = ../fribidi
LINEBREAK_DIR = ../linebreak
HARBOUR_LIB_DIR = ../harbour-lib
HARBOUR_INCLUDE_DIR = $$HARBOUR_LIB_DIR/include
HARBOUR_SRC_DIR = $$HARBOUR_LIB_DIR/src
@ -194,6 +194,7 @@ openrepos {
HEADERS += \
$$HARBOUR_INCLUDE_DIR/HarbourBase45.h \
$$HARBOUR_INCLUDE_DIR/HarbourBattery.h \
$$HARBOUR_INCLUDE_DIR/HarbourColorEditorModel.h \
$$HARBOUR_INCLUDE_DIR/HarbourDisplayBlanking.h \
$$HARBOUR_INCLUDE_DIR/HarbourJson.h \
@ -206,6 +207,7 @@ HEADERS += \
SOURCES += \
$$HARBOUR_SRC_DIR/HarbourBase45.cpp \
$$HARBOUR_SRC_DIR/HarbourBattery.cpp \
$$HARBOUR_SRC_DIR/HarbourColorEditorModel.cpp \
$$HARBOUR_SRC_DIR/HarbourDisplayBlanking.cpp \
$$HARBOUR_SRC_DIR/HarbourJson.cpp \

View file

@ -1,6 +1,6 @@
/*
Copyright (C) 2015-2021 Jolla Ltd.
Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
Copyright (C) 2015-2023 Slava Monich <slava@monich.com>
You may use this file under the terms of BSD license as follows:
@ -52,10 +52,12 @@ ApplicationWindow {
property variant currentShelf: mainPage.currentShelf
DisplayBlanking {
HarbourDisplayBlanking {
pauseRequested: Qt.application.active &&
Settings.currentBook &&
Settings.keepDisplayOn
Settings.currentBook && Settings.keepDisplayOn &&
(HarbourBattery.batteryState === HarbourBattery.BatteryStateCharging ||
HarbourBattery.batteryLevel === 0 || // Zero if unknown (not reported by mce)
HarbourBattery.batteryLevel >= 20)
}
Binding {

View file

@ -1,6 +1,6 @@
/*
* Copyright (C) 2015-2022 Jolla Ltd.
* Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
* Copyright (C) 2015-2023 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@ -52,6 +52,7 @@
#include "BooksHints.h"
#include "BooksUtil.h"
#include "HarbourBattery.h"
#include "HarbourColorEditorModel.h"
#include "HarbourDisplayBlanking.h"
#include "HarbourDebug.h"
@ -96,14 +97,15 @@ Q_DECL_EXPORT int main(int argc, char **argv)
BOOKS_QML_REGISTER_(BooksPageWidget, "PageWidget");
BOOKS_QML_REGISTER_(BooksListWatcher, "ListWatcher");
BOOKS_QML_REGISTER_(BooksCoverWidget, "BookCover");
BOOKS_QML_REGISTER_(HarbourDisplayBlanking, "DisplayBlanking");
// But these do (and I think it's a good idea)
BOOKS_QML_REGISTER(HarbourColorEditorModel);
BOOKS_QML_REGISTER(HarbourDisplayBlanking);
BOOKS_QML_REGISTER(BooksColorSchemeModel);
BOOKS_QML_REGISTER(BooksImportModel);
BOOKS_QML_REGISTER(BooksPathModel);
BOOKS_QML_REGISTER(BooksPageStack);
BOOKS_QML_REGISTER_SINGLETON(HarbourBattery);
BOOKS_QML_REGISTER_SINGLETON(HarbourUtil);
BOOKS_QML_REGISTER_SINGLETON(BooksHints);
BOOKS_QML_REGISTER_SINGLETON(BooksUtil);

@ -1 +1 @@
Subproject commit 323fc6b6c98f85265e55425c22d617991178cc44
Subproject commit 6f745a05d05a236fa8053a4c2f40a807f83141ab