diff --git a/apps.ui b/apps.ui index bef8bac..5c01a56 100644 --- a/apps.ui +++ b/apps.ui @@ -204,7 +204,7 @@ QFrame::Plain - 5 + 3 Qt::Horizontal diff --git a/eink.qrc b/eink.qrc index 5b4508c..be6cef4 100644 --- a/eink.qrc +++ b/eink.qrc @@ -40,5 +40,8 @@ resources/battery_alert.png resources/apps-inverted.png resources/home.png + resources/settings-inverted.png + resources/kobox-icon.png + resources/X11.png diff --git a/functions.h b/functions.h index c98541a..3d26fde 100644 --- a/functions.h +++ b/functions.h @@ -24,8 +24,11 @@ namespace global { } namespace mainwindow { namespace tabSwitcher { + inline bool repaint; + inline bool appsWidgetCreated; inline bool appsWidgetSelected; + inline bool settingsWidgetSelected; } inline bool updateDialog; inline bool lowBatteryDialog; diff --git a/mainwindow.cpp b/mainwindow.cpp index e056cee..1e83f88 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -20,6 +20,7 @@ #include #include #include +#include using namespace std; @@ -36,6 +37,8 @@ MainWindow::MainWindow(QWidget *parent) ui->pushButton->setProperty("type", "borderless"); ui->brightnessBtn->setProperty("type", "borderless"); ui->homeBtn->setProperty("type", "borderless"); + ui->inkboxSettingsBtn->setProperty("type", "borderless"); + ui->koboxSettingsBtn->setProperty("type", "borderless"); ui->settingsBtn->setText(""); ui->appsBtn->setText(""); @@ -44,12 +47,21 @@ MainWindow::MainWindow(QWidget *parent) ui->searchBtn->setText(""); ui->brightnessBtn->setText(""); ui->homeBtn->setText(""); + ui->inkboxSettingsBtn->setText("\t\t\tInkBox settings"); + ui->koboxSettingsBtn->setText("\t\t\tKoBox settings"); + ui->quoteLabel->setText(""); + + ui->quotePictureLabel->setText(""); ui->quoteHeadingLabel->setStyleSheet("padding: 30px"); + ui->homeBtn->setStyleSheet("padding: 5px"); + ui->inkboxSettingsBtn->setStyleSheet("padding: 40px; Text-align: left"); + ui->koboxSettingsBtn->setStyleSheet("padding: 40px; Text-align: left"); // Variables global::battery::showLowBatteryDialog = true; global::battery::showCriticalBatteryAlert = true; + global::mainwindow::tabSwitcher::repaint = true; // Getting the screen's size sW = QGuiApplication::screens()[0]->size().width(); @@ -92,6 +104,11 @@ MainWindow::MainWindow(QWidget *parent) ui->brightnessBtn->setIcon(QIcon(":/resources/frontlight.png")); ui->brightnessBtn->setIconSize(QSize(brightnessIconWidth, brightnessIconHeight)); + ui->inkboxSettingsBtn->setIcon(QIcon(":/resources/settings.png")); + ui->inkboxSettingsBtn->setIconSize(QSize(homeIconWidth, homeIconHeight)); + ui->koboxSettingsBtn->setIcon(QIcon(":/resources/X11.png")); + ui->koboxSettingsBtn->setIconSize(QSize(homeIconWidth, homeIconHeight)); + // Battery string_checkconfig_ro("/opt/inkbox_device"); if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n") { @@ -387,8 +404,9 @@ MainWindow::MainWindow(QWidget *parent) } } else { - ui->quoteLabel->hide(); - ui->quotePictureLabel->hide(); + ui->gridLayout_4->deleteLater(); + ui->quotePictureLabel->deleteLater(); + ui->quoteLabel->deleteLater(); ui->quoteHeadingLabel->setText("Books"); ui->book1Btn->show(); ui->book2Btn->show(); @@ -530,26 +548,47 @@ void MainWindow::openCriticalBatteryAlertWindow() { void MainWindow::on_settingsBtn_clicked() { - settingsWindow = new settings(); - settingsWindow->setAttribute(Qt::WA_DeleteOnClose); - settingsWindow->showFullScreen(); + resetWindow(false); + if(global::mainwindow::tabSwitcher::settingsWidgetSelected != true) { + ui->settingsBtn->setStyleSheet("background: black"); + ui->settingsBtn->setIcon(QIcon(":/resources/settings-inverted.png")); + + // Switch tab + ui->stackedWidget->setCurrentIndex(2); + global::mainwindow::tabSwitcher::settingsWidgetSelected = true; + + // Repaint + this->repaint(); + } + else { + ; + } } void MainWindow::on_appsBtn_clicked() { - ui->appsBtn->setStyleSheet("background: black"); - ui->appsBtn->setIcon(QIcon(":/resources/apps-inverted.png")); + resetWindow(false); + if(global::mainwindow::tabSwitcher::appsWidgetSelected != true) { + ui->appsBtn->setStyleSheet("background: black"); + ui->appsBtn->setIcon(QIcon(":/resources/apps-inverted.png")); - // Create the widget only once - if(global::mainwindow::tabSwitcher::appsWidgetCreated != true) { - appsWindow = new apps(); - ui->stackedWidget->insertWidget(1, appsWindow); - global::mainwindow::tabSwitcher::appsWidgetCreated = true; + // Create the widget only once + if(global::mainwindow::tabSwitcher::appsWidgetCreated != true) { + appsWindow = new apps(); + ui->stackedWidget->insertWidget(1, appsWindow); + global::mainwindow::tabSwitcher::appsWidgetCreated = true; + } + + // Switch tab + ui->stackedWidget->setCurrentIndex(1); + global::mainwindow::tabSwitcher::appsWidgetSelected = true; + + // Repaint + this->repaint(); + } + else { + ; } - - // Switch tab - ui->stackedWidget->setCurrentIndex(1); - global::mainwindow::tabSwitcher::appsWidgetSelected = true; } void MainWindow::on_pushButton_clicked() @@ -563,11 +602,9 @@ void MainWindow::on_searchBtn_clicked() { /*global::battery::showCriticalBatteryAlert = true; global::battery::showLowBatteryDialog = false; - - alertWindow = new alert(); - alertWindow->setAttribute(Qt::WA_DeleteOnClose); - alertWindow->setGeometry(QRect(QPoint(0,0), screen()->geometry ().size())); - alertWindow->show();*/ + settingsWindow = new settings(); + ui->stackedWidget->insertWidget(2, settingsWindow); + ui->stackedWidget->setCurrentIndex(2);*/ } void MainWindow::on_quitBtn_clicked() @@ -626,18 +663,27 @@ void MainWindow::on_brightnessBtn_clicked() void MainWindow::on_homeBtn_clicked() { - resetWindow(); + global::mainwindow::tabSwitcher::repaint = true; + resetWindow(true); } -void MainWindow::resetWindow() { +void MainWindow::resetWindow(bool resetStackedWidget) { // Reset layout - ui->stackedWidget->setCurrentIndex(0); + if(resetStackedWidget == true) { + ui->stackedWidget->setCurrentIndex(0); + } + global::mainwindow::tabSwitcher::appsWidgetSelected = false; + global::mainwindow::tabSwitcher::settingsWidgetSelected = false; resetIcons(); - this->repaint(); + if(global::mainwindow::tabSwitcher::repaint == true) { + this->repaint(); + } } void MainWindow::resetIcons() { // Reset icons ui->appsBtn->setStyleSheet("background: white"); ui->appsBtn->setIcon(QIcon(":/resources/apps.png")); + ui->settingsBtn->setStyleSheet("background: white"); + ui->settingsBtn->setIcon(QIcon(":/resources/settings.png")); } diff --git a/mainwindow.h b/mainwindow.h index 217e102..a85710d 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -41,7 +41,7 @@ public: void openLowBatteryDialog(); void openCriticalBatteryAlertWindow(); - void resetWindow(); + void resetWindow(bool resetStackedWidget); void resetIcons(); public slots: diff --git a/mainwindow.ui b/mainwindow.ui index 9f9238f..33ba5ac 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -167,16 +167,29 @@ - - + + + + Qt::Vertical + + + + 20 + 40 + + + + + + - Chivo - true + 75 + true - Recently read books will appear here. + Author's quote Qt::AlignCenter @@ -275,35 +288,6 @@ - - - - - 75 - true - - - - Author's quote - - - Qt::AlignCenter - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -353,14 +337,172 @@ + + + + + Chivo + true + + + + Recently read books will appear here. + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + - + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + QFrame::Plain + + + 3 + + + Qt::Horizontal + + + + + + + 0 + + + + + + Chivo + 50 + true + false + + + + KoBox settings + + + + + + + + Chivo + true + + + + InkBox settings + + + + + + + QFrame::Plain + + + Qt::Horizontal + + + + + + + QFrame::Plain + + + Qt::Horizontal + + + + + + + + + + 75 + true + + + + Settings + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + - diff --git a/resources/X11.png b/resources/X11.png new file mode 100644 index 0000000..426850c Binary files /dev/null and b/resources/X11.png differ diff --git a/resources/kobox-icon.png b/resources/kobox-icon.png new file mode 100644 index 0000000..484776d Binary files /dev/null and b/resources/kobox-icon.png differ diff --git a/resources/settings-inverted.png b/resources/settings-inverted.png new file mode 100644 index 0000000..27a8e15 Binary files /dev/null and b/resources/settings-inverted.png differ