Migrated Settings to QStackedWidget

This commit is contained in:
Nicolas Mailloux 2021-03-28 01:14:37 -04:00
parent 2f0c8d2a30
commit ae00cc42a3
3 changed files with 473 additions and 477 deletions

View file

@ -115,7 +115,7 @@
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>4</number>
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>

View file

@ -46,14 +46,8 @@ settings::settings(QWidget *parent) :
ui->label_6->hide();
ui->line_3->hide();
ui->line_7->hide();
ui->line_9->hide();
ui->softwareLabel->hide();
ui->updateBtn->hide();
ui->updateLabel->hide();
ui->darkModeCheckBox->hide();
ui->uiScalingLabel->hide();
ui->uiScalingSlider->hide();
ui->uiScaleNumberLabel->hide();
// Settings tweaking + enabling specific features whether it's running on the provided integrated OS or Kobo firmware
if(checkconfig(".config/01-demo/config") == true) {
@ -281,31 +275,13 @@ void settings::on_usbmsBtn_clicked()
usbms_t->start();
}
// Please forgive me, I didn't know that QStackedWidget existed back then...
// Now I know that QStackedWidget exists... ;p
void settings::on_previousBtn_clicked()
{
settings_page = settings_page - 1;
if(settings_page == 1) {
ui->line_6->show();
ui->label_2->show();
ui->demoCheckBox->show();
ui->quoteCheckBox->show();
ui->line_8->show();
ui->label_7->show();
ui->wordsNumber->show();
ui->wordsNumberLabel->show();
ui->clockCheckBox->show();
ui->menuBarCheckBox->show();
ui->line_9->hide();
ui->softwareLabel->hide();
ui->updateBtn->hide();
ui->updateLabel->hide();
ui->darkModeCheckBox->hide();
ui->uiScalingLabel->hide();
ui->uiScalingSlider->hide();
ui->uiScaleNumberLabel->hide();
ui->stackedWidget->setCurrentIndex(0);
if(checkconfig("/opt/inkbox_genuine") == true) {
// Enforcing security policy if the user has not rooted the device
@ -321,38 +297,20 @@ void settings::on_previousBtn_clicked()
ui->label_3->hide();
ui->line_3->hide();
}
ui->label_5->show();
ui->label_6->show();
ui->line_7->show();
ui->usbmsBtn->show();
}
}
else {
if(settings_page == 2) {
ui->line_6->hide();
ui->label_2->hide();
ui->label_7->hide();
ui->line_8->hide();
ui->clockCheckBox->hide();
ui->menuBarCheckBox->hide();
ui->demoCheckBox->hide();
ui->quoteCheckBox->hide();
ui->stackedWidget->setCurrentIndex(1);
if(checkconfig("/opt/inkbox_genuine") == true) {
ui->label_3->hide();
ui->label_4->hide();
ui->label_5->hide();
ui->label_6->hide();
ui->line_7->hide();
ui->line_3->hide();
ui->line_9->show();
ui->softwareLabel->show();
ui->darkModeCheckBox->show();
if(checkconfig("/mnt/onboard/onboard/.inkbox/can_update") == true) {
ui->updateBtn->show();
ui->updateLabel->show();
}
else {
ui->updateBtn->show();
ui->updateLabel->show();
}
}
}
if(settings_page <= 0) {
@ -366,23 +324,7 @@ void settings::on_nextBtn_clicked()
{
settings_page = settings_page + 1;
if(settings_page == 2) {
ui->line_6->hide();
ui->label_2->hide();
ui->label_7->hide();
ui->line_8->hide();
ui->demoCheckBox->hide();
ui->quoteCheckBox->hide();
ui->clockCheckBox->hide();
ui->menuBarCheckBox->hide();
ui->wordsNumber->hide();
ui->wordsNumberLabel->hide();
ui->line_9->show();
ui->softwareLabel->show();
ui->darkModeCheckBox->show();
ui->uiScalingLabel->show();
ui->uiScalingSlider->show();
ui->uiScaleNumberLabel->show();
ui->stackedWidget->setCurrentIndex(1);
if(checkconfig("/opt/inkbox_genuine") == true) {
// Enforcing security policy if the user has not rooted the device
@ -398,14 +340,6 @@ void settings::on_nextBtn_clicked()
ui->label_3->hide();
ui->line_3->hide();
}
ui->label_3->hide();
ui->label_4->hide();
ui->label_5->hide();
ui->label_6->hide();
ui->line_7->hide();
ui->line_3->hide();
ui->requestLeaseBtn->hide();
ui->usbmsBtn->hide();
if(checkconfig("/mnt/onboard/onboard/.inkbox/can_update") == true) {
ui->updateBtn->show();

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>477</width>
<height>650</height>
<height>603</height>
</rect>
</property>
<property name="windowTitle">
@ -16,13 +16,119 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="33" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="Line" name="line_4">
<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="29" column="0">
<widget class="QPushButton" name="aboutBtn">
<property name="text">
<string>About InkBox</string>
</property>
</widget>
</item>
<item row="28" column="0">
<widget class="Line" name="line_5">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="26" column="0">
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>6</number>
</property>
<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 row="0" column="0">
<widget class="QPushButton" name="okBtn">
<item>
<layout class="QGridLayout" name="gridLayout_11">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="9" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Networking</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="clockCheckBox">
<property name="text">
<string>Clock: Show seconds</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Home</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="Line" name="line_6">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="15" column="0">
<layout class="QGridLayout" name="gridLayout_4">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="2">
<widget class="QPushButton" name="usbmsBtn">
<property name="font">
<font>
<weight>75</weight>
@ -30,15 +136,46 @@
</font>
</property>
<property name="text">
<string>
OK
</string>
<string>Go</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Enter USB Mass Storage session</string>
</property>
</widget>
</item>
<item row="0" column="1">
<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="23" column="0">
<item row="0" column="0">
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Reading</string>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
@ -51,8 +188,8 @@ OK
</property>
</widget>
</item>
<item row="21" column="0">
<widget class="Line" name="line_3">
<item row="14" column="0">
<widget class="Line" name="line_7">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
@ -61,12 +198,19 @@ OK
</property>
</widget>
</item>
<item row="12" column="0">
<item row="8" column="0">
<widget class="QCheckBox" name="demoCheckBox">
<property name="text">
<string>Disable &quot;Welcome to InkBox&quot; message</string>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QGridLayout" name="gridLayout_6">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="1">
<item row="1" column="1">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -79,14 +223,14 @@ OK
</property>
</spacer>
</item>
<item row="0" column="0">
<item row="1" column="0">
<widget class="QLabel" name="wordsNumberLabel">
<property name="text">
<string>Words number per page</string>
</property>
</widget>
</item>
<item row="0" column="2">
<item row="1" column="2">
<widget class="QSpinBox" name="wordsNumber">
<property name="minimum">
<number>20</number>
@ -104,21 +248,8 @@ OK
</item>
</layout>
</item>
<item row="32" column="0">
<widget class="Line" name="line">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="Line" name="line_9">
<item row="10" column="0">
<widget class="Line" name="line_3">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
@ -127,58 +258,50 @@ OK
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<item row="7" column="0">
<widget class="QCheckBox" name="quoteCheckBox">
<property name="text">
<string>Home</string>
<string>Disable authors quotes</string>
</property>
</widget>
</item>
<item row="6" column="0">
<layout class="QGridLayout" name="gridLayout_8">
<item row="1" column="0">
<widget class="Line" name="line_8">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="12" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Request DHCP lease</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSlider" name="uiScalingSlider">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>2</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="uiScalingLabel">
<property name="text">
<string>UI scaling factor</string>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</spacer>
</item>
<item row="0" column="2">
<widget class="QLabel" name="uiScaleNumberLabel">
<widget class="QPushButton" name="requestLeaseBtn">
<property name="font">
<font>
<weight>75</weight>
@ -186,82 +309,40 @@ OK
</font>
</property>
<property name="text">
<string>1</string>
<string>Request</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="darkModeCheckBox">
<item row="3" column="0">
<widget class="QCheckBox" name="menuBarCheckBox">
<property name="text">
<string>Enable night mode</string>
<string>Always show menu bar</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Reading</string>
</property>
</layout>
</item>
</layout>
</widget>
</item>
<item row="16" column="0">
<widget class="Line" name="line_6">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
<property name="topMargin">
<number>0</number>
</property>
</widget>
</item>
<item row="29" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<property name="rightMargin">
<number>0</number>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
<property name="bottomMargin">
<number>0</number>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="Line" name="line_4">
<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="30" column="0">
<widget class="Line" name="line_5">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="8" column="0">
<item>
<layout class="QGridLayout" name="gridLayout_10">
<item row="4" column="0">
<layout class="QGridLayout" name="gridLayout_7">
<property name="bottomMargin">
<number>0</number>
@ -307,8 +388,15 @@ OK
</item>
</layout>
</item>
<item row="24" column="0">
<widget class="Line" name="line_7">
<item row="3" column="0">
<widget class="QCheckBox" name="darkModeCheckBox">
<property name="text">
<string>Enable night mode</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="Line" name="line_9">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
@ -317,11 +405,98 @@ OK
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="Line" name="line_8">
<item row="0" column="0">
<widget class="QLabel" name="softwareLabel">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Software</string>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QGridLayout" name="gridLayout_8">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="uiScalingLabel">
<property name="text">
<string>UI scaling factor</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSlider" name="uiScalingSlider">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>2</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="uiScaleNumberLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>1</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<spacer name="verticalSpacer_3">
<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>
</item>
<item row="30" column="0">
<widget class="Line" name="line">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -390,13 +565,26 @@ OK
</item>
</layout>
</item>
<item row="22" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<item row="27" 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>
<item row="32" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="2">
<widget class="QPushButton" name="requestLeaseBtn">
<item row="0" column="0">
<widget class="QPushButton" name="okBtn">
<property name="font">
<font>
<weight>75</weight>
@ -404,135 +592,9 @@ OK
</font>
</property>
<property name="text">
<string>Request</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Request DHCP lease</string>
</property>
</widget>
</item>
<item row="0" column="1">
<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>
</layout>
</item>
<item row="25" column="0">
<layout class="QGridLayout" name="gridLayout_4">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="1">
<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>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Enter USB Mass Storage session</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="usbmsBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Go</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="18" column="0">
<widget class="QCheckBox" name="quoteCheckBox">
<property name="text">
<string>Disable authors quotes</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="softwareLabel">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Software</string>
</property>
</widget>
</item>
<item row="19" column="0">
<widget class="QCheckBox" name="demoCheckBox">
<property name="text">
<string>Disable &quot;Welcome to InkBox&quot; message</string>
</property>
</widget>
</item>
<item row="20" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Networking</string>
</property>
</widget>
</item>
<item row="31" column="0">
<widget class="QPushButton" name="aboutBtn">
<property name="text">
<string>About InkBox</string>
</property>
</widget>
</item>
<item row="17" column="0">
<widget class="QCheckBox" name="clockCheckBox">
<property name="text">
<string>Clock: Show seconds</string>
</property>
</widget>
</item>
<item row="13" column="0">
<layout class="QGridLayout" name="gridLayout_10">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QCheckBox" name="menuBarCheckBox">
<property name="text">
<string>Always show menu bar</string>
<string>
OK
</string>
</property>
</widget>
</item>