Create new libraryWidget class and associate it with libraryButton

This commit is contained in:
Nicolas Mailloux 2021-12-26 08:36:29 -05:00
parent 591ecfe72f
commit 3cdce7d0d1
10 changed files with 129 additions and 15 deletions

View file

@ -69,5 +69,6 @@
<file>resources/error.png</file> <file>resources/error.png</file>
<file>resources/alert-triangle.png</file> <file>resources/alert-triangle.png</file>
<file>resources/online-library.png</file> <file>resources/online-library.png</file>
<file>resources/online-library-inverted.png</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -46,6 +46,8 @@ namespace global {
inline bool appsWidgetSelected; inline bool appsWidgetSelected;
inline bool settingsChooserWidgetCreated; inline bool settingsChooserWidgetCreated;
inline bool settingsChooserWidgetSelected; inline bool settingsChooserWidgetSelected;
inline bool libraryWidgetCreated;
inline bool libraryWidgetSelected;
} }
inline bool updateDialog; inline bool updateDialog;
inline bool lowBatteryDialog; inline bool lowBatteryDialog;

View file

@ -21,6 +21,7 @@ SOURCES += \
hourglassanimationwidget.cpp \ hourglassanimationwidget.cpp \
koboxappsdialog.cpp \ koboxappsdialog.cpp \
koboxsettings.cpp \ koboxsettings.cpp \
librarywidget.cpp \
main.cpp \ main.cpp \
mainwindow.cpp \ mainwindow.cpp \
otamanager.cpp \ otamanager.cpp \
@ -49,6 +50,7 @@ HEADERS += \
hourglassanimationwidget.h \ hourglassanimationwidget.h \
koboxappsdialog.h \ koboxappsdialog.h \
koboxsettings.h \ koboxsettings.h \
librarywidget.h \
mainwindow.h \ mainwindow.h \
otamanager.h \ otamanager.h \
quit.h \ quit.h \
@ -75,6 +77,7 @@ FORMS += \
hourglassanimationwidget.ui \ hourglassanimationwidget.ui \
koboxappsdialog.ui \ koboxappsdialog.ui \
koboxsettings.ui \ koboxsettings.ui \
librarywidget.ui \
mainwindow.ui \ mainwindow.ui \
otamanager.ui \ otamanager.ui \
quit.ui \ quit.ui \

14
librarywidget.cpp Normal file
View file

@ -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;
}

22
librarywidget.h Normal file
View file

@ -0,0 +1,22 @@
#ifndef LIBRARYWIDGET_H
#define LIBRARYWIDGET_H
#include <QWidget>
namespace Ui {
class libraryWidget;
}
class libraryWidget : public QWidget
{
Q_OBJECT
public:
explicit libraryWidget(QWidget *parent = nullptr);
~libraryWidget();
private:
Ui::libraryWidget *ui;
};
#endif // LIBRARYWIDGET_H

21
librarywidget.ui Normal file
View file

@ -0,0 +1,21 @@
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>libraryWidget</class>
<widget class="QWidget" name="libraryWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<pixmapfunction/>
<connections/>
</ui>

View file

@ -720,11 +720,16 @@ void MainWindow::resetWindow(bool resetStackedWidget) {
if(global::mainwindow::tabSwitcher::settingsChooserWidgetCreated == true) { if(global::mainwindow::tabSwitcher::settingsChooserWidgetCreated == true) {
settingsChooserWindow->deleteLater(); settingsChooserWindow->deleteLater();
} }
if(global::mainwindow::tabSwitcher::libraryWidgetCreated == true) {
libraryWidgetWindow->deleteLater();
}
global::mainwindow::tabSwitcher::appsWidgetCreated = false; global::mainwindow::tabSwitcher::appsWidgetCreated = false;
global::mainwindow::tabSwitcher::settingsChooserWidgetCreated = false; global::mainwindow::tabSwitcher::settingsChooserWidgetCreated = false;
global::mainwindow::tabSwitcher::appsWidgetSelected = false; global::mainwindow::tabSwitcher::appsWidgetSelected = false;
global::mainwindow::tabSwitcher::settingsChooserWidgetSelected = false; global::mainwindow::tabSwitcher::settingsChooserWidgetSelected = false;
global::mainwindow::tabSwitcher::libraryWidgetCreated = false;
global::mainwindow::tabSwitcher::libraryWidgetSelected = false;
resetIcons(); resetIcons();
setBatteryIcon(); setBatteryIcon();
@ -739,6 +744,8 @@ void MainWindow::resetIcons() {
ui->appsBtn->setIcon(QIcon(":/resources/apps.png")); ui->appsBtn->setIcon(QIcon(":/resources/apps.png"));
ui->settingsBtn->setStyleSheet("background: white"); ui->settingsBtn->setStyleSheet("background: white");
ui->settingsBtn->setIcon(QIcon(":/resources/settings.png")); ui->settingsBtn->setIcon(QIcon(":/resources/settings.png"));
ui->libraryButton->setStyleSheet("background: white");
ui->libraryButton->setIcon(QIcon(":/resources/online-library.png"));
} }
void MainWindow::setBatteryIcon() { void MainWindow::setBatteryIcon() {
@ -1030,3 +1037,27 @@ void MainWindow::checkForUpdate() {
void MainWindow::openEncfsEncryptDialog() { 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 {
;
}
}

View file

@ -17,6 +17,7 @@
#include "virtualkeypad.h" #include "virtualkeypad.h"
#include "toast.h" #include "toast.h"
#include "otamanager.h" #include "otamanager.h"
#include "librarywidget.h"
using namespace std; using namespace std;
@ -90,6 +91,8 @@ private slots:
void checkForUpdate(); void checkForUpdate();
void openEncfsEncryptDialog(); void openEncfsEncryptDialog();
void on_libraryButton_clicked();
private: private:
Ui::MainWindow * ui; Ui::MainWindow * ui;
settingsChooser * settingsChooserWindow; settingsChooser * settingsChooserWindow;
@ -106,6 +109,7 @@ private:
virtualkeypad * keypadWidget; virtualkeypad * keypadWidget;
toast * toastWindow; toast * toastWindow;
otaManager * otaManagerWindow; otaManager * otaManagerWindow;
libraryWidget * libraryWidgetWindow;
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

View file

@ -437,6 +437,22 @@
</property> </property>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="page_4">
<layout class="QVBoxLayout" name="verticalLayout_4">
<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>
</layout>
</widget>
</widget> </widget>
</item> </item>
<item> <item>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB