From 3cdce7d0d1b1f6bbd2b89e5b91471f66b8f1348e Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Sun, 26 Dec 2021 08:36:29 -0500 Subject: [PATCH] Create new libraryWidget class and associate it with libraryButton --- eink.qrc | 1 + functions.h | 2 ++ inkbox.pro | 3 +++ librarywidget.cpp | 14 +++++++++++ librarywidget.h | 22 +++++++++++++++++ librarywidget.ui | 21 ++++++++++++++++ mainwindow.cpp | 31 +++++++++++++++++++++++ mainwindow.h | 34 ++++++++++++++------------ mainwindow.ui | 16 ++++++++++++ resources/online-library-inverted.png | Bin 0 -> 2581 bytes 10 files changed, 129 insertions(+), 15 deletions(-) create mode 100644 librarywidget.cpp create mode 100644 librarywidget.h create mode 100644 librarywidget.ui create mode 100644 resources/online-library-inverted.png diff --git a/eink.qrc b/eink.qrc index 50ea3e6..aa1f896 100644 --- a/eink.qrc +++ b/eink.qrc @@ -69,5 +69,6 @@ resources/error.png resources/alert-triangle.png resources/online-library.png + resources/online-library-inverted.png diff --git a/functions.h b/functions.h index d3eb55d..563010e 100644 --- a/functions.h +++ b/functions.h @@ -46,6 +46,8 @@ namespace global { inline bool appsWidgetSelected; inline bool settingsChooserWidgetCreated; inline bool settingsChooserWidgetSelected; + inline bool libraryWidgetCreated; + inline bool libraryWidgetSelected; } inline bool updateDialog; inline bool lowBatteryDialog; diff --git a/inkbox.pro b/inkbox.pro index 3ce87ae..5de523f 100644 --- a/inkbox.pro +++ b/inkbox.pro @@ -21,6 +21,7 @@ SOURCES += \ hourglassanimationwidget.cpp \ koboxappsdialog.cpp \ koboxsettings.cpp \ + librarywidget.cpp \ main.cpp \ mainwindow.cpp \ otamanager.cpp \ @@ -49,6 +50,7 @@ HEADERS += \ hourglassanimationwidget.h \ koboxappsdialog.h \ koboxsettings.h \ + librarywidget.h \ mainwindow.h \ otamanager.h \ quit.h \ @@ -75,6 +77,7 @@ FORMS += \ hourglassanimationwidget.ui \ koboxappsdialog.ui \ koboxsettings.ui \ + librarywidget.ui \ mainwindow.ui \ otamanager.ui \ quit.ui \ diff --git a/librarywidget.cpp b/librarywidget.cpp new file mode 100644 index 0000000..41cfcc1 --- /dev/null +++ b/librarywidget.cpp @@ -0,0 +1,14 @@ +#include "librarywidget.h" +#include "ui_librarywidget.h" + +libraryWidget::libraryWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::libraryWidget) +{ + ui->setupUi(this); +} + +libraryWidget::~libraryWidget() +{ + delete ui; +} diff --git a/librarywidget.h b/librarywidget.h new file mode 100644 index 0000000..55e8dec --- /dev/null +++ b/librarywidget.h @@ -0,0 +1,22 @@ +#ifndef LIBRARYWIDGET_H +#define LIBRARYWIDGET_H + +#include + +namespace Ui { +class libraryWidget; +} + +class libraryWidget : public QWidget +{ + Q_OBJECT + +public: + explicit libraryWidget(QWidget *parent = nullptr); + ~libraryWidget(); + +private: + Ui::libraryWidget *ui; +}; + +#endif // LIBRARYWIDGET_H diff --git a/librarywidget.ui b/librarywidget.ui new file mode 100644 index 0000000..5334eed --- /dev/null +++ b/librarywidget.ui @@ -0,0 +1,21 @@ + + + + + libraryWidget + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/mainwindow.cpp b/mainwindow.cpp index fd8c832..94c6117 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -720,11 +720,16 @@ void MainWindow::resetWindow(bool resetStackedWidget) { if(global::mainwindow::tabSwitcher::settingsChooserWidgetCreated == true) { settingsChooserWindow->deleteLater(); } + if(global::mainwindow::tabSwitcher::libraryWidgetCreated == true) { + libraryWidgetWindow->deleteLater(); + } global::mainwindow::tabSwitcher::appsWidgetCreated = false; global::mainwindow::tabSwitcher::settingsChooserWidgetCreated = false; global::mainwindow::tabSwitcher::appsWidgetSelected = false; global::mainwindow::tabSwitcher::settingsChooserWidgetSelected = false; + global::mainwindow::tabSwitcher::libraryWidgetCreated = false; + global::mainwindow::tabSwitcher::libraryWidgetSelected = false; resetIcons(); setBatteryIcon(); @@ -739,6 +744,8 @@ void MainWindow::resetIcons() { ui->appsBtn->setIcon(QIcon(":/resources/apps.png")); ui->settingsBtn->setStyleSheet("background: white"); ui->settingsBtn->setIcon(QIcon(":/resources/settings.png")); + ui->libraryButton->setStyleSheet("background: white"); + ui->libraryButton->setIcon(QIcon(":/resources/online-library.png")); } void MainWindow::setBatteryIcon() { @@ -1030,3 +1037,27 @@ void MainWindow::checkForUpdate() { void MainWindow::openEncfsEncryptDialog() { } + +void MainWindow::on_libraryButton_clicked() +{ + resetWindow(false); + if(global::mainwindow::tabSwitcher::libraryWidgetSelected != true) { + ui->libraryButton->setStyleSheet("background: black; color: white"); + ui->libraryButton->setIcon(QIcon(":/resources/online-library-inverted.png")); + + // Create widget + libraryWidgetWindow = new libraryWidget(); + ui->stackedWidget->insertWidget(3, libraryWidgetWindow); + global::mainwindow::tabSwitcher::libraryWidgetCreated = true; + + // Switch tab + ui->stackedWidget->setCurrentIndex(3); + global::mainwindow::tabSwitcher::libraryWidgetSelected = true; + + // Repaint + this->repaint(); + } + else { + ; + } +} diff --git a/mainwindow.h b/mainwindow.h index 9039716..c74197a 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -17,6 +17,7 @@ #include "virtualkeypad.h" #include "toast.h" #include "otamanager.h" +#include "librarywidget.h" using namespace std; @@ -90,22 +91,25 @@ private slots: void checkForUpdate(); void openEncfsEncryptDialog(); + void on_libraryButton_clicked(); + private: - Ui::MainWindow *ui; - settingsChooser *settingsChooserWindow; - apps *appsWindow; - reader *readerWindow; - quit *quitWindow; - alert *alertWindow; - usbms_splash *usbmsWindow; - brightnessDialog *brightnessDialogWindow; - generalDialog *generalDialogWindow; - koboxSettings *koboxSettingsWindow; - koboxAppsDialog *koboxAppsDialogWindow; - textwidget *textwidgetWindow; - virtualkeypad *keypadWidget; - toast *toastWindow; - otaManager *otaManagerWindow; + Ui::MainWindow * ui; + settingsChooser * settingsChooserWindow; + apps * appsWindow; + reader * readerWindow; + quit * quitWindow; + alert * alertWindow; + usbms_splash * usbmsWindow; + brightnessDialog * brightnessDialogWindow; + generalDialog * generalDialogWindow; + koboxSettings * koboxSettingsWindow; + koboxAppsDialog * koboxAppsDialogWindow; + textwidget * textwidgetWindow; + virtualkeypad * keypadWidget; + toast * toastWindow; + otaManager * otaManagerWindow; + libraryWidget * libraryWidgetWindow; }; #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index 886b345..6f5eb65 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -437,6 +437,22 @@ + + + + 0 + + + 0 + + + 0 + + + 0 + + + diff --git a/resources/online-library-inverted.png b/resources/online-library-inverted.png new file mode 100644 index 0000000000000000000000000000000000000000..5596ccbc929998a4386f87e79477addbb910a515 GIT binary patch literal 2581 zcmb_e3s4hB82;~ac@SO!f(k}C5U`*`ET|Mg0z@SRV^C4Bl$RsQU^Tv|cAy-u7F$$M zYd{$uTBH?3Kxc}BU?`%kprSBXtI|LVQbz$56eU9U&<@aOhR%31ncLm}+i$=B|91DX zMyaE76O&mBZ^y=Hy{1O05j`H@FNxZ#D`L->QQJdBSe2@{B;qFr_ z64ZsREI8(16_ehcp6?pOGu_&3&(HVz!F26T$8&wUN1Uzgg!>YsYijn_olN@nOo>5B zA~}GycXoc?Wo0uo$L?%uzpBEbr`x@|74xcUa4w1#H14?LXVV^GTWQY6 z{mag}KNnnMDwsKD^P7I$-R@WxxN%*<-k=-JsfDS>Po7v=o&Gqm<9uDvtTjPTbJQs{ z+12F@JCD@*gcKvS<7!mJ2-qn^lf2GzU8p& zHbeM1l|R#a{`xgfn)pw4t6rs5+v)1H;#JWhTdu}sFM_BC_PZGZ0e+l$C8VdfJLg&J zkbBd^9`=Xv+xAZDv@Jolup)eyiqRWAFT5+`(Mw0}6SN(`z?S}D$9inkXpp@_vTQNC zL(g1a&rp1)vH*Z%ED?LI+V%URyZ)OWIPw?!OFLdHfAQ?6ld_DDDVGhWjQY;)sfugs zk73Z<@Apv!N9ed5%`z(jH#ep6hD=a~8cj&C?8qmr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