KoBox settings: enable/disable X11

This commit is contained in:
Nicolas Mailloux 2021-05-01 15:53:52 -04:00
parent 3404337e29
commit e19f3867ca
7 changed files with 191 additions and 44 deletions

View file

@ -24,6 +24,7 @@ namespace global {
} }
namespace kobox { namespace kobox {
inline bool showKoboxSplash; inline bool showKoboxSplash;
inline bool koboxSettingsRebootDialog;
} }
namespace mainwindow { namespace mainwindow {
namespace tabSwitcher { namespace tabSwitcher {
@ -37,6 +38,9 @@ namespace global {
inline bool updateDialog; inline bool updateDialog;
inline bool lowBatteryDialog; inline bool lowBatteryDialog;
} }
namespace settings {
inline bool settingsRebootDialog;
}
} }
// https://stackoverflow.com/questions/6080853/c-multiple-definition-error-for-global-functions-in-the-header-file/20679534#20679534 // https://stackoverflow.com/questions/6080853/c-multiple-definition-error-for-global-functions-in-the-header-file/20679534#20679534

View file

@ -62,13 +62,18 @@ generalDialog::generalDialog(QWidget *parent) :
this->adjustSize(); this->adjustSize();
string_writeconfig("/inkbox/updateDialog", "false"); string_writeconfig("/inkbox/updateDialog", "false");
} }
else if(checkconfig("/inkbox/settingsRebootDialog") == true) { else if(global::settings::settingsRebootDialog == true) {
settingsRebootDialog = true; settingsRebootDialog = true;
ui->stackedWidget->setCurrentIndex(1); ui->stackedWidget->setCurrentIndex(1);
ui->bodyLabel->setText("The settings you chose might require a complete reboot of the device for them to work properly."); if(global::kobox::koboxSettingsRebootDialog == true) {
koboxSettingsRebootDialog = true;
ui->bodyLabel->setText("The device will reboot now, since the settings you chose require it to work properly.");
}
else {
ui->bodyLabel->setText("The settings you chose might require a complete reboot of the device for them to work properly.");
}
ui->headerLabel->setText("Information"); ui->headerLabel->setText("Information");
this->adjustSize(); this->adjustSize();
string_writeconfig("/inkbox/settingsRebootDialog", "false");
} }
else if(global::mainwindow::lowBatteryDialog == true) { else if(global::mainwindow::lowBatteryDialog == true) {
lowBatteryDialog = true; lowBatteryDialog = true;
@ -158,9 +163,14 @@ void generalDialog::on_acceptBtn_clicked()
} }
if(settingsRebootDialog == true) { if(settingsRebootDialog == true) {
QProcess process; if(koboxSettingsRebootDialog == true) {
process.startDetached("inkbox.sh", QStringList()); reboot(true);
qApp->quit(); }
else {
QProcess process;
process.startDetached("inkbox.sh", QStringList());
qApp->quit();
}
} }
// We don't have any other option ;p // We don't have any other option ;p

View file

@ -19,6 +19,7 @@ public:
bool resetDialog = false; bool resetDialog = false;
bool updateDialog = false; bool updateDialog = false;
bool settingsRebootDialog = false; bool settingsRebootDialog = false;
bool koboxSettingsRebootDialog = false;
bool lowBatteryDialog = false; bool lowBatteryDialog = false;
private slots: private slots:

View file

@ -1,5 +1,6 @@
#include "koboxsettings.h" #include "koboxsettings.h"
#include "ui_koboxsettings.h" #include "ui_koboxsettings.h"
#include "functions.h"
#include <QFile> #include <QFile>
@ -17,6 +18,15 @@ koboxSettings::koboxSettings(QWidget *parent) :
// UI tweaks // UI tweaks
ui->okBtn->setProperty("type", "borderless"); ui->okBtn->setProperty("type", "borderless");
if(checkconfig("/external_root/boot/flags/X11_START") == true) {
ui->koboxStatusLabel->setText("KoBox is <b>enabled</b>");
not_user_change = true;
ui->checkBox->click();
}
else {
ui->koboxStatusLabel->setText("KoBox is <b>disabled</b>");
}
} }
koboxSettings::~koboxSettings() koboxSettings::~koboxSettings()
@ -28,3 +38,28 @@ void koboxSettings::on_okBtn_clicked()
{ {
koboxSettings::close(); koboxSettings::close();
} }
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);
generalDialogWindow->show();
}

View file

@ -3,6 +3,8 @@
#include <QWidget> #include <QWidget>
#include "generaldialog.h"
namespace Ui { namespace Ui {
class koboxSettings; class koboxSettings;
} }
@ -15,11 +17,16 @@ public:
explicit koboxSettings(QWidget *parent = nullptr); explicit koboxSettings(QWidget *parent = nullptr);
~koboxSettings(); ~koboxSettings();
bool not_user_change = false;
void openSettingsRebootDialog();
private slots: private slots:
void on_okBtn_clicked(); void on_okBtn_clicked();
void on_checkBox_toggled(bool checked);
private: private:
Ui::koboxSettings *ui; Ui::koboxSettings *ui;
generalDialog *generalDialogWindow;
}; };
#endif // KOBOXSETTINGS_H #endif // KOBOXSETTINGS_H

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>446</width>
<height>300</height> <height>514</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -16,17 +16,112 @@
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="1" column="0"> <item row="2" column="0">
<widget class="Line" name="line"> <widget class="QStackedWidget" name="stackedWidget">
<property name="frameShadow"> <widget class="QWidget" name="page">
<enum>QFrame::Plain</enum> <layout class="QVBoxLayout" name="verticalLayout_2">
</property> <property name="leftMargin">
<property name="lineWidth"> <number>0</number>
<number>5</number> </property>
</property> <property name="topMargin">
<property name="orientation"> <number>0</number>
<enum>Qt::Horizontal</enum> </property>
</property> <property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="3" column="0">
<widget class="QLabel" name="koboxStatusLabel">
<property name="text">
<string>KoBox is &lt;status&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="Line" name="line_3">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="5" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="1">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Enable</string>
</property>
</widget>
</item>
<item row="0" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>KoBox status</string>
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2"/>
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
@ -46,31 +141,26 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="5" column="0">
<widget class="QStackedWidget" name="stackedWidget"> <widget class="QStackedWidget" name="settingsWidget">
<widget class="QWidget" name="page"> <widget class="QWidget" name="page_5"/>
<layout class="QVBoxLayout" name="verticalLayout_2"> <widget class="QWidget" name="page_6"/>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout_2"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2"/>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="1" column="0">
<widget class="Line" name="line">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>5</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QPushButton" name="okBtn"> <widget class="QPushButton" name="okBtn">
<property name="font"> <property name="font">
<font> <font>
@ -86,7 +176,7 @@ OK
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="7" column="0">
<widget class="Line" name="line_2"> <widget class="Line" name="line_2">
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Plain</enum> <enum>QFrame::Plain</enum>

View file

@ -241,7 +241,7 @@ void settings::on_okBtn_clicked() {
if(launch_sh == true) { if(launch_sh == true) {
if(ui_enable_changed == true) { if(ui_enable_changed == true) {
ui_enable_changed = false; ui_enable_changed = false;
string_writeconfig("/inkbox/settingsRebootDialog", "true"); global::settings::settingsRebootDialog = true;
generalDialogWindow = new generalDialog(); generalDialogWindow = new generalDialog();
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose); generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
generalDialogWindow->show(); generalDialogWindow->show();