diff options
Diffstat (limited to 'src-qt5')
19 files changed, 452 insertions, 379 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/defaults/desktop/panels.conf b/src-qt5/core/lumina-desktop-unified/defaults/desktop/panels.conf index 07cf4635..f0cdc5a4 100644 --- a/src-qt5/core/lumina-desktop-unified/defaults/desktop/panels.conf +++ b/src-qt5/core/lumina-desktop-unified/defaults/desktop/panels.conf @@ -4,8 +4,9 @@ windows/anchor="bottom" windows/align="center" windows/length_percent=100 +windows/width_percent=3 windows/plugins="" -windows/background="rgba(0,0,0,120)" +windows/background="#1A000000" [default] active_ids="initial" @@ -18,4 +19,4 @@ align="center" length_percent=100 width_percent=2.1 plugins="" -background="rgba(0,0,0,120)" +background="#33000000" diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.cpp index bfded781..ad2bc445 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.cpp @@ -153,19 +153,32 @@ void DesktopManager::updateDesktopSettings(){ void DesktopManager::updatePanelSettings(){ QList<QScreen*> scrns = QGuiApplication::screens(); int primary = QApplication::desktop()->primaryScreen(); + qDebug() << "Panel Settings Changed:" << primary << scrns.length(); + QStringList total_ids; for(int i=0; i<scrns.length(); i++){ + //qDebug() << " - Check Screen Name:" << scrns[i]->name(); ScreenObject *sObj = RootDesktopObject::instance()->screen(scrns[i]->name()); if(sObj == 0){ continue; } //screen is not managed directly - skip it QStringList ids = DesktopSettings::instance()->value(DesktopSettings::Panels, scrns[i]->name().replace("-","_")+"/active_ids", QStringList()).toStringList(); if(ids.isEmpty() && (scrns.length()==1 || i==primary)){ + //qDebug() << " -- PRIMARY"; //Also look for the "default" panel id's for the primary/default screen ids = DesktopSettings::instance()->value(DesktopSettings::Panels, "default/active_ids", QStringList()).toStringList(); } - sObj->setPanels(ids); + ids.removeAll(""); + //qDebug() << " -- settings:" << ids; + for(int j=0; j<ids.length(); j++){ + total_ids << scrns[i]->name()+"/"+ids[j]; + } } //Now do the global-session panels QStringList ids = DesktopSettings::instance()->value(DesktopSettings::Panels, "session/active_ids", QStringList()).toStringList(); - RootDesktopObject::instance()->setPanels(ids); //put the new ones in place + ids.removeAll(""); + for(int i=0; i<ids.length(); i++){ + total_ids << "session/"+ids[i]; + } + //qDebug() << "Panel Settings Changed:" << total_ids; + RootDesktopObject::instance()->setPanels(total_ids); //put the new ones in place } void DesktopManager::updatePluginSettings(){ diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp index 9bb78dd0..e2cac852 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp @@ -242,6 +242,10 @@ bool NativeWindowObject::isSticky(){ return (this->property(NativeWindowObject::Workspace).toInt()<0 || this->property(NativeWindowObject::States).value<QList<NativeWindowObject::State> >().contains(NativeWindowObject::S_STICKY) ); } +bool NativeWindowObject::isVisible(){ + return (this->property(NativeWindowObject::Visible).toBool() ); +} + int NativeWindowObject::workspace(){ return this->property(NativeWindowObject::Workspace).toInt(); } @@ -262,14 +266,13 @@ void NativeWindowObject::updateGeometry(int x, int y, int width, int height, boo if(fgeom.isEmpty()){ fgeom << 0<<0<<0<<0; } //just in case (left/right/top/bottom) QPoint pos(x+fgeom[0], y+fgeom[2]); QSize sz(width-fgeom[0]-fgeom[1], height-fgeom[2]-fgeom[3]); + newgeom = QRect(pos, sz); if(!now){ - newgeom = QRect(pos, sz); //qDebug() << "Update Geometry:" << fgeom << QRect(x,y,width,height) << pos << sz; //requestProperties(QList<NativeWindowObject::Property>() << NativeWindowObject::GlobalPos << NativeWindowObject::Size, QList<QVariant>() << pos << sz); if(!geomTimer->isActive()){ geomTimer->start(); } }else{ - requestProperties(QList<NativeWindowObject::Property>() << NativeWindowObject::GlobalPos << NativeWindowObject::Size , QList<QVariant>() << pos << sz ); - setProperties(QList<NativeWindowObject::Property>() << NativeWindowObject::GlobalPos << NativeWindowObject::Size , QList<QVariant>() << pos << sz ); + sendNewGeom(); } } @@ -311,6 +314,8 @@ void NativeWindowObject::emitSinglePropChanged(NativeWindowObject::Property prop emit winImageChanged(); break; case NativeWindowObject::WinTypes: emit winTypeChanged(); break; + case NativeWindowObject::Visible: + emit visibilityChanged(); break; default: break; //do nothing otherwise } @@ -321,4 +326,5 @@ void NativeWindowObject::sendNewGeom(){ QList<QVariant> vals; vals << newgeom.topLeft() << newgeom.size(); requestProperties(props, vals); setProperties(props,vals); + emit VerifyNewGeometry(winid); } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.h index 6a63813e..87df1f10 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.h @@ -23,6 +23,7 @@ class NativeWindowObject : public QObject{ Q_PROPERTY( QString shortTitle READ shortTitle NOTIFY shortTitleChanged) Q_PROPERTY( QString icon READ icon NOTIFY iconChanged) Q_PROPERTY( bool sticky READ isSticky NOTIFY stickyChanged) + Q_PROPERTY(bool isVisible READ isVisible NOTIFY visibilityChanged) //Button/Titlebar visibility Q_PROPERTY( bool showCloseButton READ showCloseButton NOTIFY winTypeChanged) Q_PROPERTY( bool showMinButton READ showMinButton NOTIFY winTypeChanged) @@ -109,6 +110,7 @@ public: Q_INVOKABLE bool showWindowFrame(); //QML Window States Q_INVOKABLE bool isSticky(); + Q_INVOKABLE bool isVisible(); Q_INVOKABLE int workspace(); //QML Geometry reporting @@ -150,6 +152,7 @@ signals: void RequestKill(WId); //Kill the window/app (usually from being unresponsive) void RequestPing(WId); //Verify that the window is still active (such as not closing after a request void RequestReparent(WId, WId, QPoint); //client window, frame window, relative origin point in frame + void VerifyNewGeometry(WId); // System Tray Icon Embed/Unembed Requests //void RequestEmbed(WId, QWidget*); //void RequestUnEmbed(WId, QWidget*); @@ -163,6 +166,7 @@ signals: void stickyChanged(); void winTypeChanged(); void geomChanged(); + void visibilityChanged(); }; // Declare the enumerations as Qt MetaTypes diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp index 9054f528..a0f58e71 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp @@ -47,14 +47,15 @@ void PanelObject::setGeometry( QRect newgeom ){ void PanelObject::syncWithSettings(QRect parent_geom){ //Read off all the settings - //qDebug() << "Sync Panel Settings:" << panel_id << parent_geom; - QString anchor = DesktopSettings::instance()->value(DesktopSettings::Panels, panel_id+"/anchor", "bottom").toString().toLower(); - QString align = DesktopSettings::instance()->value(DesktopSettings::Panels, panel_id+"/align", "center").toString().toLower(); - double length = DesktopSettings::instance()->value(DesktopSettings::Panels, panel_id+"/length_percent", 100).toDouble()/100.0; - double width = DesktopSettings::instance()->value(DesktopSettings::Panels, panel_id+"/width_font_percent", 2.1).toDouble(); + QString id = panel_id.section("/",-1); //last section (allow for prefixes to distinguish multiple monitors with the same profile but different screens) + //qDebug() << "Sync Panel Settings:" << panel_id << id << parent_geom; + QString anchor = DesktopSettings::instance()->value(DesktopSettings::Panels, id+"/anchor", "bottom").toString().toLower(); + QString align = DesktopSettings::instance()->value(DesktopSettings::Panels, id+"/align", "center").toString().toLower(); + double length = DesktopSettings::instance()->value(DesktopSettings::Panels, id+"/length_percent", 100).toDouble()/100.0; + double width = DesktopSettings::instance()->value(DesktopSettings::Panels, id+"/width_font_percent", 2.1).toDouble(); width = qRound(width * QApplication::fontMetrics().height() ); - this->setBackground( DesktopSettings::instance()->value(DesktopSettings::Panels, panel_id+"/background", "rgba(0,0,0,120)").toString() ); - // qDebug() << "Update Panel:" << panel_id << anchor+"/"+align << length << width; + this->setBackground( DesktopSettings::instance()->value(DesktopSettings::Panels, id+"/background", "rgba(0,0,0,120)").toString() ); + // qDebug() << "Update Panel:" << panel_id << id << anchor+"/"+align << length << width; //Now calculate the geometry of the panel QRect newgeom; //Figure out the size of the panel @@ -79,6 +80,9 @@ void PanelObject::syncWithSettings(QRect parent_geom){ else if(anchor=="right"){ newgeom.moveTopRight(QPoint(parent_geom.width(), (parent_geom.height()-newgeom.height())/2 )); } else{ newgeom.moveBottomLeft(QPoint( (parent_geom.width()-newgeom.width())/2, parent_geom.height()) ); } } - //qDebug() << " - Calculated Geometry:" << newgeom; - this->setGeometry(newgeom); //Note: This is in parent-relative coordinates (not global) + //qDebug() << " - Calculated Geometry (relative to parent):" << newgeom; + //Note: newgeom is currently in parent-relative coordinates (not global) + newgeom.translate(parent_geom.x(), parent_geom.y()); + //qDebug() << " - Calculated Geometry (global):" << newgeom; + this->setGeometry(newgeom); //shift to global coordinates } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp index 8540f44e..254a67ac 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp @@ -95,31 +95,45 @@ void RootDesktopObject::setPanels(QStringList ids){ this->emit changePanels(ids); return; } - + //qDebug() << "GOT PANEL CHANGE:" << ids; //Get the current bounding rectangle for the session QRect total; - for(int i=0; i<s_objects.length(); i++){ - total = total.united(s_objects[i]->geometry()); - } - //First update/remove any current panel objects bool change = false; - for(int i=0; i<panel_objects.length(); i++){ - if(ids.contains(panel_objects[i]->name()) ){ - ids.removeAll(panel_objects[i]->name()); //already handled - panel_objects[i]->syncWithSettings(total); + for(int i=0; i<=s_objects.length(); i++){ + QRect geom; + QString prefix; + if(i==s_objects.length()){ + geom = total; //session geometry + prefix="session/"; }else{ - panel_objects.takeAt(i)->deleteLater(); - i--; + geom = s_objects[i]->geometry(); + total = total.united(geom); + prefix=s_objects[i]->name()+"/"; + } + QStringList newids = ids.filter(prefix); + //qDebug() << " Check Panel IDs:" << prefix << newids << ids; + //First update/remove any current panel objects + for(int i=0; i<panel_objects.length(); i++){ + if(newids.contains(panel_objects[i]->name()) ){ + //qDebug() << " - Update Existing Panel:" << panel_objects[i]->name(); + newids.removeAll(panel_objects[i]->name()); //already handled + panel_objects[i]->syncWithSettings(geom); + }else if(panel_objects[i]->name().startsWith(prefix) ){ + //qDebug() << " - Remove Existing Panel:" << panel_objects[i]->name(); + panel_objects.takeAt(i)->deleteLater(); + i--; + change = true; //list changed + } + } + //Now create any new panel objects as needed + for(int i=0; i<newids.length(); i++){ + //qDebug() << " - Create Panel:" << newids[i]; + PanelObject *tmp = new PanelObject(newids[i], this); + tmp->syncWithSettings(geom); + panel_objects << tmp; change = true; //list changed } - } - //Now create any new panel objects as needed - for(int i=0; i<ids.length(); i++){ - PanelObject *tmp = new PanelObject(ids[i], this); - tmp->syncWithSettings(total); - panel_objects << tmp; - change = true; //list changed - } + } //end loop over screens+session if(change){ emit panelsChanged(); } } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/NativeWindow.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/NativeWindow.qml index a0bd36f4..d75f2898 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/NativeWindow.qml +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/NativeWindow.qml @@ -14,10 +14,11 @@ Rectangle { SystemPalette { id:palette } id: windowFrame + visible: object.isVisible border.width: 5 border.color: palette.highlight radius: 5 - color: "transparent" //palette.window + color: palette.window //"transparent" x: object.frameGeometry.x y: object.frameGeometry.y width: object.frameGeometry.width @@ -201,6 +202,13 @@ Rectangle { anchors.bottomMargin: windowFrame.border.width width: parent.width height: parent.height + //color: palette.window + + //Image { + //anchors.fill: frameContents + //cache: false + //source: windowFrame.object.winImage + //} MouseArea { width: parent.width diff --git a/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.cpp b/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.cpp index 3d6b0f3e..28c223ab 100644 --- a/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.cpp @@ -629,9 +629,10 @@ void NativeWindowSystem::SetupNewWindow(NativeWindowObject *win){ } QImage NativeWindowSystem::GetWindowImage(NativeWindowObject* win){ - QImage img; //qDebug() << "Update Window Image:" << win->name(); QRect geom(QPoint(0,0), win->property(NativeWindowObject::Size).toSize()); + QImage img; //(geom.width(), geom.height(), QImage::Format_ARGB32); + //img.fill(QGuiApplication::palette().window()); if(DISABLE_COMPOSITING){ QList<QScreen*> screens = static_cast<QApplication*>( QApplication::instance() )->screens(); if(!screens.isEmpty()){ @@ -788,8 +789,6 @@ void NativeWindowSystem::NewWindowDetected(WId id){ win->setProperty(NativeWindowObject::FrameExtents, QVariant::fromValue<QList<int> >( QList<int>() << 5 << 5 << 30 << 5 )); } qDebug() << "New Window [& associated ID's]:" << win->id() << win->property(NativeWindowObject::Name).toString(); - SetupNewWindow(win); - CheckWindowPosition(id, true); //first time placement //Now setup the connections with this window connect(win, SIGNAL(RequestClose(WId)), this, SLOT(RequestClose(WId)) ); connect(win, SIGNAL(RequestKill(WId)), this, SLOT(RequestKill(WId)) ); @@ -797,6 +796,8 @@ void NativeWindowSystem::NewWindowDetected(WId id){ connect(win, SIGNAL(RequestReparent(WId, WId, QPoint)), this, SLOT(RequestReparent(WId, WId, QPoint)) ); connect(win, SIGNAL(RequestPropertiesChange(WId, QList<NativeWindowObject::Property>, QList<QVariant>)), this, SLOT(RequestPropertiesChange(WId, QList<NativeWindowObject::Property>, QList<QVariant>)) ); connect(win, SIGNAL(VerifyNewGeometry(WId)), this, SLOT(CheckWindowPosition(WId)) ); + SetupNewWindow(win); + CheckWindowPosition(id, true); //first time placement xcb_map_window(QX11Info::connection(), win->id()); emit NewWindowAvailable(win); } @@ -831,22 +832,22 @@ void NativeWindowSystem::NewTrayWindowDetected(WId id){ void NativeWindowSystem::WindowCloseDetected(WId id){ NativeWindowObject *win = findWindow(id, false); + if(win==0){ win = findWindow(id, true); } //qDebug() << "Got Window Closed" << id << win; //qDebug() << "Old Window List:" << NWindows.length(); if(win!=0){ NWindows.removeAll(win); - //RequestReparent(id, QX11Info::appRootWindow(), QPoint(0,0)); win->emit WindowClosed(id); //qDebug() << "Visible Window Closed!!!"; - //win->deleteLater(); emit WindowClosed(); + win->deleteLater(); }else{ win = findTrayWindow(id); if(win!=0){ TWindows.removeAll(win); win->emit WindowClosed(id); - win->deleteLater(); emit TrayWindowClosed(); + win->deleteLater(); } } //qDebug() << " - Now:" << NWindows.length(); diff --git a/src-qt5/core/lumina-desktop/LSession.cpp b/src-qt5/core/lumina-desktop/LSession.cpp index dab30f01..111a17b6 100644 --- a/src-qt5/core/lumina-desktop/LSession.cpp +++ b/src-qt5/core/lumina-desktop/LSession.cpp @@ -346,6 +346,8 @@ void LSession::watcherChange(QString changed){ //qDebug() << "Set Qt5 theme engine: " << engine; if(engine.isEmpty()){ unsetenv("QT_QPA_PLATFORMTHEME"); } else{ setenv("QT_QPA_PLATFORMTHEME", engine.toUtf8().data(),1); } + }else{ + setenv("QT_QPA_PLATFORMTHEME", "lthemeengine",1); //ensure the lumina theme engine is always enabled } emit SessionConfigChanged(); }else if(changed.endsWith("desktopsettings.conf") ){ emit DesktopConfigChanged(); } 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, |