reader.cpp: More fixes

This commit is contained in:
Nicolas Mailloux 2023-06-12 17:09:53 -04:00
parent 683c28c4da
commit 73ff36502e
10 changed files with 264 additions and 19 deletions

View file

@ -36,6 +36,7 @@ SOURCES += \
src/widgets/dialogs/wifi/connectiondialog.cpp \ src/widgets/dialogs/wifi/connectiondialog.cpp \
src/widgets/dialogs/wifi/network.cpp \ src/widgets/dialogs/wifi/network.cpp \
src/widgets/dialogs/wifi/wifilogger.cpp \ src/widgets/dialogs/wifi/wifilogger.cpp \
src/widgets/misc/egg.cpp \
src/widgets/reader/dictionarywidget.cpp \ src/widgets/reader/dictionarywidget.cpp \
src/encfs/encryptionmanager.cpp \ src/encfs/encryptionmanager.cpp \
src/widgets/dialogs/generaldialog.cpp \ src/widgets/dialogs/generaldialog.cpp \
@ -80,6 +81,7 @@ HEADERS += \
src/widgets/dialogs/wifi/connectiondialog.h \ src/widgets/dialogs/wifi/connectiondialog.h \
src/widgets/dialogs/wifi/network.h \ src/widgets/dialogs/wifi/network.h \
src/widgets/dialogs/wifi/wifilogger.h \ src/widgets/dialogs/wifi/wifilogger.h \
src/widgets/misc/egg.h \
src/widgets/reader/dictionarywidget.h \ src/widgets/reader/dictionarywidget.h \
src/encfs/encryptionmanager.h \ src/encfs/encryptionmanager.h \
src/functions.h \ src/functions.h \
@ -124,6 +126,7 @@ FORMS += \
src/widgets/dialogs/wifi/connectiondialog.ui \ src/widgets/dialogs/wifi/connectiondialog.ui \
src/widgets/dialogs/wifi/network.ui \ src/widgets/dialogs/wifi/network.ui \
src/widgets/dialogs/wifi/wifilogger.ui \ src/widgets/dialogs/wifi/wifilogger.ui \
src/widgets/misc/egg.ui \
src/widgets/reader/dictionarywidget.ui \ src/widgets/reader/dictionarywidget.ui \
src/encfs/encryptionmanager.ui \ src/encfs/encryptionmanager.ui \
src/widgets/dialogs/generaldialog.ui \ src/widgets/dialogs/generaldialog.ui \

View file

