9 |
9 |
10 import contextlib |
10 import contextlib |
11 import os |
11 import os |
12 import pathlib |
12 import pathlib |
13 |
13 |
14 from PyQt6.QtCore import Qt, pyqtSignal, QSize, pyqtSlot, QPointF |
14 from PyQt6.QtCore import QPointF, QSize, Qt, pyqtSignal, pyqtSlot |
15 from PyQt6.QtGui import ( |
15 from PyQt6.QtGui import QAction, QActionGroup, QClipboard, QGuiApplication, QKeySequence |
16 QAction, QKeySequence, QActionGroup, QGuiApplication, QClipboard |
|
17 ) |
|
18 from PyQt6.QtPdf import QPdfDocument, QPdfLink |
16 from PyQt6.QtPdf import QPdfDocument, QPdfLink |
19 from PyQt6.QtPdfWidgets import QPdfView |
17 from PyQt6.QtPdfWidgets import QPdfView |
20 from PyQt6.QtWidgets import ( |
18 from PyQt6.QtWidgets import ( |
21 QWhatsThis, QMenu, QTabWidget, QSplitter, QToolBar, QDialog, QInputDialog, |
19 QDialog, |
22 QLineEdit |
20 QInputDialog, |
|
21 QLineEdit, |
|
22 QMenu, |
|
23 QSplitter, |
|
24 QTabWidget, |
|
25 QToolBar, |
|
26 QWhatsThis, |
23 ) |
27 ) |
24 |
28 |
25 from eric7 import Preferences |
29 from eric7 import Preferences |
26 from eric7.EricGui import EricPixmapCache |
30 from eric7.EricGui import EricPixmapCache |
27 from eric7.EricGui.EricAction import EricAction |
31 from eric7.EricGui.EricAction import EricAction |
29 from eric7.EricWidgets.EricMainWindow import EricMainWindow |
33 from eric7.EricWidgets.EricMainWindow import EricMainWindow |
30 from eric7.EricWidgets.EricStretchableSpacer import EricStretchableSpacer |
34 from eric7.EricWidgets.EricStretchableSpacer import EricStretchableSpacer |
31 from eric7.Globals import recentNamePdfFiles |
35 from eric7.Globals import recentNamePdfFiles |
32 from eric7.SystemUtilities import FileSystemUtilities, OSUtilities |
36 from eric7.SystemUtilities import FileSystemUtilities, OSUtilities |
33 |
37 |
|
38 from .PdfInfoWidget import PdfInfoWidget |
34 from .PdfPageSelector import PdfPageSelector |
39 from .PdfPageSelector import PdfPageSelector |
|
40 from .PdfSearchWidget import PdfSearchWidget |
|
41 from .PdfToCWidget import PdfToCWidget |
|
42 from .PdfView import PdfView |
35 from .PdfZoomSelector import PdfZoomSelector |
43 from .PdfZoomSelector import PdfZoomSelector |
36 from .PdfToCWidget import PdfToCWidget |
|
37 from .PdfInfoWidget import PdfInfoWidget |
|
38 from .PdfSearchWidget import PdfSearchWidget |
|
39 from .PdfView import PdfView |
|
40 |
44 |
41 |
45 |
42 class PdfViewerWindow(EricMainWindow): |
46 class PdfViewerWindow(EricMainWindow): |
43 """ |
47 """ |
44 Class implementing the PDF viewer main window. |
48 Class implementing the PDF viewer main window. |
368 QKeySequence(self.tr("Ctrl+End", "Goto|End")), |
372 QKeySequence(self.tr("Ctrl+End", "Goto|End")), |
369 0, |
373 0, |
370 self, |
374 self, |
371 "pdfviewer_goto_end", |
375 "pdfviewer_goto_end", |
372 ) |
376 ) |
373 self.endDocumentAct.setStatusTip( |
377 self.endDocumentAct.setStatusTip(self.tr("Go to the last page of the document")) |
374 self.tr("Go to the last page of the document") |
|
375 ) |
|
376 self.endDocumentAct.triggered.connect(self.__endDocument) |
378 self.endDocumentAct.triggered.connect(self.__endDocument) |
377 self.__actions.append(self.endDocumentAct) |
379 self.__actions.append(self.endDocumentAct) |
378 |
380 |
379 self.backwardAct = EricAction( |
381 self.backwardAct = EricAction( |
380 self.tr("Back"), |
382 self.tr("Back"), |
383 QKeySequence(self.tr("Alt+Shift+Left", "Goto|Back")), |
385 QKeySequence(self.tr("Alt+Shift+Left", "Goto|Back")), |
384 0, |
386 0, |
385 self, |
387 self, |
386 "pdfviewer_goto_back", |
388 "pdfviewer_goto_back", |
387 ) |
389 ) |
388 self.backwardAct.setStatusTip( |
390 self.backwardAct.setStatusTip(self.tr("Go back in the view history")) |
389 self.tr("Go back in the view history") |
|
390 ) |
|
391 self.backwardAct.triggered.connect(self.__backInHistory) |
391 self.backwardAct.triggered.connect(self.__backInHistory) |
392 self.__actions.append(self.backwardAct) |
392 self.__actions.append(self.backwardAct) |
393 |
393 |
394 self.forwardAct = EricAction( |
394 self.forwardAct = EricAction( |
395 self.tr("Forward"), |
395 self.tr("Forward"), |
398 QKeySequence(self.tr("Alt+Shift+Right", "Goto|Forward")), |
398 QKeySequence(self.tr("Alt+Shift+Right", "Goto|Forward")), |
399 0, |
399 0, |
400 self, |
400 self, |
401 "pdfviewer_goto_forward", |
401 "pdfviewer_goto_forward", |
402 ) |
402 ) |
403 self.forwardAct.setStatusTip( |
403 self.forwardAct.setStatusTip(self.tr("Go forward in the view history")) |
404 self.tr("Go forward in the view history") |
|
405 ) |
|
406 self.forwardAct.triggered.connect(self.__forwardInHistory) |
404 self.forwardAct.triggered.connect(self.__forwardInHistory) |
407 self.__actions.append(self.forwardAct) |
405 self.__actions.append(self.forwardAct) |
408 |
406 |
409 self.gotoAct = EricAction( |
407 self.gotoAct = EricAction( |
410 self.tr("Go to Page"), |
408 self.tr("Go to Page"), |
413 QKeySequence(self.tr("Ctrl+G", "Goto|Go to Page")), |
411 QKeySequence(self.tr("Ctrl+G", "Goto|Go to Page")), |
414 0, |
412 0, |
415 self, |
413 self, |
416 "pdfviewer_goto_gotopage", |
414 "pdfviewer_goto_gotopage", |
417 ) |
415 ) |
418 self.gotoAct.setStatusTip( |
416 self.gotoAct.setStatusTip(self.tr("Jump to a page selected via a dialog")) |
419 self.tr("Jump to a page selected via a dialog") |
|
420 ) |
|
421 self.gotoAct.triggered.connect(self.__gotoPage) |
417 self.gotoAct.triggered.connect(self.__gotoPage) |
422 self.__actions.append(self.gotoAct) |
418 self.__actions.append(self.gotoAct) |
423 |
419 |
424 def __initViewActions(self): |
420 def __initViewActions(self): |
425 """ |
421 """ |
517 self, |
513 self, |
518 "pdfviewer_edit_copy", |
514 "pdfviewer_edit_copy", |
519 ) |
515 ) |
520 self.copyAct.triggered.connect(self.__copyText) |
516 self.copyAct.triggered.connect(self.__copyText) |
521 self.__actions.append(self.copyAct) |
517 self.__actions.append(self.copyAct) |
522 |
518 |
523 self.copyAllAct = EricAction( |
519 self.copyAllAct = EricAction( |
524 self.tr("Copy All Text"), |
520 self.tr("Copy All Text"), |
525 self.tr("Copy &All Text"), |
521 self.tr("Copy &All Text"), |
526 QKeySequence(self.tr("Alt+Ctrl+C", "Edit|Copy All Text")), |
522 QKeySequence(self.tr("Alt+Ctrl+C", "Edit|Copy All Text")), |
527 0, |
523 0, |
1142 Private slot to show a little About message. |
1138 Private slot to show a little About message. |
1143 """ |
1139 """ |
1144 EricMessageBox.about( |
1140 EricMessageBox.about( |
1145 self, |
1141 self, |
1146 self.tr("About eric PDF Viewer"), |
1142 self.tr("About eric PDF Viewer"), |
1147 self.tr( |
1143 self.tr("The eric PDF Viewer is a simple component for viewing PDF files."), |
1148 "The eric PDF Viewer is a simple component for viewing PDF files." |
|
1149 ), |
|
1150 ) |
1144 ) |
1151 |
1145 |
1152 @pyqtSlot() |
1146 @pyqtSlot() |
1153 def __aboutQt(self): |
1147 def __aboutQt(self): |
1154 """ |
1148 """ |
1437 self.__view.setPageMode(QPdfView.PageMode.SinglePage) |
1431 self.__view.setPageMode(QPdfView.PageMode.SinglePage) |
1438 self.__singlePageAct.setChecked(True) |
1432 self.__singlePageAct.setChecked(True) |
1439 else: |
1433 else: |
1440 self.__view.setPageMode(QPdfView.PageMode.MultiPage) |
1434 self.__view.setPageMode(QPdfView.PageMode.MultiPage) |
1441 self.__continuousPageAct.setChecked(True) |
1435 self.__continuousPageAct.setChecked(True) |
1442 return |
1436 return |
1443 |
1437 |
1444 @pyqtSlot(bool) |
1438 @pyqtSlot(bool) |
1445 def __toggleSideBar(self, visible): |
1439 def __toggleSideBar(self, visible): |
1446 """ |
1440 """ |
1447 Private slot to togle the sidebar (info) widget. |
1441 Private slot to togle the sidebar (info) widget. |