diff options
Diffstat (limited to 'src-qt5/desktop-utils')
17 files changed, 300 insertions, 117 deletions
diff --git a/src-qt5/desktop-utils/lumina-pdf/Bookmark.h b/src-qt5/desktop-utils/lumina-pdf/Bookmark.h new file mode 100644 index 00000000..9a78beb2 --- /dev/null +++ b/src-qt5/desktop-utils/lumina-pdf/Bookmark.h @@ -0,0 +1,17 @@ +#pragma once + +class Bookmark { + public: + Bookmark(char *_title, char *_link, int _pagenum, int _level) : + pagenum(_pagenum), + level(_level) + { + title = QString::fromLocal8Bit(_title); + link = QString::fromLocal8Bit(_link); + } + + QString title; + QString link; + int pagenum; + int level; +}; diff --git a/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp b/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp new file mode 100644 index 00000000..0a8dd695 --- /dev/null +++ b/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp @@ -0,0 +1,53 @@ +//=========================================== +// Lumina Desktop source code +// Copyright (c) 2017, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== + +#include "BookmarkMenu.h" +#include "ui_BookmarkMenu.h" +#include <LuminaXDG.h> + +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() { + QTreeWidgetItem *item=nullptr, *parent=nullptr; + QList<Bookmark*> bookmarks = BACKEND->getBookmarks(); + + if(ui->bookmarks->topLevelItemCount() != 0) { + ui->bookmarks->clear(); + } + + //Modfiy for more than 2 levels + if(bookmarks.empty()) { + item = new QTreeWidgetItem(ui->bookmarks); + item->setText(0, "No Bookmarks"); + item->setData(1, Qt::UserRole, ""); + item->setIcon(0, LXDG::findIcon("bookmark-remove")); + }else{ + foreach(Bookmark *bm, bookmarks) { + if(bm->level == 0) { + item = new QTreeWidgetItem(ui->bookmarks); + parent = item; + }else{ + item = new QTreeWidgetItem(parent); + } + + item->setText(0, bm->title); + item->setData(1, Qt::UserRole, bm->link); + if(!bm->link.isEmpty()) + item->setIcon(0, LXDG::findIcon("bookmark-new")); + else + item->setIcon(0, LXDG::findIcon("bookmark-remove")); + } + } +} diff --git a/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.h b/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.h new file mode 100644 index 00000000..46921f6f --- /dev/null +++ b/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.h @@ -0,0 +1,27 @@ +//=========================================== +// Lumina Desktop source code +// Copyright (c) 2017, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#pragma once + +#include <QDialog> +#include <QTextEdit> +#include "Renderer.h" + +namespace Ui{ + class BookmarkMenu; +}; + +class BookmarkMenu : public QWidget{ + Q_OBJECT + public: + BookmarkMenu(Renderer *Backend, QWidget *parent=NULL); + public slots: + void loadBookmarks(); + + private: + Ui::BookmarkMenu *ui; + Renderer *BACKEND; +}; diff --git a/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.ui b/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.ui new file mode 100644 index 00000000..de19be66 --- /dev/null +++ b/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.ui @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>BookmarkMenu</class> + <widget class="QWidget" name="BookmarkMenu"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>109</width> + <height>507</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </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> + </item> + <item> + <widget class="QTreeWidget" name="bookmarks"> + <column> + <property name="text"> + <string notr="true">1</string> + </property> + </column> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp index 7c0fd323..63d25be4 100644 --- a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp @@ -315,3 +315,19 @@ void PrintWidget::fit(bool doFitting) { //zoomFactor = this->transform().m11() * (float(printer->logicalDpiY()) / this->logicalDpiY()); } + +void PrintWidget::goToPosition(int pagenum, float x, float y) { + setCurrentPage(pagenum+1); + QPointF pt = this->transform().map(pages.at(pagenum)->pos()); + + if (zoomMode != FitInView) { + if(x != 0) { + QScrollBar *hsc = this->horizontalScrollBar(); + hsc->setValue(int(pt.x() + x) - 10); + } + if(y != 0) { + QScrollBar *vsc = this->verticalScrollBar(); + vsc->setValue(int(pt.y() + y) - 10); + } + } +} diff --git a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h index 98bcd259..92d82e11 100644 --- a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h +++ b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h @@ -20,8 +20,7 @@ #include <QtMath> #include <QPageLayout> #include "Renderer.h" - -#include "textData.h" +#include "TextData.h" class PageItem : public QGraphicsItem { public: @@ -135,6 +134,7 @@ public slots: void setCurrentPage(int); void setVisible(bool) Q_DECL_OVERRIDE; void highlightText(TextData*); + void goToPosition(int, float, float); void updatePreview(); void fitView(); diff --git a/src-qt5/desktop-utils/lumina-pdf/propDialog.cpp b/src-qt5/desktop-utils/lumina-pdf/PropDialog.cpp index c721f65f..a7a67f03 100644 --- a/src-qt5/desktop-utils/lumina-pdf/propDialog.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/PropDialog.cpp @@ -5,12 +5,11 @@ // See the LICENSE file for full details //=========================================== -#include "propDialog.h" -#include "ui_propDialog.h" - +#include "PropDialog.h" +#include "ui_PropDialog.h" #include <LuminaXDG.h> -PropDialog::PropDialog(Renderer *Backend) : QDialog(), ui(new Ui::PropDialog()){ +PropDialog::PropDialog(Renderer *Backend) : QDialog(), ui(new Ui::PropDialog()), BACKEND(Backend){ ui->setupUi(this); this->setWindowTitle(tr("PDF Information")); this->setWindowIcon( LXDG::findIcon("dialog-information","unknown")); @@ -26,13 +25,18 @@ PropDialog::PropDialog(Renderer *Backend) : QDialog(), ui(new Ui::PropDialog()){ ui->keywordsL->setText(tr("Keywords:")); ui->createdL->setText(tr("Created:")); ui->modifiedL->setText(tr("Modified:")); - ui->sizeL->setText(tr("Page Size: ")); - ui->numberL->setText(tr("Number of Pages: ")); ui->saveButton->setText(tr("Save")); ui->closeButton->setText(tr("Close")); +} + +//Load size from mainUI after pages have loaded +void PropDialog::setSize(QSizeF pageSize) { + ui->sizeL->setText(tr("Page Size: ") + QString::number(pageSize.width())+", "+QString::number(pageSize.height())); +} - QJsonObject info = Backend->properties(); - //Fill the text boxes with information from the document +//Fill the text boxes with information from the document +void PropDialog::setInformation() { + QJsonObject info = BACKEND->properties(); ui->titleE->setText( info.value("title").toString() ); ui->subjectE->setText( info.value("subject").toString() ); ui->authorE->setText( info.value("author").toString() ); @@ -41,10 +45,5 @@ PropDialog::PropDialog(Renderer *Backend) : QDialog(), ui(new Ui::PropDialog()){ ui->keywordE->setText( info.value("keywords").toString() ); ui->createdEntry->setText( info.value("dt_created").toString() ); ui->modifiedEntry->setText( info.value("dt_modified").toString() ); - ui->numberL->setText( ui->numberL->text() + QString::number(Backend->numPages()) ); -} - -//Load size from mainUI after pages have loaded -void PropDialog::setSize(QSizeF pageSize) { - ui->sizeL->setText(ui->sizeL->text()+QString::number(pageSize.width())+", "+QString::number(pageSize.height())); + ui->numberL->setText( tr("Number of Pages: ") + QString::number(BACKEND->numPages()) ); } diff --git a/src-qt5/desktop-utils/lumina-pdf/propDialog.h b/src-qt5/desktop-utils/lumina-pdf/PropDialog.h index 23b8c877..aa8f4d92 100644 --- a/src-qt5/desktop-utils/lumina-pdf/propDialog.h +++ b/src-qt5/desktop-utils/lumina-pdf/PropDialog.h @@ -4,8 +4,7 @@ // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== -#ifndef _LUMINA_PDF_VIEWER_PROP_DIALOG_H -#define _LUMINA_PDF_VIEWER_PROP_DIALOG_H +#pragma once #include <QDialog> #include <QTextEdit> @@ -19,9 +18,12 @@ class PropDialog : public QDialog { Q_OBJECT public: PropDialog(Renderer *Backend); + + public slots: void setSize(QSizeF); + void setInformation(); private: Ui::PropDialog *ui; + Renderer *BACKEND; }; -#endif diff --git a/src-qt5/desktop-utils/lumina-pdf/propDialog.ui b/src-qt5/desktop-utils/lumina-pdf/PropDialog.ui index d79d2087..d79d2087 100644 --- a/src-qt5/desktop-utils/lumina-pdf/propDialog.ui +++ b/src-qt5/desktop-utils/lumina-pdf/PropDialog.ui diff --git a/src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp b/src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp index 23d9b3d1..7846e9c1 100644 --- a/src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp @@ -1,14 +1,14 @@ #include "Renderer.h" #include <QDateTime> #include <mupdf/fitz.h> +#include <mupdf/pdf.h> #include <QMutex> #include <QFuture> #include <QtConcurrent> class Data { public: - Data(int _pagenum, fz_context *_ctx, fz_display_list *_list, fz_rect _bbox, fz_pixmap *_pix, fz_matrix _ctm, double _sf) : - pagenumber(_pagenum), + Data(int _pagenum, fz_context *_ctx, fz_display_list *_list, fz_rect _bbox, fz_pixmap *_pix, fz_matrix _ctm, double _sf) : pagenumber(_pagenum), ctx(_ctx), list(_list), bbox(_bbox), @@ -66,9 +66,8 @@ Renderer::Renderer(){ } Renderer::~Renderer(){ - qDebug() << "Calling destructor"; - qDeleteAll(dataHash); - dataHash.clear(); + qDebug() << "Dropping Context"; + clearHash(); fz_drop_document(CTX, DOC); DOC = NULL; fz_drop_context(CTX); @@ -77,6 +76,33 @@ Renderer::~Renderer(){ bool Renderer::loadMultiThread(){ return false; } +void Renderer::handleLink(QString link) { + float xp = 0.0, yp = 0.0; + int pagenum = 0; + + QByteArray linkData = link.toLocal8Bit(); + char *uri = linkData.data(); + + if(!link.isEmpty()) { + pagenum = fz_resolve_link(CTX, DOC, uri, &xp, &yp); + emit goToPosition(pagenum, xp, yp); + } +} + +//Traverse the outline tree through Preorder traversal +void Renderer::traverseOutline(void *link, int level) { + fz_outline *olink = (fz_outline*)link; + + Bookmark *bm = new Bookmark(olink->title, olink->uri, olink->page, level); + bookmarks.push_back(bm); + + if(olink->down) + traverseOutline(olink->down, level+1); + + if(olink->next) + traverseOutline(olink->next, level); +} + bool Renderer::loadDocument(QString path, QString password){ //first time through if(path != docpath) { @@ -86,13 +112,17 @@ bool Renderer::loadDocument(QString path, QString password){ DOC = NULL; needpass = false; docpath = path; + if(bookmarks.size() > 0) { + qDeleteAll(bookmarks); + bookmarks.clear(); + } }else if(DOC==0){ fz_register_document_handlers(CTX); qDebug() << "Document handlers registered"; } - DOC = fz_open_document(CTX, path.toLocal8Bit().data()); docpath = path; + DOC = fz_open_document(CTX, path.toLocal8Bit().data()); qDebug() << "File opened" << DOC; if(DOC==0){ qDebug() << "Could not open file:" << path; @@ -107,13 +137,13 @@ bool Renderer::loadDocument(QString path, QString password){ if(needpass){ return false; } //incorrect password } - //qDebug() << "Password Check cleared"; + qDebug() << "Password Check cleared"; pnum = fz_count_pages(CTX, DOC); qDebug() << "Page count: " << pnum; doctitle.clear(); - //qDebug() << "Opening File:" << path; - jobj.insert("title", getTextInfo("Title") ); + + qDebug() << "Opening File:" << path; jobj.insert("subject", getTextInfo("Subject") ); jobj.insert("author", getTextInfo("Author") ); jobj.insert("creator", getTextInfo("Creator") ); @@ -122,13 +152,21 @@ bool Renderer::loadDocument(QString path, QString password){ jobj.insert("dt_created", QDateTime::fromString( getTextInfo("CreationDate").left(16), "'D:'yyyyMMddHHmmss").toString() ); jobj.insert("dt_modified", QDateTime::fromString( getTextInfo("ModDate").left(16), "'D:'yyyyMMddHHmmss").toString() ); - if(!jobj["title"].isNull()) + if(!jobj["title"].toString().isEmpty()) doctitle = jobj["title"].toString(); else doctitle = path.section("/",-1); - qDebug() << "Page Loaded"; //Possibly check Page orientation + + fz_outline *outline = fz_load_outline(CTX, DOC); + if(outline) + traverseOutline(outline, 0); + else + qDebug() << "No Bookmarks"; + + fz_drop_outline(CTX, outline); + return true; } return false; @@ -162,7 +200,6 @@ void renderer(Data *data, Renderer *obj) emit obj->PageLoaded(pagenum); } -//Consider rendering through a display list void Renderer::renderPage(int pagenum, QSize DPI, int degrees){ //qDebug() << "- Rendering Page:" << pagenum << degrees; Data *data; @@ -172,7 +209,7 @@ void Renderer::renderPage(int pagenum, QSize DPI, int degrees){ fz_pixmap *pixmap; fz_display_list *list; - double pageDPI = 96.0; + double pageDPI = 150.0; double sf = DPI.width() / pageDPI; fz_scale(&matrix, sf, sf); fz_pre_rotate(&matrix, degrees); @@ -185,6 +222,17 @@ void Renderer::renderPage(int pagenum, QSize DPI, int degrees){ list = fz_new_display_list(CTX, &bbox); fz_device *dev = fz_new_list_device(CTX, list); fz_run_page(CTX, PAGE, dev, &fz_identity, NULL); + /*fz_annot *annot = fz_first_annot(CTX, PAGE); + + while(annot) { + fz_run_annot(CTX, annot, dev, &fz_identity, NULL); + fz_rect bbox; + fz_bound_annot(CTX, annot, &bbox); + + QRectF rect(bbox.x0, bbox.y0, (bbox.x1-bbox.x0), (bbox.y1 - bbox.y0)); + qDebug() << "Annotation:" << rect << "at" << pagenum; + annot = fz_next_annot(CTX, annot); + }*/ fz_close_device(CTX, dev); fz_drop_device(CTX, dev); @@ -201,7 +249,7 @@ QList<TextData*> Renderer::searchDocument(QString text, bool matchCase){ fz_rect rectBuffer[1000]; QList<TextData*> results; for(int i = 0; i < pnum; i++) { - int count = fz_search_display_list(CTX, dataHash[i]->list, text.toLatin1().data(), rectBuffer, 1000); + int count = fz_search_display_list(CTX, dataHash[i]->list, text.toLocal8Bit().data(), rectBuffer, 1000); //qDebug() << "Page " << i+1 << ": Count, " << count; for(int j = 0; j < count; j++) { double sf = dataHash[i]->sf; diff --git a/src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp b/src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp index 439fd804..28045539 100644 --- a/src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp @@ -128,3 +128,7 @@ void Renderer::clearHash() { } bool Renderer::supportsExtraFeatures() { return false; } + +void Renderer::traverseOutline(void *, int) { } + +void Renderer::handleLink(QString link) { } diff --git a/src-qt5/desktop-utils/lumina-pdf/Renderer.h b/src-qt5/desktop-utils/lumina-pdf/Renderer.h index ab86724d..22548278 100644 --- a/src-qt5/desktop-utils/lumina-pdf/Renderer.h +++ b/src-qt5/desktop-utils/lumina-pdf/Renderer.h @@ -10,7 +10,8 @@ #include <QImage> #include <QDebug> #include <QJsonObject> -#include "textData.h" +#include "TextData.h" +#include "Bookmark.h" class Renderer : public QObject { Q_OBJECT @@ -22,6 +23,7 @@ private: QString doctitle; QJsonObject jobj; int degrees; + QList<Bookmark*> bookmarks; public: Renderer(); @@ -36,11 +38,14 @@ public: int hashSize(); QImage imageHash(int pagenum); int rotatedDegrees() { return degrees; } + QList<Bookmark*> getBookmarks() { return bookmarks; } //Main access functions bool loadDocument(QString path, QString password); void renderPage(int pagenum, QSize DPI, int degrees=0); QList<TextData*> searchDocument(QString text, bool matchCase); + void traverseOutline(void *, int); + void handleLink(QString); void clearHash(); //Makes sure degrees is between 0 and 360 then rotates the matrix and @@ -56,6 +61,7 @@ signals: void PageLoaded(int); void OrigSize(QSizeF); void reloadPages(int); + void goToPosition(int, float, float); }; #endif diff --git a/src-qt5/desktop-utils/lumina-pdf/textData.h b/src-qt5/desktop-utils/lumina-pdf/TextData.h index 9bf7e5bb..9bf7e5bb 100644 --- a/src-qt5/desktop-utils/lumina-pdf/textData.h +++ b/src-qt5/desktop-utils/lumina-pdf/TextData.h diff --git a/src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro b/src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro index 8ed0e9f3..17a76c3a 100644 --- a/src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro +++ b/src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro @@ -19,18 +19,22 @@ message("Qt Modules Needed: $${QT}") SOURCES += main.cpp \ mainUI.cpp \ - propDialog.cpp \ - PrintWidget.cpp + PropDialog.cpp \ + PrintWidget.cpp \ + BookmarkMenu.cpp HEADERS += mainUI.h \ PrintWidget.h \ PresentationLabel.h \ PropDialog.h \ Renderer.h \ - textData.h + TextData.h \ + Bookmark.h \ + BookmarkMenu.h FORMS += mainUI.ui \ - propDialog.ui + PropDialog.ui \ + BookmarkMenu.ui isEmpty(USE_MUPDF){ message("Using Poppler-Qt5 Backend") diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp index 3c2d1541..011f8660 100644 --- a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp @@ -29,7 +29,10 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ CurrentPage = 1; lastdir = QDir::homePath(); BACKEND = new Renderer(); - PROPDIALOG=nullptr; + PROPDIALOG = new PropDialog(BACKEND); + BOOKMARKS = new BookmarkMenu(BACKEND, this->centralWidget()); + BOOKMARKS->setContextMenuPolicy(Qt::CustomContextMenu); + BOOKMARKS->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); //Create the interface widgets WIDGET = new PrintWidget(BACKEND, this->centralWidget()); WIDGET->setContextMenuPolicy(Qt::CustomContextMenu); @@ -52,11 +55,13 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ connect(contextMenu, SIGNAL(aboutToShow()), this, SLOT(updateContextMenu())); this->centralWidget()->layout()->replaceWidget(ui->label_replaceme, WIDGET); ui->label_replaceme->setVisible(false); - WIDGET->setContextMenuPolicy(Qt::CustomContextMenu); + this->centralWidget()->layout()->replaceWidget(ui->label_replaceme2, BOOKMARKS); + ui->label_replaceme2->setVisible(false); 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)) ); connect(BACKEND, SIGNAL(reloadPages(int)), this, SLOT(startLoadingPages(int))); + connect(BACKEND, SIGNAL(goToPosition(int, float, float)), WIDGET, SLOT(goToPosition(int, float, float))); PrintDLG = new QPrintDialog(this); connect(PrintDLG, SIGNAL(accepted(QPrinter*)), this, SLOT(paintToPrinter(QPrinter*)) ); @@ -133,11 +138,9 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ [&] (bool value) { this->matchCase = value; }); connect(ui->closeFind, &QPushButton::clicked, this, [&] { ui->findGroup->setVisible(false); this->setFocus(); }); - connect(ui->closeBookmarks, &QPushButton::clicked, this, - [&] { ui->bookmarksFrame->setVisible(false); this->setFocus(); }); connect(ui->actionClearHighlights, &QAction::triggered, WIDGET, [&] { WIDGET->updatePreview(); }); - connect(ui->actionBookmarks, SIGNAL(triggered()), this, SLOT(showBookmarks())); + connect(ui->actionBookmarks, &QAction::triggered, this, [=] () { BOOKMARKS->setVisible(true); }); //qDebug() << "Finished connctions"; @@ -195,9 +198,6 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ ui->findNextB->setIcon(LXDG::findIcon("go-down-search")); ui->matchCase->setIcon(LXDG::findIcon("format-text-italic")); ui->closeFind->setIcon(LXDG::findIcon("dialog-close")); - ui->closeBookmarks->setIcon(LXDG::findIcon("dialog-close")); - - //qDebug() << "Finished setting icons"; //Now set the default state of the menu's and actions ui->actionStop_Presentation->setEnabled(false); @@ -205,7 +205,6 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ ui->actionStart_Begin->setEnabled(false); ui->findGroup->setVisible(false); - ui->bookmarksFrame->setVisible(false); //TESTING features/functionality bool TESTING = BACKEND->supportsExtraFeatures(); @@ -234,6 +233,8 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ } MainUI::~MainUI(){ + if(BOOKMARKS!=0){ BOOKMARKS->deleteLater(); } + if(PROPDIALOG!=0) { PROPDIALOG->deleteLater(); } delete BACKEND; } @@ -247,19 +248,18 @@ void MainUI::loadFile(QString path){ if(!ok){ break; } //cancelled } //Clear the current display + WIDGET->setVisible(false); - QTimer::singleShot(10, WIDGET, SLOT(updatePreview())); + BOOKMARKS->setVisible(false); //Load the new document info this->setWindowTitle( BACKEND->title()); if(BACKEND->needPassword()){ return; } //cancelled; qDebug() << " - Document Setup : start loading pages now"; - QTimer::singleShot(50, [&]() { startLoadingPages(0); } ); -} -void MainUI::loadPage(int num, MainUI *obj, QSize dpi, int degrees){ - //qDebug() << " - Render Page:" << num; - BACKEND->renderPage(num, dpi, degrees); - //qDebug() << "Image at" << num << "accessed outside:" << BACKEND->imageHash(num).isNull(); + //Populate or repopulate the Bookmarks menu and Properties Dialog + QTimer::singleShot(10, BOOKMARKS, SLOT(loadBookmarks()) ); + QTimer::singleShot(10, PROPDIALOG, SLOT(setInformation()) ); + QTimer::singleShot(50, [&]() { startLoadingPages(0); } ); } QScreen* MainUI::getScreen(bool current, bool &cancelled){ @@ -373,8 +373,6 @@ void MainUI::startLoadingPages(int degrees){ qDebug() <<"Start Loading Pages"; //if(BACKEND->hashSize() != 0) { return; } //currently loaded[ing] loadingQueue.clear(); - if(PROPDIALOG) - delete PROPDIALOG; BACKEND->clearHash(); WIDGET->setVisible(false); //qDebug() << "Update Progress Bar"; @@ -389,15 +387,15 @@ void MainUI::startLoadingPages(int degrees){ QSize DPI(300,300); //print-quality (some printers even go to 600 DPI nowdays) - qDebug() << "Screen Resolutions:"; + /*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(this, &MainUI::loadPage, i, this, DPI, degrees); + QtConcurrent::run(BACKEND, &Renderer::renderPage, i, DPI, degrees); }else{ BACKEND->renderPage(i, DPI, degrees); } @@ -406,20 +404,18 @@ void MainUI::startLoadingPages(int degrees){ } void MainUI::slotPageLoaded(int page){ - loadingQueue.push_back(page); + loadingQueue.push_back(page); int finished = loadingQueue.size(); //qDebug() << "Page Loaded:" << page << finished; if(finished == BACKEND->numPages()){ - //qDebug() << " - finished:" << finished; progAct->setVisible(false); WIDGET->setVisible(true); WIDGET->setCurrentPage(1); - PROPDIALOG = new PropDialog(BACKEND); - PROPDIALOG->setSize(pageSize); ui->actionStop_Presentation->setEnabled(false); ui->actionStart_Here->setEnabled(true); ui->actionStart_Begin->setEnabled(true); pageAct->setVisible(true); + PROPDIALOG->setSize(pageSize); qDebug() << " - Document Setup: All pages loaded"; QTimer::singleShot(10, WIDGET, SLOT(updatePreview())); //start loading the file preview }else{ @@ -644,7 +640,3 @@ void MainUI::find(QString text, bool forward) { } } } - -void MainUI::showBookmarks() { - ui->bookmarksFrame->setVisible(true); -} diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.h b/src-qt5/desktop-utils/lumina-pdf/mainUI.h index 311bb46d..10f2d2e4 100644 --- a/src-qt5/desktop-utils/lumina-pdf/mainUI.h +++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.h @@ -21,10 +21,11 @@ #include <QTimer> #include "Renderer.h" +#include "BookmarkMenu.h" #include "PresentationLabel.h" -#include "propDialog.h" +#include "PropDialog.h" #include "PrintWidget.h" -#include "textData.h" +#include "TextData.h" namespace Ui{ class MainUI; @@ -43,6 +44,7 @@ private: PrintWidget *WIDGET; Ui::MainUI *ui; PropDialog *PROPDIALOG; + BookmarkMenu *BOOKMARKS; QPrintDialog *PrintDLG; QString lastdir; bool matchCase; @@ -62,8 +64,6 @@ private: //PDF Page Loading cache variables Renderer *BACKEND; - void loadPage(int num, MainUI *obj, QSize dpi, int degrees); - //Functions/variables for the presentation mode PresentationLabel *presentationLabel; QScreen *getScreen(bool current, bool &cancelled); @@ -86,7 +86,6 @@ private slots: void closePresentation(){ endPresentation(); } void find(QString text, bool forward); - void showBookmarks(); void paintToPrinter(QPrinter *PRINTER); diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.ui b/src-qt5/desktop-utils/lumina-pdf/mainUI.ui index e8b07c26..92921057 100644 --- a/src-qt5/desktop-utils/lumina-pdf/mainUI.ui +++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.ui @@ -46,50 +46,6 @@ </property> </widget> </item> - <item row="0" column="0"> - <widget class="QFrame" name="bookmarksFrame"> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Raised</enum> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="spacing"> - <number>6</number> - </property> - <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> - <item> - <widget class="QPushButton" name="closeBookmarks"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Bookmarks</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - </widget> - </item> - </layout> - </widget> - </item> <item row="1" column="0" colspan="2"> <widget class="QFrame" name="findGroup"> <property name="sizePolicy"> @@ -170,6 +126,19 @@ </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"> @@ -178,7 +147,7 @@ <x>0</x> <y>0</y> <width>697</width> - <height>38</height> + <height>23</height> </rect> </property> <property name="contextMenuPolicy"> |