Compare commits
10 Commits
50b14562fc
...
1bdd6f0c1e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1bdd6f0c1e | ||
|
|
72a262c718 | ||
|
|
eaaa00890e | ||
|
|
a48e39d9ac | ||
|
|
babff15a24 | ||
|
|
e682fba042 | ||
|
|
4b4758b747 | ||
|
|
918510d5e6 | ||
|
|
c2e0cbf9a1 | ||
|
|
9f1c54c1e7 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,3 +5,4 @@ venv
|
|||||||
*.db
|
*.db
|
||||||
__pycache__
|
__pycache__
|
||||||
DocketPDF
|
DocketPDF
|
||||||
|
example
|
||||||
|
|||||||
@@ -1,49 +1,30 @@
|
|||||||
from typing import Any, Self, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from PySide6.QtCore import (
|
from PySide6.QtCore import (
|
||||||
QDate,
|
QDate,
|
||||||
QEvent,
|
|
||||||
QModelIndex,
|
QModelIndex,
|
||||||
QObject,
|
|
||||||
QPersistentModelIndex,
|
QPersistentModelIndex,
|
||||||
QPoint,
|
QPoint,
|
||||||
QRect,
|
|
||||||
QSize,
|
|
||||||
Qt,
|
Qt,
|
||||||
Signal,
|
Signal,
|
||||||
Slot,
|
Slot,
|
||||||
)
|
)
|
||||||
from PySide6.QtGui import (
|
from PySide6.QtGui import (
|
||||||
QColor,
|
QColor,
|
||||||
QFont,
|
|
||||||
QPainter,
|
|
||||||
QTextDocument,
|
|
||||||
QTextDocumentFragment,
|
|
||||||
)
|
)
|
||||||
from PySide6.QtSql import QSqlTableModel
|
from PySide6.QtSql import QSqlTableModel
|
||||||
from PySide6.QtWidgets import (
|
from PySide6.QtWidgets import (
|
||||||
QAbstractItemView,
|
QAbstractItemView,
|
||||||
QHeaderView,
|
QHeaderView,
|
||||||
QMainWindow,
|
QMainWindow,
|
||||||
QStyle,
|
|
||||||
QStyledItemDelegate,
|
QStyledItemDelegate,
|
||||||
QStyleOptionViewItem,
|
QStyleOptionViewItem,
|
||||||
QTableView,
|
|
||||||
QWidget,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from docketModel import docketModel
|
from docketModel import docketModel
|
||||||
from dockettableview import documentDelegate
|
from lib.utils import QStyleOptionViewItemInit
|
||||||
from ui.MainWindow import Ui_MainWindow
|
from ui.MainWindow import Ui_MainWindow
|
||||||
from workers import loadCases, updateThread
|
from workers import updateThread
|
||||||
|
|
||||||
|
|
||||||
class QStyleOptionViewItemInit(QStyleOptionViewItem):
|
|
||||||
backgroundBrush: QColor
|
|
||||||
rect: QRect
|
|
||||||
widget: QWidget
|
|
||||||
font: QFont
|
|
||||||
text: str
|
|
||||||
|
|
||||||
|
|
||||||
class dateDelegate(QStyledItemDelegate):
|
class dateDelegate(QStyledItemDelegate):
|
||||||
@@ -59,7 +40,10 @@ class dateDelegate(QStyledItemDelegate):
|
|||||||
options = cast(QStyleOptionViewItemInit, option)
|
options = cast(QStyleOptionViewItemInit, option)
|
||||||
super().initStyleOption(options, index)
|
super().initStyleOption(options, index)
|
||||||
assert isinstance(index, QModelIndex)
|
assert isinstance(index, QModelIndex)
|
||||||
if index.siblingAtColumn(5).data() == 0:
|
if (
|
||||||
|
index.siblingAtColumn(5).data(Qt.ItemDataRole.CheckStateRole)
|
||||||
|
== Qt.CheckState.Unchecked
|
||||||
|
):
|
||||||
options.backgroundBrush = QColor(0x444444)
|
options.backgroundBrush = QColor(0x444444)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -74,11 +58,58 @@ class activeDelegate(QStyledItemDelegate):
|
|||||||
options = cast(QStyleOptionViewItemInit, option)
|
options = cast(QStyleOptionViewItemInit, option)
|
||||||
super().initStyleOption(options, index)
|
super().initStyleOption(options, index)
|
||||||
assert isinstance(index, QModelIndex)
|
assert isinstance(index, QModelIndex)
|
||||||
if index.siblingAtColumn(5).data() == 0:
|
if (
|
||||||
|
index.siblingAtColumn(5).data(Qt.ItemDataRole.CheckStateRole)
|
||||||
|
== Qt.CheckState.Unchecked
|
||||||
|
):
|
||||||
options.backgroundBrush = QColor(0x444444)
|
options.backgroundBrush = QColor(0x444444)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class casesModel(QSqlTableModel):
|
||||||
|
def flags(self, index: QModelIndex | QPersistentModelIndex) -> Qt.ItemFlag:
|
||||||
|
if not index.isValid():
|
||||||
|
return Qt.ItemFlag.NoItemFlags
|
||||||
|
flags = super(casesModel, self).flags(index)
|
||||||
|
if index.column() == 5:
|
||||||
|
flags = (
|
||||||
|
Qt.ItemFlag.ItemIsEnabled
|
||||||
|
| Qt.ItemFlag.ItemIsEditable
|
||||||
|
| Qt.ItemFlag.ItemIsUserCheckable
|
||||||
|
)
|
||||||
|
return flags
|
||||||
|
|
||||||
|
def data(
|
||||||
|
self,
|
||||||
|
index: QModelIndex | QPersistentModelIndex,
|
||||||
|
role: int = Qt.ItemDataRole.DisplayRole,
|
||||||
|
) -> Any:
|
||||||
|
if not index.isValid():
|
||||||
|
return None
|
||||||
|
if index.column() == 5:
|
||||||
|
if role == Qt.ItemDataRole.CheckStateRole:
|
||||||
|
value = super(casesModel, self).data(index)
|
||||||
|
return (
|
||||||
|
Qt.CheckState.Checked
|
||||||
|
if value == 1
|
||||||
|
else Qt.CheckState.Unchecked
|
||||||
|
)
|
||||||
|
elif role == Qt.ItemDataRole.DisplayRole:
|
||||||
|
return ""
|
||||||
|
return super().data(index, role)
|
||||||
|
|
||||||
|
def setData(
|
||||||
|
self,
|
||||||
|
index: QModelIndex | QPersistentModelIndex,
|
||||||
|
value: Any,
|
||||||
|
role: int = Qt.ItemDataRole.DisplayRole,
|
||||||
|
) -> bool:
|
||||||
|
if role == Qt.ItemDataRole.CheckStateRole and index.column() == 5:
|
||||||
|
super(casesModel, self).setData(index, 1 if value else 0)
|
||||||
|
return True
|
||||||
|
return super().setData(index, value, role)
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(QMainWindow, Ui_MainWindow):
|
class MainWindow(QMainWindow, Ui_MainWindow):
|
||||||
show_entries = Signal(int)
|
show_entries = Signal(int)
|
||||||
|
|
||||||
@@ -87,17 +118,19 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super(MainWindow, self).__init__()
|
super(MainWindow, self).__init__()
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
# self.loadThread = loadCases()
|
|
||||||
# self.loadThread.finished.connect(self.updateDone)
|
|
||||||
# self.loadThread.start()
|
|
||||||
|
|
||||||
model = QSqlTableModel()
|
model = casesModel()
|
||||||
model.setTable("cases")
|
model.setTable("cases")
|
||||||
model.sort(1, Qt.SortOrder.AscendingOrder)
|
# model.sort(1, Qt.SortOrder.AscendingOrder)
|
||||||
|
model.setFilter(
|
||||||
|
"1=1 ORDER BY SUBSTRING(docket_id, 1, 3), CAST(SUBSTRING(docket_id,4) AS INTEGER)"
|
||||||
|
)
|
||||||
model.select()
|
model.select()
|
||||||
model.setHeaderData(1, Qt.Orientation.Horizontal, "Docket")
|
model.setHeaderData(1, Qt.Orientation.Horizontal, "Docket")
|
||||||
model.setHeaderData(2, Qt.Orientation.Horizontal, "Petitioners")
|
model.setHeaderData(2, Qt.Orientation.Horizontal, "Petitioners")
|
||||||
model.setHeaderData(3, Qt.Orientation.Horizontal, "Respondents")
|
model.setHeaderData(3, Qt.Orientation.Horizontal, "Respondents")
|
||||||
|
model.setHeaderData(4, Qt.Orientation.Horizontal, "Date")
|
||||||
|
model.setHeaderData(5, Qt.Orientation.Horizontal, "Active")
|
||||||
self.casesView.setModel(model)
|
self.casesView.setModel(model)
|
||||||
|
|
||||||
self.casesView.setSelectionMode(
|
self.casesView.setSelectionMode(
|
||||||
@@ -133,7 +166,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||||||
self.docketView.horizontalHeader().setSectionResizeMode(
|
self.docketView.horizontalHeader().setSectionResizeMode(
|
||||||
1, QHeaderView.ResizeMode.Stretch
|
1, QHeaderView.ResizeMode.Stretch
|
||||||
)
|
)
|
||||||
self.docketView.resizeRowsToContents()
|
# self.docketView.resizeRowsToContents()
|
||||||
# self.docketView.setItemDelegateForColumn(1, documentDelegate())
|
# self.docketView.setItemDelegateForColumn(1, documentDelegate())
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -161,6 +194,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||||||
assert isinstance(self.updateThread, updateThread)
|
assert isinstance(self.updateThread, updateThread)
|
||||||
self.updateThread.finished.connect(self.updateDone)
|
self.updateThread.finished.connect(self.updateDone)
|
||||||
self.updateThread.setDocketId(text)
|
self.updateThread.setDocketId(text)
|
||||||
|
self.updateThread.setDocketId(text)
|
||||||
self.updateThread.start()
|
self.updateThread.start()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ from PySide6.QtCore import (
|
|||||||
QObject,
|
QObject,
|
||||||
QPersistentModelIndex,
|
QPersistentModelIndex,
|
||||||
QPoint,
|
QPoint,
|
||||||
QRect,
|
|
||||||
QSize,
|
QSize,
|
||||||
Qt,
|
Qt,
|
||||||
QUrl,
|
QUrl,
|
||||||
@@ -16,11 +15,7 @@ from PySide6.QtCore import (
|
|||||||
Slot,
|
Slot,
|
||||||
)
|
)
|
||||||
from PySide6.QtGui import (
|
from PySide6.QtGui import (
|
||||||
QColor,
|
|
||||||
QFont,
|
|
||||||
QMouseEvent,
|
QMouseEvent,
|
||||||
QPaintEvent,
|
|
||||||
QPainter,
|
|
||||||
QPalette,
|
QPalette,
|
||||||
QTextDocument,
|
QTextDocument,
|
||||||
)
|
)
|
||||||
@@ -30,8 +25,8 @@ from PySide6.QtNetwork import (
|
|||||||
QNetworkRequest,
|
QNetworkRequest,
|
||||||
)
|
)
|
||||||
from PySide6.QtWidgets import (
|
from PySide6.QtWidgets import (
|
||||||
|
QAbstractItemView,
|
||||||
QSizePolicy,
|
QSizePolicy,
|
||||||
QStyle,
|
|
||||||
QStyledItemDelegate,
|
QStyledItemDelegate,
|
||||||
QStyleOptionViewItem,
|
QStyleOptionViewItem,
|
||||||
QTableView,
|
QTableView,
|
||||||
@@ -42,80 +37,35 @@ from PySide6.QtWidgets import (
|
|||||||
from pdfView import PDFViewer
|
from pdfView import PDFViewer
|
||||||
|
|
||||||
|
|
||||||
class QStyleOptionViewItemInit(QStyleOptionViewItem):
|
class docketEntryDelegate(QStyledItemDelegate):
|
||||||
backgroundBrush: QColor
|
def __init__(
|
||||||
rect: QRect
|
self, view: QAbstractItemView, parent: QWidget | None = None
|
||||||
widget: QWidget
|
|
||||||
font: QFont
|
|
||||||
text: str
|
|
||||||
|
|
||||||
|
|
||||||
class documentDelegate(QStyledItemDelegate):
|
|
||||||
def initStyleOption(
|
|
||||||
self,
|
|
||||||
option: QStyleOptionViewItem,
|
|
||||||
index: QModelIndex | QPersistentModelIndex,
|
|
||||||
/,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
options = cast(QStyleOptionViewItemInit, option)
|
super(docketEntryDelegate, self).__init__(parent)
|
||||||
super().initStyleOption(options, index)
|
self.view = view
|
||||||
assert index.isValid() and isinstance(index, QModelIndex)
|
|
||||||
if index.siblingAtColumn(6).data() == 0:
|
|
||||||
options.backgroundBrush = QColor(0x444444)
|
|
||||||
return
|
|
||||||
|
|
||||||
def paint(
|
|
||||||
self,
|
|
||||||
painter: QPainter,
|
|
||||||
option: QStyleOptionViewItem,
|
|
||||||
index: QModelIndex | QPersistentModelIndex,
|
|
||||||
) -> None:
|
|
||||||
options = cast(QStyleOptionViewItemInit, option)
|
|
||||||
self.initStyleOption(options, index)
|
|
||||||
painter.save()
|
|
||||||
doc = QTextDocument()
|
|
||||||
doc.setTextWidth(options.rect.width())
|
|
||||||
doc.setHtml(options.text)
|
|
||||||
options.text = ""
|
|
||||||
options.widget.style().drawControl(
|
|
||||||
QStyle.ControlElement.CE_ItemViewItem,
|
|
||||||
options,
|
|
||||||
painter,
|
|
||||||
)
|
|
||||||
painter.translate(options.rect.left(), options.rect.top())
|
|
||||||
clip = QRect(0, 0, options.rect.width(), options.rect.height())
|
|
||||||
doc.drawContents(painter, clip)
|
|
||||||
painter.restore()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def sizeHint(
|
def sizeHint(
|
||||||
self,
|
self,
|
||||||
option: QStyleOptionViewItem,
|
_: QStyleOptionViewItem,
|
||||||
index: QModelIndex | QPersistentModelIndex,
|
index: QModelIndex | QPersistentModelIndex,
|
||||||
) -> QSize:
|
) -> QSize:
|
||||||
options = cast(QStyleOptionViewItemInit, option)
|
widget = self.view.indexWidget(index)
|
||||||
self.initStyleOption(options, index)
|
return widget.sizeHint()
|
||||||
doc = QTextDocument()
|
|
||||||
doc.setTextWidth(options.rect.width())
|
|
||||||
doc.setHtml(options.text)
|
|
||||||
doc.setTextWidth(options.rect.width())
|
|
||||||
print(f"sizeHint: {doc.idealWidth()}, {doc.size().height()}")
|
|
||||||
return QSize(int(doc.idealWidth()), int(doc.size().height()))
|
|
||||||
|
|
||||||
|
|
||||||
class docketEntry(QTextEdit):
|
class docketEntry(QTextEdit):
|
||||||
def __init__(self, parent: QWidget | None = None) -> None:
|
def __init__(self, parent: QWidget | None = None) -> None:
|
||||||
super(docketEntry, self).__init__(parent)
|
super(docketEntry, self).__init__(parent)
|
||||||
self.setSizePolicy(QSizePolicy.Policy.Preferred ,
|
self.setSizePolicy(
|
||||||
QSizePolicy.Policy.Fixed)
|
QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Fixed
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
def mousePressEvent(self, e: QMouseEvent) -> None:
|
def mousePressEvent(self, e: QMouseEvent) -> None:
|
||||||
super().mousePressEvent(e)
|
super().mousePressEvent(e)
|
||||||
anchor = self.anchorAt(e.pos())
|
anchor = self.anchorAt(e.pos())
|
||||||
print(f"self.size(): {self.size()}")
|
|
||||||
if anchor:
|
if anchor:
|
||||||
print(f"Anchors away: {anchor}")
|
|
||||||
obj = cast(QObject, self)
|
obj = cast(QObject, self)
|
||||||
while not isinstance(obj, docketTableView) and obj is not None:
|
while not isinstance(obj, docketTableView) and obj is not None:
|
||||||
obj = obj.parent()
|
obj = obj.parent()
|
||||||
@@ -132,20 +82,18 @@ class docketEntry(QTextEdit):
|
|||||||
docSize = doc.size()
|
docSize = doc.size()
|
||||||
return QSize(size.width(), int(docSize.height()))
|
return QSize(size.width(), int(docSize.height()))
|
||||||
|
|
||||||
def paintEvent(self, e: QPaintEvent) -> None:
|
|
||||||
print(f"event.rect: {e.rect()}, size: {self.size()}")
|
|
||||||
print(self.document().toPlainText())
|
|
||||||
return super().paintEvent(e)
|
|
||||||
|
|
||||||
|
|
||||||
class docketTableView(QTableView):
|
class docketTableView(QTableView):
|
||||||
manager = QNetworkAccessManager()
|
manager: QNetworkAccessManager
|
||||||
clickedEvent = Signal(QPoint)
|
clickedEvent = Signal(QPoint)
|
||||||
anchorSignal = Signal(QModelIndex, str)
|
anchorSignal = Signal(QModelIndex, str)
|
||||||
|
pdf: PDFViewer
|
||||||
|
|
||||||
def __init__(self, parent: QWidget | None = None) -> None:
|
def __init__(self, parent: QWidget | None = None) -> None:
|
||||||
super(docketTableView, self).__init__(parent)
|
super(docketTableView, self).__init__(parent)
|
||||||
|
self.setItemDelegateForColumn(1, docketEntryDelegate(self))
|
||||||
self.anchorSignal.connect(self.doAnchor)
|
self.anchorSignal.connect(self.doAnchor)
|
||||||
|
self.manager = QNetworkAccessManager()
|
||||||
self.manager.finished.connect(self.getDone)
|
self.manager.finished.connect(self.getDone)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -153,7 +101,6 @@ class docketTableView(QTableView):
|
|||||||
assert model is not None
|
assert model is not None
|
||||||
super().setModel(model)
|
super().setModel(model)
|
||||||
self.model().modelReset.connect(self.modelReset)
|
self.model().modelReset.connect(self.modelReset)
|
||||||
print("Setting Model")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@Slot(QNetworkReply) # type: ignore
|
@Slot(QNetworkReply) # type: ignore
|
||||||
@@ -163,27 +110,27 @@ class docketTableView(QTableView):
|
|||||||
dest.write(reply.readAll())
|
dest.write(reply.readAll())
|
||||||
dest.close()
|
dest.close()
|
||||||
reply.deleteLater()
|
reply.deleteLater()
|
||||||
self.pdf = PDFViewer(self)
|
self.pdf.open(dest)
|
||||||
self.pdf.load_pdf(dest)
|
|
||||||
self.pdf.show()
|
self.pdf.show()
|
||||||
return
|
return
|
||||||
|
|
||||||
@Slot(QModelIndex, str) # type: ignore
|
@Slot(QModelIndex, str) # type: ignore
|
||||||
def doAnchor(self, index: QModelIndex, anchor: str) -> None:
|
def doAnchor(self, _: QModelIndex, anchor: str) -> None:
|
||||||
url = QUrl(anchor)
|
url = QUrl(anchor)
|
||||||
print(f"{index.row()}, {index.column()} -> {url.path()}")
|
|
||||||
dirs = url.path().split("/")
|
dirs = url.path().split("/")
|
||||||
dirs.pop()
|
dirs.pop()
|
||||||
dirs.pop(0)
|
dirs.pop(0)
|
||||||
currentDir = QDir()
|
currentDir = QDir()
|
||||||
path = "/".join(dirs)
|
path = "/".join(dirs)
|
||||||
currentDir.mkpath(path)
|
currentDir.mkpath(path)
|
||||||
if QDir("." + url.path()).exists():
|
print(f"Checking for .{url.path()} existance.")
|
||||||
file = QFile("." + url.path())
|
if not hasattr(self, "pdf"):
|
||||||
self.pdf = PDFViewer(self)
|
self.pdf = PDFViewer(self)
|
||||||
self.pdf.load_pdf(file)
|
if QFile("." + url.path()).exists():
|
||||||
|
self.pdf.open(QFile("." + url.path()))
|
||||||
self.pdf.show()
|
self.pdf.show()
|
||||||
else:
|
else:
|
||||||
|
print(f"Fetching {url}")
|
||||||
self.manager.get(QNetworkRequest(url))
|
self.manager.get(QNetworkRequest(url))
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -200,16 +147,3 @@ class docketTableView(QTableView):
|
|||||||
widget.setPalette(red)
|
widget.setPalette(red)
|
||||||
self.setIndexWidget(index, widget)
|
self.setIndexWidget(index, widget)
|
||||||
return
|
return
|
||||||
|
|
||||||
def paintEvent(self, e: QPaintEvent) -> None:
|
|
||||||
|
|
||||||
for row in range(0, self.model().rowCount()):
|
|
||||||
index = self.model().index(row, 1)
|
|
||||||
widget = cast(docketEntry, self.indexWidget(index))
|
|
||||||
print(f"{row}: {widget.toPlainText()}")
|
|
||||||
print(f"{row}: {widget.sizeHint()}")
|
|
||||||
print(f"{row}: {widget.size()}")
|
|
||||||
print()
|
|
||||||
widget.resize(75,27)
|
|
||||||
super().paintEvent(e)
|
|
||||||
return
|
|
||||||
|
|||||||
14
lib/utils.py
14
lib/utils.py
@@ -1,7 +1,9 @@
|
|||||||
from typing import NoReturn
|
from typing import NoReturn, cast
|
||||||
|
|
||||||
from PySide6.QtCore import QCoreApplication
|
from PySide6.QtCore import QCoreApplication, QObject, QRect, Signal
|
||||||
|
from PySide6.QtGui import QColor, QFont
|
||||||
from PySide6.QtSql import QSqlQuery
|
from PySide6.QtSql import QSqlQuery
|
||||||
|
from PySide6.QtWidgets import QStyleOptionViewItem, QWidget
|
||||||
|
|
||||||
translate = QCoreApplication.translate
|
translate = QCoreApplication.translate
|
||||||
|
|
||||||
@@ -18,3 +20,11 @@ def query_error(query: QSqlQuery) -> NoReturn:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
raise Exception(translate("MainWindow", "SQL Error"))
|
raise Exception(translate("MainWindow", "SQL Error"))
|
||||||
|
|
||||||
|
|
||||||
|
class QStyleOptionViewItemInit(QStyleOptionViewItem):
|
||||||
|
backgroundBrush: QColor
|
||||||
|
rect: QRect
|
||||||
|
widget: QWidget
|
||||||
|
font: QFont
|
||||||
|
text: str
|
||||||
|
|||||||
213
pdfView.py
213
pdfView.py
@@ -1,31 +1,202 @@
|
|||||||
from PySide6.QtCore import QFile
|
import math
|
||||||
from PySide6.QtPdf import QPdfDocument
|
|
||||||
|
from PySide6.QtCore import QFile, QModelIndex, QPoint, Signal, Slot
|
||||||
|
from PySide6.QtPdf import QPdfBookmarkModel, QPdfDocument
|
||||||
from PySide6.QtPdfWidgets import QPdfView
|
from PySide6.QtPdfWidgets import QPdfView
|
||||||
from PySide6.QtWidgets import QDialog, QVBoxLayout, QWidget
|
from PySide6.QtWidgets import QComboBox, QDialog, QMenuBar, QSpinBox, QWidget
|
||||||
|
|
||||||
|
from ui.pdfViewer import Ui_pdfViewer
|
||||||
|
|
||||||
|
ZOOM_MULTIPLIER = math.sqrt(2.0)
|
||||||
|
|
||||||
|
|
||||||
class PDFViewer(QDialog):
|
class ZoomSelector(QComboBox):
|
||||||
pdf_view: QPdfView
|
zoom_mode_changed = Signal(QPdfView.ZoomMode)
|
||||||
pdf_document: QPdfDocument
|
zoom_factor_changed = Signal(float)
|
||||||
|
|
||||||
def __init__(self, parent: QWidget) -> None:
|
def __init__(self, parent: QWidget | None = None) -> None:
|
||||||
|
super(ZoomSelector, self).__init__(parent)
|
||||||
|
self.setEditable(True)
|
||||||
|
|
||||||
|
for text in [
|
||||||
|
"Fit Width",
|
||||||
|
"Fit Page",
|
||||||
|
"12%",
|
||||||
|
"25%",
|
||||||
|
"33%",
|
||||||
|
"50%",
|
||||||
|
"66%",
|
||||||
|
"75%",
|
||||||
|
"100%",
|
||||||
|
"125%",
|
||||||
|
"150%",
|
||||||
|
"200%",
|
||||||
|
"400%",
|
||||||
|
]:
|
||||||
|
self.addItem(text)
|
||||||
|
self.currentTextChanged.connect(self.on_current_text_changed)
|
||||||
|
lineEdit = self.lineEdit()
|
||||||
|
assert lineEdit is not None
|
||||||
|
lineEdit.editingFinished.connect(self._editing_finished)
|
||||||
|
return
|
||||||
|
|
||||||
|
@Slot(float) # type: ignore
|
||||||
|
def set_zoom_factor(self, zoomFactor: float) -> None:
|
||||||
|
percent = int(zoomFactor * 100)
|
||||||
|
self.setCurrentText(f"{percent}%")
|
||||||
|
return
|
||||||
|
|
||||||
|
@Slot()
|
||||||
|
def reset(self) -> None:
|
||||||
|
self.setCurrentIndex(8) # 100%
|
||||||
|
return
|
||||||
|
|
||||||
|
@Slot(str) # type: ignore
|
||||||
|
def on_current_text_changed(self, text: str) -> None:
|
||||||
|
if text == "Fit Width":
|
||||||
|
self.zoom_mode_changed.emit(QPdfView.ZoomMode.FitToWidth)
|
||||||
|
elif text == "Fit Page":
|
||||||
|
self.zoom_mode_changed.emit(QPdfView.ZoomMode.FitInView)
|
||||||
|
elif text.endswith("%"):
|
||||||
|
zoom_level = int(text[:-1])
|
||||||
|
factor = zoom_level / 100.0
|
||||||
|
self.zoom_mode_changed.emit(QPdfView.ZoomMode.Custom)
|
||||||
|
self.zoom_factor_changed.emit(factor)
|
||||||
|
return
|
||||||
|
|
||||||
|
@Slot()
|
||||||
|
def _editing_finished(self) -> None:
|
||||||
|
lineEdit = self.lineEdit()
|
||||||
|
assert lineEdit is not None
|
||||||
|
self.on_current_text_changed(lineEdit.text())
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class PDFViewer(QDialog, Ui_pdfViewer):
|
||||||
|
menubar: QMenuBar
|
||||||
|
zoomSelector: ZoomSelector
|
||||||
|
pageSelector: QSpinBox
|
||||||
|
document: QPdfDocument
|
||||||
|
|
||||||
|
def __init__(self, parent: QWidget | None) -> None:
|
||||||
super(PDFViewer, self).__init__(parent)
|
super(PDFViewer, self).__init__(parent)
|
||||||
|
self.setupUi(self)
|
||||||
|
|
||||||
self.pdf_view = QPdfView()
|
self.zoomSelector = ZoomSelector(self)
|
||||||
self.pdf_document = QPdfDocument()
|
self.pageSelector = QSpinBox(self)
|
||||||
|
self.document = QPdfDocument(self)
|
||||||
|
|
||||||
layout = QVBoxLayout(self)
|
self.zoomSelector.setMaximumWidth(150)
|
||||||
layout.addWidget(self.pdf_view)
|
self.mainToolBar.insertWidget(self.actionZoom_In, self.zoomSelector)
|
||||||
self.setLayout(layout)
|
self.mainToolBar.insertWidget(self.actionForward, self.pageSelector)
|
||||||
|
self.pageSelector.valueChanged.connect(self.page_selected)
|
||||||
|
nav = self.pdfView.pageNavigator()
|
||||||
|
nav.currentPageChanged.connect(self.pageSelector.setValue)
|
||||||
|
nav.backAvailableChanged.connect(self.actionBack.setEnabled)
|
||||||
|
nav.forwardAvailableChanged.connect(self.actionForward.setEnabled)
|
||||||
|
self.zoomSelector.zoom_mode_changed.connect(self.pdfView.setZoomMode)
|
||||||
|
self.zoomSelector.zoom_factor_changed.connect(
|
||||||
|
self.pdfView.setZoomFactor
|
||||||
|
)
|
||||||
|
self.zoomSelector.reset()
|
||||||
|
|
||||||
|
bookmark_model = QPdfBookmarkModel(self)
|
||||||
|
bookmark_model.setDocument(self.document)
|
||||||
|
|
||||||
|
self.bookmarkView.setModel(bookmark_model)
|
||||||
|
self.bookmarkView.activated.connect(self.bookmark_selected)
|
||||||
|
|
||||||
|
self.tabWidget.setTabEnabled(1, False) # disable pages tabwidget
|
||||||
|
self.pdfView.setDocument(self.document)
|
||||||
|
self.pdfView.zoomFactorChanged.connect(
|
||||||
|
self.zoomSelector.set_zoom_factor
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
def load_pdf(self, file: QFile) -> None:
|
@Slot(QFile) # type: ignore
|
||||||
if not file.isOpen():
|
def open(self, file: QFile) -> None:
|
||||||
file.open(file.OpenModeFlag.ReadOnly)
|
# assert file.exists()
|
||||||
self.pdf_document.load(file)
|
# if not file.isOpen():
|
||||||
self.pdf_view.setDocument(self.pdf_document)
|
# file.open(QFile.OpenModeFlag.ReadOnly)
|
||||||
self.pdf_view.setPageMode(QPdfView.PageMode.MultiPage)
|
# self.document.load(file)
|
||||||
size = self.pdf_document.pagePointSize(1)
|
self.document.load(file.fileName())
|
||||||
self.resize(size.toSize())
|
document_title = self.document.metaData(
|
||||||
print(size)
|
QPdfDocument.MetaDataField.Title
|
||||||
|
)
|
||||||
|
self.setWindowTitle(document_title if document_title else "PDF Viewer")
|
||||||
|
self.page_selected(0)
|
||||||
|
self.pageSelector.setMaximum(self.document.pageCount() - 1)
|
||||||
|
return
|
||||||
|
|
||||||
|
@Slot(QModelIndex) # type: ignore
|
||||||
|
def bookmark_selected(self, index: QModelIndex) -> None:
|
||||||
|
if not index.isValid():
|
||||||
|
return
|
||||||
|
|
||||||
|
page = index.data(int(QPdfBookmarkModel.Role.Page))
|
||||||
|
zoom_level = index.data(int(QPdfBookmarkModel.Role.Level))
|
||||||
|
nav = self.pdfView.pageNavigator()
|
||||||
|
assert nav is not None
|
||||||
|
nav.jump(page, QPoint(), zoom_level)
|
||||||
|
return
|
||||||
|
|
||||||
|
@Slot(int) # type: ignore
|
||||||
|
def page_selected(self, page: int) -> None:
|
||||||
|
nav = self.pdfView.pageNavigator()
|
||||||
|
nav.jump(page, QPoint(), nav.currentZoom())
|
||||||
|
return
|
||||||
|
|
||||||
|
@Slot()
|
||||||
|
def on_actionOpen_triggered(self) -> None:
|
||||||
|
print("What are you doing in actionOpen_triggered?")
|
||||||
|
return
|
||||||
|
|
||||||
|
@Slot()
|
||||||
|
def on_actionQuit_triggered(self) -> None:
|
||||||
|
self.close()
|
||||||
|
return
|
||||||
|
|
||||||
|
@Slot()
|
||||||
|
def on_actionZoom_In_triggered(self) -> None:
|
||||||
|
factor = self.pdfView.zoomFactor() * ZOOM_MULTIPLIER
|
||||||
|
self.pdfView.setZoomFactor(factor)
|
||||||
|
return
|
||||||
|
|
||||||
|
@Slot()
|
||||||
|
def on_actionZoom_Out_triggered(self) -> None:
|
||||||
|
factor = self.pdfView.zoomFactor() / ZOOM_MULTIPLIER
|
||||||
|
self.pdfView.setZoomFactor(factor)
|
||||||
|
return
|
||||||
|
|
||||||
|
@Slot()
|
||||||
|
def on_actionPrevious_Page_triggered(self) -> None:
|
||||||
|
nav = self.pdfView.pageNavigator()
|
||||||
|
nav.jump(nav.currentPage() - 1, QPoint(), nav.currentZoom())
|
||||||
|
return
|
||||||
|
|
||||||
|
@Slot()
|
||||||
|
def on_actionNext_Page_triggered(self) -> None:
|
||||||
|
nav = self.pdfView.pageNavigator()
|
||||||
|
nav.jump(nav.currentPage() + 1, QPoint(), nav.currentZoom())
|
||||||
|
return
|
||||||
|
|
||||||
|
@Slot()
|
||||||
|
def on_actionContinuous_triggered(self) -> None:
|
||||||
|
cont_checked = self.actionContinuous.isChecked()
|
||||||
|
mode = (
|
||||||
|
QPdfView.PageMode.MultiPage
|
||||||
|
if cont_checked
|
||||||
|
else QPdfView.PageMode.SinglePage
|
||||||
|
)
|
||||||
|
self.pdfView.setPageMode(mode)
|
||||||
|
return
|
||||||
|
|
||||||
|
@Slot()
|
||||||
|
def on_actionBack_triggered(self) -> None:
|
||||||
|
self.pdfView.pageNavigator().back()
|
||||||
|
return
|
||||||
|
|
||||||
|
@Slot()
|
||||||
|
def on_actionForward_triggered(self) -> None:
|
||||||
|
self.pdfView.pageNavigator().forward()
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#!venv/bin/python3
|
#!venv/bin/python3
|
||||||
|
import faulthandler
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PySide6.QtSql import (
|
from PySide6.QtSql import (
|
||||||
@@ -8,6 +9,8 @@ from PySide6.QtWidgets import (
|
|||||||
QApplication,
|
QApplication,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
faulthandler.enable()
|
||||||
|
|
||||||
from MainWindow import MainWindow
|
from MainWindow import MainWindow
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
3
tracker.org
Normal file
3
tracker.org
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#+AUTHOR: Christopher T. Johnson
|
||||||
|
#+STARTUP: indent
|
||||||
|
#+OPTIONS: num:nil toc:nil
|
||||||
BIN
ui/images/document-open.svgz
Normal file
BIN
ui/images/document-open.svgz
Normal file
Binary file not shown.
BIN
ui/images/go-next-view-page.svgz
Normal file
BIN
ui/images/go-next-view-page.svgz
Normal file
Binary file not shown.
BIN
ui/images/go-next-view.svgz
Normal file
BIN
ui/images/go-next-view.svgz
Normal file
Binary file not shown.
BIN
ui/images/go-previous-view-page.svgz
Normal file
BIN
ui/images/go-previous-view-page.svgz
Normal file
Binary file not shown.
BIN
ui/images/go-previous-view.svgz
Normal file
BIN
ui/images/go-previous-view.svgz
Normal file
Binary file not shown.
BIN
ui/images/zoom-fit-best.svgz
Normal file
BIN
ui/images/zoom-fit-best.svgz
Normal file
Binary file not shown.
BIN
ui/images/zoom-fit-width.svgz
Normal file
BIN
ui/images/zoom-fit-width.svgz
Normal file
Binary file not shown.
BIN
ui/images/zoom-in.svgz
Normal file
BIN
ui/images/zoom-in.svgz
Normal file
Binary file not shown.
BIN
ui/images/zoom-original.svgz
Normal file
BIN
ui/images/zoom-original.svgz
Normal file
Binary file not shown.
BIN
ui/images/zoom-out.svgz
Normal file
BIN
ui/images/zoom-out.svgz
Normal file
Binary file not shown.
BIN
ui/images/zoom-previous.svgz
Normal file
BIN
ui/images/zoom-previous.svgz
Normal file
Binary file not shown.
171
ui/pdfViewer.py
Normal file
171
ui/pdfViewer.py
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
## Form generated from reading UI file 'pdfViewer.ui'
|
||||||
|
##
|
||||||
|
## Created by: Qt User Interface Compiler version 6.8.2
|
||||||
|
##
|
||||||
|
## WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
|
||||||
|
QMetaObject, QObject, QPoint, QRect,
|
||||||
|
QSize, QTime, QUrl, Qt)
|
||||||
|
from PySide6.QtGui import (QAction, QBrush, QColor, QConicalGradient,
|
||||||
|
QCursor, QFont, QFontDatabase, QGradient,
|
||||||
|
QIcon, QImage, QKeySequence, QLinearGradient,
|
||||||
|
QPainter, QPalette, QPixmap, QRadialGradient,
|
||||||
|
QTransform)
|
||||||
|
from PySide6.QtPdfWidgets import QPdfView
|
||||||
|
from PySide6.QtWidgets import (QApplication, QDialog, QHeaderView, QSizePolicy,
|
||||||
|
QSplitter, QTabWidget, QToolBar, QTreeView,
|
||||||
|
QVBoxLayout, QWidget)
|
||||||
|
import ui.resources_rc
|
||||||
|
|
||||||
|
class Ui_pdfViewer(object):
|
||||||
|
def setupUi(self, pdfViewer):
|
||||||
|
if not pdfViewer.objectName():
|
||||||
|
pdfViewer.setObjectName(u"pdfViewer")
|
||||||
|
pdfViewer.resize(700, 513)
|
||||||
|
self.actionZoom_In = QAction(pdfViewer)
|
||||||
|
self.actionZoom_In.setObjectName(u"actionZoom_In")
|
||||||
|
icon = QIcon(QIcon.fromTheme(QIcon.ThemeIcon.ZoomIn))
|
||||||
|
self.actionZoom_In.setIcon(icon)
|
||||||
|
self.actionZoom_In.setMenuRole(QAction.MenuRole.NoRole)
|
||||||
|
self.actionZoom_Out = QAction(pdfViewer)
|
||||||
|
self.actionZoom_Out.setObjectName(u"actionZoom_Out")
|
||||||
|
icon1 = QIcon(QIcon.fromTheme(QIcon.ThemeIcon.ZoomOut))
|
||||||
|
self.actionZoom_Out.setIcon(icon1)
|
||||||
|
self.actionZoom_Out.setMenuRole(QAction.MenuRole.NoRole)
|
||||||
|
self.actionPrevious_Page = QAction(pdfViewer)
|
||||||
|
self.actionPrevious_Page.setObjectName(u"actionPrevious_Page")
|
||||||
|
icon2 = QIcon()
|
||||||
|
icon2.addFile(u":/icons/images/go-previous-view-page.svgz", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
|
||||||
|
self.actionPrevious_Page.setIcon(icon2)
|
||||||
|
self.actionPrevious_Page.setMenuRole(QAction.MenuRole.NoRole)
|
||||||
|
self.actionNext_Page = QAction(pdfViewer)
|
||||||
|
self.actionNext_Page.setObjectName(u"actionNext_Page")
|
||||||
|
icon3 = QIcon()
|
||||||
|
icon3.addFile(u":/icons/images/go-next-view-page.svgz", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
|
||||||
|
self.actionNext_Page.setIcon(icon3)
|
||||||
|
self.actionNext_Page.setMenuRole(QAction.MenuRole.NoRole)
|
||||||
|
self.actionContinuous = QAction(pdfViewer)
|
||||||
|
self.actionContinuous.setObjectName(u"actionContinuous")
|
||||||
|
self.actionContinuous.setCheckable(True)
|
||||||
|
self.actionContinuous.setMenuRole(QAction.MenuRole.NoRole)
|
||||||
|
self.actionBack = QAction(pdfViewer)
|
||||||
|
self.actionBack.setObjectName(u"actionBack")
|
||||||
|
icon4 = QIcon()
|
||||||
|
icon4.addFile(u":/icons/images/go-previous-view.svgz", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
|
||||||
|
self.actionBack.setIcon(icon4)
|
||||||
|
self.actionBack.setMenuRole(QAction.MenuRole.NoRole)
|
||||||
|
self.actionForward = QAction(pdfViewer)
|
||||||
|
self.actionForward.setObjectName(u"actionForward")
|
||||||
|
icon5 = QIcon()
|
||||||
|
icon5.addFile(u":/icons/images/go-next-view.svgz", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
|
||||||
|
self.actionForward.setIcon(icon5)
|
||||||
|
self.actionForward.setMenuRole(QAction.MenuRole.NoRole)
|
||||||
|
self.verticalLayout = QVBoxLayout(pdfViewer)
|
||||||
|
self.verticalLayout.setObjectName(u"verticalLayout")
|
||||||
|
self.mainToolBar = QToolBar(pdfViewer)
|
||||||
|
self.mainToolBar.setObjectName(u"mainToolBar")
|
||||||
|
|
||||||
|
self.verticalLayout.addWidget(self.mainToolBar)
|
||||||
|
|
||||||
|
self.widget = QWidget(pdfViewer)
|
||||||
|
self.widget.setObjectName(u"widget")
|
||||||
|
self.verticalLayout_2 = QVBoxLayout(self.widget)
|
||||||
|
self.verticalLayout_2.setSpacing(0)
|
||||||
|
self.verticalLayout_2.setObjectName(u"verticalLayout_2")
|
||||||
|
self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
|
||||||
|
self.splitter = QSplitter(self.widget)
|
||||||
|
self.splitter.setObjectName(u"splitter")
|
||||||
|
self.splitter.setOrientation(Qt.Orientation.Horizontal)
|
||||||
|
self.tabWidget = QTabWidget(self.splitter)
|
||||||
|
self.tabWidget.setObjectName(u"tabWidget")
|
||||||
|
sizePolicy = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Expanding)
|
||||||
|
sizePolicy.setHorizontalStretch(0)
|
||||||
|
sizePolicy.setVerticalStretch(0)
|
||||||
|
sizePolicy.setHeightForWidth(self.tabWidget.sizePolicy().hasHeightForWidth())
|
||||||
|
self.tabWidget.setSizePolicy(sizePolicy)
|
||||||
|
self.tabWidget.setTabPosition(QTabWidget.TabPosition.West)
|
||||||
|
self.bookmarkTab = QWidget()
|
||||||
|
self.bookmarkTab.setObjectName(u"bookmarkTab")
|
||||||
|
self.verticalLayout_3 = QVBoxLayout(self.bookmarkTab)
|
||||||
|
self.verticalLayout_3.setSpacing(0)
|
||||||
|
self.verticalLayout_3.setObjectName(u"verticalLayout_3")
|
||||||
|
self.verticalLayout_3.setContentsMargins(2, 2, 2, 2)
|
||||||
|
self.bookmarkView = QTreeView(self.bookmarkTab)
|
||||||
|
self.bookmarkView.setObjectName(u"bookmarkView")
|
||||||
|
sizePolicy.setHeightForWidth(self.bookmarkView.sizePolicy().hasHeightForWidth())
|
||||||
|
self.bookmarkView.setSizePolicy(sizePolicy)
|
||||||
|
|
||||||
|
self.verticalLayout_3.addWidget(self.bookmarkView)
|
||||||
|
|
||||||
|
self.tabWidget.addTab(self.bookmarkTab, "")
|
||||||
|
self.pagesTab = QWidget()
|
||||||
|
self.pagesTab.setObjectName(u"pagesTab")
|
||||||
|
self.tabWidget.addTab(self.pagesTab, "")
|
||||||
|
self.splitter.addWidget(self.tabWidget)
|
||||||
|
self.pdfView = QPdfView(self.splitter)
|
||||||
|
self.pdfView.setObjectName(u"pdfView")
|
||||||
|
sizePolicy1 = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
|
||||||
|
sizePolicy1.setHorizontalStretch(10)
|
||||||
|
sizePolicy1.setVerticalStretch(0)
|
||||||
|
sizePolicy1.setHeightForWidth(self.pdfView.sizePolicy().hasHeightForWidth())
|
||||||
|
self.pdfView.setSizePolicy(sizePolicy1)
|
||||||
|
self.splitter.addWidget(self.pdfView)
|
||||||
|
|
||||||
|
self.verticalLayout_2.addWidget(self.splitter)
|
||||||
|
|
||||||
|
|
||||||
|
self.verticalLayout.addWidget(self.widget)
|
||||||
|
|
||||||
|
|
||||||
|
self.mainToolBar.addAction(self.actionZoom_Out)
|
||||||
|
self.mainToolBar.addAction(self.actionZoom_In)
|
||||||
|
self.mainToolBar.addSeparator()
|
||||||
|
self.mainToolBar.addAction(self.actionBack)
|
||||||
|
self.mainToolBar.addAction(self.actionForward)
|
||||||
|
self.mainToolBar.addAction(self.actionPrevious_Page)
|
||||||
|
self.mainToolBar.addAction(self.actionNext_Page)
|
||||||
|
|
||||||
|
self.retranslateUi(pdfViewer)
|
||||||
|
|
||||||
|
self.tabWidget.setCurrentIndex(0)
|
||||||
|
|
||||||
|
|
||||||
|
QMetaObject.connectSlotsByName(pdfViewer)
|
||||||
|
# setupUi
|
||||||
|
|
||||||
|
def retranslateUi(self, pdfViewer):
|
||||||
|
pdfViewer.setWindowTitle(QCoreApplication.translate("pdfViewer", u"PDF Viewer", None))
|
||||||
|
self.actionZoom_In.setText(QCoreApplication.translate("pdfViewer", u"Zoom In", None))
|
||||||
|
#if QT_CONFIG(tooltip)
|
||||||
|
self.actionZoom_In.setToolTip(QCoreApplication.translate("pdfViewer", u"Zoom In", None))
|
||||||
|
#endif // QT_CONFIG(tooltip)
|
||||||
|
#if QT_CONFIG(shortcut)
|
||||||
|
self.actionZoom_In.setShortcut(QCoreApplication.translate("pdfViewer", u"Ctrl+=", None))
|
||||||
|
#endif // QT_CONFIG(shortcut)
|
||||||
|
self.actionZoom_Out.setText(QCoreApplication.translate("pdfViewer", u"Zoom Out", None))
|
||||||
|
#if QT_CONFIG(shortcut)
|
||||||
|
self.actionZoom_Out.setShortcut(QCoreApplication.translate("pdfViewer", u"Ctrl+-", None))
|
||||||
|
#endif // QT_CONFIG(shortcut)
|
||||||
|
self.actionPrevious_Page.setText(QCoreApplication.translate("pdfViewer", u"Previous Page", None))
|
||||||
|
#if QT_CONFIG(shortcut)
|
||||||
|
self.actionPrevious_Page.setShortcut(QCoreApplication.translate("pdfViewer", u"PgUp", None))
|
||||||
|
#endif // QT_CONFIG(shortcut)
|
||||||
|
self.actionNext_Page.setText(QCoreApplication.translate("pdfViewer", u"Next Page", None))
|
||||||
|
#if QT_CONFIG(shortcut)
|
||||||
|
self.actionNext_Page.setShortcut(QCoreApplication.translate("pdfViewer", u"PgDown", None))
|
||||||
|
#endif // QT_CONFIG(shortcut)
|
||||||
|
self.actionContinuous.setText(QCoreApplication.translate("pdfViewer", u"Continuous", None))
|
||||||
|
#if QT_CONFIG(tooltip)
|
||||||
|
self.actionContinuous.setToolTip(QCoreApplication.translate("pdfViewer", u"Continuous", None))
|
||||||
|
#endif // QT_CONFIG(tooltip)
|
||||||
|
self.actionBack.setText(QCoreApplication.translate("pdfViewer", u"Back", None))
|
||||||
|
self.actionForward.setText(QCoreApplication.translate("pdfViewer", u"Forward", None))
|
||||||
|
self.tabWidget.setTabText(self.tabWidget.indexOf(self.bookmarkTab), QCoreApplication.translate("pdfViewer", u"Bookmarks", None))
|
||||||
|
self.tabWidget.setTabText(self.tabWidget.indexOf(self.pagesTab), QCoreApplication.translate("pdfViewer", u"Pages", None))
|
||||||
|
# retranslateUi
|
||||||
|
|
||||||
227
ui/pdfViewer.ui
Normal file
227
ui/pdfViewer.ui
Normal file
@@ -0,0 +1,227 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>pdfViewer</class>
|
||||||
|
<widget class="QDialog" name="pdfViewer">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>700</width>
|
||||||
|
<height>513</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>PDF Viewer</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QToolBar" name="mainToolBar">
|
||||||
|
<addaction name="actionZoom_Out"/>
|
||||||
|
<addaction name="actionZoom_In"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionBack"/>
|
||||||
|
<addaction name="actionForward"/>
|
||||||
|
<addaction name="actionPrevious_Page"/>
|
||||||
|
<addaction name="actionNext_Page"/>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="widget" native="true">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QSplitter" name="splitter">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="tabPosition">
|
||||||
|
<enum>QTabWidget::TabPosition::West</enum>
|
||||||
|
</property>
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="bookmarkTab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Bookmarks</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QTreeView" name="bookmarkView">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="pagesTab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Pages</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPdfView" name="pdfView" native="true">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>10</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
<action name="actionZoom_In">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="QIcon::ThemeIcon::ZoomIn"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Zoom In</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Zoom In</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+=</string>
|
||||||
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::MenuRole::NoRole</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionZoom_Out">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="QIcon::ThemeIcon::ZoomOut"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Zoom Out</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+-</string>
|
||||||
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::MenuRole::NoRole</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionPrevious_Page">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="resources.qrc">
|
||||||
|
<normaloff>:/icons/images/go-previous-view-page.svgz</normaloff>:/icons/images/go-previous-view-page.svgz</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Previous Page</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>PgUp</string>
|
||||||
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::MenuRole::NoRole</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionNext_Page">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="resources.qrc">
|
||||||
|
<normaloff>:/icons/images/go-next-view-page.svgz</normaloff>:/icons/images/go-next-view-page.svgz</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Next Page</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>PgDown</string>
|
||||||
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::MenuRole::NoRole</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionContinuous">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Continuous</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Continuous</string>
|
||||||
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::MenuRole::NoRole</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionBack">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="resources.qrc">
|
||||||
|
<normaloff>:/icons/images/go-previous-view.svgz</normaloff>:/icons/images/go-previous-view.svgz</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Back</string>
|
||||||
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::MenuRole::NoRole</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionForward">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="resources.qrc">
|
||||||
|
<normaloff>:/icons/images/go-next-view.svgz</normaloff>:/icons/images/go-next-view.svgz</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Forward</string>
|
||||||
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::MenuRole::NoRole</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>QPdfView</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>qpdfview.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources>
|
||||||
|
<include location="resources.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
11
ui/resources.qrc
Normal file
11
ui/resources.qrc
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/icons">
|
||||||
|
<file>images/document-open.svgz</file>
|
||||||
|
<file>images/go-next-view.svgz</file>
|
||||||
|
<file>images/go-previous-view.svgz</file>
|
||||||
|
<file>images/go-next-view-page.svgz</file>
|
||||||
|
<file>images/go-previous-view-page.svgz</file>
|
||||||
|
<file>images/zoom-in.svgz</file>
|
||||||
|
<file>images/zoom-out.svgz</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
||||||
3468
ui/resources_rc.py
Normal file
3468
ui/resources_rc.py
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user