quill/quit.cpp

86 lines
2.2 KiB
C++
Raw Normal View History

2021-03-25 05:00:19 -07:00
#include "quit.h"
#include "ui_quit.h"
#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);
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;
poweroff(true);
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;
reboot(true);
qApp->quit();
2021-03-25 05:00:19 -07:00
}
void quit::on_pushButton_4_clicked()
{
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()
{
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
}