mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-25 15:17:21 -08:00
Implemented "Go to page" dialog and function.
This commit is contained in:
parent
db12e81896
commit
9fd002213e
13 changed files with 480 additions and 3 deletions
2
eink.qrc
2
eink.qrc
|
@ -46,5 +46,7 @@
|
|||
<file>resources/info.png</file>
|
||||
<file>resources/nightmode-empty.png</file>
|
||||
<file>resources/nightmode-full.png</file>
|
||||
<file>resources/backspace.png</file>
|
||||
<file>resources/x-circle.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -59,10 +59,17 @@ namespace global {
|
|||
inline bool textBrowserDialog;
|
||||
inline QString textBrowserContents;
|
||||
}
|
||||
namespace keyboard {
|
||||
inline bool keyboardDialog;
|
||||
inline bool keypadDialog;
|
||||
inline QString keyboardText;
|
||||
inline QString keypadText;
|
||||
}
|
||||
inline QString systemInfoText;
|
||||
inline bool isN705;
|
||||
inline bool isN905C;
|
||||
inline bool isN613;
|
||||
inline int *readerptr;
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/6080853/c-multiple-definition-error-for-global-functions-in-the-header-file/20679534#20679534
|
||||
|
|
|
@ -111,6 +111,16 @@ generalDialog::generalDialog(QWidget *parent) :
|
|||
ui->bodyLabel->setText("This will erase all KoBox user data. KoBox settings will be reset.");
|
||||
this->adjustSize();
|
||||
}
|
||||
else if(global::keyboard::keypadDialog == true) {
|
||||
keypadDialog = true;
|
||||
keypadWidget = new virtualkeypad();
|
||||
ui->headerLabel->setText("Enter a number");
|
||||
ui->okBtn->setText("OK");
|
||||
ui->cancelBtn->setText("Cancel");
|
||||
ui->mainStackedWidget->insertWidget(1, keypadWidget);
|
||||
ui->mainStackedWidget->setCurrentIndex(1);
|
||||
this->adjustSize();
|
||||
}
|
||||
else {
|
||||
// We shouldn't be there ;)
|
||||
;
|
||||
|
@ -186,6 +196,16 @@ void generalDialog::on_okBtn_clicked()
|
|||
if(resetKoboxDialog == true) {
|
||||
resetKoboxUserData();
|
||||
}
|
||||
if(keypadDialog == true) {
|
||||
int number = global::keyboard::keypadText.toInt();
|
||||
emit gotoPageSelected(number);
|
||||
global::keyboard::keypadDialog = false;
|
||||
generalDialog::close();
|
||||
}
|
||||
if(keyboardDialog == true) {
|
||||
global::keyboard::keyboardDialog = false;
|
||||
generalDialog::close();
|
||||
}
|
||||
}
|
||||
void generalDialog::on_acceptBtn_clicked()
|
||||
{
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "usbms_splash.h"
|
||||
#include "textwidget.h"
|
||||
#include "virtualkeypad.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -27,6 +28,8 @@ public:
|
|||
bool usbmsDialog = false;
|
||||
bool textBrowserDialog = false;
|
||||
bool resetKoboxDialog = false;
|
||||
bool keyboardDialog = false;
|
||||
bool keypadDialog = false;
|
||||
|
||||
private slots:
|
||||
void on_cancelBtn_clicked();
|
||||
|
@ -37,6 +40,10 @@ private:
|
|||
Ui::generalDialog *ui;
|
||||
usbms_splash *usbmsWindow;
|
||||
textwidget *textwidgetWindow;
|
||||
virtualkeypad *keypadWidget;
|
||||
|
||||
signals:
|
||||
void gotoPageSelected(int value);
|
||||
};
|
||||
|
||||
#endif // GENERALDIALOG_H
|
||||
|
|
|
@ -26,7 +26,8 @@ SOURCES += \
|
|||
settings.cpp \
|
||||
settingschooser.cpp \
|
||||
textwidget.cpp \
|
||||
usbms_splash.cpp
|
||||
usbms_splash.cpp \
|
||||
virtualkeypad.cpp
|
||||
|
||||
HEADERS += \
|
||||
alert.h \
|
||||
|
@ -44,7 +45,8 @@ HEADERS += \
|
|||
settings.h \
|
||||
settingschooser.h \
|
||||
textwidget.h \
|
||||
usbms_splash.h
|
||||
usbms_splash.h \
|
||||
virtualkeypad.h
|
||||
|
||||
FORMS += \
|
||||
alert.ui \
|
||||
|
@ -61,7 +63,8 @@ FORMS += \
|
|||
settings.ui \
|
||||
settingschooser.ui \
|
||||
textwidget.ui \
|
||||
usbms_splash.ui
|
||||
usbms_splash.ui \
|
||||
virtualkeypad.ui
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "koboxsettings.h"
|
||||
#include "koboxappsdialog.h"
|
||||
#include "textwidget.h"
|
||||
#include "virtualkeypad.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -81,6 +82,7 @@ private:
|
|||
koboxSettings *koboxSettingsWindow;
|
||||
koboxAppsDialog *koboxAppsDialogWindow;
|
||||
textwidget *textwidgetWindow;
|
||||
virtualkeypad *keypadWidget;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
45
reader.cpp
45
reader.cpp
|
@ -602,6 +602,7 @@ reader::reader(QWidget *parent) :
|
|||
getTotalEpubPagesNumber();
|
||||
}
|
||||
setupPageWidget();
|
||||
//connect(this, SIGNAL(gotoPageSelected(int)), this, SLOT(gotoPage(int)));
|
||||
}
|
||||
|
||||
reader::~reader()
|
||||
|
@ -1531,3 +1532,47 @@ void reader::getTotalEpubPagesNumber() {
|
|||
string_checkconfig_ro("/run/epub_total_pages_number");
|
||||
totalPagesInt = checkconfig_str_val.toInt();
|
||||
}
|
||||
|
||||
void reader::on_gotoBtn_clicked()
|
||||
{
|
||||
global::keyboard::keypadDialog = true;
|
||||
generalDialogWindow = new generalDialog();
|
||||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(generalDialogWindow, SIGNAL(gotoPageSelected(int)), SLOT(gotoPage(int)));
|
||||
generalDialogWindow->show();
|
||||
}
|
||||
|
||||
void reader::gotoPage(int pageNumber) {
|
||||
if(is_epub == true) {
|
||||
if(pageNumber > totalPagesInt or pageNumber < 1) {
|
||||
QMessageBox::critical(this, tr("Invalid argument"), tr("Request is beyond the page range."));
|
||||
}
|
||||
else {
|
||||
mupdf::epubPageNumber = pageNumber;
|
||||
setup_book(book_file, mupdf::epubPageNumber, true);
|
||||
ui->text->setText("");
|
||||
ui->text->setText(epubPageContent);
|
||||
|
||||
pagesTurned = 0;
|
||||
writeconfig_pagenumber();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(split_files_number - pageNumber < 2 or split_files_number - pageNumber > split_files_number - 1) {
|
||||
QMessageBox::critical(this, tr("Invalid argument"), tr("You've reached the end of the document."));
|
||||
}
|
||||
else {
|
||||
split_total = split_files_number - pageNumber;
|
||||
|
||||
setup_book(book_file, split_total, false);
|
||||
ui->text->setText("");
|
||||
ui->text->setText(ittext);
|
||||
|
||||
pagesTurned = 0;
|
||||
writeconfig_pagenumber();
|
||||
}
|
||||
}
|
||||
alignText(textAlignment);
|
||||
setupPageWidget();
|
||||
refreshScreen();
|
||||
}
|
||||
|
|
2
reader.h
2
reader.h
|
@ -122,6 +122,8 @@ private slots:
|
|||
void quit_restart();
|
||||
void on_text_selectionChanged();
|
||||
void on_nightModeBtn_clicked();
|
||||
void on_gotoBtn_clicked();
|
||||
void gotoPage(int pageNumber);
|
||||
|
||||
private:
|
||||
Ui::reader *ui;
|
||||
|
|
BIN
resources/backspace.png
Normal file
BIN
resources/backspace.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.6 KiB |
BIN
resources/x-circle.png
Normal file
BIN
resources/x-circle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
132
virtualkeypad.cpp
Normal file
132
virtualkeypad.cpp
Normal file
|
@ -0,0 +1,132 @@
|
|||
#include "virtualkeypad.h"
|
||||
#include "ui_virtualkeypad.h"
|
||||
#include "reader.h"
|
||||
#include <QDebug>
|
||||
|
||||
virtualkeypad::virtualkeypad(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::virtualkeypad)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Style
|
||||
ui->n1->setProperty("type", "borderless");
|
||||
ui->n2->setProperty("type", "borderless");
|
||||
ui->n3->setProperty("type", "borderless");
|
||||
ui->n4->setProperty("type", "borderless");
|
||||
ui->n5->setProperty("type", "borderless");
|
||||
ui->n6->setProperty("type", "borderless");
|
||||
ui->n7->setProperty("type", "borderless");
|
||||
ui->n8->setProperty("type", "borderless");
|
||||
ui->n9->setProperty("type", "borderless");
|
||||
ui->n0->setProperty("type", "borderless");
|
||||
ui->eraseBtn->setProperty("type", "borderless");
|
||||
ui->clearBtn->setProperty("type", "borderless");
|
||||
|
||||
ui->n1->setStyleSheet("font-weight: bold; font-size: 13pt");
|
||||
ui->n2->setStyleSheet("font-weight: bold; font-size: 13pt");
|
||||
ui->n3->setStyleSheet("font-weight: bold; font-size: 13pt");
|
||||
ui->n4->setStyleSheet("font-weight: bold; font-size: 13pt");
|
||||
ui->n5->setStyleSheet("font-weight: bold; font-size: 13pt");
|
||||
ui->n6->setStyleSheet("font-weight: bold; font-size: 13pt");
|
||||
ui->n7->setStyleSheet("font-weight: bold; font-size: 13pt");
|
||||
ui->n8->setStyleSheet("font-weight: bold; font-size: 13pt");
|
||||
ui->n9->setStyleSheet("font-weight: bold; font-size: 13pt");
|
||||
ui->n0->setStyleSheet("font-weight: bold; font-size: 13pt");
|
||||
ui->eraseBtn->setStyleSheet("font-weight: bold; font-size: 13pt; padding: 7.35px");
|
||||
ui->clearBtn->setStyleSheet("font-weight: bold; font-size: 13pt; padding: 7.35px");
|
||||
|
||||
ui->eraseBtn->setText("");
|
||||
ui->eraseBtn->setIcon(QIcon(":/resources/backspace.png"));
|
||||
ui->clearBtn->setText("");
|
||||
ui->clearBtn->setIcon(QIcon(":/resources/x-circle.png"));
|
||||
}
|
||||
|
||||
virtualkeypad::~virtualkeypad()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void virtualkeypad::on_clearBtn_clicked()
|
||||
{
|
||||
ui->lineEdit->clear();
|
||||
QString text = ui->lineEdit->text();
|
||||
global::keyboard::keypadText = text;
|
||||
}
|
||||
|
||||
void virtualkeypad::on_eraseBtn_clicked()
|
||||
{
|
||||
ui->lineEdit->backspace();
|
||||
QString text = ui->lineEdit->text();
|
||||
global::keyboard::keypadText = text;
|
||||
}
|
||||
|
||||
void virtualkeypad::on_n1_clicked()
|
||||
{
|
||||
ui->lineEdit->insert("1");
|
||||
QString text = ui->lineEdit->text();
|
||||
global::keyboard::keypadText = text;
|
||||
}
|
||||
|
||||
void virtualkeypad::on_n2_clicked()
|
||||
{
|
||||
ui->lineEdit->insert("2");
|
||||
QString text = ui->lineEdit->text();
|
||||
global::keyboard::keypadText = text;
|
||||
}
|
||||
|
||||
void virtualkeypad::on_n3_clicked()
|
||||
{
|
||||
ui->lineEdit->insert("3");
|
||||
QString text = ui->lineEdit->text();
|
||||
global::keyboard::keypadText = text;
|
||||
}
|
||||
|
||||
void virtualkeypad::on_n4_clicked()
|
||||
{
|
||||
ui->lineEdit->insert("4");
|
||||
QString text = ui->lineEdit->text();
|
||||
global::keyboard::keypadText = text;
|
||||
}
|
||||
|
||||
void virtualkeypad::on_n5_clicked()
|
||||
{
|
||||
ui->lineEdit->insert("5");
|
||||
QString text = ui->lineEdit->text();
|
||||
global::keyboard::keypadText = text;
|
||||
}
|
||||
|
||||
void virtualkeypad::on_n6_clicked()
|
||||
{
|
||||
ui->lineEdit->insert("6");
|
||||
QString text = ui->lineEdit->text();
|
||||
global::keyboard::keypadText = text;
|
||||
}
|
||||
|
||||
void virtualkeypad::on_n7_clicked()
|
||||
{
|
||||
ui->lineEdit->insert("7");
|
||||
QString text = ui->lineEdit->text();
|
||||
global::keyboard::keypadText = text;
|
||||
}
|
||||
|
||||
void virtualkeypad::on_n8_clicked()
|
||||
{
|
||||
ui->lineEdit->insert("8");
|
||||
QString text = ui->lineEdit->text();
|
||||
global::keyboard::keypadText = text;
|
||||
}
|
||||
|
||||
void virtualkeypad::on_n9_clicked()
|
||||
{
|
||||
ui->lineEdit->insert("9");
|
||||
QString text = ui->lineEdit->text();
|
||||
global::keyboard::keypadText = text;
|
||||
}
|
||||
|
||||
void virtualkeypad::on_n0_clicked()
|
||||
{
|
||||
ui->lineEdit->insert("0");
|
||||
QString text = ui->lineEdit->text();
|
||||
global::keyboard::keypadText = text;
|
||||
}
|
36
virtualkeypad.h
Normal file
36
virtualkeypad.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#ifndef VIRTUALKEYPAD_H
|
||||
#define VIRTUALKEYPAD_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class virtualkeypad;
|
||||
}
|
||||
|
||||
class virtualkeypad : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit virtualkeypad(QWidget *parent = nullptr);
|
||||
~virtualkeypad();
|
||||
|
||||
private slots:
|
||||
void on_n1_clicked();
|
||||
void on_clearBtn_clicked();
|
||||
void on_eraseBtn_clicked();
|
||||
void on_n2_clicked();
|
||||
void on_n3_clicked();
|
||||
void on_n4_clicked();
|
||||
void on_n5_clicked();
|
||||
void on_n6_clicked();
|
||||
void on_n7_clicked();
|
||||
void on_n8_clicked();
|
||||
void on_n9_clicked();
|
||||
void on_n0_clicked();
|
||||
|
||||
private:
|
||||
Ui::virtualkeypad *ui;
|
||||
};
|
||||
|
||||
#endif // VIRTUALKEYPAD_H
|
221
virtualkeypad.ui
Normal file
221
virtualkeypad.ui
Normal file
|
@ -0,0 +1,221 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>virtualkeypad</class>
|
||||
<widget class="QWidget" name="virtualkeypad">
|
||||
<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>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<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>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="n5">
|
||||
<property name="text">
|
||||
<string>5</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="n3">
|
||||
<property name="text">
|
||||
<string>3</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QPushButton" name="n9">
|
||||
<property name="text">
|
||||
<string>9</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="n4">
|
||||
<property name="text">
|
||||
<string>4</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="n1">
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="n6">
|
||||
<property name="text">
|
||||
<string>6</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QPushButton" name="n7">
|
||||
<property name="text">
|
||||
<string>7</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QPushButton" name="n8">
|
||||
<property name="text">
|
||||
<string>8</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="n2">
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QPushButton" name="n0">
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="Line" name="line">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="Line" name="line_3">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="Line" name="line_4">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="Line" name="line_5">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="Line" name="line_6">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="Line" name="line_7">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="2">
|
||||
<widget class="QPushButton" name="eraseBtn">
|
||||
<property name="text">
|
||||
<string>Erase</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QPushButton" name="clearBtn">
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="Line" name="line_8">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="Line" name="line_9">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in a new issue