2021-03-25 05:00:19 -07:00
|
|
|
#include "quit.h"
|
|
|
|
#include "ui_quit.h"
|
2021-04-05 06:50:58 -07:00
|
|
|
#include "functions.h"
|
2021-03-25 05:00:19 -07:00
|
|
|
#include <QProcess>
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QScreen>
|
|
|
|
|
|
|
|
quit::quit(QWidget *parent) :
|
|
|
|
QWidget(parent),
|
|
|
|
ui(new Ui::quit)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2022-03-02 21:40:11 -08:00
|
|
|
ui->backBtn->setFont(QFont("u001"));
|
2021-03-25 05:00:19 -07:00
|
|
|
|
|
|
|
ui->pushButton->setProperty("type", "borderless");
|
|
|
|
ui->pushButton_2->setProperty("type", "borderless");
|
|
|
|
ui->pushButton_3->setProperty("type", "borderless");
|
|
|
|
ui->pushButton_4->setProperty("type", "borderless");
|
|
|
|
ui->backBtn->setProperty("type", "borderless");
|
|
|
|
|
|
|
|
// Stylesheet
|
2022-04-03 20:26:15 -07:00
|
|
|
QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss");
|
2021-03-25 05:00:19 -07:00
|
|
|
stylesheetFile.open(QFile::ReadOnly);
|
|
|
|
this->setStyleSheet(stylesheetFile.readAll());
|
|
|
|
stylesheetFile.close();
|
|
|
|
|
|
|
|
// Getting the screen's size
|
|
|
|
float sW = QGuiApplication::screens()[0]->size().width();
|
|
|
|
float sH = QGuiApplication::screens()[0]->size().height();
|
|
|
|
// Defining what the "Quit" icon size will be
|
|
|
|
float stdIconWidth = sW / 1.25;
|
|
|
|
float stdIconHeight = sH / 1.25;
|
|
|
|
|
|
|
|
QPixmap pixmap(":/resources/exit.png");
|
|
|
|
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
|
|
|
|
ui->label->setPixmap(scaledPixmap);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
quit::~quit()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void quit::on_pushButton_clicked()
|
|
|
|
{
|
2021-04-25 08:27:51 -07:00
|
|
|
// Prevent strange "appearing from nowhere" low battery or critical battery alerts due to sysfs unmount
|
|
|
|
global::battery::showCriticalBatteryAlert = false;
|
|
|
|
global::battery::showLowBatteryDialog = false;
|
|
|
|
|
2022-06-18 06:26:52 -07:00
|
|
|
// GUI apps
|
|
|
|
updateUserAppsMainJsonFile();
|
|
|
|
|
2021-04-22 04:38:54 -07:00
|
|
|
poweroff(true);
|
2022-03-03 19:03:20 -08:00
|
|
|
qApp->quit();
|
2021-03-25 05:00:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void quit::on_pushButton_2_clicked()
|
|
|
|
{
|
2021-04-25 08:27:51 -07:00
|
|
|
global::battery::showCriticalBatteryAlert = false;
|
|
|
|
global::battery::showLowBatteryDialog = false;
|
|
|
|
|
2022-06-18 06:26:52 -07:00
|
|
|
// GUI apps
|
|
|
|
updateUserAppsMainJsonFile();
|
|
|
|
|
2021-04-22 04:38:54 -07:00
|
|
|
reboot(true);
|
2022-03-03 19:03:20 -08:00
|
|
|
qApp->quit();
|
2021-03-25 05:00:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void quit::on_pushButton_4_clicked()
|
|
|
|
{
|
2022-04-10 18:37:33 -07:00
|
|
|
log("Restarting InkBox", className);
|
2021-03-25 05:00:19 -07:00
|
|
|
QProcess process;
|
|
|
|
process.startDetached("inkbox", QStringList());
|
|
|
|
qApp->quit();
|
|
|
|
}
|
|
|
|
|
|
|
|
void quit::on_backBtn_clicked()
|
|
|
|
{
|
|
|
|
quit::close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void quit::on_pushButton_3_clicked()
|
|
|
|
{
|
2022-04-10 18:37:33 -07:00
|
|
|
log("Suspending", className);
|
2021-03-25 05:00:19 -07:00
|
|
|
// inotifywait waits for a MODIFY event, so we just do it instead of evtest and the power button
|
2021-07-13 09:27:38 -07:00
|
|
|
string_writeconfig("/external_root/tmp/power", "KEY_POWER");
|
2021-03-25 05:00:19 -07:00
|
|
|
}
|