quill/koboxsettings.cpp

132 lines
3.9 KiB
C++
Raw Normal View History

2021-04-27 05:40:08 -07:00
#include "koboxsettings.h"
#include "ui_koboxsettings.h"
2021-05-01 12:53:52 -07:00
#include "functions.h"
2021-04-27 05:40:08 -07:00
#include <QFile>
2021-05-13 18:40:05 -07:00
#include <QScreen>
2021-04-27 05:40:08 -07:00
koboxSettings::koboxSettings(QWidget *parent) :
QWidget(parent),
ui(new Ui::koboxSettings)
{
ui->setupUi(this);
koboxSettings::setFont(QFont("u001"));
ui->okBtn->setFont(QFont("Inter"));
2021-04-27 05:40:08 -07:00
2021-05-13 18:40:05 -07:00
// UI tweaks
ui->okBtn->setProperty("type", "borderless");
ui->pushButton->setProperty("type", "borderless");
ui->resetKoboxBtn->setProperty("type", "borderless");
ui->pushButton->setStyleSheet("font-weight: bold");
2022-03-06 10:37:01 -08:00
ui->resetKoboxBtn->setStyleSheet("font-weight: bold");
ui->okBtn->setStyleSheet("font-weight: bold");
2021-05-13 18:40:05 -07:00
2021-04-27 05:40:08 -07:00
// Stylesheet
2022-04-03 20:26:15 -07:00
QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss");
2021-04-27 05:40:08 -07:00
stylesheetFile.open(QFile::ReadOnly);
this->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
2021-05-01 12:53:52 -07:00
if(checkconfig("/external_root/boot/flags/X11_START") == true) {
ui->koboxStatusLabel->setText("KoBox is <b>enabled</b>");
not_user_change = true;
ui->checkBox->click();
ui->runtimeSettingsWidget->setVisible(true);
2021-05-01 12:53:52 -07:00
}
else {
ui->koboxStatusLabel->setText("KoBox is <b>disabled</b>");
ui->runtimeSettingsWidget->setVisible(false);
2021-05-01 12:53:52 -07:00
}
// DPI setting
QString dpiSetting;
string_checkconfig(".config/00-kobox/dpiSetting");
if(checkconfig_str_val == "") {
if(global::deviceID == "n705\n" or global::deviceID == "n905\n") {
dpiSetting = "125";
}
else if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n306\n") {
dpiSetting = "175";
}
else if(global::deviceID == "n437\n") {
2022-02-06 19:49:06 -08:00
dpiSetting = "225";
}
else if(global::deviceID == "n873\n") {
dpiSetting = "250";
}
else {
dpiSetting = "125";
}
std::string dpiSetting_str = dpiSetting.toStdString();
string_writeconfig(".config/00-kobox/dpiSetting", dpiSetting_str);
}
string_checkconfig(".config/00-kobox/dpiSetting");
int dpi_setting = checkconfig_str_val.toInt();
ui->spinBox->setValue(dpi_setting);
2021-04-27 05:40:08 -07:00
}
koboxSettings::~koboxSettings()
{
delete ui;
}
void koboxSettings::on_okBtn_clicked()
{
koboxSettings::close();
}
2021-05-01 12:53:52 -07:00
void koboxSettings::on_checkBox_toggled(bool checked)
{
if(checked == true) {
if(not_user_change != true) {
string_writeconfig("/external_root/boot/flags/X11_START", "true");
openSettingsRebootDialog();
}
else {
not_user_change = false;
}
}
else {
string_writeconfig("/external_root/boot/flags/X11_START", "false");
openSettingsRebootDialog();
}
}
void koboxSettings::openSettingsRebootDialog() {
global::settings::settingsRebootDialog = true;
global::kobox::koboxSettingsRebootDialog = true;
generalDialogWindow = new generalDialog(this);
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
}
void koboxSettings::openResetKoboxDialog() {
global::kobox::resetKoboxDialog = true;
generalDialogWindow = new generalDialog(this);
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
}
void koboxSettings::on_spinBox_valueChanged(int arg1)
{
QString number = QString::number(arg1);
string number_str = number.toStdString();
string_writeconfig(".config/00-kobox/dpiSetting", number_str);
}
2021-05-13 18:40:05 -07:00
void koboxSettings::on_pushButton_clicked()
{
// Export Extensions disk image over USB with g_mass_storage
global::usbms::usbmsDialog = false;
global::usbms::launchUsbms = true;
global::usbms::koboxExportExtensions = true;
usbmsWindow = new usbms_splash();
usbmsWindow->setAttribute(Qt::WA_DeleteOnClose);
usbmsWindow->setGeometry(QRect(QPoint(0,0), screen()->geometry ().size()));
usbmsWindow->show();
}
void koboxSettings::on_resetKoboxBtn_clicked()
{
openResetKoboxDialog();
}