aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
diff options
context:
space:
mode:
authorZackaryWelch <welch.zackary@gmail.com>2018-03-23 16:23:05 -0400
committerZackaryWelch <welch.zackary@gmail.com>2018-03-23 16:23:05 -0400
commitec5b45e3cac35c660dcb6922428fd0b37ae3a9b0 (patch)
tree32e14d995e49ec1e46b27e0c2f6804f6d0f8a042 /src-qt5
parentJumps to page location instead of just page when using find or certain bookmarks (diff)
downloadlumina-ec5b45e3cac35c660dcb6922428fd0b37ae3a9b0.tar.gz
lumina-ec5b45e3cac35c660dcb6922428fd0b37ae3a9b0.tar.bz2
lumina-ec5b45e3cac35c660dcb6922428fd0b37ae3a9b0.zip
Improved page layout for pdfs with unequal page sizes. Currently broke all page mode. Added tooltips for zoom in/zoom out.
Diffstat (limited to 'src-qt5')
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp47
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/mainUI.cpp9
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/mainUI.h1
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/mainUI.ui6
4 files changed, 39 insertions, 24 deletions
diff --git a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp
index db2f6058..c8d093a5 100644
--- a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp
+++ b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp
@@ -70,7 +70,7 @@ void PrintWidget::setViewMode(ViewMode mode) {
this->fitInView(scene->itemsBoundingRect(), Qt::KeepAspectRatio);
fitting = false;
zoomMode = CustomZoom;
- //zoomFactor = this->transform().m11() * (double(printer->logicalDpiY()) / logicalDpiY());
+ zoomFactor = this->transform().m11() * (150.0 / logicalDpiY());
} else {
fitting = true;
fit();
@@ -128,7 +128,6 @@ void PrintWidget::setCurrentPage(int pageNumber) {
void PrintWidget::highlightText(TextData *text) {
//Creates a rectangle around the text if the text has not already been highlighted
if(!text->highlighted()) {
- double pageHeight = pages.at(text->page()-1)->boundingRect().height();
int degrees = BACKEND->rotatedDegrees();
//Shows the text's location on a non-rotated page
QRectF rect = text->loc();
@@ -150,7 +149,11 @@ void PrintWidget::highlightText(TextData *text) {
rect.adjust(cy, cx, cy, cx);
}
//Moves the rectangle onto the right page
- rect.moveTop(rect.y() + pageHeight*(text->page()-1));
+ double pageHeight = 0;
+ for(int i = 0; i < text->page() - 1; i++)
+ pageHeight += pages.at(i)->boundingRect().height();
+
+ rect.moveTop(rect.y() + pageHeight);
//Transparent yellow for the highlight box
QBrush highlightFill(QColor(255, 255, 177, 100));
QPen highlightOutline(QColor(255, 255, 100, 125));
@@ -178,7 +181,7 @@ void PrintWidget::layoutPages() {
int numPagePlaces = numPages;
int cols = 1; // singleMode and default
- QSize pageSize = BACKEND->imageHash(0).size();
+ QSize pageSize = BACKEND->imageHash(curPage-1).size();
if (viewMode == AllPagesView) {
cols = pageSize.width() > pageSize.height() ? qFloor(qSqrt(numPages)) : qCeil(qSqrt(numPages));
cols += cols % 2; // Nicer with an even number of cols
@@ -188,17 +191,28 @@ void PrintWidget::layoutPages() {
}
int rows = qCeil(double(numPagePlaces) / cols);
- double itemWidth = pages.at(0)->boundingRect().width();
- double itemHeight = pages.at(0)->boundingRect().height();
- int pageNum = 1; for (int i = 0; i < rows && pageNum <= numPages; i++) {
- for (int j = 0; j < cols && pageNum <= numPages; j++) {
- if (!i && !j && viewMode == FacingPagesView) {
- continue;
- } else {
- pages.at(pageNum-1)->setPos(QPointF(j*itemWidth, i*itemHeight));
- pageNum++;
+ int pageNum = 0;
+ QList<double> rowMaxList;
+ for (int i = 0; i < rows && pageNum < numPages; i++) {
+ double rowMax = 0;
+ for (int j = 0; j < cols && pageNum < numPages; j++) {
+ double itemWidth = 0, itemHeight = 0;
+ double pageHeight = pages.at(pageNum)->boundingRect().height();
+ //qDebug() << "Row:" << i << "Page Num:" << pageNum << "Columns:" << cols << "Floor Value: " << pageNum / cols << "f(x):" << i + (pageNum / cols);
+
+ for(int k = i + (pageNum / cols); k < pageNum; k++) {
+ itemWidth += pages.at(k)->boundingRect().width();
}
+
+ foreach(double size, rowMaxList)
+ itemHeight += size;
+
+ //qDebug() << pageNum << QPointF(itemWidth, itemHeight);
+ pages.at(pageNum)->setPos(QPointF(itemWidth, itemHeight));
+ pageNum++;
+ rowMax = qMax(rowMax, pageHeight);
}
+ rowMaxList.push_back(rowMax);
}
scene->setSceneRect(scene->itemsBoundingRect());
//qDebug() << "Finished Page Layout";
@@ -300,6 +314,7 @@ void PrintWidget::fit(bool doFitting) {
this->setTransform(t);
if (doFitting && fitting) {
QRectF viewSceneRect = this->viewportTransform().mapRect(this->viewport()->rect());
+ qDebug() << viewSceneRect;
viewSceneRect.moveTop(target.top());
this->ensureVisible(viewSceneRect); // Nah...
}
@@ -312,7 +327,7 @@ void PrintWidget::fit(bool doFitting) {
}
}
- //zoomFactor = this->transform().m11() * (float(printer->logicalDpiY()) / this->logicalDpiY());
+ zoomFactor = this->transform().m11() * (150.0 / this->logicalDpiY());
}
void PrintWidget::goToPosition(int pagenum, float x, float y) {
@@ -326,8 +341,8 @@ void PrintWidget::goToPosition(int pagenum, float x, float y) {
double realHeight = pages.at(pagenum-1)->boundingRect().height();
double virtualHeight = qAbs(pt2.y() - pt.y());
- int yConv = int(pt.y() + y*(virtualHeight/realHeight)) - 10;
- int xConv = int(pt.x() + x*(virtualHeight/realHeight)) - 10;
+ int yConv = int(pt.y() + y*(virtualHeight/realHeight)) - 30;
+ int xConv = int(pt.x() + x*(virtualHeight/realHeight)) - 30;
//qDebug() << "Y:" << y << "RATIO:" << virtualHeight/realHeight << "YCONV:" << yConv << "PTY" << pt.y() << "MAX" << vsc->maximum();
if(yConv > vsc->maximum())
diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp
index 24955bb1..1c529fbe 100644
--- a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp
+++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp
@@ -57,7 +57,8 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){
connect(BACKEND, SIGNAL(PageLoaded(int)), this, SLOT(slotPageLoaded(int)) );
connect(BACKEND, SIGNAL(reloadPages(int)), this, SLOT(startLoadingPages(int)));
connect(BACKEND, SIGNAL(goToPosition(int, float, float)), WIDGET, SLOT(goToPosition(int, float, float)));
- connect(ui->splitter, SIGNAL(splitterMoved(int, int)), this, SLOT(splitterMoved()) );
+ connect(ui->splitter, &QSplitter::splitterMoved, this, [=]() {
+ double percent = qBound(0.0, (ui->splitter->sizes().first()/(double)this->width())*100.0, 33.3); ui->splitter->setSizes( QList<int>() << this->width()*(percent/100.0) << this->width() * ((100.0-percent)/100.0)); });
PrintDLG = new QPrintDialog(this);
connect(PrintDLG, SIGNAL(accepted(QPrinter*)), this, SLOT(paintToPrinter(QPrinter*)) );
@@ -626,9 +627,3 @@ void MainUI::find(QString text, bool forward) {
}
}
}
-
-void MainUI::splitterMoved() {
- float percent = (ui->splitter->sizes().first() / ( (float) this->width()) )*100.0;
- percent = percent > 33.3 ? 33.3 : percent;
- ui->splitter->setSizes( QList<int>() << this->width()*(percent/100.0) << this->width() * ((100.0-percent)/100.0) );
-}
diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.h b/src-qt5/desktop-utils/lumina-pdf/mainUI.h
index e8760c55..10f2d2e4 100644
--- a/src-qt5/desktop-utils/lumina-pdf/mainUI.h
+++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.h
@@ -98,7 +98,6 @@ private slots:
void showContextMenu(const QPoint&){ contextMenu->popup(QCursor::pos()); }
void updateContextMenu();
//void setScroll(bool);
- void splitterMoved();
protected:
void keyPressEvent(QKeyEvent*);
diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.ui b/src-qt5/desktop-utils/lumina-pdf/mainUI.ui
index ec35345b..0db7460b 100644
--- a/src-qt5/desktop-utils/lumina-pdf/mainUI.ui
+++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.ui
@@ -371,11 +371,17 @@
<property name="text">
<string/>
</property>
+ <property name="toolTip">
+ <string>Zoom Out</string>
+ </property>
</action>
<action name="actionZoom_In_2">
<property name="text">
<string/>
</property>
+ <property name="toolTip">
+ <string>Zoom In</string>
+ </property>
</action>
<action name="actionStart_Here">
<property name="text">
bgstack15