@ -109,5 +109,7 @@
<file>resources/question-mark.png</file> <file>resources/question-mark.png</file>
<file>resources/refresh-small.png</file> <file>resources/refresh-small.png</file>
<file>resources/checkbox-indeterminate.png</file> <file>resources/checkbox-indeterminate.png</file>
<file>resources/egg/0.jpg</file>
<file>resources/egg/3.jpg</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -127,6 +127,11 @@ reader::reader(QWidget *parent) :
ui->line_19->deleteLater(); ui->line_19->deleteLater();
} }
if(!(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n")) {
ui->brightnessBtn->setVisible(true);
ui->line_15->setVisible(true);
}
// Style misc. // Style misc.
ui->bookInfoLabel->setStyleSheet("font-style: italic"); ui->bookInfoLabel->setStyleSheet("font-style: italic");
@ -308,9 +313,10 @@ reader::reader(QWidget *parent) :
ui->pageNumberLabel->setFont(QFont("Source Serif Pro")); ui->pageNumberLabel->setFont(QFont("Source Serif Pro"));
ui->viewHighlightsBtn->setStyleSheet("padding: 9px"); ui->viewHighlightsBtn->setStyleSheet("padding: 9px");
// Hiding the menubar + definition widget + brightness widget + buttons bar widget // Hiding the menubar + definition widget + brightness button + buttons bar widget
ui->menuWidget->setVisible(false); ui->menuWidget->setVisible(false);
ui->brightnessBtn->setVisible(false); ui->brightnessBtn->setVisible(false);
ui->line_15->setVisible(false);
ui->menuBarWidget->setVisible(false); ui->menuBarWidget->setVisible(false);
ui->buttonsBarWidget->setVisible(false); ui->buttonsBarWidget->setVisible(false);
ui->pdfScaleWidget->setVisible(false); ui->pdfScaleWidget->setVisible(false);
@ -1398,25 +1404,11 @@ void reader::menubar_show() {
ui->pageWidget->setVisible(true); ui->pageWidget->setVisible(true);
} }
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") {
;
}
else {
ui->brightnessBtn->setVisible(true);
}
menubar_shown = true; menubar_shown = true;
} }
void reader::menubar_hide() { void reader::menubar_hide() {
log("Hiding menu bar", className); log("Hiding menu bar", className);
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") {
ui->brightnessBtn->setVisible(true);
}
else {
// Safety measure
ui->brightnessBtn->setVisible(false);
}
if(is_pdf == false && is_image == false) { if(is_pdf == false && is_image == false) {
ui->menuBarWidget->setVisible(false); ui->menuBarWidget->setVisible(false);

BIN
src/resources/egg/0.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

BIN
src/resources/egg/3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 KiB

97
src/widgets/misc/egg.cpp Normal file
View file

@ -0,0 +1,97 @@
#include "egg.h"
#include "ui_egg.h"
egg::egg(QWidget *parent) :
QDialog(parent),
ui(new Ui::egg)
{
ui->setupUi(this);
this->setStyleSheet(readFile("/mnt/onboard/.adds/inkbox/eink.qss"));
ui->previousBtn->setProperty("type", "borderless");
ui->nextBtn->setProperty("type", "borderless");
ui->quitBtn->setProperty("type", "borderless");
ui->previousBtn->setFont(QFont("u001"));
ui->nextBtn->setFont(QFont("u001"));
ui->quitBtn->setFont(QFont("u001"));
ui->titleLabel->setFont(QFont("Inter"));
ui->contributorName->setFont(QFont("Inter"));
graphicsScene = new QGraphicsScene(this);
changeIndex(index);
}
egg::~egg()
{
delete ui;
}
void egg::changeIndex(int index) {
/*
Contributors list:
Szybet (0)
NiLuJe (1)
akemnade (2)
Maintainer:
tux-linux (3)
*/
if(firstRun == true) {
firstRun = false;
}
else {
graphicsScene->clear();
ui->graphicsView->items().clear();
}
QPixmap pixmap(":/resources/egg/" + QString::number(index) + ".jpg");
graphicsScene->addPixmap(pixmap);
// Shrinking scene if item is smaller than previous one
QRectF rect = graphicsScene->itemsBoundingRect();
graphicsScene->setSceneRect(rect);
ui->graphicsView->setScene(graphicsScene);
// Contributor name
QString name = "<div align='center'><b>";
if(index == 0) {
name.append("Szybet");
}
else if(index == 1) {
name.append("NiLuJe");
}
else if(index == 2) {
name.append("akemnade");
}
else if(index == 3) {
name.append("tux-linux (Maintainer)");
}
name.append("</b></div>");
ui->contributorName->setText(name);
}
void egg::on_previousBtn_clicked()
{
if(index - 1 <= maximumIndex && index - 1 >= 0) {
index--;
changeIndex(index);
}
else {
QMessageBox::critical(this, "Critical", "Index out of range");
}
}
void egg::on_nextBtn_clicked()
{
if(index + 1 <= maximumIndex && index + 1 >= 0) {
index++;
changeIndex(index);
}
else {
QMessageBox::critical(this, "Critical", "Index out of range");
}
}
void egg::on_quitBtn_clicked()
{
this->close();
}

36
src/widgets/misc/egg.h Normal file
View file

@ -0,0 +1,36 @@
#ifndef EGG_H
#define EGG_H
#include <QDialog>
#include <QMessageBox>
#include <QGraphicsScene>
#include "functions.h"
namespace Ui {
class egg;
}
class egg : public QDialog
{
Q_OBJECT
public:
explicit egg(QWidget *parent = nullptr);
~egg();
int index = 0;
const int maximumIndex = 3;
bool firstRun = true;
private slots:
void on_previousBtn_clicked();
void on_nextBtn_clicked();
void changeIndex(int index);
void on_quitBtn_clicked();
private:
Ui::egg *ui;
QGraphicsScene * graphicsScene;
};
#endif // EGG_H

106
src/widgets/misc/egg.ui Normal file
View file

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>egg</class>
<widget class="QDialog" name="egg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QGraphicsView" name="graphicsView"/>
</item>
<item row="3" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="4">
<widget class="QPushButton" name="nextBtn">
<property name="text">
<string>Next</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="contributorName">
<property name="text">
<string>Contributor</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter|Qt::AlignHCenter|Qt::AlignLeading|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="previousBtn">
<property name="text">
<string>Previous</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Line" name="line_2">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="Line" name="line_3">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="titleLabel">
<property name="text">
<string>&lt;b&gt;InkBox OS project - People&lt;/b&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter|Qt::AlignHCenter|Qt::AlignLeading|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="quitBtn">
<property name="text">
<string>Quit</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -774,10 +774,17 @@ void virtualkeyboard::clearLineEdit() {
void virtualkeyboard::on_enterBtn_clicked() void virtualkeyboard::on_enterBtn_clicked()
{ {
if(global::keyboard::keyboardText == "sudo rm -rf /" or global::keyboard::keyboardText == "rm -rf /") {
egg * eggWindow = new egg();
eggWindow->setAttribute(Qt::WA_DeleteOnClose);
eggWindow->showFullScreen();
}
else {
global::keyboard::keyboardText = ui->lineEdit->text(); global::keyboard::keyboardText = ui->lineEdit->text();
emit enterBtnPressed(global::keyboard::keyboardText); emit enterBtnPressed(global::keyboard::keyboardText);
this->close(); this->close();
} }
}
void virtualkeyboard::on_closeBtn_clicked() void virtualkeyboard::on_closeBtn_clicked()
{ {

View file

@ -3,6 +3,7 @@
#include <QWidget> #include <QWidget>
#include "functions.h" #include "functions.h"
#include "egg.h"
namespace Ui { namespace Ui {
class virtualkeyboard; class virtualkeyboard;
@ -76,6 +77,7 @@ private slots:
private: private:
Ui::virtualkeyboard * ui; Ui::virtualkeyboard * ui;
egg * eggWindow;
keyboardMode currentMode = keyboardMode::lowerCase; keyboardMode currentMode = keyboardMode::lowerCase;
signals: signals: