diff options
Diffstat (limited to 'src-qt5/desktop-utils/lumina-pdf/mainUI.cpp')
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/mainUI.cpp | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp index c2f31e01..7a310e85 100644 --- a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp @@ -29,7 +29,17 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ CurrentPage = 0; lastdir = QDir::homePath(); Printer = new QPrinter(); + //Create the interface widgets WIDGET = new QPrintPreviewWidget(Printer,this); + clockTimer = new QTimer(this); + clockTimer->setInterval(1000); //1-second updates to clock + connect(clockTimer, SIGNAL(timeout()), this, SLOT(updateClock()) ); + //frame_presenter = new QFrame(this); + label_clock = new QLabel(this); + 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; }"); + //Now put the widgets into the UI this->setCentralWidget(WIDGET); connect(WIDGET, SIGNAL(paintRequested(QPrinter*)), this, SLOT(paintOnWidget(QPrinter*)) ); DOC = 0; @@ -44,7 +54,9 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ progress->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); progress->setFormat("%v/%m (%p%)"); // [current]/[total] progAct = ui->toolBar->addWidget(progress); - progAct->setVisible(false); + progAct->setVisible(false); + clockAct = ui->toolBar->addWidget(label_clock); + clockAct->setVisible(false); //Put the various actions into logical groups QActionGroup *tmp = new QActionGroup(this); tmp->setExclusive(true); @@ -130,7 +142,7 @@ void MainUI::loadFile(QString path){ Printer->setOrientation(QPrinter::Portrait); } delete PAGE; - qDebug() << " - Document Setup : start loading pages now"; + //qDebug() << " - Document Setup : start loading pages now"; QTimer::singleShot(10, WIDGET, SLOT(updatePreview())); //start loading the file preview } @@ -142,6 +154,14 @@ void MainUI::loadPage(int num, Poppler::Document *doc, MainUI *obj, QSize dpi, Q 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) ); + /* + QList<Annotation*> anno = PAGE->annotations(Annotations::AText ); + QStringList annoS; + for(int i=0; i<anno.length(); i++){ + annoS << static_cast<TextAnnotation*>(anno[i])->??? + } + annotateHash.insert(num, PAGE-> + */ }else{ loadingHash.insert(num, QImage()); } @@ -187,7 +207,7 @@ void MainUI::startPresentation(bool atStart){ QScreen *screen = getScreen(false, cancelled); //let the user select which screen to use (if multiples) if(cancelled){ return;} int page = 0; - if(!atStart){ page = CurrentPage; } + if(!atStart){ page = WIDGET->currentPage()-1; } //currentPage() starts at 1 rather than 0 //PDPI = QSize(SCALEFACTOR*screen->physicalDotsPerInchX(), SCALEFACTOR*screen->physicalDotsPerInchY()); //Now create the full-screen window on the selected screen if(presentationLabel == 0){ @@ -202,6 +222,9 @@ void MainUI::startPresentation(bool atStart){ ui->actionStop_Presentation->setEnabled(true); ui->menuStart_Presentation->setEnabled(false); + updateClock(); + clockAct->setVisible(true); + clockTimer->start(); QApplication::processEvents(); //Now start at the proper page ShowPage(page); @@ -209,13 +232,15 @@ void MainUI::startPresentation(bool atStart){ } void MainUI::ShowPage(int page){ - if(presentationLabel == 0 || !presentationLabel->isVisible()){ return; } //Check for valid document/page - //qDebug() << "Load Page:" << page << "/" << numPages-1; - if(page<0 || page > numPages ){ + //qDebug() << "Load Page:" << page << "/" << numPages << "Index:" << page; + if(page<0 || page > numPages || (page==numPages && CurrentPage==page) ){ endPresentation(); return; //invalid - no document loaded or invalid page specified } + WIDGET->setCurrentPage(page+1); //page numbers start at 1 for this widget + //Stop here if no presentation currently running + if(presentationLabel == 0 || !presentationLabel->isVisible()){ return; } CurrentPage = page; QImage PAGEIMAGE; if(page<numPages){ PAGEIMAGE = loadingHash[page]; } @@ -237,6 +262,8 @@ void MainUI::endPresentation(){ presentationLabel->hide(); //just hide this (no need to re-create the label for future presentations) ui->actionStop_Presentation->setEnabled(false); ui->menuStart_Presentation->setEnabled(true); + clockTimer->stop(); + clockAct->setVisible(false); this->releaseKeyboard(); } @@ -244,6 +271,7 @@ void MainUI::startLoadingPages(QPrinter *printer){ if(numPages>0){ return; } //currently loaded[ing] //qDebug() << " - Start Loading Pages"; numPages = DOC->numPages(); + //qDebug() << "numPages:" << numPages; progress->setRange(0,numPages); progress->setValue(0); progAct->setVisible(true); @@ -351,3 +379,7 @@ void MainUI::OpenNewFile(){ //Now Open it if(!path.isEmpty()){ loadFile(path); } } + +void MainUI::updateClock(){ + label_clock->setText( QDateTime::currentDateTime().toString("<b>hh:mm:ss</b>") ); +} |