aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2018-01-29 14:24:39 -0500
committerKen Moore <ken@ixsystems.com>2018-01-29 14:24:39 -0500
commit4cb92713a97042dadd0a2e168b78ef3a936a9442 (patch)
treeed6268f9b8fa2346edda8386a0846bc9e8752bf8 /src-qt5/desktop-utils
parentSome more updates for Lumina 2: (diff)
parentSome more final changes to lumina-pdf. (diff)
downloadlumina-4cb92713a97042dadd0a2e168b78ef3a936a9442.tar.gz
lumina-4cb92713a97042dadd0a2e168b78ef3a936a9442.tar.bz2
lumina-4cb92713a97042dadd0a2e168b78ef3a936a9442.zip
Merge branch 'master' of github.com:trueos/lumina
Diffstat (limited to 'src-qt5/desktop-utils')
-rw-r--r--src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp5
-rw-r--r--src-qt5/desktop-utils/lumina-notify/README.md41
-rw-r--r--src-qt5/desktop-utils/lumina-notify/lumina-notify.pro19
-rw-r--r--src-qt5/desktop-utils/lumina-notify/main.cpp25
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp43
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/PrintWidget.h183
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/mainUI.cpp115
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/mainUI.h45
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/mainUI.ui216
-rw-r--r--src-qt5/desktop-utils/lumina-textedit/syntax_rules/javascript.syntax2
10 files changed, 357 insertions, 337 deletions
diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp
index 91e233d0..714cfe45 100644
--- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp
+++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp
@@ -114,7 +114,10 @@ void Backend::startAdd(QStringList paths, bool absolutePaths){
paths[i] = paths[i].section(parent,1,-1);
if(paths[i].startsWith("/")){ paths[i].remove(0,1); }
}
- args << "-C" << parent; }
+ args << "-C" << parent;
+ }else{
+ args << "-C" << "/";
+ }
args << paths;
if(QFile::exists(filepath)){ //append to existing
args.replaceInStrings(filepath, tmpfilepath);
diff --git a/src-qt5/desktop-utils/lumina-notify/README.md b/src-qt5/desktop-utils/lumina-notify/README.md
deleted file mode 100644
index 4772a743..00000000
--- a/src-qt5/desktop-utils/lumina-notify/README.md
+++ /dev/null
@@ -1,41 +0,0 @@
-### lumina-notify
-
-This is a simple application for launching QDialogs from shell.
-
-Use:
-
-lumina-notify arg1 arg2 arg3 arg4
-
-* arg1 = Message Text
-* arg2 = Button Text (Accept Role)
-* arg3 = Button Text (Reject Role)
-* arg4 = Window Title
-
-For multiple word arguments encapsulate them with "s
-
-***
-Example usage in shell script
-
-~~~~
-#!/bin/csh
-set a=`./lumina-notify "Did Jar Jar do anything wrong?" Yes No "Question"`
-if ($a == 1) then
-set b=`./lumina-notify "Are you sure?" Yes No "Are you Sure?"`
-if ($b == 1) then
-./lumina-notify "Please stop being a hater." Ok Ok "Haters gunna hate"
-else
-set c=`./lumina-notify "Thank you for changing your mind" OK OK "You're Awesome"`
-endif
-else
-./lumina-notify "High Five for Darth Jar Jar" Sure OK "Respect"
-endif`
-~~~~
-
-***
-
-### Library Dependencies
-
-1. Qt 5.0+ (specific modules listed below)
- * core
- * gui
- * widgets
diff --git a/src-qt5/desktop-utils/lumina-notify/lumina-notify.pro b/src-qt5/desktop-utils/lumina-notify/lumina-notify.pro
deleted file mode 100644
index 7aa09583..00000000
--- a/src-qt5/desktop-utils/lumina-notify/lumina-notify.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-#-------------------------------------------------
-# Created by q5sys
-# Released under MIT License 2017-03-08
-#-------------------------------------------------
-include($${PWD}/../../OS-detect.pri)
-
-QT += core gui
-
-greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
-
-TARGET = lumina-notify
-target.path = $${L_BINDIR}
-TEMPLATE = app
-
-DEFINES += QT_DEPRECATED_WARNINGS
-
-SOURCES += main.cpp
-
-INSTALLS += target desktop
diff --git a/src-qt5/desktop-utils/lumina-notify/main.cpp b/src-qt5/desktop-utils/lumina-notify/main.cpp
deleted file mode 100644
index 23f30b95..00000000
--- a/src-qt5/desktop-utils/lumina-notify/main.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//-------------------------------------------------
-// Created by q5sys (JT)
-// Released under MIT License 2017-03-08
-// A Simple GUI Dialog Program
-//-------------------------------------------------
-
-#include <QApplication>
-#include <QMessageBox>
-#include <QDebug>
-#include <QTextStream>
-
-int main(int argc, char *argv[])
-{
- QApplication a(argc, argv);
- a.setAttribute(Qt::AA_UseHighDpiPixmaps);
- int answer;
- QMessageBox *messageBox = new QMessageBox;
- messageBox->setText(argv[1]);
- QPushButton *pushButtonOk = messageBox->addButton(argv[2], QMessageBox::AcceptRole);
- QPushButton *pushButtonNo = messageBox->addButton(argv[3], QMessageBox::RejectRole);
- messageBox->QDialog::setWindowTitle(argv[4]);
- messageBox->show();
- if(messageBox->exec() == QMessageBox::AcceptRole){ answer = 0; QTextStream cout(stdout); cout << answer;}
- else { answer = 1; QTextStream cout(stdout); cout << answer;}
-}
diff --git a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp
index be00e675..d2f2cd46 100644
--- a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp
+++ b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp
@@ -1,6 +1,6 @@
#include "PrintWidget.h"
-PrintWidget::PrintWidget(QWidget *parent) : QGraphicsView(parent), scene(0), curPage(1),
+PrintWidget::PrintWidget(QWidget *parent) : QGraphicsView(parent), scene(0), curPage(1),
viewMode(SinglePageView), zoomMode(FitInView), zoomFactor(1), initialized(false), fitting(true) {
this->setMouseTracking(true);
@@ -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) {
@@ -101,9 +103,11 @@ 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;
curPage = pageNumber;
@@ -132,8 +136,9 @@ void PrintWidget::generatePreview() {
populateScene(); // i.e. setPreviewPrintedPictures() e.l.
layoutPages();
curPage = qBound(1, curPage, pages.count());
- if (fitting)
- fit();
+ publicPageNum = curPage;
+ emit currentPageChanged();
+ if (fitting){ fit(); }
}
void PrintWidget::layoutPages() {
@@ -145,22 +150,22 @@ void PrintWidget::layoutPages() {
int cols = 1; // singleMode and default
if (viewMode == AllPagesView) {
cols = ((pictures->value(0)).width() > (pictures->value(0)).height()) ? qFloor(qSqrt(numPages)) : qCeil(qSqrt(numPages));
- cols += cols % 2; // Nicer with an even number of cols
- } else if (viewMode == FacingPagesView) {
+ cols += cols % 2; // Nicer with an even number of cols
+ } else if (viewMode == FacingPagesView) {
cols = 2;
- numPagePlaces += 1;
- }
+ numPagePlaces += 1;
+ }
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++) {
+ 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++;
+ continue;
+ } else {
+ pages.at(pageNum-1)->setPos(QPointF(j*itemWidth, i*itemHeight));
+ pageNum++;
}
}
}
@@ -180,7 +185,7 @@ void PrintWidget::populateScene()
qDebug() << "Image paperSize" << paperSize;
for (int i = 0; i < numPages; i++) {
- PageItem* item = new PageItem(i+1, (*pictures)[i], paperSize);
+ PageItem* item = new PageItem(i+1, (*pictures)[i].scaled( paperSize, Qt::KeepAspectRatio, Qt::SmoothTransformation), paperSize);
scene->addItem(item);
pages.append(item);
}
@@ -194,6 +199,8 @@ void PrintWidget::updateCurrentPage() {
int newPage = calcCurrentPage();
if (newPage != curPage) {
curPage = newPage;
+ publicPageNum = curPage;
+ emit currentPageChanged();
}
}
@@ -272,7 +279,7 @@ void PrintWidget::fit(bool doFitting) {
void PrintWidget::setPictures(QHash<int, QImage> *hash) {
pictures = hash;
-}
+}
void PrintWidget::setOrientation(QPageLayout::Orientation ori) {
this->orientation = ori;
diff --git a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h
index 62543e45..0bc2dbac 100644
--- a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h
+++ b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h
@@ -20,26 +20,62 @@
#include <QtMath>
#include <QPageLayout>
-namespace {
-class PageItem : public QGraphicsItem
-{
+class PageItem : public QGraphicsItem {
public:
- PageItem(int _pageNum, const QImage _pagePicture, QSize _paperSize)
- : pageNum(_pageNum), pagePicture(_pagePicture),
- paperSize(_paperSize)
- {
- brect = QRectF(QPointF(-25, -25),
- QSizeF(paperSize)+QSizeF(50, 50));
- setCacheMode(DeviceCoordinateCache);
- }
-
- QRectF boundingRect() const Q_DECL_OVERRIDE
- { return brect; }
-
- inline int pageNumber() const
- { return pageNum; }
+ PageItem(int _pageNum, const QImage _pagePicture, QSize _paperSize)
+ : pageNum(_pageNum), pagePicture(_pagePicture), paperSize(_paperSize)
+ {
+ brect = QRectF(QPointF(-25, -25),
+ QSizeF(paperSize)+QSizeF(50, 50));
+ setCacheMode(DeviceCoordinateCache);
+ }
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget) Q_DECL_OVERRIDE;
+ QRectF boundingRect() const Q_DECL_OVERRIDE
+ { return brect; }
+
+ inline int pageNumber() const
+ { return pageNum; }
+
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE
+ {
+ Q_UNUSED(widget);
+ //Ensure all the antialiasing/smoothing options are turned on
+ painter->setRenderHint(QPainter::Antialiasing);
+ painter->setRenderHint(QPainter::TextAntialiasing);
+ painter->setRenderHint(QPainter::SmoothPixmapTransform);
+
+ QRectF paperRect(0,0, paperSize.width(), paperSize.height());
+
+ // Draw shadow
+ painter->setClipRect(option->exposedRect);
+ qreal shWidth = paperRect.width()/100;
+ QRectF rshadow(paperRect.topRight() + QPointF(0, shWidth),
+ paperRect.bottomRight() + QPointF(shWidth, 0));
+ QLinearGradient rgrad(rshadow.topLeft(), rshadow.topRight());
+ rgrad.setColorAt(0.0, QColor(0,0,0,255));
+ rgrad.setColorAt(1.0, QColor(0,0,0,0));
+ painter->fillRect(rshadow, QBrush(rgrad));
+ QRectF bshadow(paperRect.bottomLeft() + QPointF(shWidth, 0),
+ paperRect.bottomRight() + QPointF(0, shWidth));
+ QLinearGradient bgrad(bshadow.topLeft(), bshadow.bottomLeft());
+ bgrad.setColorAt(0.0, QColor(0,0,0,255));
+ bgrad.setColorAt(1.0, QColor(0,0,0,0));
+ painter->fillRect(bshadow, QBrush(bgrad));
+ QRectF cshadow(paperRect.bottomRight(),
+ paperRect.bottomRight() + QPointF(shWidth, shWidth));
+ QRadialGradient cgrad(cshadow.topLeft(), shWidth, cshadow.topLeft());
+ cgrad.setColorAt(0.0, QColor(0,0,0,255));
+ cgrad.setColorAt(1.0, QColor(0,0,0,0));
+ painter->fillRect(cshadow, QBrush(cgrad));
+
+ painter->setClipRect(paperRect & option->exposedRect);
+ painter->fillRect(paperRect, Qt::white);
+ if (pagePicture.isNull()){
+ qDebug() << "NULL";
+ return;
+ }
+ painter->drawImage(QPoint(0,0), pagePicture);
+ }
private:
int pageNum;
@@ -48,49 +84,11 @@ private:
QRectF brect;
};
-void PageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
-{
- Q_UNUSED(widget);
- QRectF paperRect(0,0, paperSize.width(), paperSize.height());
-
- // Draw shadow
- painter->setClipRect(option->exposedRect);
- qreal shWidth = paperRect.width()/100;
- QRectF rshadow(paperRect.topRight() + QPointF(0, shWidth),
- paperRect.bottomRight() + QPointF(shWidth, 0));
- QLinearGradient rgrad(rshadow.topLeft(), rshadow.topRight());
- rgrad.setColorAt(0.0, QColor(0,0,0,255));
- rgrad.setColorAt(1.0, QColor(0,0,0,0));
- painter->fillRect(rshadow, QBrush(rgrad));
- QRectF bshadow(paperRect.bottomLeft() + QPointF(shWidth, 0),
- paperRect.bottomRight() + QPointF(0, shWidth));
- QLinearGradient bgrad(bshadow.topLeft(), bshadow.bottomLeft());
- bgrad.setColorAt(0.0, QColor(0,0,0,255));
- bgrad.setColorAt(1.0, QColor(0,0,0,0));
- painter->fillRect(bshadow, QBrush(bgrad));
- QRectF cshadow(paperRect.bottomRight(),
- paperRect.bottomRight() + QPointF(shWidth, shWidth));
- QRadialGradient cgrad(cshadow.topLeft(), shWidth, cshadow.topLeft());
- cgrad.setColorAt(0.0, QColor(0,0,0,255));
- cgrad.setColorAt(1.0, QColor(0,0,0,0));
- painter->fillRect(cshadow, QBrush(cgrad));
-
- painter->setClipRect(paperRect & option->exposedRect);
- painter->fillRect(paperRect, Qt::white);
- if (pagePicture.isNull()){
- qDebug() << "NULL";
- return;
- }
- painter->drawImage(QPoint(0,0), pagePicture);
-}
-}
class PrintWidget : public QGraphicsView
{
Q_OBJECT
public:
- PrintWidget(QWidget *parent = 0);
- ~PrintWidget();
enum ViewMode {
SinglePageView,
FacingPagesView,
@@ -103,33 +101,58 @@ public:
FitInView
};
- double getZoomFactor() const { return this->zoomFactor; };
- ZoomMode getZoomMode() const { return this->zoomMode; };
- int currentPage() const { return curPage; };
- void setPictures(QHash<int, QImage>*);
+private:
+ void generatePreview();
+ void layoutPages();
+ void populateScene();
+ void setViewMode(ViewMode);
+ void setZoomMode(ZoomMode);
+
+ QGraphicsScene *scene;
+
+ int curPage, publicPageNum;
+ ViewMode viewMode;
+ ZoomMode zoomMode;
+ QPageLayout::Orientation orientation;
+ double zoomFactor;
+ bool initialized, fitting;
+ QList<QGraphicsItem*> pages;
+ QHash<int, QImage> *pictures;
+
+public:
+ PrintWidget(QWidget *parent = 0);
+ ~PrintWidget();
+
+ double getZoomFactor() const { return this->zoomFactor; };
+ ZoomMode getZoomMode() const { return this->zoomMode; };
+ int currentPage() const { return publicPageNum; };
+ void setPictures(QHash<int, QImage>*);
signals:
void resized();
void customContextMenuRequested(const QPoint&);
+ void currentPageChanged();
+
public slots:
void zoomIn(double factor=1.2);
- void zoomOut(double factor=1.2);
- void setCurrentPage(int);
- void setVisible(bool) Q_DECL_OVERRIDE;
- void setOrientation(QPageLayout::Orientation);
- void highlightText(int, QRectF);
+ void zoomOut(double factor=1.2);
+ void setCurrentPage(int);
+ void setVisible(bool) Q_DECL_OVERRIDE;
+ void setOrientation(QPageLayout::Orientation);
+ void highlightText(int, QRectF);
- void updatePreview();
+ void updatePreview();
void fitView();
- void fitToWidth();
- void setAllPagesViewMode();
- void setSinglePageViewMode();
- void setFacingPagesViewMode();
+ void fitToWidth();
+ void setAllPagesViewMode();
+ void setSinglePageViewMode();
+ void setFacingPagesViewMode();
private slots:
void updateCurrentPage();
- int calcCurrentPage();
- void fit(bool doFitting=false);
+ int calcCurrentPage();
+ void fit(bool doFitting=false);
+
protected:
void resizeEvent(QResizeEvent* e) Q_DECL_OVERRIDE {
/*{
@@ -144,21 +167,5 @@ protected:
QGraphicsView::showEvent(e);
emit resized();
}
-private:
- void generatePreview();
- void layoutPages();
- void populateScene();
- void setViewMode(ViewMode);
- void setZoomMode(ZoomMode);
- QGraphicsScene *scene;
-
- int curPage;
- ViewMode viewMode;
- ZoomMode zoomMode;
- QPageLayout::Orientation orientation;
- double zoomFactor;
- bool initialized, fitting;
- QList<QGraphicsItem*> pages;
- QHash<int, QImage> *pictures;
};
#endif
diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp
index 57afbfe1..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);
@@ -106,7 +115,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){
connect(ui->actionNext_Page, SIGNAL(triggered()), this, SLOT(nextPage()) );
connect(ui->actionLast_Page, SIGNAL(triggered()), this, SLOT(lastPage()) );
connect(ui->actionProperties, SIGNAL(triggered()), this, SLOT(showInformation()));
- connect(ui->actionFind, SIGNAL(triggered()), this, SLOT(enableFind()));
+ connect(ui->actionFind, SIGNAL(triggered()), this, SLOT(enableFind()));
connect(ui->actionFind_Next, &QAction::triggered, this,
[&] { find(ui->textEdit->text(), true); });
connect(ui->actionFind_Previous, &QAction::triggered, 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){
@@ -244,20 +252,12 @@ void MainUI::loadFile(QString path){
}
void MainUI::loadPage(int num, Poppler::Document *doc, MainUI *obj, QSize dpi, QSizeF page){
- //PERFORMANCE NOTES:
- // Using Poppler to scale the image (adjust dpi value) helps a bit but you take a large 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)
-
//qDebug() << " - Render Page:" << num;
Poppler::Page *PAGE = doc->page(num);
if(PAGE!=0){
- //qDebug() << "DPI:" << dpi << "Size:" << page << "Page Size (pt):" << PAGE->pageSize();
- float scalefactor = (dpi.width()/72.0); //How different the screen DPI compares to standard page DPI
- //qDebug() << "Scale Factor:" << scalefactor;
- QImage raw = PAGE->renderToImage((scalefactor+0.2)*dpi.width(), (scalefactor+0.2)*dpi.height()); //make the raw image a tiny bit larger than the end result
+ QImage raw = PAGE->renderToImage(dpi.width(),dpi.height()); //make the raw image a bit larger than the end result
//qDebug() << " - Raw Image Size:" << raw.size();
- loadingHash.insert(num, raw.scaled(scalefactor*page.width(), scalefactor*page.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation) );
+ loadingHash.insert(num, raw.scaled(page.width(), page.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation) );
raw = QImage(); //clear it
/*
QList<Annotation*> anno = PAGE->annotations(Annotations::AText );
@@ -311,8 +311,8 @@ 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;
- if(!atStart){ page = WIDGET->currentPage()-1; } //currentPage() starts at 1 rather than 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
if(presentationLabel == 0){
@@ -332,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();
@@ -343,16 +344,18 @@ void MainUI::startPresentation(bool atStart){
void MainUI::ShowPage(int page){
//Check for valid document/page
//qDebug() << "Load Page:" << page << "/" << numPages << "Index:" << page;
- if(page<0 || page > numPages || (page==numPages && CurrentPage==page) ){
+ if(page<0 || page > numPages+1 || (page==numPages && CurrentPage==page) ){
endPresentation();
return; //invalid - no document loaded or invalid page specified
}
WIDGET->setCurrentPage(page); //page numbers start at 1 for this widget
//Stop here if no presentation currently running
+
if(presentationLabel == 0 || !presentationLabel->isVisible()){ return; }
+ //qDebug() << "Show Page:" << page << "/" << numPages;
CurrentPage = page;
QImage PAGEIMAGE;
- if(page<numPages){ PAGEIMAGE = loadingHash[page]; }
+ if(page<numPages+1){ PAGEIMAGE = loadingHash[page-1]; }
//Now scale the image according to the user-designations and show it
if(!PAGEIMAGE.isNull()){
@@ -375,25 +378,37 @@ void MainUI::endPresentation(){
clockTimer->stop();
clockAct->setVisible(false);
this->releaseKeyboard();
+ updatePageNumber();
}
void MainUI::startLoadingPages(){
if(numPages>0){ return; } //currently loaded[ing]
- qDebug() << " - Start Loading Pages";
+ //qDebug() << " - Start Loading Pages";
+ loadingHash.clear();
numPages = DOC->numPages();
//qDebug() << "numPages:" << numPages;
progress->setRange(0,numPages);
progress->setValue(0);
progAct->setVisible(true);
- QSizeF pageSize = DOC->page(0)->pageSizeF()*2;
+ 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.5;
+ QSizeF pageSize = DOC->page(0)->pageSizeF()*scalefactor;
//QSize DPI(loadingHash[0]->resolution(),loadingHash[0]->resolution());
- QSize DPI(76,76);
+ //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();
for(int i=0; i<screens.length(); i++){
qDebug() << screens[i]->name() << screens[i]->logicalDotsPerInchX() << screens[i]->logicalDotsPerInchY();
}*/
- qDebug() << "Poppler pageSize: " << pageSize;
+ //qDebug() << "Poppler pageSize: " << pageSize;
for(int i=0; i<numPages; i++){
//qDebug() << " - Kickoff page load:" << i;
QtConcurrent::run(this, &MainUI::loadPage, i, DOC, this, DPI, pageSize);
@@ -404,25 +419,23 @@ void MainUI::slotPageLoaded(int page){
Q_UNUSED(page);
//qDebug() << "Page Loaded:" << page;
int finished = loadingHash.keys().length();
+ //qDebug() << " - finished:" << finished;
if(finished == numPages){
progAct->setVisible(false);
- qDebug() << "Setting Pictures";
+ //qDebug() << "Setting Pictures";
WIDGET->setPictures(&loadingHash);
WIDGET->setVisible(true);
- //QTimer::singleShot(10, WIDGET, SLOT(updatePreview()));
+ QTimer::singleShot(10, WIDGET, SLOT(updatePreview()));
//qDebug() << "Updating";
ui->actionStop_Presentation->setEnabled(false);
ui->actionStart_Here->setEnabled(true);
ui->actionStart_Begin->setEnabled(true);
+ pageAct->setVisible(true);
}else{
progress->setValue(finished);
}
}
-/*void MainUI::slotStartPresentation(QAction *act){
- startPresentation(act == ui->actionAt_Beginning);
-}*/
-
void MainUI::paintToPrinter(QPrinter *PRINTER){
if(loadingHash.keys().length() != numPages){ return; }
@@ -430,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 ){
@@ -466,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
@@ -493,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);
@@ -512,7 +545,7 @@ void MainUI::rotate(bool ccw) {
loadingHash.insert(i, image);
}
//Rotates the page as well as the image
- //WIDGET->setOrientation((WIDGET->orientation() == QPageLayout::Landscape) ?
+ //WIDGET->setOrientation((WIDGET->orientation() == QPageLayout::Landscape) ?
//QPageLayout::Portrait : QPageLayout::Landscape);
QTimer::singleShot(0, WIDGET, SLOT(updatePreview()));
}
@@ -553,7 +586,7 @@ void MainUI::keyPressEvent(QKeyEvent *event){
if(inPresentation){ endPresentation(); }
else{ startPresentationHere(); }
}else if(event->key() == Qt::Key_Up) {
- //Scroll the widget up
+ //Scroll the widget up
}else if(event->key() == Qt::Key_Down) {
//Scroll the widget down
/*qDebug() << "Send Wheel Event";
@@ -589,7 +622,7 @@ void MainUI::find(QString text, bool forward) {
for(int i = 0; i < numPages; i++) {
QList<Poppler::TextBox*> textList = DOC->page(i)->textList();
for(int j = 0; j < textList.size(); j++) {
- if(textList[j]->text().contains(text, (matchCase)
+ if(textList[j]->text().contains(text, (matchCase)
? Qt::CaseSensitive : Qt::CaseInsensitive)) {
results.insert(textList[j], i);
}
@@ -606,7 +639,7 @@ void MainUI::find(QString text, bool forward) {
}else{
currentHighlight--;
//Ensure currentHighlight will be between 0 and results.size() - 1
- if(currentHighlight < 0)
+ if(currentHighlight < 0)
currentHighlight = results.size() - 1;
}
@@ -618,7 +651,7 @@ void MainUI::find(QString text, bool forward) {
QTimer::singleShot(10, WIDGET, SLOT(updatePreview()));
}else{
- //Print "No results found"
+ //Print "No results found"
}
}
}
@@ -626,17 +659,17 @@ void MainUI::find(QString text, bool forward) {
void MainUI::enableFind() {
if(ui->findGroup->isVisible()) {
qDebug() << "Disabling Find";
- ui->findGroup->setVisible(false);
- WIDGET->setGeometry(QRect(WIDGET->pos(),
+ ui->findGroup->setVisible(false);
+ WIDGET->setGeometry(QRect(WIDGET->pos(),
QSize(WIDGET->width(), WIDGET->height()+ui->findGroup->height())));
QTimer::singleShot(0, WIDGET, SLOT(updatePreview()));
this->setFocus();
}else{
qDebug() << "Enabling Find";
- ui->findGroup->setGeometry(QRect(QPoint(0, WIDGET->height()-ui->findGroup->height()),
+ ui->findGroup->setGeometry(QRect(QPoint(0, WIDGET->height()-ui->findGroup->height()),
QSize(WIDGET->width()-12, ui->findGroup->height())));
- ui->findGroup->setVisible(true);
- WIDGET->setGeometry(QRect(WIDGET->pos(),
+ ui->findGroup->setVisible(true);
+ WIDGET->setGeometry(QRect(WIDGET->pos(),
QSize(WIDGET->width(), WIDGET->height()-ui->findGroup->height())));
QTimer::singleShot(0, WIDGET, SLOT(updatePreview()));
@@ -650,7 +683,7 @@ void MainUI::showBookmarks() {
void MainUI::resizeEvent(QResizeEvent *event) {
if(ui->findGroup->isVisible()) {
- ui->findGroup->setGeometry(QRect(QPoint(0, WIDGET->height()-ui->findGroup->height()),
+ ui->findGroup->setGeometry(QRect(QPoint(0, WIDGET->height()-ui->findGroup->height()),
QSize(WIDGET->width()-10, ui->findGroup->height())));
}
QMainWindow::resizeEvent(event);
diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.h b/src-qt5/desktop-utils/lumina-pdf/mainUI.h
index 2d23b402..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;
@@ -73,21 +73,20 @@ private:
private slots:
void startLoadingPages();
void slotPageLoaded(int);
- //void slotStartPresentation(QAction *act);
//Simplification routines
- void nextPage(){ ShowPage( WIDGET->currentPage() ); } //currentPage() starts at 1 rather than 0
- void prevPage(){ ShowPage( WIDGET->currentPage()-2 ); } //currentPage() starts at 1 rather than 0
- void firstPage(){ ShowPage(0); }
- void lastPage(){ ShowPage(numPages-1); }
+ void nextPage(){ ShowPage( WIDGET->currentPage()+1 ); } //currentPage() starts at 1 rather than 0
+ void prevPage(){ ShowPage( WIDGET->currentPage()-1 ); } //currentPage() starts at 1 rather than 0
+ void firstPage(){ ShowPage(1); }
+ void lastPage(){ ShowPage(numPages); }
void startPresentationHere(){ startPresentation(false); }
void startPresentationBeginning(){ startPresentation(true); }
void closePresentation(){ endPresentation(); }
- void showInformation();
- void find(QString text, bool forward);
- void enableFind();
- void showBookmarks();
+ void showInformation();
+ void find(QString text, bool forward);
+ void enableFind();
+ void showBookmarks();
void paintToPrinter(QPrinter *PRINTER);
@@ -96,18 +95,24 @@ 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);
+ void setScroll(bool);
+ void rotate(bool);
+
signals:
void PageLoaded(int);
protected:
- void keyPressEvent(QKeyEvent*);
- void wheelEvent(QWheelEvent*);
- void resizeEvent(QResizeEvent*);
+ 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">
diff --git a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/javascript.syntax b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/javascript.syntax
index 02e1092a..a5ddee9d 100644
--- a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/javascript.syntax
+++ b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/javascript.syntax
@@ -8,7 +8,7 @@
{
"meta": {
"name": "Javascript",
- "file_suffix": ["js"]
+ "file_suffix": ["js", "qml"]
},
"format": {
"line_wrap": false,
bgstack15