3
Copyright 2012 Adam Reichold
5
This file is part of qpdfview.
7
qpdfview is free software: you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation, either version 2 of the License, or
10
(at your option) any later version.
12
qpdfview is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with qpdfview. If not, see <http://www.gnu.org/licenses/>.
22
#include "mainwindow.h"
24
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent),
36
slotTabWidgetCurrentChanged(-1);
40
DocumentView::thumbnailWidth = m_settings.value("documentView/thumbnailWidth", 96.0).toReal();
41
DocumentView::thumbnailHeight = m_settings.value("documentView/thumbnailHeight", 144.0).toReal();
43
DocumentView::fitToEqualWidth = m_settings.value("documentView/fitToEqualWidth", false).toBool();
45
DocumentView::highlightLinks = m_settings.value("documentView/highlightLinks", true).toBool();
46
DocumentView::externalLinks = m_settings.value("documentView/externalLinks", false).toBool();
48
m_matchCaseCheckBox->setChecked(m_settings.value("mainWindow/matchCase", true).toBool());
50
restoreGeometry(m_settings.value("mainWindow/geometry").toByteArray());
51
restoreState(m_settings.value("mainWindow/state").toByteArray());
53
m_tabWidget->setTabBarAsNeeded(m_settings.value("mainWindow/tabBarAsNeeded", false).toBool());
54
m_tabWidget->setTabPosition(static_cast< QTabWidget::TabPosition >(m_settings.value("mainWindow/tabPosition", static_cast< uint >(QTabWidget::North)).toUInt()));
58
if(m_settings.value("mainWindow/restoreTabs", false).toBool())
60
QStringList filePaths = m_settings.value("mainWindow/tabs/filePaths", QStringList()).toStringList();
61
QList< QVariant > currentPages = m_settings.value("mainWindow/tabs/currentPages", QList< QVariant >()).toList();
62
QList< QVariant > pageLayouts = m_settings.value("mainWindow/tabs/pageLayouts", QList< QVariant >()).toList();
63
QList< QVariant > scaleModes = m_settings.value("mainWindow/tabs/scaleModes", QList< QVariant >()).toList();
64
QList< QVariant > scaleFactors = m_settings.value("mainWindow/tabs/scaleFactors", QList< QVariant >()).toList();
65
QList< QVariant > rotations = m_settings.value("mainWindow/tabs/rotations", QList< QVariant >()).toList();
67
for(int index = 0; index < filePaths.count(); index++)
69
if(openInNewTab(filePaths.at(index)))
71
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
73
documentView->setCurrentPage(currentPages.value(index, documentView->currentPage()).toInt());
74
documentView->setPageLayout(static_cast< DocumentView::PageLayout >(pageLayouts.value(index, static_cast< uint >(documentView->pageLayout())).toUInt()));
75
documentView->setScaleMode(static_cast< DocumentView::ScaleMode >(scaleModes.value(index, static_cast< uint >(documentView->scaleMode())).toUInt()));
76
documentView->setScaleFactor(scaleFactors.value(index, documentView->scaleFactor()).toReal());
77
documentView->setRotation(static_cast< DocumentView::Rotation >(rotations.value(index, static_cast< uint >(documentView->rotation())).toUInt()));
81
m_tabWidget->setCurrentIndex(m_settings.value("mainWindow/tabs/currentIndex", -1).toInt());
85
QSize MainWindow::sizeHint() const
87
return QSize(500, 700);
90
QMenu* MainWindow::createPopupMenu()
92
QMenu* menu = new QMenu();
94
menu->addAction(m_fileToolBar->toggleViewAction());
95
menu->addAction(m_editToolBar->toggleViewAction());
96
menu->addAction(m_viewToolBar->toggleViewAction());
98
menu->addAction(m_outlineDock->toggleViewAction());
99
menu->addAction(m_metaInformationDock->toggleViewAction());
100
menu->addAction(m_thumbnailsDock->toggleViewAction());
105
bool MainWindow::open(const QString& filePath, int page, qreal top)
107
if(m_tabWidget->currentIndex() != -1)
109
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
111
if(documentView->open(filePath))
113
documentView->setCurrentPage(page, top);
114
documentView->clearBookmarks();
120
QMessageBox::warning(this, tr("Warning"), tr("Could not open document at \"%1\".").arg(QFileInfo(filePath).absoluteFilePath()));
127
return openInNewTab(filePath, page, top);
131
bool MainWindow::openInNewTab(const QString& filePath, int page, qreal top)
133
DocumentView* documentView = new DocumentView();
135
if(documentView->open(filePath))
137
QFileInfo fileInfo(filePath);
139
int index = m_tabWidget->addTab(documentView, fileInfo.completeBaseName());
140
m_tabWidget->setTabToolTip(index, fileInfo.absoluteFilePath());
141
m_tabWidget->setCurrentIndex(index);
143
m_tabMenu->addAction(documentView->tabAction());
145
connect(documentView, SIGNAL(filePathChanged(QString)), SLOT(slotFilePathChanged(QString)));
146
connect(documentView, SIGNAL(numberOfPagesChanged(int)), SLOT(slotNumberOfPagesChanged(int)));
148
connect(documentView, SIGNAL(currentPageChanged(int)), SLOT(slotCurrentPageChanged(int)));
150
connect(documentView, SIGNAL(searchProgressed(int)), SLOT(slotSearchProgressed(int)));
151
connect(documentView, SIGNAL(searchCanceled()), SLOT(slotSearchCanceled()));
152
connect(documentView, SIGNAL(searchFinished()), SLOT(slotSearchFinished()));
154
connect(documentView, SIGNAL(pageLayoutChanged(DocumentView::PageLayout)), SLOT(slotPageLayoutChanged(DocumentView::PageLayout)));
155
connect(documentView, SIGNAL(scaleModeChanged(DocumentView::ScaleMode)), SLOT(slotScaleModeChanged(DocumentView::ScaleMode)));
156
connect(documentView, SIGNAL(scaleFactorChanged(qreal)), SLOT(slotScaleFactorChanged(qreal)));
158
connect(documentView, SIGNAL(highlightAllChanged(bool)), SLOT(slotHighlightAllChanged(bool)));
160
documentView->setCurrentPage(page, top);
161
documentView->clearBookmarks();
163
documentView->setFocus();
171
QMessageBox::warning(this, tr("Warning"), tr("Could not open document at \"%1\".").arg(QFileInfo(filePath).absoluteFilePath()));
177
void MainWindow::closeEvent(QCloseEvent*)
181
if(m_settings.value("mainWindow/restoreTabs", false).toBool())
183
QStringList filePaths;
184
QList< QVariant > currentPages;
185
QList< QVariant > pageLayouts;
186
QList< QVariant > scaleModes;
187
QList< QVariant > scaleFactors;
188
QList< QVariant > rotations;
190
for(int index = 0; index < m_tabWidget->count(); index++)
192
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->widget(index));
194
filePaths.append(QFileInfo(documentView->filePath()).absoluteFilePath());
195
currentPages.append(documentView->currentPage());
196
pageLayouts.append(static_cast< uint >(documentView->pageLayout()));
197
scaleModes.append(static_cast< uint >(documentView->scaleMode()));
198
scaleFactors.append(documentView->scaleFactor());
199
rotations.append(static_cast< uint >(documentView->rotation()));
202
m_settings.setValue("mainWindow/tabs/filePaths", filePaths);
203
m_settings.setValue("mainWindow/tabs/currentPages", currentPages);
204
m_settings.setValue("mainWindow/tabs/pageLayouts", pageLayouts);
205
m_settings.setValue("mainWindow/tabs/scaleModes", scaleModes);
206
m_settings.setValue("mainWindow/tabs/scaleFactors", scaleFactors);
207
m_settings.setValue("mainWindow/tabs/rotations", rotations);
209
m_settings.setValue("mainWindow/tabs/currentIndex", m_tabWidget->currentIndex());
213
m_settings.remove("mainWindow/tabs/filePaths");
214
m_settings.remove("mainWindow/tabs/currentPages");
215
m_settings.remove("mainWindow/tabs/pageLayouts");
216
m_settings.remove("mainWindow/tabs/scaleModes");
217
m_settings.remove("mainWindow/tabs/scaleFactors");
218
m_settings.remove("mainWindow/tabs/rotations");
220
m_settings.remove("mainWindow/tabs/currentIndex");
227
m_settings.setValue("mainWindow/matchCase", m_matchCaseCheckBox->isChecked());
229
if(m_fullscreenAction->isChecked())
231
m_settings.setValue("mainWindow/geometry", m_geometry);
235
m_settings.setValue("mainWindow/geometry", saveGeometry());
238
m_settings.setValue("mainWindow/state", saveState());
240
m_settings.setValue("mainWindow/tabBarAsNeeded", m_tabWidget->tabBarAsNeeded());
241
m_settings.setValue("mainWindow/tabPosition", static_cast< uint >(m_tabWidget->tabPosition()));
244
void MainWindow::dragEnterEvent(QDragEnterEvent* event)
246
if(event->mimeData()->hasUrls())
248
event->acceptProposedAction();
252
void MainWindow::dropEvent(QDropEvent* event)
254
if(event->mimeData()->hasUrls())
256
event->acceptProposedAction();
258
disconnect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotTabWidgetCurrentChanged(int)));
260
foreach(QUrl url, event->mimeData()->urls())
262
if(url.scheme() == "file")
264
openInNewTab(url.path());
268
slotTabWidgetCurrentChanged(m_tabWidget->currentIndex());
270
connect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotTabWidgetCurrentChanged(int)));
274
void MainWindow::keyPressEvent(QKeyEvent* event)
276
if(m_tabWidget->currentIndex() != -1)
278
QKeyEvent keyEvent(*event);
280
QApplication::sendEvent(m_tabWidget->currentWidget(), &keyEvent);
284
void MainWindow::slotOpen()
286
if(m_tabWidget->currentIndex() != -1)
288
QString path = m_settings.value("mainWindow/path", QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).toString();
289
QString filePath = QFileDialog::getOpenFileName(this, tr("Open document"), path, "Portable Document Format (*.pdf)");
291
if(!filePath.isEmpty())
295
m_recentlyUsedAction->addEntry(filePath);
297
m_settings.setValue("mainWindow/path", QFileInfo(filePath).absolutePath());
307
void MainWindow::slotOpenInNewTab()
309
QString path = m_settings.value("mainWindow/path", QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).toString();
310
QStringList filePaths = QFileDialog::getOpenFileNames(this, tr("Open documents"), path, "Portable Document Format (*.pdf)");
312
disconnect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotTabWidgetCurrentChanged(int)));
314
foreach(QString filePath, filePaths)
316
if(openInNewTab(filePath))
318
m_recentlyUsedAction->addEntry(filePath);
320
m_settings.setValue("mainWindow/path", QFileInfo(filePath).absolutePath());
324
slotTabWidgetCurrentChanged(m_tabWidget->currentIndex());
326
connect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotTabWidgetCurrentChanged(int)));
329
void MainWindow::slotRecentyUsedActionEntrySelected(const QString& filePath)
334
void MainWindow::slotRefresh()
336
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
338
documentView->refresh();
341
void MainWindow::slotSaveCopy()
343
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
345
QString path = m_settings.value("mainWindow/path", QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).toString() + "/" + QFileInfo(documentView->filePath()).fileName();
346
QString filePath = QFileDialog::getSaveFileName(this, tr("Save copy"), path, "Portable Document Format (*.pdf)");
348
if(!filePath.isEmpty())
350
if(documentView->saveCopy(filePath))
352
m_settings.setValue("mainWindow/path", QFileInfo(filePath).absolutePath());
356
QMessageBox::warning(this, tr("Warning"), tr("Could not save copy at \"%1\".").arg(filePath));
361
void MainWindow::slotPrint()
363
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
365
QPrinter* printer = new QPrinter();
367
QPrintDialog printDialog(printer, this);
369
printDialog.setOptions(QAbstractPrintDialog::PrintDialogOptions());
370
printDialog.setOption(QAbstractPrintDialog::PrintCollateCopies, true);
371
printDialog.setOption(QAbstractPrintDialog::PrintPageRange, true);
373
printDialog.setMinMax(1, documentView->numberOfPages());
375
if(printDialog.exec() == QDialog::Accepted)
377
int fromPage = printDialog.fromPage() != 0 ? printDialog.fromPage() : 1;
378
int toPage = printDialog.toPage() != 0 ? printDialog.toPage() : documentView->numberOfPages();
380
QProgressDialog progressDialog;
382
progressDialog.setLabelText(tr("Printing pages %1 to %2...").arg(fromPage).arg(toPage));
383
progressDialog.setRange(0, 100);
384
progressDialog.setValue(0);
386
connect(documentView, SIGNAL(printProgressed(int)), &progressDialog, SLOT(setValue(int)));
387
connect(documentView, SIGNAL(printCanceled()), &progressDialog, SLOT(close()));
388
connect(documentView, SIGNAL(printFinished()), &progressDialog, SLOT(close()));
390
connect(&progressDialog, SIGNAL(canceled()), documentView, SLOT(cancelPrint()));
392
documentView->startPrint(printer, fromPage, toPage);
394
progressDialog.exec();
398
void MainWindow::slotPreviousPage()
400
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
402
documentView->previousPage();
405
void MainWindow::slotNextPage()
407
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
409
documentView->nextPage();
412
void MainWindow::slotFirstPage()
414
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
416
documentView->firstPage();
419
void MainWindow::slotLastPage()
421
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
423
documentView->lastPage();
426
void MainWindow::slotJumpToPage()
428
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
431
int page = QInputDialog::getInt(this, tr("Jump to page"), tr("Page:"), documentView->currentPage(), 1, documentView->numberOfPages(), 1, &ok);
435
documentView->setCurrentPage(page);
439
void MainWindow::slotSearch()
441
if(m_searchToolBar->isHidden())
443
m_searchToolBar->show();
447
m_searchLineEdit->selectAll();
450
m_searchLineEdit->setFocus();
453
void MainWindow::slotStartSearch()
455
m_searchTimer->stop();
457
if(m_searchToolBar->isVisible() && !m_searchLineEdit->text().isEmpty())
459
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
461
documentView->startSearch(m_searchLineEdit->text(), m_matchCaseCheckBox->isChecked());
465
void MainWindow::slotSearchProgressed(int value)
467
QPoint pos = centralWidget()->mapToGlobal(centralWidget()->rect().bottomLeft());
468
pos.rx() += 10; pos.ry() -= 50;
470
QToolTip::showText(pos, tr("Searched %1% of the current document...").arg(value), centralWidget());
473
void MainWindow::slotSearchCanceled()
475
QPoint pos = centralWidget()->mapToGlobal(centralWidget()->rect().bottomLeft());
476
pos.rx() += 10; pos.ry() -= 50;
478
QToolTip::showText(pos, tr("Search canceled."), centralWidget());
481
void MainWindow::slotSearchFinished()
483
QPoint pos = centralWidget()->mapToGlobal(centralWidget()->rect().bottomLeft());
484
pos.rx() += 10; pos.ry() -= 50;
486
QToolTip::showText(pos, tr("Search finished."), centralWidget());
489
void MainWindow::slotFindPrevious()
491
if(m_tabWidget->currentIndex() != -1)
493
if(m_searchToolBar->isHidden())
495
m_searchToolBar->show();
496
m_searchLineEdit->setFocus();
500
if(!m_searchLineEdit->text().isEmpty())
502
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
504
documentView->findPrevious();
510
void MainWindow::slotFindNext()
512
if(m_tabWidget->currentIndex() != -1)
514
if(m_searchToolBar->isHidden())
516
m_searchToolBar->show();
517
m_searchLineEdit->setFocus();
521
if(!m_searchLineEdit->text().isEmpty())
523
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
525
documentView->findNext();
531
void MainWindow::slotCancelSearch()
533
m_searchLineEdit->clear();
534
m_searchTimer->stop();
535
m_searchToolBar->hide();
537
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
539
documentView->cancelSearch();
542
void MainWindow::slotSettings()
544
m_settings.setValue("mainWindow/tabBarAsNeeded", m_tabWidget->tabBarAsNeeded());
545
m_settings.setValue("mainWindow/tabPosition", static_cast< uint >(m_tabWidget->tabPosition()));
549
SettingsDialog settingsDialog;
551
if(settingsDialog.exec() == QDialog::Accepted)
553
m_tabWidget->setTabBarAsNeeded(m_settings.value("mainWindow/tabBarAsNeeded", false).toBool());
554
m_tabWidget->setTabPosition(static_cast< QTabWidget::TabPosition >(m_settings.value("mainWindow/tabPosition", static_cast< uint >(QTabWidget::North)).toUInt()));
556
DocumentView::fitToEqualWidth = m_settings.value("documentView/fitToEqualWidth", false).toBool();
558
DocumentView::highlightLinks = m_settings.value("documentView/highlightLinks", true).toBool();
559
DocumentView::externalLinks = m_settings.value("documentView/externalLinks", false).toBool();
561
for(int index = 0; index < m_tabWidget->count(); index++)
563
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->widget(index)); Q_ASSERT(documentView);
565
documentView->refresh();
570
void MainWindow::slotPageLayoutGroupTriggered(QAction* action)
572
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
574
documentView->setPageLayout(static_cast< DocumentView::PageLayout >(action->data().toUInt()));
577
void MainWindow::slotScaleModeGroupTriggered(QAction* action)
579
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
581
documentView->setScaleMode(static_cast< DocumentView::ScaleMode >(action->data().toUInt()));
584
void MainWindow::slotZoomIn()
586
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
588
documentView->zoomIn();
591
void MainWindow::slotZoomOut()
593
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
595
documentView->zoomOut();
598
void MainWindow::slotRotateLeft()
600
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
602
documentView->rotateLeft();
605
void MainWindow::slotRotateRight()
607
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
609
documentView->rotateRight();
612
void MainWindow::slotFonts()
614
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
616
FontsDialog fontsDialog(documentView->fontsTableWidget());
618
fontsDialog.resize(m_settings.value("mainWindow/fontsDialogSize", fontsDialog.sizeHint()).toSize());
622
m_settings.setValue("mainWindow/fontsDialogSize", fontsDialog.size());
625
void MainWindow::slotFullscreen()
627
if(m_fullscreenAction->isChecked())
629
m_geometry = saveGeometry();
635
restoreGeometry(m_geometry);
639
restoreGeometry(m_geometry);
643
void MainWindow::slotPresentation()
645
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
646
PresentationView* presentationView = new PresentationView();
648
if(presentationView->open(documentView->filePath()))
650
presentationView->setCurrentPage(documentView->currentPage());
652
presentationView->show();
653
presentationView->setAttribute(Qt::WA_DeleteOnClose);
657
delete presentationView;
659
QMessageBox::warning(this, tr("Warning"), tr("Could not open document \"%1\".").arg(QFileInfo(documentView->filePath()).completeBaseName()));
663
void MainWindow::slotPreviousTab()
665
if(m_tabWidget->currentIndex() > 0)
667
m_tabWidget->setCurrentIndex(m_tabWidget->currentIndex() - 1);
671
m_tabWidget->setCurrentIndex(m_tabWidget->count() - 1);
675
void MainWindow::slotNextTab()
677
if(m_tabWidget->currentIndex() < m_tabWidget->count() - 1)
679
m_tabWidget->setCurrentIndex(m_tabWidget->currentIndex() + 1);
683
m_tabWidget->setCurrentIndex(0);
687
void MainWindow::slotCloseTab()
689
delete m_tabWidget->currentWidget();
692
void MainWindow::slotCloseAllTabs()
694
disconnect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotTabWidgetCurrentChanged(int)));
696
while(m_tabWidget->count() > 0)
698
delete m_tabWidget->widget(0);
701
slotTabWidgetCurrentChanged(-1);
703
connect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotTabWidgetCurrentChanged(int)));
706
void MainWindow::slotCloseAllTabsButCurrentTab()
708
if(m_tabWidget->currentIndex() != -1)
710
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
712
m_tabWidget->removeTab(m_tabWidget->currentIndex());
716
QFileInfo fileInfo(documentView->filePath());
718
int index = m_tabWidget->addTab(documentView, fileInfo.completeBaseName());
719
m_tabWidget->setTabToolTip(index, fileInfo.absoluteFilePath());
720
m_tabWidget->setCurrentIndex(index);
724
void MainWindow::slotContents()
726
HelpDialog helpDialog;
728
helpDialog.resize(m_settings.value("mainWindow/helpDialogSize", helpDialog.sizeHint()).toSize());
732
m_settings.setValue("mainWindow/helpDialogSize", helpDialog.size());
735
void MainWindow::slotAbout()
737
QMessageBox::about(this, tr("About qpdfview"), tr("<p><b>qpdfview %1</b></p><p>qpdfview is a tabbed PDF viewer using the poppler library. See <a href=\"https://launchpad.net/qpdfview\">launchpad.net/qpdfview</a> for more information.</p><p>© 2012 Adam Reichold</p>").arg(QApplication::applicationVersion()));
740
void MainWindow::slotTabWidgetCurrentChanged(int index)
744
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
746
m_refreshAction->setEnabled(true);
747
m_saveCopyAction->setEnabled(true);
748
m_printAction->setEnabled(true);
750
m_previousPageAction->setEnabled(true);
751
m_nextPageAction->setEnabled(true);
752
m_firstPageAction->setEnabled(true);
753
m_lastPageAction->setEnabled(true);
754
m_jumpToPageAction->setEnabled(true);
756
m_searchAction->setEnabled(true);
757
m_findPreviousAction->setEnabled(true);
758
m_findNextAction->setEnabled(true);
759
m_cancelSearchAction->setEnabled(true);
761
m_pageLayoutGroup->setEnabled(true);
763
m_scaleModeGroup->setEnabled(true);
765
m_zoomInAction->setEnabled(true);
766
m_zoomOutAction->setEnabled(true);
768
m_rotateLeftAction->setEnabled(true);
769
m_rotateRightAction->setEnabled(true);
771
m_fontsAction->setEnabled(true);
773
m_presentationAction->setEnabled(true);
775
m_previousTabAction->setEnabled(true);
776
m_nextTabAction->setEnabled(true);
777
m_closeTabAction->setEnabled(true);
778
m_closeAllTabsAction->setEnabled(true);
779
m_closeAllTabsButCurrentTabAction->setEnabled(true);
781
m_editToolBar->setEnabled(true);
782
m_viewToolBar->setEnabled(true);
784
m_searchToolBar->setEnabled(true);
786
if(m_searchToolBar->isVisible())
788
m_searchLineEdit->clear();
789
m_searchTimer->stop();
791
for(int index = 0; index < m_tabWidget->count(); index++)
793
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->widget(index)); Q_ASSERT(documentView);
795
documentView->cancelSearch();
799
slotCurrentPageChanged(documentView->currentPage());
800
slotNumberOfPagesChanged(documentView->numberOfPages());
801
slotPageLayoutChanged(documentView->pageLayout());
802
slotScaleModeChanged(documentView->scaleMode());
803
slotScaleFactorChanged(documentView->scaleFactor());
804
slotHighlightAllChanged(documentView->highlightAll());
806
m_outlineDock->setWidget(documentView->outlineTreeWidget());
807
m_metaInformationDock->setWidget(documentView->metaInformationTableWidget());
808
m_thumbnailsDock->setWidget(documentView->thumbnailsGraphicsView());
810
setWindowTitle(m_tabWidget->tabText(index) + " - qpdfview");
814
m_refreshAction->setEnabled(false);
815
m_saveCopyAction->setEnabled(false);
816
m_printAction->setEnabled(false);
818
m_previousPageAction->setEnabled(false);
819
m_nextPageAction->setEnabled(false);
820
m_firstPageAction->setEnabled(false);
821
m_lastPageAction->setEnabled(false);
822
m_jumpToPageAction->setEnabled(false);
824
m_searchAction->setEnabled(false);
825
m_findPreviousAction->setEnabled(false);
826
m_findNextAction->setEnabled(false);
827
m_cancelSearchAction->setEnabled(false);
829
m_onePageAction->setChecked(true);
830
m_pageLayoutGroup->setEnabled(false);
832
m_doNotScaleAction->setChecked(true);
833
m_scaleModeGroup->setEnabled(false);
835
m_zoomInAction->setEnabled(false);
836
m_zoomOutAction->setEnabled(false);
838
m_rotateLeftAction->setEnabled(false);
839
m_rotateRightAction->setEnabled(false);
841
m_fontsAction->setEnabled(false);
843
m_presentationAction->setEnabled(false);
845
m_previousTabAction->setEnabled(false);
846
m_nextTabAction->setEnabled(false);
847
m_closeTabAction->setEnabled(false);
848
m_closeAllTabsAction->setEnabled(false);
849
m_closeAllTabsButCurrentTabAction->setEnabled(false);
851
m_currentPageLineEdit->setText(QString());
852
m_numberOfPagesLabel->setText(QString());
853
m_editToolBar->setEnabled(false);
855
m_scaleFactorComboBox->setCurrentIndex(2);
856
m_viewToolBar->setEnabled(false);
858
m_highlightAllCheckBox->setChecked(false);
859
m_searchToolBar->setEnabled(false);
861
if(m_searchToolBar->isVisible())
863
m_searchLineEdit->clear();
864
m_searchTimer->stop();
865
m_searchToolBar->hide();
868
m_outlineDock->setWidget(0);
869
m_metaInformationDock->setWidget(0);
870
m_thumbnailsDock->setWidget(0);
872
setWindowTitle("qpdfview");
876
void MainWindow::slotTabWidgetTabCloseRequested(int index)
878
delete m_tabWidget->widget(index);
881
void MainWindow::slotCurrentPageLineEditEditingFinished()
883
if(m_tabWidget->currentIndex() != -1)
885
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
887
documentView->setCurrentPage(m_currentPageLineEdit->text().toInt());
891
void MainWindow::slotCurrentPageLineEditReturnPressed()
893
m_tabWidget->currentWidget()->setFocus();
896
void MainWindow::slotScaleFactorComboBoxCurrentIndexChanged(int index)
898
if(m_tabWidget->currentIndex() != -1)
900
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
902
documentView->setScaleMode(static_cast< DocumentView::ScaleMode >(m_scaleFactorComboBox->itemData(index).toUInt()));
906
void MainWindow::slotScaleFactorComboBoxEditingFinished()
908
if(m_tabWidget->currentIndex() != -1)
910
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
912
QString text = m_scaleFactorComboBox->lineEdit()->text();
914
text = text.trimmed();
916
text = text.endsWith('%') ? text.left(text.size() - 1) : text;
918
text = text.trimmed();
921
qreal scaleFactor = QLocale::system().toInt(text, &ok) / 100.0;
923
if(ok && scaleFactor >= DocumentView::mininumScaleFactor && scaleFactor <= DocumentView::maximumScaleFactor)
925
documentView->setScaleFactor(scaleFactor);
926
documentView->setScaleMode(DocumentView::ScaleFactor);
929
slotScaleFactorChanged(documentView->scaleFactor());
930
slotScaleModeChanged(documentView->scaleMode());
934
void MainWindow::slotScaleFactorComboBoxReturnPressed()
936
m_tabWidget->currentWidget()->setFocus();
939
void MainWindow::slotHighlightAllCheckBoxClicked(bool checked)
941
DocumentView* documentView = qobject_cast< DocumentView* >(m_tabWidget->currentWidget()); Q_ASSERT(documentView);
943
documentView->setHighlightAll(checked);
946
void MainWindow::slotFilePathChanged(const QString& filePath)
948
DocumentView* documentView = qobject_cast< DocumentView* >(sender());
950
if(documentView == 0 || documentView == m_tabWidget->currentWidget())
952
QFileInfo fileInfo(filePath);
954
m_tabWidget->setTabText(m_tabWidget->currentIndex(), fileInfo.completeBaseName());
955
m_tabWidget->setTabToolTip(m_tabWidget->currentIndex(), fileInfo.absoluteFilePath());
957
setWindowTitle(fileInfo.completeBaseName() + " - qpdfview");
961
void MainWindow::slotNumberOfPagesChanged(int numberOfPages)
963
DocumentView* documentView = qobject_cast< DocumentView* >(sender());
965
if(documentView == 0 || documentView == m_tabWidget->currentWidget())
967
m_currentPageValidator->setRange(1, numberOfPages);
968
m_numberOfPagesLabel->setText(tr(" of %1").arg(numberOfPages));
972
void MainWindow::slotCurrentPageChanged(int currentPage)
974
DocumentView* documentView = qobject_cast< DocumentView* >(sender());
976
if(documentView == 0 || documentView == m_tabWidget->currentWidget())
978
m_currentPageLineEdit->setText(QLocale::system().toString(currentPage));
982
void MainWindow::slotPageLayoutChanged(DocumentView::PageLayout pageLayout)
984
DocumentView* documentView = qobject_cast< DocumentView* >(sender());
986
if(documentView == 0 || documentView == m_tabWidget->currentWidget())
988
foreach(QAction* action, m_pageLayoutGroup->actions())
990
action->setChecked(action->data().toUInt() == static_cast< uint >(pageLayout));
995
void MainWindow::slotScaleModeChanged(DocumentView::ScaleMode scaleMode)
997
DocumentView* documentView = qobject_cast< DocumentView* >(sender());
999
if(documentView == 0 || documentView == m_tabWidget->currentWidget())
1001
foreach(QAction* action, m_scaleModeGroup->actions())
1003
action->setChecked(action->data().toUInt() == static_cast< uint >(scaleMode));
1006
for(int index = 0; index < m_scaleFactorComboBox->count(); index++)
1008
if(m_scaleFactorComboBox->itemData(index).toUInt() == static_cast< uint >(scaleMode))
1010
m_scaleFactorComboBox->setCurrentIndex(index);
1016
void MainWindow::slotScaleFactorChanged(qreal scaleFactor)
1018
DocumentView* documentView = qobject_cast< DocumentView* >(sender());
1020
if(documentView == 0 || documentView == m_tabWidget->currentWidget())
1022
m_scaleFactorComboBox->setItemText(3, tr("Scale to %1%").arg(100.0 * scaleFactor, 0, 'f', 0));
1026
void MainWindow::slotHighlightAllChanged(bool highlightAll)
1028
DocumentView* documentView = qobject_cast< DocumentView* >(sender());
1030
if(documentView == 0 || documentView == m_tabWidget->currentWidget())
1032
m_highlightAllCheckBox->setChecked(highlightAll);
1036
void MainWindow::createActions()
1038
if(m_settings.contains("mainWindow/iconTheme"))
1040
QIcon::setThemeName(m_settings.value("mainWindow/iconTheme").toString());
1045
m_openAction = new QAction(tr("&Open..."), this);
1046
m_openAction->setShortcut(QKeySequence::Open);
1047
m_openAction->setIconVisibleInMenu(true);
1048
connect(m_openAction, SIGNAL(triggered()), SLOT(slotOpen()));
1050
if(QIcon::hasThemeIcon("document-open"))
1052
m_openAction->setIcon(QIcon::fromTheme("document-open"));
1056
#ifdef DATA_INSTALL_PATH
1057
m_openAction->setIcon(QIcon(QString("%1/document-open.svg").arg(DATA_INSTALL_PATH)));
1059
m_openAction->setIcon(QIcon(":/icons/document-open.svg"));
1065
m_openInNewTabAction = new QAction(tr("Open in new &tab..."), this);
1066
m_openInNewTabAction->setShortcut(QKeySequence::AddTab);
1067
m_openInNewTabAction->setIconVisibleInMenu(true);
1068
connect(m_openInNewTabAction, SIGNAL(triggered()), SLOT(slotOpenInNewTab()));
1070
if(QIcon::hasThemeIcon("tab-new"))
1072
m_openInNewTabAction->setIcon(QIcon::fromTheme("tab-new"));
1076
#ifdef DATA_INSTALL_PATH
1077
m_openInNewTabAction->setIcon(QIcon(QString("%1/tab-new.svg").arg(DATA_INSTALL_PATH)));
1079
m_openInNewTabAction->setIcon(QIcon(":/icons/tab-new.svg"));
1085
m_recentlyUsedAction = new RecentlyUsedAction(this);
1086
m_recentlyUsedAction->setIcon(QIcon::fromTheme("document-open-recent"));
1087
m_recentlyUsedAction->setIconVisibleInMenu(true);
1088
connect(m_recentlyUsedAction, SIGNAL(entrySelected(QString)), SLOT(slotRecentyUsedActionEntrySelected(QString)));
1092
m_refreshAction = new QAction(tr("&Refresh"), this);
1093
m_refreshAction->setShortcut(QKeySequence::Refresh);
1094
m_refreshAction->setIconVisibleInMenu(true);
1095
connect(m_refreshAction, SIGNAL(triggered()), SLOT(slotRefresh()));
1097
if(QIcon::hasThemeIcon("view-refresh"))
1099
m_refreshAction->setIcon(QIcon::fromTheme("view-refresh"));
1103
#ifdef DATA_INSTALL_PATH
1104
m_refreshAction->setIcon(QIcon(QString("%1/view-refresh.svg").arg(DATA_INSTALL_PATH)));
1106
m_refreshAction->setIcon(QIcon(":/icons/view-refresh.svg"));
1112
m_saveCopyAction = new QAction(tr("&Save copy..."), this);
1113
m_saveCopyAction->setShortcut(QKeySequence::Save);
1114
m_saveCopyAction->setIconVisibleInMenu(true);
1115
connect(m_saveCopyAction, SIGNAL(triggered()), SLOT(slotSaveCopy()));
1117
if(QIcon::hasThemeIcon("document-save"))
1119
m_saveCopyAction->setIcon(QIcon::fromTheme("document-save"));
1123
#ifdef DATA_INSTALL_PATH
1124
m_saveCopyAction->setIcon(QIcon(QString("%1/document-save.svg").arg(DATA_INSTALL_PATH)));
1126
m_saveCopyAction->setIcon(QIcon(":/icons/document-save.svg"));
1132
m_printAction = new QAction(tr("&Print..."), this);
1133
m_printAction->setShortcut(QKeySequence::Print);
1134
m_printAction->setIconVisibleInMenu(true);
1135
connect(m_printAction, SIGNAL(triggered()), SLOT(slotPrint()));
1137
if(QIcon::hasThemeIcon("document-print"))
1139
m_printAction->setIcon(QIcon::fromTheme("document-print"));
1143
#ifdef DATA_INSTALL_PATH
1144
m_printAction->setIcon(QIcon(QString("%1/document-print.svg").arg(DATA_INSTALL_PATH)));
1146
m_printAction->setIcon(QIcon(":/icons/document-print.svg"));
1152
m_exitAction = new QAction(tr("&Exit"), this);
1153
m_exitAction->setShortcut(QKeySequence::Quit);
1154
m_exitAction->setIcon(QIcon::fromTheme("application-exit"));
1155
m_exitAction->setIconVisibleInMenu(true);
1156
connect(m_exitAction, SIGNAL(triggered()), SLOT(close()));
1160
m_previousPageAction = new QAction(tr("&Previous page"), this);
1161
m_previousPageAction->setShortcut(QKeySequence(Qt::Key_Left));
1162
m_previousPageAction->setIconVisibleInMenu(true);
1163
connect(m_previousPageAction, SIGNAL(triggered()), SLOT(slotPreviousPage()));
1165
if(QIcon::hasThemeIcon("go-previous"))
1167
m_previousPageAction->setIcon(QIcon::fromTheme("go-previous"));
1171
#ifdef DATA_INSTALL_PATH
1172
m_previousPageAction->setIcon(QIcon(QString("%1/go-previous.svg").arg(DATA_INSTALL_PATH)));
1174
m_previousPageAction->setIcon(QIcon(":/icons/go-previous.svg"));
1180
m_nextPageAction = new QAction(tr("&Next page"), this);
1181
m_nextPageAction->setShortcut(QKeySequence(Qt::Key_Right));
1182
m_nextPageAction->setIconVisibleInMenu(true);
1183
connect(m_nextPageAction, SIGNAL(triggered()), SLOT(slotNextPage()));
1185
if(QIcon::hasThemeIcon("go-next"))
1187
m_nextPageAction->setIcon(QIcon::fromTheme("go-next"));
1191
#ifdef DATA_INSTALL_PATH
1192
m_nextPageAction->setIcon(QIcon(QString("%1/go-next.svg").arg(DATA_INSTALL_PATH)));
1194
m_nextPageAction->setIcon(QIcon(":/icons/go-next.svg"));
1200
m_firstPageAction = new QAction(tr("&First page"), this);
1201
m_firstPageAction->setShortcut(QKeySequence(Qt::Key_Home));
1202
m_firstPageAction->setIconVisibleInMenu(true);
1203
connect(m_firstPageAction, SIGNAL(triggered()), SLOT(slotFirstPage()));
1205
if(QIcon::hasThemeIcon("go-first"))
1207
m_firstPageAction->setIcon(QIcon::fromTheme("go-first"));
1211
#ifdef DATA_INSTALL_PATH
1212
m_firstPageAction->setIcon(QIcon(QString("%1/go-first.svg").arg(DATA_INSTALL_PATH)));
1214
m_firstPageAction->setIcon(QIcon(":/icons/go-first.svg"));
1220
m_lastPageAction = new QAction(tr("&Last page"), this);
1221
m_lastPageAction->setShortcut(QKeySequence(Qt::Key_End));
1222
m_lastPageAction->setIconVisibleInMenu(true);
1223
connect(m_lastPageAction, SIGNAL(triggered()), SLOT(slotLastPage()));
1225
if(QIcon::hasThemeIcon("go-last"))
1227
m_lastPageAction->setIcon(QIcon::fromTheme("go-last"));
1231
#ifdef DATA_INSTALL_PATH
1232
m_lastPageAction->setIcon(QIcon(QString("%1/go-last.svg").arg(DATA_INSTALL_PATH)));
1234
m_lastPageAction->setIcon(QIcon(":/icons/go-last.svg"));
1240
m_jumpToPageAction = new QAction(tr("&Jump to page..."), this);
1241
m_jumpToPageAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_J));
1242
m_jumpToPageAction->setIconVisibleInMenu(true);
1243
connect(m_jumpToPageAction, SIGNAL(triggered()), SLOT(slotJumpToPage()));
1245
if(QIcon::hasThemeIcon("go-jump"))
1247
m_jumpToPageAction->setIcon(QIcon::fromTheme("go-jump"));
1251
#ifdef DATA_INSTALL_PATH
1252
m_jumpToPageAction->setIcon(QIcon(QString("%1/go-jump.svg").arg(DATA_INSTALL_PATH)));
1254
m_jumpToPageAction->setIcon(QIcon(":/icons/go-jump.svg"));
1260
m_searchAction = new QAction(tr("&Search..."), this);
1261
m_searchAction->setShortcut(QKeySequence::Find);
1262
m_searchAction->setIconVisibleInMenu(true);
1263
connect(m_searchAction, SIGNAL(triggered()), SLOT(slotSearch()));
1265
if(QIcon::hasThemeIcon("edit-find"))
1267
m_searchAction->setIcon(QIcon::fromTheme("edit-find"));
1271
#ifdef DATA_INSTALL_PATH
1272
m_searchAction->setIcon(QIcon(QString("%1/edit-find.svg").arg(DATA_INSTALL_PATH)));
1274
m_searchAction->setIcon(QIcon(":/icons/edit-find.svg"));
1280
m_findPreviousAction = new QAction(tr("Find previous"), this);
1281
m_findPreviousAction->setShortcut(QKeySequence::FindPrevious);
1282
m_findPreviousAction->setIconVisibleInMenu(true);
1283
connect(m_findPreviousAction, SIGNAL(triggered()), SLOT(slotFindPrevious()));
1285
if(QIcon::hasThemeIcon("go-up"))
1287
m_findPreviousAction->setIcon(QIcon::fromTheme("go-up"));
1291
#ifdef DATA_INSTALL_PATH
1292
m_findPreviousAction->setIcon(QIcon(QString("%1/go-up.svg").arg(DATA_INSTALL_PATH)));
1294
m_findPreviousAction->setIcon(QIcon(":/icons/go-up.svg"));
1300
m_findNextAction = new QAction(tr("Find next"), this);
1301
m_findNextAction->setShortcut(QKeySequence::FindNext);
1302
m_findNextAction->setIconVisibleInMenu(true);
1303
connect(m_findNextAction, SIGNAL(triggered()), SLOT(slotFindNext()));
1305
if(QIcon::hasThemeIcon("go-down"))
1307
m_findNextAction->setIcon(QIcon::fromTheme("go-down"));
1311
#ifdef DATA_INSTALL_PATH
1312
m_findNextAction->setIcon(QIcon(QString("%1/go-down.svg").arg(DATA_INSTALL_PATH)));
1314
m_findNextAction->setIcon(QIcon(":/icons/go-down.svg"));
1320
m_cancelSearchAction = new QAction(tr("Cancel search"), this);
1321
m_cancelSearchAction->setShortcut(QKeySequence(Qt::Key_Escape));
1322
m_cancelSearchAction->setIconVisibleInMenu(true);
1323
connect(m_cancelSearchAction, SIGNAL(triggered()), SLOT(slotCancelSearch()));
1325
if(QIcon::hasThemeIcon("process-stop"))
1327
m_cancelSearchAction->setIcon(QIcon::fromTheme("process-stop"));
1331
#ifdef DATA_INSTALL_PATH
1332
m_cancelSearchAction->setIcon(QIcon(QString("%1/process-stop.svg").arg(DATA_INSTALL_PATH)));
1334
m_cancelSearchAction->setIcon(QIcon(":/icons/process-stop.svg"));
1340
m_settingsAction = new QAction(tr("Settings..."), this);
1341
m_settingsAction->setIcon(QIcon::fromTheme("preferences-other"));
1342
m_settingsAction->setIconVisibleInMenu(true);
1343
connect(m_settingsAction, SIGNAL(triggered()), SLOT(slotSettings()));
1347
m_onePageAction = new QAction(tr("One page"), this);
1348
m_onePageAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_1));
1349
m_onePageAction->setCheckable(true);
1350
m_onePageAction->setData(static_cast< uint >(DocumentView::OnePage));
1351
m_twoPagesAction = new QAction(tr("Two pages"), this);
1352
m_twoPagesAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_2));
1353
m_twoPagesAction->setCheckable(true);
1354
m_twoPagesAction->setData(static_cast< uint >(DocumentView::TwoPages));
1355
m_oneColumnAction = new QAction(tr("One column"), this);
1356
m_oneColumnAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_3));
1357
m_oneColumnAction->setCheckable(true);
1358
m_oneColumnAction->setData(static_cast< uint >(DocumentView::OneColumn));
1359
m_twoColumnsAction = new QAction(tr("Two columns"), this);
1360
m_twoColumnsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_4));
1361
m_twoColumnsAction->setCheckable(true);
1362
m_twoColumnsAction->setData(static_cast< uint >(DocumentView::TwoColumns));
1364
m_pageLayoutGroup = new QActionGroup(this);
1365
m_pageLayoutGroup->addAction(m_onePageAction);
1366
m_pageLayoutGroup->addAction(m_twoPagesAction);
1367
m_pageLayoutGroup->addAction(m_oneColumnAction);
1368
m_pageLayoutGroup->addAction(m_twoColumnsAction);
1369
connect(m_pageLayoutGroup, SIGNAL(selected(QAction*)), SLOT(slotPageLayoutGroupTriggered(QAction*)));
1371
#ifdef DATA_INSTALL_PATH
1372
m_onePageAction->setIcon(QIcon(QString("%1/one-page.svg").arg(DATA_INSTALL_PATH)));
1373
m_twoPagesAction->setIcon(QIcon(QString("%1/two-pages.svg").arg(DATA_INSTALL_PATH)));
1374
m_oneColumnAction->setIcon(QIcon(QString("%1/one-column.svg").arg(DATA_INSTALL_PATH)));
1375
m_twoColumnsAction->setIcon(QIcon(QString("%1/two-columns.svg").arg(DATA_INSTALL_PATH)));
1377
m_onePageAction->setIcon(QIcon(":/icons/one-page.svg"));
1378
m_twoPagesAction->setIcon(QIcon(":/icons/two-pages.svg"));
1379
m_oneColumnAction->setIcon(QIcon(":/icons/one-column.svg"));
1380
m_twoColumnsAction->setIcon(QIcon(":/icons/two-columns.svg"));
1385
m_fitToPageAction = new QAction(tr("Fit to page"), this);
1386
m_fitToPageAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_8));
1387
m_fitToPageAction->setCheckable(true);
1388
m_fitToPageAction->setData(static_cast< uint >(DocumentView::FitToPage));
1389
m_fitToPageWidthAction = new QAction(tr("Fit to page width"), this);
1390
m_fitToPageWidthAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_9));
1391
m_fitToPageWidthAction->setCheckable(true);
1392
m_fitToPageWidthAction->setData(static_cast< uint >(DocumentView::FitToPageWidth));
1393
m_doNotScaleAction = new QAction(tr("Do not scale"), this);
1394
m_doNotScaleAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0));
1395
m_doNotScaleAction->setCheckable(true);
1396
m_doNotScaleAction->setData(static_cast< uint >(DocumentView::DoNotScale));
1398
m_scaleModeGroup = new QActionGroup(this);
1399
m_scaleModeGroup->addAction(m_fitToPageAction);
1400
m_scaleModeGroup->addAction(m_fitToPageWidthAction);
1401
m_scaleModeGroup->addAction(m_doNotScaleAction);
1402
connect(m_scaleModeGroup, SIGNAL(selected(QAction*)), SLOT(slotScaleModeGroupTriggered(QAction*)));
1404
#ifdef DATA_INSTALL_PATH
1405
m_fitToPageAction->setIcon(QIcon(QString("%1/fit-to-page.svg").arg(DATA_INSTALL_PATH)));
1406
m_fitToPageWidthAction->setIcon(QIcon(QString("%1/fit-to-page-width.svg").arg(DATA_INSTALL_PATH)));
1407
m_doNotScaleAction->setIcon(QIcon(QString("%1/do-not-scale.svg").arg(DATA_INSTALL_PATH)));
1409
m_fitToPageAction->setIcon(QIcon(":/icons/fit-to-page.svg"));
1410
m_fitToPageWidthAction->setIcon(QIcon(":/icons/fit-to-page-width.svg"));
1411
m_doNotScaleAction->setIcon(QIcon(":/icons/do-not-scale.svg"));
1416
m_zoomInAction = new QAction(tr("Zoom &in"), this);
1417
m_zoomInAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Up));
1418
m_zoomInAction->setIconVisibleInMenu(true);
1419
connect(m_zoomInAction, SIGNAL(triggered()), SLOT(slotZoomIn()));
1421
if(QIcon::hasThemeIcon("zoom-in"))
1423
m_zoomInAction->setIcon(QIcon::fromTheme("zoom-in"));
1427
#ifdef DATA_INSTALL_PATH
1428
m_zoomInAction->setIcon(QIcon(QString("%1/zoom-in.svg").arg(DATA_INSTALL_PATH)));
1430
m_zoomInAction->setIcon(QIcon(":/icons/zoom-in.svg"));
1434
m_zoomOutAction = new QAction(tr("Zoom &out"), this);
1435
m_zoomOutAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Down));
1436
m_zoomOutAction->setIconVisibleInMenu(true);
1437
connect(m_zoomOutAction, SIGNAL(triggered()), SLOT(slotZoomOut()));
1439
if(QIcon::hasThemeIcon("zoom-out"))
1441
m_zoomOutAction->setIcon(QIcon::fromTheme("zoom-out"));
1445
#ifdef DATA_INSTALL_PATH
1446
m_zoomOutAction->setIcon(QIcon(QString("%1/zoom-out.svg").arg(DATA_INSTALL_PATH)));
1448
m_zoomOutAction->setIcon(QIcon(":/icons/zoom-out.svg"));
1454
m_rotateLeftAction = new QAction(tr("Rotate &left"), this);
1455
m_rotateLeftAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Left));
1456
m_rotateLeftAction->setIconVisibleInMenu(true);
1457
connect(m_rotateLeftAction, SIGNAL(triggered()), SLOT(slotRotateLeft()));
1459
if(QIcon::hasThemeIcon("object-rotate-left"))
1461
m_rotateLeftAction->setIcon(QIcon::fromTheme("object-rotate-left"));
1465
#ifdef DATA_INSTALL_PATH
1466
m_rotateLeftAction->setIcon(QIcon(QString("%1/object-rotate-left.svg").arg(DATA_INSTALL_PATH)));
1468
m_rotateLeftAction->setIcon(QIcon(":/icons/object-rotate-left.svg"));
1472
m_rotateRightAction = new QAction(tr("Rotate &right"), this);
1473
m_rotateRightAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Right));
1474
m_rotateRightAction->setIconVisibleInMenu(true);
1475
connect(m_rotateRightAction, SIGNAL(triggered()), SLOT(slotRotateRight()));
1477
if(QIcon::hasThemeIcon("object-rotate-right"))
1479
m_rotateRightAction->setIcon(QIcon::fromTheme("object-rotate-right"));
1483
#ifdef DATA_INSTALL_PATH
1484
m_rotateRightAction->setIcon(QIcon(QString("%1/object-rotate-right.svg").arg(DATA_INSTALL_PATH)));
1486
m_rotateRightAction->setIcon(QIcon(":/icons/object-rotate-right.svg"));
1492
m_fontsAction = new QAction(tr("Fonts..."), this);
1493
connect(m_fontsAction, SIGNAL(triggered()), SLOT(slotFonts()));
1497
m_fullscreenAction = new QAction(tr("&Fullscreen"), this);
1498
m_fullscreenAction->setCheckable(true);
1499
m_fullscreenAction->setShortcut(QKeySequence(Qt::Key_F11));
1500
m_fullscreenAction->setIconVisibleInMenu(true);
1501
connect(m_fullscreenAction, SIGNAL(triggered()), SLOT(slotFullscreen()));
1503
if(QIcon::hasThemeIcon("view-fullscreen"))
1505
m_fullscreenAction->setIcon(QIcon::fromTheme("view-fullscreen"));
1509
#ifdef DATA_INSTALL_PATH
1510
m_fullscreenAction->setIcon(QIcon(QString("%1/view-fullscreen.svg").arg(DATA_INSTALL_PATH)));
1512
m_fullscreenAction->setIcon(QIcon(":/icons/view-fullscreen.svg"));
1518
m_presentationAction = new QAction(tr("&Presentation..."), this);
1519
m_presentationAction->setShortcut(QKeySequence(Qt::Key_F12));
1520
m_presentationAction->setIconVisibleInMenu(true);
1521
connect(m_presentationAction, SIGNAL(triggered()), SLOT(slotPresentation()));
1523
if(QIcon::hasThemeIcon("x-office-presentation"))
1525
m_presentationAction->setIcon(QIcon::fromTheme("x-office-presentation"));
1529
#ifdef DATA_INSTALL_PATH
1530
m_fullscreenAction->setIcon(QIcon(QString("%1/x-office-presentation.svg").arg(DATA_INSTALL_PATH)));
1532
m_fullscreenAction->setIcon(QIcon(":/icons/x-office-presentation.svg"));
1538
m_previousTabAction = new QAction(tr("&Previous tab"), this);
1539
m_previousTabAction->setShortcut(QKeySequence::PreviousChild);
1540
connect(m_previousTabAction, SIGNAL(triggered()), SLOT(slotPreviousTab()));
1544
m_nextTabAction = new QAction(tr("&Next tab"), this);
1545
m_nextTabAction->setShortcut(QKeySequence::NextChild);
1546
connect(m_nextTabAction, SIGNAL(triggered()), SLOT(slotNextTab()));
1550
m_closeTabAction = new QAction(tr("&Close tab"), this);
1551
m_closeTabAction->setShortcut(QKeySequence::Close);
1552
m_closeTabAction->setIcon(QIcon::fromTheme("window-close"));
1553
m_closeTabAction->setIconVisibleInMenu(true);
1554
connect(m_closeTabAction, SIGNAL(triggered()), SLOT(slotCloseTab()));
1558
m_closeAllTabsAction = new QAction(tr("Close all &tabs"), this);
1559
m_closeAllTabsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_W));
1560
connect(m_closeAllTabsAction, SIGNAL(triggered()), SLOT(slotCloseAllTabs()));
1562
// close all tabs but current tab
1564
m_closeAllTabsButCurrentTabAction = new QAction(tr("Close all tabs &but current tab"), this);
1565
m_closeAllTabsButCurrentTabAction->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_W));
1566
connect(m_closeAllTabsButCurrentTabAction, SIGNAL(triggered()), SLOT(slotCloseAllTabsButCurrentTab()));
1570
m_contentsAction = new QAction(tr("&Contents"), this);
1571
m_contentsAction->setShortcut(QKeySequence::HelpContents);
1572
m_contentsAction->setIcon(QIcon::fromTheme("help-contents"));
1573
m_contentsAction->setIconVisibleInMenu(true);
1574
connect(m_contentsAction, SIGNAL(triggered()), SLOT(slotContents()));
1578
m_aboutAction = new QAction(tr("&About"), this);
1579
m_aboutAction->setIcon(QIcon::fromTheme("help-about"));
1580
m_aboutAction->setIconVisibleInMenu(true);
1581
connect(m_aboutAction, SIGNAL(triggered()), SLOT(slotAbout()));
1584
void MainWindow::createWidgets()
1588
m_tabWidget = new TabWidget(this);
1590
m_tabWidget->setTabsClosable(true);
1591
m_tabWidget->setMovable(true);
1592
m_tabWidget->setDocumentMode(true);
1593
m_tabWidget->setElideMode(Qt::ElideRight);
1595
setCentralWidget(m_tabWidget);
1597
connect(m_tabWidget, SIGNAL(currentChanged(int)), SLOT(slotTabWidgetCurrentChanged(int)));
1598
connect(m_tabWidget, SIGNAL(tabCloseRequested(int)), SLOT(slotTabWidgetTabCloseRequested(int)));
1602
m_currentPageLineEdit = new LineEdit(this);
1603
m_currentPageValidator = new QIntValidator(m_currentPageLineEdit);
1605
m_currentPageLineEdit->setValidator(m_currentPageValidator);
1606
m_currentPageLineEdit->setAlignment(Qt::AlignCenter);
1607
m_currentPageLineEdit->setFixedWidth(40);
1609
connect(m_currentPageLineEdit, SIGNAL(editingFinished()), SLOT(slotCurrentPageLineEditEditingFinished()));
1610
connect(m_currentPageLineEdit, SIGNAL(returnPressed()), SLOT(slotCurrentPageLineEditReturnPressed()));
1614
m_numberOfPagesLabel = new QLabel(this);
1616
m_numberOfPagesLabel->setAlignment(Qt::AlignCenter);
1617
m_numberOfPagesLabel->setFixedWidth(60);
1621
m_scaleFactorComboBox = new ComboBox(this);
1623
m_scaleFactorComboBox->setEditable(true);
1624
m_scaleFactorComboBox->setInsertPolicy(QComboBox::NoInsert);
1626
m_scaleFactorComboBox->addItem(tr("Fit to page"), static_cast< uint >(DocumentView::FitToPage));
1627
m_scaleFactorComboBox->addItem(tr("Fit to page width"), static_cast< uint >(DocumentView::FitToPageWidth));
1628
m_scaleFactorComboBox->addItem(tr("Do not scale"), static_cast< uint >(DocumentView::DoNotScale));
1629
m_scaleFactorComboBox->addItem(QString(), static_cast< uint >(DocumentView::ScaleFactor));
1631
connect(m_scaleFactorComboBox, SIGNAL(currentIndexChanged(int)), SLOT(slotScaleFactorComboBoxCurrentIndexChanged(int)));
1632
connect(m_scaleFactorComboBox->lineEdit(), SIGNAL(editingFinished()), SLOT(slotScaleFactorComboBoxEditingFinished()));
1633
connect(m_scaleFactorComboBox->lineEdit(), SIGNAL(returnPressed()), SLOT(slotScaleFactorComboBoxReturnPressed()));
1637
m_searchWidget = new QWidget(this);
1638
m_searchLineEdit = new QLineEdit(m_searchWidget);
1639
m_searchTimer = new QTimer(this);
1640
m_matchCaseCheckBox = new QCheckBox(tr("Match &case"), m_searchWidget);
1641
m_highlightAllCheckBox = new QCheckBox(tr("Highlight &all"), m_searchWidget);
1642
m_searchTimer->setInterval(2000);
1643
m_searchTimer->setSingleShot(true);
1645
m_searchWidget->setLayout(new QHBoxLayout());
1646
m_searchWidget->layout()->setContentsMargins(5, 0, 5, 0);
1647
m_searchWidget->layout()->addWidget(m_searchLineEdit);
1648
m_searchWidget->layout()->addWidget(m_matchCaseCheckBox);
1649
m_searchWidget->layout()->addWidget(m_highlightAllCheckBox);
1651
connect(m_searchLineEdit, SIGNAL(textEdited(QString)), m_searchTimer, SLOT(start()));
1652
connect(m_searchLineEdit, SIGNAL(returnPressed()), this, SLOT(slotStartSearch()));
1653
connect(m_searchTimer, SIGNAL(timeout()), this, SLOT(slotStartSearch()));
1655
connect(m_highlightAllCheckBox, SIGNAL(clicked(bool)), SLOT(slotHighlightAllCheckBoxClicked(bool)));
1658
void MainWindow::createToolBars()
1662
m_fileToolBar = new QToolBar(tr("&File"));
1663
m_fileToolBar->setObjectName("fileToolBar");
1665
QStringList fileToolBar = QStringList() << "openInNewTab" << "refresh";
1666
fileToolBar = m_settings.value("mainWindow/fileToolBar", fileToolBar).toStringList();
1668
foreach(QString entry, fileToolBar)
1670
if(entry == "open") { m_fileToolBar->addAction(m_openAction); }
1671
else if(entry == "openInNewTab") { m_fileToolBar->addAction(m_openInNewTabAction); }
1672
else if(entry == "refresh") { m_fileToolBar->addAction(m_refreshAction); }
1673
else if(entry == "saveCopy") { m_fileToolBar->addAction(m_saveCopyAction); }
1674
else if(entry == "print") { m_fileToolBar->addAction(m_printAction); }
1677
addToolBar(Qt::TopToolBarArea, m_fileToolBar);
1681
m_editToolBar = new QToolBar(tr("&Edit"));
1682
m_editToolBar->setObjectName("editToolBar");
1684
QStringList editToolBar = QStringList() << "currentPage" << "numberOfPages" << "previousPage" << "nextPage";
1685
editToolBar = m_settings.value("mainWindow/editToolBar", editToolBar).toStringList();
1687
foreach(QString entry, editToolBar)
1689
if(entry == "currentPage") { m_editToolBar->addWidget(m_currentPageLineEdit); }
1690
else if(entry == "numberOfPages") { m_editToolBar->addWidget(m_numberOfPagesLabel); }
1691
else if(entry == "previousPage") { m_editToolBar->addAction(m_previousPageAction); }
1692
else if(entry == "nextPage") { m_editToolBar->addAction(m_nextPageAction); }
1693
else if(entry == "firstPage") { m_editToolBar->addAction(m_firstPageAction); }
1694
else if(entry == "lastPage") { m_editToolBar->addAction(m_lastPageAction); }
1695
else if(entry == "jumpToPage") { m_editToolBar->addAction(m_jumpToPageAction); }
1696
else if(entry == "search") { m_editToolBar->addAction(m_searchAction); }
1699
addToolBar(Qt::TopToolBarArea, m_editToolBar);
1703
m_viewToolBar = new QToolBar(tr("&View"));
1704
m_viewToolBar->setObjectName("viewToolBar");
1706
m_viewToolBar->setHidden(true);
1708
QStringList viewToolBar = QStringList() << "scaleFactor" << "zoomIn" << "zoomOut";
1709
viewToolBar = m_settings.value("mainWindow/viewToolBar", viewToolBar).toStringList();
1711
foreach(QString entry, viewToolBar)
1713
if(entry == "scaleFactor") { m_viewToolBar->addWidget(m_scaleFactorComboBox); }
1714
else if(entry == "onePage") { m_viewToolBar->addAction(m_onePageAction); }
1715
else if(entry == "twoPages") { m_viewToolBar->addAction(m_twoPagesAction); }
1716
else if(entry == "oneColumn") { m_viewToolBar->addAction(m_oneColumnAction); }
1717
else if(entry == "twoColumns") { m_viewToolBar->addAction(m_twoColumnsAction); }
1718
else if(entry == "fitToPage") { m_viewToolBar->addAction(m_fitToPageAction); }
1719
else if(entry == "fitToPageWidth") { m_viewToolBar->addAction(m_fitToPageWidthAction); }
1720
else if(entry == "doNotScale") { m_viewToolBar->addAction(m_doNotScaleAction); }
1721
else if(entry == "zoomIn") { m_viewToolBar->addAction(m_zoomInAction); }
1722
else if(entry == "zoomOut") { m_viewToolBar->addAction(m_zoomOutAction); }
1723
else if(entry == "rotateLeft") { m_viewToolBar->addAction(m_rotateLeftAction); }
1724
else if(entry == "rotateRight") { m_viewToolBar->addAction(m_rotateRightAction); }
1725
else if(entry == "fullscreen") { m_viewToolBar->addAction(m_fullscreenAction); }
1726
else if(entry == "presentation") { m_viewToolBar->addAction(m_presentationAction); }
1729
addToolBar(Qt::TopToolBarArea, m_viewToolBar);
1733
m_searchToolBar = new QToolBar(tr("&Search"));
1734
m_searchToolBar->setObjectName("searchToolBar");
1736
m_searchToolBar->setHidden(true);
1737
m_searchToolBar->setMovable(false);
1739
m_searchToolBar->addWidget(m_searchWidget);
1740
m_searchToolBar->addAction(m_findPreviousAction);
1741
m_searchToolBar->addAction(m_findNextAction);
1742
m_searchToolBar->addAction(m_cancelSearchAction);
1744
addToolBar(Qt::BottomToolBarArea, m_searchToolBar);
1747
void MainWindow::createDocks()
1751
m_outlineDock = new QDockWidget(tr("&Outline"), this);
1752
m_outlineDock->setObjectName("outlineDock");
1753
m_outlineDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1754
m_outlineDock->setFeatures(QDockWidget::AllDockWidgetFeatures);
1756
addDockWidget(Qt::LeftDockWidgetArea, m_outlineDock);
1757
m_outlineDock->hide();
1759
m_outlineDock->toggleViewAction()->setShortcut(QKeySequence(Qt::Key_F6));
1763
m_metaInformationDock = new QDockWidget(tr("&Meta-information"), this);
1764
m_metaInformationDock->setObjectName("metaInformationDock");
1765
m_metaInformationDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1766
m_metaInformationDock->setFeatures(QDockWidget::AllDockWidgetFeatures);
1768
addDockWidget(Qt::LeftDockWidgetArea, m_metaInformationDock);
1769
m_metaInformationDock->hide();
1771
m_metaInformationDock->toggleViewAction()->setShortcut(QKeySequence(Qt::Key_F7));
1775
m_thumbnailsDock = new QDockWidget(tr("&Thumbnails"), this);
1776
m_thumbnailsDock->setObjectName("thumbnailsDock");
1777
m_thumbnailsDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1778
m_thumbnailsDock->setFeatures(QDockWidget::AllDockWidgetFeatures);
1780
addDockWidget(Qt::RightDockWidgetArea, m_thumbnailsDock);
1781
m_thumbnailsDock->hide();
1783
m_thumbnailsDock->toggleViewAction()->setShortcut(QKeySequence(Qt::Key_F8));
1786
void MainWindow::createMenus()
1790
m_fileMenu = menuBar()->addMenu(tr("&File"));
1791
m_fileMenu->addAction(m_openAction);
1792
m_fileMenu->addAction(m_openInNewTabAction);
1793
m_fileMenu->addAction(m_recentlyUsedAction);
1794
m_fileMenu->addAction(m_refreshAction);
1795
m_fileMenu->addAction(m_saveCopyAction);
1796
m_fileMenu->addAction(m_printAction);
1797
m_fileMenu->addSeparator();
1798
m_fileMenu->addAction(m_exitAction);
1802
m_editMenu = menuBar()->addMenu(tr("&Edit"));
1803
m_editMenu->addAction(m_previousPageAction);
1804
m_editMenu->addAction(m_nextPageAction);
1805
m_editMenu->addAction(m_firstPageAction);
1806
m_editMenu->addAction(m_lastPageAction);
1807
m_editMenu->addAction(m_jumpToPageAction);
1808
m_editMenu->addSeparator();
1809
m_editMenu->addAction(m_searchAction);
1810
m_editMenu->addAction(m_findPreviousAction);
1811
m_editMenu->addAction(m_findNextAction);
1812
m_editMenu->addAction(m_cancelSearchAction);
1813
m_editMenu->addSeparator();
1814
m_editMenu->addAction(m_settingsAction);
1818
m_viewMenu = menuBar()->addMenu(tr("&View"));
1819
m_viewMenu->addAction(m_onePageAction);
1820
m_viewMenu->addAction(m_twoPagesAction);
1821
m_viewMenu->addAction(m_oneColumnAction);
1822
m_viewMenu->addAction(m_twoColumnsAction);
1823
m_viewMenu->addSeparator();
1824
m_viewMenu->addAction(m_fitToPageAction);
1825
m_viewMenu->addAction(m_fitToPageWidthAction);
1826
m_viewMenu->addAction(m_doNotScaleAction);
1827
m_viewMenu->addAction(m_zoomInAction);
1828
m_viewMenu->addAction(m_zoomOutAction);
1829
m_viewMenu->addSeparator();
1830
m_viewMenu->addAction(m_rotateLeftAction);
1831
m_viewMenu->addAction(m_rotateRightAction);
1832
m_viewMenu->addSeparator();
1836
QMenu* toolbarsMenu = m_viewMenu->addMenu(tr("&Toolbars"));
1837
toolbarsMenu->addAction(m_fileToolBar->toggleViewAction());
1838
toolbarsMenu->addAction(m_editToolBar->toggleViewAction());
1839
toolbarsMenu->addAction(m_viewToolBar->toggleViewAction());
1843
QMenu* docksMenu = m_viewMenu->addMenu(tr("&Docks"));
1844
docksMenu->addAction(m_outlineDock->toggleViewAction());
1845
docksMenu->addAction(m_metaInformationDock->toggleViewAction());
1846
docksMenu->addAction(m_thumbnailsDock->toggleViewAction());
1848
m_viewMenu->addAction(m_fontsAction);
1850
m_viewMenu->addAction(m_fullscreenAction);
1851
m_viewMenu->addAction(m_presentationAction);
1855
m_tabMenu = menuBar()->addMenu(tr("&Tab"));
1856
m_tabMenu->addAction(m_previousTabAction);
1857
m_tabMenu->addAction(m_nextTabAction);
1858
m_tabMenu->addSeparator();
1859
m_tabMenu->addAction(m_closeTabAction);
1860
m_tabMenu->addAction(m_closeAllTabsAction);
1861
m_tabMenu->addAction(m_closeAllTabsButCurrentTabAction);
1862
m_tabMenu->addSeparator();
1866
m_helpMenu = menuBar()->addMenu(tr("&Help"));
1867
m_helpMenu->addAction(m_contentsAction);
1868
m_helpMenu->addAction(m_aboutAction);
1873
MainWindowAdaptor::MainWindowAdaptor(MainWindow* mainWindow) : QDBusAbstractAdaptor(mainWindow)
1877
bool MainWindowAdaptor::open(const QString& filePath, int page, qreal top)
1879
MainWindow* mainWindow = qobject_cast< MainWindow* >(parent()); Q_ASSERT(mainWindow);
1881
return mainWindow->open(filePath, page, top);
1884
bool MainWindowAdaptor::openInNewTab(const QString& filePath, int page, qreal top)
1886
MainWindow* mainWindow = qobject_cast< MainWindow* >(parent()); Q_ASSERT(mainWindow);
1888
return mainWindow->openInNewTab(filePath, page, top);
1891
void MainWindowAdaptor::refresh(const QString& filePath, int page, qreal top)
1893
MainWindow* mainWindow = qobject_cast< MainWindow* >(parent()); Q_ASSERT(mainWindow);
1895
bool openInNewTab = true;
1896
QFileInfo fileInfo(filePath);
1898
for(int index = 0; index < mainWindow->m_tabWidget->count(); index++)
1900
DocumentView* documentView = qobject_cast< DocumentView* >(mainWindow->m_tabWidget->widget(index)); Q_ASSERT(documentView);
1902
if(QFileInfo(documentView->filePath()).absoluteFilePath() == fileInfo.absoluteFilePath())
1904
documentView->refresh();
1905
documentView->setCurrentPage(page, top);
1907
mainWindow->m_tabWidget->setCurrentIndex(index);
1909
openInNewTab = false;
1915
mainWindow->openInNewTab(filePath, page, top);