aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp5
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/PrintWidget.h1
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/mainUI.cpp52
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/mainUI.h18
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/mainUI.ui216
5 files changed, 193 insertions, 99 deletions
diff --git a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp
index 30f94e32..d2f2cd46 100644
--- a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp
+++ b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp
@@ -36,10 +36,12 @@ PrintWidget::~PrintWidget() {
void PrintWidget::fitView() {
setZoomMode(FitInView);
+ setCurrentPage(publicPageNum); //Make sure we stay on the same page
}
void PrintWidget::fitToWidth() {
setZoomMode(FitToWidth);
+ setCurrentPage(publicPageNum); //Make sure we stay on the same page
}
void PrintWidget::setZoomMode(ZoomMode mode) {
@@ -103,6 +105,7 @@ void PrintWidget::setVisible(bool visible) {
void PrintWidget::setCurrentPage(int pageNumber) {
if(pageNumber < 0 || pageNumber > (pages.count()+1) ){ return; }
publicPageNum = pageNumber; //publicly requested page number (+/- 1 from actual page range)
+ emit currentPageChanged();
if(pageNumber < 1 || pageNumber > pages.count())
return;
int lastPage = curPage;
@@ -134,6 +137,7 @@ void PrintWidget::generatePreview() {
layoutPages();
curPage = qBound(1, curPage, pages.count());
publicPageNum = curPage;
+ emit currentPageChanged();
if (fitting){ fit(); }
}
@@ -196,6 +200,7 @@ void PrintWidget::updateCurrentPage() {
if (newPage != curPage) {
curPage = newPage;
publicPageNum = curPage;
+ emit currentPageChanged();
}
}
diff --git a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h
index f18f8ace..0bc2dbac 100644
--- a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h
+++ b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h
@@ -131,6 +131,7 @@ public:
signals:
void resized();
void customContextMenuRequested(const QPoint&);
+ void currentPageChanged();
public slots:
void zoomIn(double factor=1.2);
diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp
index 04cba34b..fc7c1105 100644
--- a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp
+++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp
@@ -31,9 +31,10 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){
CurrentPage = 1;
lastdir = QDir::homePath();
//Create the interface widgets
- WIDGET = new PrintWidget(this);
+ WIDGET = new PrintWidget(this->centralWidget());
WIDGET->setVisible(false);
WIDGET->setContextMenuPolicy(Qt::CustomContextMenu);
+ WIDGET->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
clockTimer = new QTimer(this);
clockTimer->setInterval(1000); //1-second updates to clock
connect(clockTimer, SIGNAL(timeout()), this, SLOT(updateClock()) );
@@ -42,6 +43,10 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){
label_clock->setAlignment(Qt::AlignCenter );
label_clock->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
label_clock->setStyleSheet("QLabel{color: palette(highlight-text); background-color: palette(highlight); border-radius: 5px; }");
+
+ label_page = new QLabel(this);
+ label_page->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
+ label_page->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
//Context Menu
contextMenu = new QMenu(this);
connect(contextMenu, SIGNAL(aboutToShow()), this, SLOT(updateContextMenu()));
@@ -49,9 +54,11 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){
ui->bookmarksFrame->setParent(WIDGET);
ui->findGroup->setParent(WIDGET);
qDebug() << "Setting central widget";
- this->setCentralWidget(WIDGET);
+ this->centralWidget()->layout()->replaceWidget(ui->label_replaceme, WIDGET); //setCentralWidget(WIDGET);
+ ui->label_replaceme->setVisible(false);
WIDGET->setContextMenuPolicy(Qt::CustomContextMenu);
connect(WIDGET, SIGNAL(customContextMenuRequested(const QPoint&)),this, SLOT(showContextMenu(const QPoint&)) );
+ connect(WIDGET, SIGNAL(currentPageChanged()), this, SLOT(updatePageNumber()) );
DOC = 0;
connect(this, SIGNAL(PageLoaded(int)), this, SLOT(slotPageLoaded(int)) );
@@ -67,6 +74,8 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){
progAct->setVisible(false);
clockAct = ui->toolBar->addWidget(label_clock);
clockAct->setVisible(false);
+ pageAct = ui->toolBar->addWidget(label_page);
+ pageAct->setVisible(false);
//Put the various actions into logical groups
QActionGroup *tmp = new QActionGroup(this);
@@ -115,7 +124,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){
[&] { find(ui->textEdit->text(), true); });
connect(ui->findPrevB, &QPushButton::clicked, this,
[&] { find(ui->textEdit->text(), false); });
- connect(ui->matchCase, &QPushButton::clicked, this,
+ connect(ui->matchCase, &QPushButton::clicked, this,
[&] (bool value) { this->matchCase = value; });
connect(ui->closeFind, &QPushButton::clicked, this,
[&] { ui->findGroup->setVisible(false); this->setFocus(); });
@@ -123,7 +132,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){
[&] { WIDGET->updatePreview(); });
connect(ui->actionBookmarks, SIGNAL(triggered()), this, SLOT(showBookmarks()));
- qDebug() << "Finished connctions";
+ //qDebug() << "Finished connctions";
//int curP = WIDGET->currentPage()-1; //currentPage reports pages starting at 1
//int lastP = numPages-1;
@@ -190,7 +199,6 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){
}
MainUI::~MainUI(){
-
}
void MainUI::loadFile(QString path){
@@ -303,7 +311,7 @@ void MainUI::startPresentation(bool atStart){
bool cancelled = false;
QScreen *screen = getScreen(false, cancelled); //let the user select which screen to use (if multiples)
if(cancelled){ return;}
- int page = 0;
+ int page = 1;
if(!atStart){ page = WIDGET->currentPage(); }
//PDPI = QSize(SCALEFACTOR*screen->physicalDotsPerInchX(), SCALEFACTOR*screen->physicalDotsPerInchY());
//Now create the full-screen window on the selected screen
@@ -324,6 +332,7 @@ void MainUI::startPresentation(bool atStart){
ui->actionStart_Here->setEnabled(false);
ui->actionStart_Begin->setEnabled(false);
updateClock();
+ updatePageNumber();
clockAct->setVisible(true);
clockTimer->start();
QApplication::processEvents();
@@ -369,6 +378,7 @@ void MainUI::endPresentation(){
clockTimer->stop();
clockAct->setVisible(false);
this->releaseKeyboard();
+ updatePageNumber();
}
void MainUI::startLoadingPages(){
@@ -380,17 +390,18 @@ void MainUI::startLoadingPages(){
progress->setRange(0,numPages);
progress->setValue(0);
progAct->setVisible(true);
-
+ pageAct->setVisible(false);
//PERFORMANCE NOTES:
// Using Poppler to scale the image (adjust dpi value) helps a bit but you take a larger CPU loading hit (and still quite a lot of pixelization)
// 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)
- double scalefactor = 2.0;
+ double scalefactor = 2.5;
QSizeF pageSize = DOC->page(0)->pageSizeF()*scalefactor;
//QSize DPI(loadingHash[0]->resolution(),loadingHash[0]->resolution());
- QSize DPI(76,76);
- DPI = DPI*(scalefactor+1); //need this a bit higher than the page scaling
+ //QSize DPI(76,76);
+ //DPI = DPI*(scalefactor+1); //need this a bit higher than the page scaling
+ QSize DPI(300,300); //print-quality (some printers even go to 600 DPI nowdays)
/*qDebug() << "Screen Resolutions:";
QList<QScreen*> screens = QApplication::screens();
@@ -419,6 +430,7 @@ void MainUI::slotPageLoaded(int page){
ui->actionStop_Presentation->setEnabled(false);
ui->actionStart_Here->setEnabled(true);
ui->actionStart_Begin->setEnabled(true);
+ pageAct->setVisible(true);
}else{
progress->setValue(finished);
}
@@ -431,6 +443,14 @@ void MainUI::paintToPrinter(QPrinter *PRINTER){
int firstpage = 0;
int copies = PRINTER->copyCount();
bool collate = PRINTER->collateCopies();
+ qDebug() << "PRINTER DPI:" << PRINTER->resolution() << PRINTER->supportedResolutions();
+ return;
+ if(PRINTER->resolution() < 300){
+ //Try to get 300 DPI resolution at least
+ PRINTER->setResolution(300);
+ qDebug() << "Trying to change print resolution to 300 minimum";
+ qDebug() << " -- Resolutions listed as supported:" << PRINTER->supportedResolutions();
+ }
//bool duplex = (PRINTER->duplex()!=QPrinter::DuplexNone);
//Determine the first page that needs to be printed, and the range
if((PRINTER->fromPage() != PRINTER->toPage() || PRINTER->fromPage()!=0 ) && PRINTER->printRange()==QPrinter::PageRange ){
@@ -467,6 +487,11 @@ void MainUI::paintToPrinter(QPrinter *PRINTER){
if(landscape){ sz = QSize(sz.height(), sz.width() ); } //flip the size dimensions as needed
//Now send out the pages in the right order/format
QPainter painter(PRINTER);
+ //Ensure all the antialiasing/smoothing options are turned on
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.setRenderHint(QPainter::TextAntialiasing);
+ painter.setRenderHint(QPainter::SmoothPixmapTransform);
+
QTransform transF;
transF.rotate(90);
//Show the progress bar
@@ -494,6 +519,13 @@ void MainUI::updateClock(){
label_clock->setText( QDateTime::currentDateTime().toString("<b>hh:mm:ss</b>") );
}
+void MainUI::updatePageNumber(){
+ QString text;
+ if(presentationLabel==0 || !presentationLabel->isVisible()){ text = tr("Page %1 of %2"); }
+ else{ text = "%1/%2"; }
+ label_page->setText( text.arg( QString::number(WIDGET->currentPage()), QString::number(numPages) ));
+}
+
void MainUI::setScroll(bool tog) {
if(tog) {
QApplication::setOverrideCursor(Qt::OpenHandCursor);
diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.h b/src-qt5/desktop-utils/lumina-pdf/mainUI.h
index ca32f74d..5a22905a 100644
--- a/src-qt5/desktop-utils/lumina-pdf/mainUI.h
+++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.h
@@ -40,12 +40,12 @@ private:
Poppler::Document *DOC;
PrintWidget *WIDGET;
Ui::MainUI *ui;
- PropDialog *PROPDIALOG;
+ PropDialog *PROPDIALOG;
QPrintDialog *PrintDLG;
QString lastdir;
- bool matchCase;
- QMap<Poppler::TextBox*, int> results;
- int currentHighlight;
+ bool matchCase;
+ QMap<Poppler::TextBox*, int> results;
+ int currentHighlight;
//Other Interface elements
QProgressBar *progress;
@@ -53,8 +53,8 @@ private:
QTimer *clockTimer;
QMenu *contextMenu;
//QFrame *frame_presenter;
- QLabel *label_clock;
- QAction *clockAct;
+ QLabel *label_clock, *label_page;
+ QAction *clockAct, *pageAct;
//PDF Page Loading cache variables
QHash<int, QImage> loadingHash;
@@ -95,12 +95,14 @@ private slots:
//Other interface slots
void updateClock();
+ void updatePageNumber();
void showContextMenu(const QPoint&){ contextMenu->popup(QCursor::pos()); }
void updateContextMenu();
void setScroll(bool);
void rotate(bool);
+
signals:
void PageLoaded(int);
@@ -108,5 +110,9 @@ protected:
void keyPressEvent(QKeyEvent*);
void wheelEvent(QWheelEvent*);
void resizeEvent(QResizeEvent*);
+ void closeEvent(QCloseEvent *ev){
+ endPresentation();
+ QMainWindow::closeEvent(ev);
+ }
};
#endif
diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.ui b/src-qt5/desktop-utils/lumina-pdf/mainUI.ui
index 8f6fff27..f6d53085 100644
--- a/src-qt5/desktop-utils/lumina-pdf/mainUI.ui
+++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.ui
@@ -14,104 +14,154 @@
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
- <widget class="QFrame" name="findGroup">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>560</y>
- <width>691</width>
- <height>61</height>
- </rect>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <property name="leftMargin">
+ <number>4</number>
</property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
+ <property name="topMargin">
+ <number>4</number>
</property>
- <property name="frameShape">
- <enum>QFrame::StyledPanel</enum>
+ <property name="rightMargin">
+ <number>4</number>
</property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
+ <property name="bottomMargin">
+ <number>4</number>
</property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="1" column="0">
- <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="spacing">
+ <number>4</number>
+ </property>
+ <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="closeFind">
+ <widget class="QLabel" name="label_2">
<property name="text">
- <string/>
+ <string>Bookmarks</string>
</property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="textEdit"/>
- </item>
- <item>
- <widget class="QPushButton" name="findPrevB">
- <property name="text">
- <string/>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
- <item>
- <widget class="QPushButton" name="findNextB">
- <property name="text">
- <string/>
- </property>
- </widget>
+ </layout>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="label_replaceme">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string notr="true">GraphicsArea (replaced)</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <widget class="QFrame" name="findGroup">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <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>
+ <item row="1" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="closeFind">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="textEdit"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="findPrevB">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="findNextB">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="matchCase">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
- <item>
- <widget class="QPushButton" name="matchCase">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
<property name="text">
- <string/>
- </property>
- <property name="checkable">
- <bool>true</bool>
+ <string>Find...</string>
</property>
</widget>
</item>
</layout>
- </item>
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Find...</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QFrame" name="bookmarksFrame">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>9</y>
- <width>81</width>
- <height>601</height>
- </rect>
- </property>
- <property name="frameShape">
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
- </property>
- <widget class="QLabel" name="label_2">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>0</y>
- <width>71</width>
- <height>16</height>
- </rect>
- </property>
- <property name="text">
- <string>Bookmarks</string>
- </property>
- </widget>
- </widget>
+ </widget>
+ </item>
+ </layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
@@ -119,7 +169,7 @@
<x>0</x>
<y>0</y>
<width>697</width>
- <height>21</height>
+ <height>42</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
bgstack15