aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-pdf
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-11-27 15:46:57 -0500
committerKen Moore <ken@ixsystems.com>2017-11-27 15:46:57 -0500
commitc1c4f85bf10d090c96a935050582ac05e2dce414 (patch)
tree83d0c57379534d2aaa7801108b0c43068dfb40bc /src-qt5/desktop-utils/lumina-pdf
parentMerge branch 'master' of github.com:trueos/lumina (diff)
downloadlumina-c1c4f85bf10d090c96a935050582ac05e2dce414.tar.gz
lumina-c1c4f85bf10d090c96a935050582ac05e2dce414.tar.bz2
lumina-c1c4f85bf10d090c96a935050582ac05e2dce414.zip
Some UI improvements for lumina-pdf:
1. Add a context menu of options. 2. Use the context menu for both the presentation label and normal viewer 3. Get things ready for better integration of keyboard shortcuts application-wide.
Diffstat (limited to 'src-qt5/desktop-utils/lumina-pdf')
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/CM_PrintPreviewWidget.h34
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/PresentationLabel.h35
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro4
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/mainUI.cpp35
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/mainUI.h30
5 files changed, 127 insertions, 11 deletions
diff --git a/src-qt5/desktop-utils/lumina-pdf/CM_PrintPreviewWidget.h b/src-qt5/desktop-utils/lumina-pdf/CM_PrintPreviewWidget.h
new file mode 100644
index 00000000..ac457a10
--- /dev/null
+++ b/src-qt5/desktop-utils/lumina-pdf/CM_PrintPreviewWidget.h
@@ -0,0 +1,34 @@
+//===========================================
+// Lumina Desktop source code
+// Copyright (c) 2017, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+// Simple subclass of QPrintPreviewWidget to provide
+// notification when a context menu is requested
+//===========================================
+#ifndef _CONTEXT_MENU_PRINT_PREVIEW_WIDGET_H
+#define _CONTEXT_MENU_PRINT_PREVIEW_WIDGET_H
+
+#include <QPrintPreviewWidget>
+#include <QMouseEvent>
+#include <QDebug>
+
+class CM_PrintPreviewWidget : public QPrintPreviewWidget{
+ Q_OBJECT
+signals:
+ void customContextMenuRequested(const QPoint&);
+
+public:
+ CM_PrintPreviewWidget(QPrinter * printer = 0, QWidget *parent = 0) : QPrintPreviewWidget(printer, parent){
+ this->setMouseTracking(true);
+ QList<QWidget*> children = this->findChildren<QWidget*>("",Qt::FindChildrenRecursively);
+ for(int i=0; i<children.length(); i++){
+ children[i]->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(children[i], SIGNAL(customContextMenuRequested(const QPoint&)), this, SIGNAL(customContextMenuRequested(const QPoint&)) );
+ }
+ }
+
+};
+
+#endif
diff --git a/src-qt5/desktop-utils/lumina-pdf/PresentationLabel.h b/src-qt5/desktop-utils/lumina-pdf/PresentationLabel.h
new file mode 100644
index 00000000..c5b552a6
--- /dev/null
+++ b/src-qt5/desktop-utils/lumina-pdf/PresentationLabel.h
@@ -0,0 +1,35 @@
+//===========================================
+// Lumina Desktop source code
+// Copyright (c) 2017, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+// Simple subclass of QLabel to provide
+// some overlay information as a presentation window
+//===========================================
+#ifndef _PRESENTATION_LABEL_WIDGET_H
+#define _PRESENTATION_LABEL_WIDGET_H
+
+#include <QLabel>
+#include <QMouseEvent>
+#include <QDebug>
+
+class PresentationLabel : public QLabel{
+ Q_OBJECT
+
+signals:
+ void nextSlide();
+
+public:
+ PresentationLabel() : QLabel(0, Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint){
+ this->setContextMenuPolicy(Qt::CustomContextMenu);
+ }
+
+protected:
+ void mousePressEvent(QMouseEvent *ev){
+ QLabel::mousePressEvent(ev);
+ if(ev->button()==Qt::LeftButton){ emit nextSlide(); }
+ }
+};
+
+#endif
diff --git a/src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro b/src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro
index e17e59c5..dc368051 100644
--- a/src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro
+++ b/src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro
@@ -20,7 +20,9 @@ message("Qt Modules Needed: $${QT}")
SOURCES += main.cpp \
mainUI.cpp
-HEADERS += mainUI.h
+HEADERS += mainUI.h \
+ CM_PrintPreviewWidget.h \
+ PresentationLabel.h
FORMS += mainUI.ui
diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp
index 7a310e85..7ad42697 100644
--- a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp
+++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp
@@ -20,6 +20,7 @@
#include <QtConcurrent>
#include <LuminaXDG.h>
+#include "CM_PrintPreviewWidget.h"
MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){
ui->setupUi(this);
@@ -30,7 +31,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){
lastdir = QDir::homePath();
Printer = new QPrinter();
//Create the interface widgets
- WIDGET = new QPrintPreviewWidget(Printer,this);
+ WIDGET = new CM_PrintPreviewWidget(Printer,this);
clockTimer = new QTimer(this);
clockTimer->setInterval(1000); //1-second updates to clock
connect(clockTimer, SIGNAL(timeout()), this, SLOT(updateClock()) );
@@ -39,8 +40,13 @@ 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; }");
+ //Context Menu
+ contextMenu = new QMenu(this);
+ connect(contextMenu, SIGNAL(aboutToShow()), this, SLOT(updateContextMenu()));
//Now put the widgets into the UI
this->setCentralWidget(WIDGET);
+ WIDGET->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(WIDGET, SIGNAL(customContextMenuRequested(const QPoint&)),this, SLOT(showContextMenu(const QPoint&)) );
connect(WIDGET, SIGNAL(paintRequested(QPrinter*)), this, SLOT(paintOnWidget(QPrinter*)) );
DOC = 0;
connect(this, SIGNAL(PageLoaded(int)), this, SLOT(slotPageLoaded(int)) );
@@ -153,7 +159,7 @@ void MainUI::loadPage(int num, Poppler::Document *doc, MainUI *obj, QSize dpi, Q
Poppler::Page *PAGE = doc->page(num);
if(PAGE!=0){
//qDebug() << "DPI:" << 4*dpi;
- loadingHash.insert(num, PAGE->renderToImage(2.5*dpi.width(), 2.5*dpi.height()).scaled(2*page.width(), 2*page.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation) );
+ loadingHash.insert(num, PAGE->renderToImage(4*dpi.width(), 4*dpi.height()).scaled(2*page.width(), 2*page.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation) );
/*
QList<Annotation*> anno = PAGE->annotations(Annotations::AText );
QStringList annoS;
@@ -212,9 +218,12 @@ void MainUI::startPresentation(bool atStart){
//Now create the full-screen window on the selected screen
if(presentationLabel == 0){
//Create the label and any special flags for it
- presentationLabel = new QLabel(0, Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
+ presentationLabel = new PresentationLabel();
presentationLabel->setStyleSheet("background-color: black;");
presentationLabel->setAlignment(Qt::AlignCenter);
+ presentationLabel->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(presentationLabel, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showContextMenu(const QPoint&)) );
+ connect(presentationLabel, SIGNAL(nextSlide()), this, SLOT(nextPage()) );
}
//Now put the label in the proper location
presentationLabel->setGeometry(screen->geometry());
@@ -311,6 +320,7 @@ void MainUI::paintOnWidget(QPrinter *PRINTER){
if(loadingHash.contains(i)){ painter.drawImage(0,0, loadingHash[i].scaled(PRINTER->pageRect().size(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); }
else{ painter.drawImage(0,0, QImage()); }
}
+ WIDGET->setContextMenuPolicy(Qt::CustomContextMenu);
}
void MainUI::paintToPrinter(QPrinter *PRINTER){
@@ -383,3 +393,22 @@ void MainUI::OpenNewFile(){
void MainUI::updateClock(){
label_clock->setText( QDateTime::currentDateTime().toString("<b>hh:mm:ss</b>") );
}
+
+void MainUI::updateContextMenu(){
+ contextMenu->clear();
+ int curP = WIDGET->currentPage()-1; //currentPage reports pages starting at 1
+ int lastP = numPages-1;
+ contextMenu->addSection( QString(tr("Page %1 of %2")).arg(QString::number(curP+1), QString::number(lastP+1) ) );
+ contextMenu->addAction(tr("Next Page"), this, SLOT(nextPage()))->setEnabled(curP<lastP);
+ contextMenu->addAction(tr("Previous Page"), this, SLOT(prevPage()))->setEnabled( curP>0 );
+ contextMenu->addSeparator();
+ contextMenu->addAction(tr("First Page"), this, SLOT(firstPage()))->setEnabled(curP!=0);
+ contextMenu->addAction(tr("Last Page"), this, SLOT(lastPage()))->setEnabled(curP!=lastP);
+ contextMenu->addSeparator();
+ if(presentationLabel==0 || !presentationLabel->isVisible()){
+ contextMenu->addAction(tr("Start Presentation (current slide)"), this, SLOT(startPresentationHere()) );
+ contextMenu->addAction(tr("Start Presentation (at beginning)"), this, SLOT(startPresentationBeginning()) );
+ }else{
+ contextMenu->addAction(tr("Stop Presentation"), this, SLOT(closePresentation()) );
+ }
+}
diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.h b/src-qt5/desktop-utils/lumina-pdf/mainUI.h
index 87d2a4e4..ad3d6809 100644
--- a/src-qt5/desktop-utils/lumina-pdf/mainUI.h
+++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.h
@@ -17,8 +17,10 @@
#include <QDebug>
#include <QWheelEvent>
#include <QApplication>
+#include <QMenu>
#include <poppler-qt5.h>
+#include "PresentationLabel.h"
namespace Ui{
class MainUI;
@@ -46,6 +48,7 @@ private:
QProgressBar *progress;
QAction *progAct; //action associated with the progressbar
QTimer *clockTimer;
+ QMenu *contextMenu;
//QFrame *frame_presenter;
QLabel *label_clock;
QAction *clockAct;
@@ -57,7 +60,7 @@ private:
void loadPage(int num, Poppler::Document *doc, MainUI *obj, QSize dpi, QSizeF page);
//Functions/variables for the presentation mode
- QLabel *presentationLabel;
+ PresentationLabel *presentationLabel;
QScreen *getScreen(bool current, bool &cancelled);
int CurrentPage;
void startPresentation(bool atStart);
@@ -69,6 +72,16 @@ private slots:
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 startPresentationHere(){ startPresentation(false); }
+ void startPresentationBeginning(){ startPresentation(true); }
+ void closePresentation(){ endPresentation(); }
+
+
void paintOnWidget(QPrinter *PRINTER);
void paintToPrinter(QPrinter *PRINTER);
@@ -77,6 +90,8 @@ private slots:
//Other interface slots
void updateClock();
+ void showContextMenu(const QPoint&){ contextMenu->popup(QCursor::pos()); }
+ void updateContextMenu();
signals:
void PageLoaded(int);
@@ -101,22 +116,23 @@ protected:
if( event->key()==Qt::Key_Escape || event->key()==Qt::Key_Backspace){
//qDebug() << " - Escape/Backspace";
- endPresentation();
+ if(inPresentation){ endPresentation(); }
}else if(event->key()==Qt::Key_Right || event->key()==Qt::Key_Down || event->key()==Qt::Key_Space || event->key()==Qt::Key_PageDown){
//qDebug() << " - Right/Down/Spacebar" << inPresentation;
- ShowPage( WIDGET->currentPage() ); //currentPage() starts at 1 rather than 0
+ nextPage();
}else if(event->key()==Qt::Key_Left || event->key()==Qt::Key_Up || event->key()==Qt::Key_PageUp){
//qDebug() << " - Left/Up";
- ShowPage( WIDGET->currentPage()-2 ); //currentPage() starts at 1 rather than 0
+ prevPage();
}else if(event->key()==Qt::Key_Home){
//qDebug() << " - Home";
- ShowPage(0); //go to the first page
+ firstPage();
}else if(event->key()==Qt::Key_End){
//qDebug() << " - End";
- ShowPage( numPages-1 ); //go to the last page
+ lastPage();
}else if(event->key()==Qt::Key_F11){
//qDebug() << " - F11";
- endPresentation();
+ if(inPresentation){ endPresentation(); }
+ else{ startPresentationHere(); }
}else{
QMainWindow::keyPressEvent(event);
}
bgstack15