diff options
author | ZackaryWelch <welch.zackary@gmail.com> | 2018-03-21 16:47:38 -0400 |
---|---|---|
committer | ZackaryWelch <welch.zackary@gmail.com> | 2018-03-21 16:47:38 -0400 |
commit | 8239f07ed001e1da3cf36e859303ddd5f62cb507 (patch) | |
tree | eaaf318d270b93f5d4e276c29842d03c4f67a8df | |
parent | Added a bookmarks menu, enabled on the MuPDF side. (diff) | |
download | lumina-8239f07ed001e1da3cf36e859303ddd5f62cb507.tar.gz lumina-8239f07ed001e1da3cf36e859303ddd5f62cb507.tar.bz2 lumina-8239f07ed001e1da3cf36e859303ddd5f62cb507.zip |
Improved Bookmarks layout and made MuPDF the default backend
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp | 4 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.ui | 58 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp | 2 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp | 2 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp | 3 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro | 11 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/mainUI.cpp | 29 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/mainUI.ui | 48 |
9 files changed, 81 insertions, 77 deletions
@@ -27,6 +27,7 @@ src-qt5/desktop-utils/lumina-textedit/lumina-textedit src-qt5/desktop-utils/lumina-archiver/lumina-archiver src-qt5/desktop-utils/lumina-calculator/lumina-calculator src-qt5/desktop-utils/lumina-pdf/lumina-pdf +src-qt5/desktop-utils/lumina-pdf/.build/ src-qt5/desktop-utils/lumina-notify/lumina-notify src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/ src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/.build/ diff --git a/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp b/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp index 0a8dd695..39d4e314 100644 --- a/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp @@ -11,12 +11,9 @@ BookmarkMenu::BookmarkMenu(Renderer *Backend, QWidget *parent) : QWidget(parent), ui(new Ui::BookmarkMenu()), BACKEND(Backend){ ui->setupUi(this); - ui->closeButton->setIcon( LXDG::findIcon("dialog-close") ); connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(close())); connect(ui->bookmarks, &QTreeWidget::itemClicked, this, [=](QTreeWidgetItem *item) { Backend->handleLink(item->data(1, Qt::UserRole).toString()); }); - - ui->bookmarks->setHeaderLabel("Title"); } void BookmarkMenu::loadBookmarks() { @@ -41,7 +38,6 @@ void BookmarkMenu::loadBookmarks() { }else{ item = new QTreeWidgetItem(parent); } - item->setText(0, bm->title); item->setData(1, Qt::UserRole, bm->link); if(!bm->link.isEmpty()) diff --git a/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.ui b/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.ui index de19be66..e9706913 100644 --- a/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.ui +++ b/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>109</width> - <height>507</height> + <width>156</width> + <height>583</height> </rect> </property> <property name="windowTitle"> @@ -15,27 +15,49 @@ </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> - <widget class="QPushButton" name="closeButton"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Bookmarks</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QToolButton" name="closeButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Bookmarks</string> + </property> + <property name="icon"> + <iconset theme="dialog-close"/> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Bookmarks</string> + </property> + </widget> + </item> + </layout> </item> <item> <widget class="QTreeWidget" name="bookmarks"> + <property name="columnCount"> + <number>1</number> + </property> <column> <property name="text"> - <string notr="true">1</string> + <string notr="true">Location</string> </property> </column> </widget> diff --git a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp index 63d25be4..65a71a74 100644 --- a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp @@ -162,7 +162,6 @@ void PrintWidget::highlightText(TextData *text) { //Private functions void PrintWidget::generatePreview() { - qDebug() << "Generating Preview"; populateScene(); // i.e. setPreviewPrintedPictures() e.l. layoutPages(); curPage = qBound(1, curPage, pages.count()); @@ -211,7 +210,6 @@ void PrintWidget::populateScene() } qDeleteAll(pages); pages.clear(); - qDebug() << "populateScene"; int numPages = BACKEND->numPages(); if(BACKEND->hashSize() < numPages){ return; } //nothing to show yet diff --git a/src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp b/src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp index 7846e9c1..2349fff3 100644 --- a/src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp @@ -209,7 +209,7 @@ void Renderer::renderPage(int pagenum, QSize DPI, int degrees){ fz_pixmap *pixmap; fz_display_list *list; - double pageDPI = 150.0; + double pageDPI = 96.0; double sf = DPI.width() / pageDPI; fz_scale(&matrix, sf, sf); fz_pre_rotate(&matrix, degrees); diff --git a/src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp b/src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp index 28045539..7f2baa5e 100644 --- a/src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp @@ -89,7 +89,7 @@ void Renderer::renderPage(int pagenum, QSize DPI, int degrees){ default: rotation = Poppler::Page::Rotation::Rotate0; } - img = PAGE->renderToImage(DPI.width(),DPI.height(), -1, -1, -1, -1, rotation); + img = PAGE->renderToImage(DPI.width(), DPI.height(), -1, -1, -1, -1, rotation); loadingHash.insert(pagenum, img); delete PAGE; } @@ -127,6 +127,7 @@ void Renderer::clearHash() { loadingHash.clear(); } +//Highlighting found text, bookmarks, and page properties disabled for Poppler bool Renderer::supportsExtraFeatures() { return false; } void Renderer::traverseOutline(void *, int) { } diff --git a/src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro b/src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro index 17a76c3a..6ca51b79 100644 --- a/src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro +++ b/src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro @@ -36,15 +36,14 @@ FORMS += mainUI.ui \ PropDialog.ui \ BookmarkMenu.ui -isEmpty(USE_MUPDF){ - message("Using Poppler-Qt5 Backend") - LIBS += -lpoppler-qt5 - SOURCES += Renderer-poppler.cpp -}else{ +isEmpty(USE_POPPLER){ message("Using MuPDF Backend") LIBS += -lmupdf -lmupdfthird SOURCES += Renderer-mupdf.cpp - +}else{ + message("Using Poppler-Qt5 Backend") + LIBS += -lpoppler-qt5 + SOURCES += Renderer-poppler.cpp } TRANSLATIONS = i18n/l-pdf_af.ts \ diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp index 011f8660..b25f61fb 100644 --- a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp @@ -32,11 +32,11 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ PROPDIALOG = new PropDialog(BACKEND); BOOKMARKS = new BookmarkMenu(BACKEND, this->centralWidget()); BOOKMARKS->setContextMenuPolicy(Qt::CustomContextMenu); - BOOKMARKS->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + //BOOKMARKS->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); //Create the interface widgets WIDGET = new PrintWidget(BACKEND, this->centralWidget()); WIDGET->setContextMenuPolicy(Qt::CustomContextMenu); - WIDGET->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + //WIDGET->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); loadingQueue.clear(); clockTimer = new QTimer(this); clockTimer->setInterval(1000); //1-second updates to clock @@ -57,6 +57,11 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ ui->label_replaceme->setVisible(false); this->centralWidget()->layout()->replaceWidget(ui->label_replaceme2, BOOKMARKS); ui->label_replaceme2->setVisible(false); + QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding); + policy.setHorizontalStretch(1); + BOOKMARKS->setSizePolicy(policy); + policy.setHorizontalStretch(4); + WIDGET->setSizePolicy(policy); connect(WIDGET, SIGNAL(customContextMenuRequested(const QPoint&)),this, SLOT(showContextMenu(const QPoint&)) ); connect(WIDGET, SIGNAL(currentPageChanged()), this, SLOT(updatePageNumber()) ); connect(BACKEND, SIGNAL(PageLoaded(int)), this, SLOT(slotPageLoaded(int)) ); @@ -208,21 +213,12 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ //TESTING features/functionality bool TESTING = BACKEND->supportsExtraFeatures(); - ui->actionSettings->setEnabled(TESTING); - ui->actionSettings->setVisible(TESTING); ui->actionBookmarks->setEnabled(TESTING); ui->actionBookmarks->setVisible(TESTING); - ui->actionScroll_Mode->setEnabled(TESTING); - ui->actionScroll_Mode->setVisible(TESTING); - ui->actionSelect_Mode->setEnabled(TESTING); - ui->actionSelect_Mode->setVisible(TESTING); ui->actionProperties->setEnabled(TESTING); ui->actionProperties->setVisible(TESTING); - ui->menuSettings->setEnabled(TESTING); - ui->menuSettings->setVisible(TESTING); - if(!TESTING){ - ui->menubar->removeAction(ui->menuSettings->menuAction() ); - } + ui->actionClearHighlights->setEnabled(TESTING); + ui->actionClearHighlights->setVisible(TESTING); ui->actionSettings->setEnabled(false); ui->actionSettings->setVisible(false); @@ -385,19 +381,21 @@ void MainUI::startLoadingPages(int degrees){ // Using Qt to scale the image (adjust page value) smooths out the image quite a bit without a lot of performance loss (but cannot scale up without pixelization) // The best approach seams to be to increase the DPI a bit, but match that with the same scaling on the page size (smoothing) - QSize DPI(300,300); //print-quality (some printers even go to 600 DPI nowdays) + QSize DPI(150,150); //print-quality (some printers even go to 600 DPI nowdays) /*qDebug() << "Screen Resolutions:"; QList<QScreen*> screens = QApplication::screens(); for(int i=0; i<screens.length(); i++){ qDebug() << screens[i]->name() << screens[i]->logicalDotsPerInchX() << screens[i]->logicalDotsPerInchY(); }*/ + for(int i=0; i<BACKEND->numPages(); i++){ //qDebug() << " - Kickoff page load:" << i; if(BACKEND->loadMultiThread()) { QtConcurrent::run(BACKEND, &Renderer::renderPage, i, DPI, degrees); }else{ BACKEND->renderPage(i, DPI, degrees); + if(i % 50 == 0){ QCoreApplication::processEvents(); } } } //qDebug() << "Finish page loading kickoff"; @@ -634,7 +632,8 @@ void MainUI::find(QString text, bool forward) { //qDebug() << "Jump to page: " << currentText.page; - WIDGET->highlightText(currentText); + if(BACKEND->supportsExtraFeatures()) + WIDGET->highlightText(currentText); }else{ ui->resultsLabel->setText("No results found"); } diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.ui b/src-qt5/desktop-utils/lumina-pdf/mainUI.ui index 92921057..09a5862d 100644 --- a/src-qt5/desktop-utils/lumina-pdf/mainUI.ui +++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.ui @@ -14,27 +14,28 @@ <string notr="true"/> </property> <widget class="QWidget" name="centralwidget"> - <layout class="QGridLayout" name="gridLayout_2"> - <property name="leftMargin"> - <number>4</number> - </property> - <property name="topMargin"> - <number>4</number> - </property> - <property name="rightMargin"> - <number>4</number> - </property> - <property name="bottomMargin"> - <number>4</number> - </property> - <property name="spacing"> - <number>4</number> - </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label_replaceme2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Bookmarks Area</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> <item row="0" column="1"> <widget class="QLabel" name="label_replaceme"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> + <horstretch>3</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> @@ -126,19 +127,6 @@ </layout> </widget> </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_replaceme2"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Bookmarks Area</string> - </property> - </widget> - </item> </layout> </widget> <widget class="QMenuBar" name="menubar"> |