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> <enum>QFrame::Plain</enum>
</property> </property>
<property name="lineWidth"> <property name="lineWidth">
<number>4</number> <number>2</number>
</property> </property>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>

View file

@ -46,14 +46,8 @@ settings::settings(QWidget *parent) :
ui->label_6->hide(); ui->label_6->hide();
ui->line_3->hide(); ui->line_3->hide();
ui->line_7->hide(); ui->line_7->hide();
ui->line_9->hide();
ui->softwareLabel->hide();
ui->updateBtn->hide(); ui->updateBtn->hide();
ui->updateLabel->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 // Settings tweaking + enabling specific features whether it's running on the provided integrated OS or Kobo firmware
if(checkconfig(".config/01-demo/config") == true) { if(checkconfig(".config/01-demo/config") == true) {
@ -281,31 +275,13 @@ void settings::on_usbmsBtn_clicked()
usbms_t->start(); 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() void settings::on_previousBtn_clicked()
{ {
settings_page = settings_page - 1; settings_page = settings_page - 1;
if(settings_page == 1) { if(settings_page == 1) {
ui->line_6->show(); ui->stackedWidget->setCurrentIndex(0);
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();
if(checkconfig("/opt/inkbox_genuine") == true) { if(checkconfig("/opt/inkbox_genuine") == true) {
// Enforcing security policy if the user has not rooted the device // 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->label_3->hide();
ui->line_3->hide(); ui->line_3->hide();
} }
ui->label_5->show();
ui->label_6->show();
ui->line_7->show();
ui->usbmsBtn->show();
} }
} }
else { else {
if(settings_page == 2) { if(settings_page == 2) {
ui->line_6->hide(); ui->stackedWidget->setCurrentIndex(1);
ui->label_2->hide();
ui->label_7->hide();
ui->line_8->hide();
ui->clockCheckBox->hide();
ui->menuBarCheckBox->hide();
ui->demoCheckBox->hide();
ui->quoteCheckBox->hide();
if(checkconfig("/opt/inkbox_genuine") == true) { 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) { if(checkconfig("/mnt/onboard/onboard/.inkbox/can_update") == true) {
ui->updateBtn->show(); ui->updateBtn->show();
ui->updateLabel->show(); ui->updateLabel->show();
} }
else {
ui->updateBtn->show();
ui->updateLabel->show();
}
} }
} }
if(settings_page <= 0) { if(settings_page <= 0) {
@ -366,23 +324,7 @@ void settings::on_nextBtn_clicked()
{ {
settings_page = settings_page + 1; settings_page = settings_page + 1;
if(settings_page == 2) { if(settings_page == 2) {
ui->line_6->hide(); ui->stackedWidget->setCurrentIndex(1);
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();
if(checkconfig("/opt/inkbox_genuine") == true) { if(checkconfig("/opt/inkbox_genuine") == true) {
// Enforcing security policy if the user has not rooted the device // 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->label_3->hide();
ui->line_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) { if(checkconfig("/mnt/onboard/onboard/.inkbox/can_update") == true) {
ui->updateBtn->show(); ui->updateBtn->show();

View file

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>477</width> <width>477</width>
<height>650</height> <height>603</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -16,13 +16,119 @@
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="33" column="0"> <item row="2" column="0">
<layout class="QGridLayout" name="gridLayout_2"> <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"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="0"> <item>
<widget class="QPushButton" name="okBtn"> <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"> <property name="font">
<font> <font>
<weight>75</weight> <weight>75</weight>
@ -30,15 +136,46 @@
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string> <string>Go</string>
OK
</string>
</property> </property>
</widget> </widget>
</item> </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> </layout>
</item> </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"> <widget class="QLabel" name="label_5">
<property name="font"> <property name="font">
<font> <font>
@ -51,8 +188,8 @@ OK
</property> </property>
</widget> </widget>
</item> </item>
<item row="21" column="0"> <item row="14" column="0">
<widget class="Line" name="line_3"> <widget class="Line" name="line_7">
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Plain</enum> <enum>QFrame::Plain</enum>
</property> </property>
@ -61,12 +198,19 @@ OK
</property> </property>
</widget> </widget>
</item> </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"> <layout class="QGridLayout" name="gridLayout_6">
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="1"> <item row="1" column="1">
<spacer name="horizontalSpacer_5"> <spacer name="horizontalSpacer_5">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -79,14 +223,14 @@ OK
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="0" column="0"> <item row="1" column="0">
<widget class="QLabel" name="wordsNumberLabel"> <widget class="QLabel" name="wordsNumberLabel">
<property name="text"> <property name="text">
<string>Words number per page</string> <string>Words number per page</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="1" column="2">
<widget class="QSpinBox" name="wordsNumber"> <widget class="QSpinBox" name="wordsNumber">
<property name="minimum"> <property name="minimum">
<number>20</number> <number>20</number>
@ -104,21 +248,8 @@ OK
</item> </item>
</layout> </layout>
</item> </item>
<item row="32" column="0"> <item row="10" column="0">
<widget class="Line" name="line"> <widget class="Line" name="line_3">
<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">
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Plain</enum> <enum>QFrame::Plain</enum>
</property> </property>
@ -127,58 +258,50 @@ OK
</property> </property>
</widget> </widget>
</item> </item>
<item row="15" column="0"> <item row="7" column="0">
<widget class="QLabel" name="label_2"> <widget class="QCheckBox" name="quoteCheckBox">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text"> <property name="text">
<string>Home</string> <string>Disable authors quotes</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_8"> <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"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </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"> <item row="0" column="1">
<widget class="QSlider" name="uiScalingSlider"> <spacer name="horizontalSpacer">
<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"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> <property name="sizeHint" stdset="0">
</item> <size>
<item row="0" column="0"> <width>40</width>
<widget class="QLabel" name="uiScalingLabel"> <height>20</height>
<property name="text"> </size>
<string>UI scaling factor</string>
</property> </property>
<property name="alignment"> </spacer>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
<widget class="QLabel" name="uiScaleNumberLabel"> <widget class="QPushButton" name="requestLeaseBtn">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight> <weight>75</weight>
@ -186,82 +309,40 @@ OK
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>1</string> <string>Request</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item row="7" column="0"> <item row="3" column="0">
<widget class="QCheckBox" name="darkModeCheckBox"> <widget class="QCheckBox" name="menuBarCheckBox">
<property name="text"> <property name="text">
<string>Enable night mode</string> <string>Always show menu bar</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="0"> </layout>
<widget class="QLabel" name="label_7"> </item>
<property name="font"> </layout>
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Reading</string>
</property>
</widget> </widget>
</item> <widget class="QWidget" name="page_2">
<item row="16" column="0"> <layout class="QVBoxLayout" name="verticalLayout_3">
<widget class="Line" name="line_6"> <property name="leftMargin">
<property name="frameShadow"> <number>0</number>
<enum>QFrame::Plain</enum>
</property> </property>
<property name="orientation"> <property name="topMargin">
<enum>Qt::Horizontal</enum> <number>0</number>
</property> </property>
</widget> <property name="rightMargin">
</item> <number>0</number>
<item row="29" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="bottomMargin">
<size> <number>0</number>
<width>20</width>
<height>40</height>
</size>
</property> </property>
</spacer> <item>
</item> <layout class="QGridLayout" name="gridLayout_10">
<item row="2" column="0"> <item row="4" 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">
<layout class="QGridLayout" name="gridLayout_7"> <layout class="QGridLayout" name="gridLayout_7">
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
@ -307,8 +388,15 @@ OK
</item> </item>
</layout> </layout>
</item> </item>
<item row="24" column="0"> <item row="3" column="0">
<widget class="Line" name="line_7"> <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"> <property name="frameShadow">
<enum>QFrame::Plain</enum> <enum>QFrame::Plain</enum>
</property> </property>
@ -317,11 +405,98 @@ OK
</property> </property>
</widget> </widget>
</item> </item>
<item row="11" column="0"> <item row="0" column="0">
<widget class="Line" name="line_8"> <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"> <property name="frameShadow">
<enum>QFrame::Plain</enum> <enum>QFrame::Plain</enum>
</property> </property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
@ -390,13 +565,26 @@ OK
</item> </item>
</layout> </layout>
</item> </item>
<item row="22" column="0"> <item row="27" column="0">
<layout class="QGridLayout" name="gridLayout_3"> <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"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="2"> <item row="0" column="0">
<widget class="QPushButton" name="requestLeaseBtn"> <widget class="QPushButton" name="okBtn">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight> <weight>75</weight>
@ -404,135 +592,9 @@ OK
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>Request</string> <string>
</property> OK
</widget> </string>
</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>
</property> </property>
</widget> </widget>
</item> </item>