mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-28 08:37:22 -08:00
USB charging fixes
This commit is contained in:
parent
89dda0247b
commit
2853ad70c3
3 changed files with 45 additions and 52 deletions
|
@ -459,6 +459,8 @@ namespace {
|
||||||
kernelVersion = proc->readAllStandardOutput();
|
kernelVersion = proc->readAllStandardOutput();
|
||||||
kernelVersion = kernelVersion.trimmed();
|
kernelVersion = kernelVersion.trimmed();
|
||||||
|
|
||||||
|
proc->deleteLater();
|
||||||
|
|
||||||
setDefaultWorkDir();
|
setDefaultWorkDir();
|
||||||
QString fifo_prog("sh");
|
QString fifo_prog("sh");
|
||||||
QStringList fifo_args;
|
QStringList fifo_args;
|
||||||
|
|
|
@ -307,8 +307,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(isBatteryCritical() == true) {
|
if(isBatteryCritical() == true) {
|
||||||
string_checkconfig_ro("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/status");
|
if(isUsbPluggedIn() == true) {
|
||||||
if(checkconfig_str_val == "Charging\n") {
|
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -328,12 +327,11 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qDebug() << "Warning! Battery is low!";
|
if(isUsbPluggedIn() == true) {
|
||||||
string_checkconfig_ro("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/status");
|
|
||||||
if(checkconfig_str_val == "Charging\n") {
|
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
qDebug() << "Warning! Battery is low!";
|
||||||
openLowBatteryDialog();
|
openLowBatteryDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -342,36 +340,6 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
} );
|
} );
|
||||||
batteryWatchdog->start();
|
batteryWatchdog->start();
|
||||||
|
|
||||||
// USB mass storage prompt
|
|
||||||
QTimer *usbmsPrompt = new QTimer(this);
|
|
||||||
usbmsPrompt->setInterval(500);
|
|
||||||
connect(usbmsPrompt, &QTimer::timeout, [&]() {
|
|
||||||
if(checkconfig("/opt/inkbox_genuine") == true) {
|
|
||||||
if(global::usbms::showUsbmsDialog != true) {
|
|
||||||
if(isUsbPluggedIn() != usbmsStatus) {
|
|
||||||
global::usbms::showUsbmsDialog = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
usbmsStatus = isUsbPluggedIn();
|
|
||||||
if(usbmsStatus == false) {
|
|
||||||
// Loop again...
|
|
||||||
;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// An USB cable is connected!
|
|
||||||
setBatteryIcon();
|
|
||||||
openUsbmsDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Do nothing, we're running along with Nickel & friends...
|
|
||||||
;
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
usbmsPrompt->start();
|
|
||||||
|
|
||||||
// We set the brightness level saved in the config file
|
// We set the brightness level saved in the config file
|
||||||
QTimer::singleShot(2000, this, SLOT(setInitialBrightness()));
|
QTimer::singleShot(2000, this, SLOT(setInitialBrightness()));
|
||||||
|
|
||||||
|
@ -522,9 +490,6 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for an update and ask if the user wants to install it
|
|
||||||
checkForUpdate();
|
|
||||||
|
|
||||||
// Check if it's the first boot since an update and confirm that it installed successfully
|
// Check if it's the first boot since an update and confirm that it installed successfully
|
||||||
if(checkconfig("/opt/inkbox_genuine") == true) {
|
if(checkconfig("/opt/inkbox_genuine") == true) {
|
||||||
if(checkconfig("/external_root/opt/update/inkbox_updated") == true) {
|
if(checkconfig("/external_root/opt/update/inkbox_updated") == true) {
|
||||||
|
@ -540,6 +505,38 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for an update and ask if the user wants to install it
|
||||||
|
checkForUpdate();
|
||||||
|
// USB mass storage prompt
|
||||||
|
QTimer *usbmsPrompt = new QTimer(this);
|
||||||
|
usbmsPrompt->setInterval(500);
|
||||||
|
connect(usbmsPrompt, &QTimer::timeout, [&]() {
|
||||||
|
if(checkconfig("/opt/inkbox_genuine") == true) {
|
||||||
|
if(global::usbms::showUsbmsDialog != true) {
|
||||||
|
if(isUsbPluggedIn() != usbmsStatus) {
|
||||||
|
global::usbms::showUsbmsDialog = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
usbmsStatus = isUsbPluggedIn();
|
||||||
|
if(usbmsStatus == false) {
|
||||||
|
// Loop again...
|
||||||
|
;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// An USB cable is connected!
|
||||||
|
setBatteryIcon();
|
||||||
|
openUsbmsDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Do nothing, we're running along with Nickel & friends...
|
||||||
|
;
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
usbmsPrompt->start();
|
||||||
|
|
||||||
// If the DEVKEY file is present, install a developer key
|
// If the DEVKEY file is present, install a developer key
|
||||||
if(QFile::exists("/mnt/onboard/onboard/.inkbox/DEVKEY") == true && QFile::exists("/mnt/onboard/onboard/.inkbox/DEVKEY.dgst") == true) {
|
if(QFile::exists("/mnt/onboard/onboard/.inkbox/DEVKEY") == true && QFile::exists("/mnt/onboard/onboard/.inkbox/DEVKEY.dgst") == true) {
|
||||||
string_checkconfig_ro("/mnt/onboard/onboard/.inkbox/DEVKEY");
|
string_checkconfig_ro("/mnt/onboard/onboard/.inkbox/DEVKEY");
|
||||||
|
@ -790,8 +787,7 @@ void MainWindow::setBatteryIcon() {
|
||||||
QPixmap scaledEmptyPixmap = emptyPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
|
QPixmap scaledEmptyPixmap = emptyPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
|
||||||
|
|
||||||
// Checking battery level and status, then displaying the relevant icon on batteryIconLabel
|
// Checking battery level and status, then displaying the relevant icon on batteryIconLabel
|
||||||
string_checkconfig_ro("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/status");
|
if(isUsbPluggedIn() == true) {
|
||||||
if(checkconfig_str_val == "Charging\n") {
|
|
||||||
ui->batteryIcon->setPixmap(scaledChargingPixmap);
|
ui->batteryIcon->setPixmap(scaledChargingPixmap);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -821,8 +817,7 @@ void MainWindow::setBatteryIcon() {
|
||||||
QPixmap scaledEmptyPixmap = emptyPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
|
QPixmap scaledEmptyPixmap = emptyPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
|
||||||
|
|
||||||
// Checking battery level and status, then displaying the relevant icon on batteryIconLabel
|
// Checking battery level and status, then displaying the relevant icon on batteryIconLabel
|
||||||
string_checkconfig_ro("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/status");
|
if(isUsbPluggedIn() == true) {
|
||||||
if(checkconfig_str_val == "Charging\n") {
|
|
||||||
ui->batteryIcon->setPixmap(scaledChargingPixmap);
|
ui->batteryIcon->setPixmap(scaledChargingPixmap);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
16
reader.cpp
16
reader.cpp
|
@ -616,15 +616,13 @@ reader::reader(QWidget *parent) :
|
||||||
connect(usbmsPrompt, &QTimer::timeout, [&]() {
|
connect(usbmsPrompt, &QTimer::timeout, [&]() {
|
||||||
if(checkconfig("/opt/inkbox_genuine") == true) {
|
if(checkconfig("/opt/inkbox_genuine") == true) {
|
||||||
if(global::usbms::showUsbmsDialog != true) {
|
if(global::usbms::showUsbmsDialog != true) {
|
||||||
string_checkconfig_ro("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/status");
|
if(isUsbPluggedIn() != usbmsStatus) {
|
||||||
if(usbmsStatus != checkconfig_str_val) {
|
|
||||||
global::usbms::showUsbmsDialog = true;
|
global::usbms::showUsbmsDialog = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
string_checkconfig_ro("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/status");
|
usbmsStatus = isUsbPluggedIn();
|
||||||
usbmsStatus = checkconfig_str_val;
|
if(usbmsStatus == false) {
|
||||||
if(usbmsStatus != "Charging\n") {
|
|
||||||
// Loop again...
|
// Loop again...
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -668,12 +666,11 @@ reader::reader(QWidget *parent) :
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qDebug() << "Warning! Battery is low!";
|
if(isUsbPluggedIn()) {
|
||||||
string_checkconfig_ro("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/status");
|
|
||||||
if(checkconfig_str_val == "Charging\n") {
|
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
qDebug() << "Warning! Battery is low!";
|
||||||
openLowBatteryDialog();
|
openLowBatteryDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1341,8 +1338,7 @@ void reader::alignText(int alignment) {
|
||||||
|
|
||||||
void reader::menubar_show() {
|
void reader::menubar_show() {
|
||||||
// Checking battery level and status, then displaying the relevant icon on batteryIconLabel
|
// Checking battery level and status, then displaying the relevant icon on batteryIconLabel
|
||||||
string_checkconfig_ro("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/status");
|
if(isUsbPluggedIn() == true) {
|
||||||
if(checkconfig_str_val == "Charging\n") {
|
|
||||||
ui->batteryIconLabel->setPixmap(scaledChargingPixmap);
|
ui->batteryIconLabel->setPixmap(scaledChargingPixmap);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in a new issue