mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 23:57:22 -08:00
Working on PDF zoom/scale
This commit is contained in:
parent
dc864f6d4e
commit
94e0319576
7 changed files with 214 additions and 3 deletions
2
eink.qrc
2
eink.qrc
|
@ -60,5 +60,7 @@
|
|||
<file>resources/wifi-connected.png</file>
|
||||
<file>resources/wifi-off.png</file>
|
||||
<file>resources/wifi-standby.png</file>
|
||||
<file>resources/zoom-in.png</file>
|
||||
<file>resources/zoom-out.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -875,7 +875,9 @@ int MainWindow::testPing() {
|
|||
QProcess *pingProcess = new QProcess();
|
||||
pingProcess->start(pingProg, pingArgs);
|
||||
pingProcess->waitForFinished();
|
||||
return pingProcess->exitCode();
|
||||
int exitCode = pingProcess->exitCode();
|
||||
pingProcess->deleteLater();
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
void MainWindow::updateWifiIcon(int mode) {
|
||||
|
|
109
reader.cpp
109
reader.cpp
|
@ -56,6 +56,8 @@ reader::reader(QWidget *parent) :
|
|||
ui->nightModeBtn->setProperty("type", "borderless");
|
||||
ui->searchBtn->setProperty("type", "borderless");
|
||||
ui->gotoBtn->setProperty("type", "borderless");
|
||||
ui->increaseScaleBtn->setProperty("type", "borderless");
|
||||
ui->decreaseScaleBtn->setProperty("type", "borderless");
|
||||
|
||||
// Icons
|
||||
ui->alignLeftBtn->setText("");
|
||||
|
@ -84,6 +86,10 @@ reader::reader(QWidget *parent) :
|
|||
ui->aboutBtn->setIcon(QIcon(":/resources/info.png"));
|
||||
ui->searchBtn->setText("");
|
||||
ui->searchBtn->setIcon(QIcon(":/resources/search.png"));
|
||||
ui->increaseScaleBtn->setText("");
|
||||
ui->increaseScaleBtn->setIcon(QIcon(":/resources/zoom-in.png"));
|
||||
ui->decreaseScaleBtn->setText("");
|
||||
ui->decreaseScaleBtn->setIcon(QIcon(":/resources/zoom-out.png"));
|
||||
|
||||
// Style misc.
|
||||
ui->bookInfoLabel->setStyleSheet("font-style: italic");
|
||||
|
@ -258,6 +264,7 @@ reader::reader(QWidget *parent) :
|
|||
ui->brightnessWidget->setVisible(false);
|
||||
ui->menuBarWidget->setVisible(false);
|
||||
ui->buttonsBarWidget->setVisible(false);
|
||||
ui->pdfScaleWidget->setVisible(false);
|
||||
ui->wordWidget->setVisible(false);
|
||||
if(checkconfig(".config/11-menubar/sticky") == true) {
|
||||
ui->menuWidget->setVisible(true);
|
||||
|
@ -1283,6 +1290,11 @@ void reader::menubar_show() {
|
|||
if(is_pdf == false) {
|
||||
ui->menuBarWidget->setVisible(true);
|
||||
}
|
||||
else {
|
||||
ui->pdfScaleWidget->setVisible(true);
|
||||
ui->graphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
ui->graphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
}
|
||||
ui->buttonsBarWidget->setVisible(true);
|
||||
ui->statusBarWidget->setVisible(true);
|
||||
ui->pageWidget->setVisible(true);
|
||||
|
@ -1312,6 +1324,17 @@ void reader::menubar_hide() {
|
|||
if(is_pdf == false) {
|
||||
ui->menuBarWidget->setVisible(false);
|
||||
}
|
||||
else {
|
||||
ui->pdfScaleWidget->setVisible(false);
|
||||
if(checkconfig(".config/14-reader_scrollbar/config") == true) {
|
||||
ui->graphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
ui->graphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
}
|
||||
else {
|
||||
ui->graphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
ui->graphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
}
|
||||
}
|
||||
ui->buttonsBarWidget->setVisible(false);
|
||||
ui->pageWidget->setVisible(false);
|
||||
if(checkconfig(".config/11-menubar/sticky") == true) {
|
||||
|
@ -1539,6 +1562,12 @@ void reader::convertMuPdfVars(int fileType) {
|
|||
* 0: ePUB
|
||||
* 1: PDF
|
||||
*/
|
||||
bool convertRelativeValuesNative;
|
||||
if(mupdf::convertRelativeValues == true) {
|
||||
// Safer approach; local bool gets destroyed when getting out of scope
|
||||
convertRelativeValuesNative = true;
|
||||
mupdf::convertRelativeValues = false;
|
||||
}
|
||||
if(fileType == 0) {
|
||||
setPageStyle(0);
|
||||
mupdf::epub::fontSize = 12;
|
||||
|
@ -1561,8 +1590,16 @@ void reader::convertMuPdfVars(int fileType) {
|
|||
setPageStyle(1);
|
||||
mupdf::pdf::width = defaultPdfPageWidth;
|
||||
mupdf::pdf::height = defaultPdfPageHeight;
|
||||
mupdf::pdf::width_qstr = QString::number(mupdf::pdf::width);
|
||||
mupdf::pdf::height_qstr = QString::number(mupdf::pdf::height);
|
||||
if(convertRelativeValuesNative == true) {
|
||||
// For scaling
|
||||
mupdf::pdf::width_qstr = QString::number(mupdf::pdf::relativeHeight);
|
||||
mupdf::pdf::height_qstr = QString::number(mupdf::pdf::relativeWidth);
|
||||
}
|
||||
else {
|
||||
// Default
|
||||
mupdf::pdf::width_qstr = QString::number(mupdf::pdf::width);
|
||||
mupdf::pdf::height_qstr = QString::number(mupdf::pdf::height);
|
||||
}
|
||||
if(global::reader::globalReadingSettings == false) {
|
||||
if(goToSavedPageDone == false) {
|
||||
string_checkconfig_ro(".config/A-page_number/config");
|
||||
|
@ -1949,3 +1986,71 @@ void reader::getTotalPdfPagesNumber() {
|
|||
string_checkconfig_ro("/run/pdf_total_pages_number");
|
||||
totalPagesInt = checkconfig_str_val.toInt();
|
||||
}
|
||||
|
||||
void reader::on_pdfScaleSlider_valueChanged(int value)
|
||||
{
|
||||
if(value == 1) {
|
||||
mupdf::pdf::relativeWidth = 1 * mupdf::pdf::width;
|
||||
mupdf::pdf::relativeHeight = 1 * mupdf::pdf::height;
|
||||
}
|
||||
else if(value == 2) {
|
||||
mupdf::pdf::relativeWidth = 1.50 * mupdf::pdf::width;
|
||||
mupdf::pdf::relativeHeight = 1.50 * mupdf::pdf::height;
|
||||
}
|
||||
else if(value == 3) {
|
||||
mupdf::pdf::relativeWidth = 2 * mupdf::pdf::width;
|
||||
mupdf::pdf::relativeHeight = 2 * mupdf::pdf::height;
|
||||
}
|
||||
else if(value == 4) {
|
||||
mupdf::pdf::relativeWidth = 2.50 * mupdf::pdf::width;
|
||||
mupdf::pdf::relativeHeight = 2.50 * mupdf::pdf::height;
|
||||
}
|
||||
|
||||
if(value != 1) {
|
||||
ui->graphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
ui->graphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
}
|
||||
else {
|
||||
if(checkconfig(".config/14-reader_scrollbar/config") == true) {
|
||||
ui->graphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
ui->graphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
}
|
||||
else {
|
||||
ui->graphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
ui->graphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
}
|
||||
}
|
||||
|
||||
mupdf::pdf::pdfPageNumber = mupdf::pdf::pdfPageNumber + 1;
|
||||
setup_book(book_file, mupdf::pdf::pdfPageNumber, true);
|
||||
setupPng();
|
||||
}
|
||||
|
||||
void reader::on_decreaseScaleBtn_clicked()
|
||||
{
|
||||
int sliderCurrentValue;
|
||||
int sliderWantedValue;
|
||||
sliderCurrentValue = ui->pdfScaleSlider->value();
|
||||
sliderWantedValue = sliderCurrentValue - 1;
|
||||
if(sliderWantedValue < ui->pdfScaleSlider->QAbstractSlider::minimum()) {
|
||||
showToast("Minimum scale reached");
|
||||
}
|
||||
else {
|
||||
ui->pdfScaleSlider->setValue(sliderWantedValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void reader::on_increaseScaleBtn_clicked()
|
||||
{
|
||||
int sliderCurrentValue;
|
||||
int sliderWantedValue;
|
||||
sliderCurrentValue = ui->pdfScaleSlider->value();
|
||||
sliderWantedValue = sliderCurrentValue + 1;
|
||||
if(sliderWantedValue > ui->pdfScaleSlider->QAbstractSlider::maximum()) {
|
||||
showToast("Maximum scale reached");
|
||||
}
|
||||
else {
|
||||
ui->pdfScaleSlider->setValue(sliderWantedValue);
|
||||
}
|
||||
}
|
||||
|
|
8
reader.h
8
reader.h
|
@ -13,6 +13,7 @@ using namespace std;
|
|||
|
||||
// ePUB scaling
|
||||
namespace mupdf {
|
||||
inline bool convertRelativeValues;
|
||||
namespace epub {
|
||||
inline int fontSize;
|
||||
inline int width;
|
||||
|
@ -26,6 +27,8 @@ namespace mupdf {
|
|||
namespace pdf {
|
||||
inline int width;
|
||||
inline int height;
|
||||
inline int relativeWidth;
|
||||
inline int relativeHeight;
|
||||
inline int pdfPageNumber;
|
||||
inline QString width_qstr;
|
||||
inline QString height_qstr;
|
||||
|
@ -150,6 +153,11 @@ private slots:
|
|||
void saveReadingSettings();
|
||||
void setupLocalSettingsEnvironment();
|
||||
void setupPng();
|
||||
void on_pdfScaleSlider_valueChanged(int value);
|
||||
|
||||
void on_decreaseScaleBtn_clicked();
|
||||
|
||||
void on_increaseScaleBtn_clicked();
|
||||
|
||||
private:
|
||||
Ui::reader * ui;
|
||||
|
|
94
reader.ui
94
reader.ui
|
@ -674,6 +674,100 @@
|
|||
<widget class="QWidget" name="page_13"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="pdfScaleWidget">
|
||||
<widget class="QWidget" name="page_15">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||
<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_21"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_20">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="increaseScaleBtn">
|
||||
<property name="text">
|
||||
<string>Increase scale</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="decreaseScaleBtn">
|
||||
<property name="text">
|
||||
<string>Decrease scale</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="pdfScaleLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Chivo</family>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Scale</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSlider" name="pdfScaleSlider">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_18">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_19">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_16"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_19">
|
||||
<item row="0" column="0">
|
||||
|
|
BIN
resources/zoom-in.png
Normal file
BIN
resources/zoom-in.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
resources/zoom-out.png
Normal file
BIN
resources/zoom-out.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
Loading…
Reference in a new issue