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);
|
2022-03-02 21:40:11 -08:00
|
|
|
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");
|
2021-06-14 11:31:49 -07:00
|
|
|
ui->resetKoboxBtn->setProperty("type", "borderless");
|
2022-03-03 19:03:20 -08:00
|
|
|
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();
|
2021-06-20 10:31:24 -07:00
|
|
|
ui->runtimeSettingsWidget->setVisible(true);
|
2021-05-01 12:53:52 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
ui->koboxStatusLabel->setText("KoBox is <b>disabled</b>");
|
2021-06-20 10:31:24 -07:00
|
|
|
ui->runtimeSettingsWidget->setVisible(false);
|
2021-05-01 12:53:52 -07:00
|
|
|
}
|
2021-05-09 11:07:05 -07:00
|
|
|
|
|
|
|
// DPI setting
|
2021-06-27 10:28:41 -07:00
|
|
|
QString dpiSetting;
|
2021-05-09 11:07:05 -07:00
|
|
|
string_checkconfig(".config/00-kobox/dpiSetting");
|
|
|
|
if(checkconfig_str_val == "") {
|
2022-05-22 12:38:02 -07:00
|
|
|
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") {
|
2021-06-27 10:28:41 -07:00
|
|
|
dpiSetting = "125";
|
|
|
|
}
|
2022-04-02 13:49:18 -07:00
|
|
|
else if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n306\n") {
|
2021-06-27 10:28:41 -07:00
|
|
|
dpiSetting = "175";
|
|
|
|
}
|
2022-04-02 13:49:18 -07:00
|
|
|
else if(global::deviceID == "n437\n") {
|
2022-02-06 19:49:06 -08:00
|
|
|
dpiSetting = "225";
|
|
|
|
}
|
2022-04-02 13:49:18 -07:00
|
|
|
else if(global::deviceID == "n873\n") {
|
2021-07-10 22:08:38 -07:00
|
|
|
dpiSetting = "250";
|
|
|
|
}
|
2021-06-27 10:28:41 -07:00
|
|
|
else {
|
|
|
|
dpiSetting = "125";
|
|
|
|
}
|
|
|
|
std::string dpiSetting_str = dpiSetting.toStdString();
|
|
|
|
string_writeconfig(".config/00-kobox/dpiSetting", dpiSetting_str);
|
2021-05-09 11:07:05 -07:00
|
|
|
}
|
2021-06-27 10:28:41 -07:00
|
|
|
|
|
|
|
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) {
|
2022-04-15 17:27:58 -07:00
|
|
|
log("Enabling KoBox subsystem", className);
|
2021-05-01 12:53:52 -07:00
|
|
|
string_writeconfig("/external_root/boot/flags/X11_START", "true");
|
|
|
|
openSettingsRebootDialog();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
not_user_change = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2022-04-15 17:27:58 -07:00
|
|
|
log("Disabling KoBox subsystem", className);
|
2021-05-01 12:53:52 -07:00
|
|
|
string_writeconfig("/external_root/boot/flags/X11_START", "false");
|
|
|
|
openSettingsRebootDialog();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void koboxSettings::openSettingsRebootDialog() {
|
2022-04-17 19:25:29 -07:00
|
|
|
log("Showing reboot dialog", className);
|
2021-05-01 12:53:52 -07:00
|
|
|
global::settings::settingsRebootDialog = true;
|
|
|
|
global::kobox::koboxSettingsRebootDialog = true;
|
|
|
|
generalDialogWindow = new generalDialog(this);
|
|
|
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
}
|
2021-06-14 11:31:49 -07:00
|
|
|
void koboxSettings::openResetKoboxDialog() {
|
2022-04-17 19:25:29 -07:00
|
|
|
log("Showing KoBox reset dialog", className);
|
2021-06-14 11:31:49 -07:00
|
|
|
global::kobox::resetKoboxDialog = true;
|
|
|
|
generalDialogWindow = new generalDialog(this);
|
|
|
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
}
|
2021-05-09 11:07:05 -07:00
|
|
|
|
|
|
|
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);
|
2022-04-15 17:27:58 -07:00
|
|
|
log("X11 DPI set to " + number, className);
|
2021-05-09 11:07:05 -07:00
|
|
|
}
|
2021-05-13 18:40:05 -07:00
|
|
|
|
|
|
|
void koboxSettings::on_pushButton_clicked()
|
|
|
|
{
|
2022-05-23 12:24:21 -07:00
|
|
|
// Export Extensions disk image over USB with g_mass_storage/g_file_storage
|
2021-05-13 18:40:05 -07:00
|
|
|
global::usbms::usbmsDialog = false;
|
|
|
|
global::usbms::launchUsbms = true;
|
|
|
|
global::usbms::koboxExportExtensions = true;
|
|
|
|
|
2022-04-15 17:27:58 -07:00
|
|
|
log("Exporting KoBox extensions onboard storage via USB", className);
|
|
|
|
log("Showing USBMS splash", className);
|
2021-05-13 18:40:05 -07:00
|
|
|
usbmsWindow = new usbms_splash();
|
|
|
|
usbmsWindow->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
usbmsWindow->setGeometry(QRect(QPoint(0,0), screen()->geometry ().size()));
|
|
|
|
usbmsWindow->show();
|
|
|
|
}
|
2021-06-14 11:31:49 -07:00
|
|
|
|
|
|
|
void koboxSettings::on_resetKoboxBtn_clicked()
|
|
|
|
{
|
|
|
|
openResetKoboxDialog();
|
|
|
|
}
|