Working on libraryWidget

This commit is contained in:
Nicolas Mailloux 2021-12-26 13:28:43 -05:00
parent 3cdce7d0d1
commit fa1e05af99
4 changed files with 148 additions and 7 deletions

View file

@ -1,14 +1,58 @@
#include "librarywidget.h"
#include "ui_librarywidget.h"
#include "functions.h"
#include <QProcess>
#include <QDebug>
libraryWidget::libraryWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::libraryWidget)
{
ui->setupUi(this);
ui->book1Btn->setText("");
ui->book2Btn->setText("");
ui->book3Btn->setText("");
ui->book4Btn->setText("");
global::toast::modalToast = true;
global::toast::indefiniteToast = true;
showToast("Sync in progress");
string_writeconfig("/opt/ibxd", "gutenberg_sync\n");
QTimer * syncCheckTimer = new QTimer(this);
syncCheckTimer->setInterval(100);
connect(syncCheckTimer, &QTimer::timeout, [&]() {
if(QFile::exists("/inkbox/gutenbergSyncDone") == true) {
if(checkconfig("/inkbox/gutenbergSyncDone") == true) {
qDebug() << "Gutenberg sync successfully completed";
toastWindow->close();
setupView();
}
else {
qDebug() << "Gutenberg sync encountered an error";
toastWindow->close();
showToast("Error");
libraryWidget::close();
}
QFile::remove("/inkbox/gutenbergSyncDone");
}
} );
syncCheckTimer->start();
}
libraryWidget::~libraryWidget()
{
delete ui;
}
void libraryWidget::setupView() {
}
void libraryWidget::showToast(QString messageToDisplay) {
global::toast::message = messageToDisplay;
toastWindow = new toast(this);
toastWindow->setAttribute(Qt::WA_DeleteOnClose);
toastWindow->show();
}

View file

@ -2,6 +2,7 @@
#define LIBRARYWIDGET_H
#include <QWidget>
#include <toast.h>
namespace Ui {
class libraryWidget;
@ -16,7 +17,13 @@ public:
~libraryWidget();
private:
Ui::libraryWidget *ui;
Ui::libraryWidget * ui;
toast * toastWindow;
private slots:
void setupView();
void showToast(QString messageToDisplay);
};
#endif // LIBRARYWIDGET_H

View file

@ -1,21 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<width>526</width>
<height>419</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QPushButton" name="book1Btn">
<property name="text">
<string>Book 1</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="book3Btn">
<property name="text">
<string>Book 3</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="book2Btn">
<property name="text">
<string>Book 2</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="book4Btn">
<property name="text">
<string>Book 4</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="book1Label">
<property name="text">
<string>Book 1</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="book2Label">
<property name="text">
<string>Book 2</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="book3Label">
<property name="text">
<string>Book 3</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="book4Label">
<property name="text">
<string>Book 4</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<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>
</layout>
</item>
</layout>
</widget>
<pixmapfunction/>
<resources/>
<connections/>
</ui>

View file

@ -1047,6 +1047,7 @@ void MainWindow::on_libraryButton_clicked()
// Create widget
libraryWidgetWindow = new libraryWidget();
libraryWidgetWindow->setAttribute(Qt::WA_DeleteOnClose);
ui->stackedWidget->insertWidget(3, libraryWidgetWindow);
global::mainwindow::tabSwitcher::libraryWidgetCreated = true;