|
|
|
@@ -25,6 +25,7 @@ from PySide6.QtWidgets import (
|
|
|
|
|
QSlider,
|
|
|
|
|
QSpinBox,
|
|
|
|
|
QStatusBar,
|
|
|
|
|
QStyle,
|
|
|
|
|
QTabWidget,
|
|
|
|
|
QToolBar,
|
|
|
|
|
QVBoxLayout,
|
|
|
|
@@ -75,6 +76,7 @@ class MainWindow(QMainWindow):
|
|
|
|
|
self.search_box = QLineEdit()
|
|
|
|
|
self.search_results = QListWidget()
|
|
|
|
|
self.right_tools = RightToolsPanel(self.search_box, self.search_results)
|
|
|
|
|
self.main_splitter: QSplitter | None = None
|
|
|
|
|
self.pending_placement: dict[str, object] | None = None
|
|
|
|
|
self.selected_annotation: AnnotationInfo | None = None
|
|
|
|
|
self.session_raster_objects: list[dict[str, object]] = []
|
|
|
|
@@ -133,7 +135,7 @@ class MainWindow(QMainWindow):
|
|
|
|
|
splitter = QSplitter()
|
|
|
|
|
splitter.addWidget(sidebar)
|
|
|
|
|
splitter.addWidget(viewer)
|
|
|
|
|
splitter.setSizes([220, 820])
|
|
|
|
|
splitter.setSizes([188, 872])
|
|
|
|
|
|
|
|
|
|
session = DocumentSession(
|
|
|
|
|
document=document,
|
|
|
|
@@ -889,12 +891,12 @@ class MainWindow(QMainWindow):
|
|
|
|
|
self.tab_widget.setObjectName("documentTabs")
|
|
|
|
|
self.right_tools.setObjectName("rightToolsPanel")
|
|
|
|
|
|
|
|
|
|
splitter = QSplitter()
|
|
|
|
|
splitter.setObjectName("mainSplitter")
|
|
|
|
|
splitter.addWidget(self.tab_widget)
|
|
|
|
|
splitter.addWidget(self.right_tools)
|
|
|
|
|
splitter.setSizes([1040, 320])
|
|
|
|
|
self.setCentralWidget(splitter)
|
|
|
|
|
self.main_splitter = QSplitter()
|
|
|
|
|
self.main_splitter.setObjectName("mainSplitter")
|
|
|
|
|
self.main_splitter.addWidget(self.tab_widget)
|
|
|
|
|
self.main_splitter.addWidget(self.right_tools)
|
|
|
|
|
self.main_splitter.setSizes([1060, 280])
|
|
|
|
|
self.setCentralWidget(self.main_splitter)
|
|
|
|
|
|
|
|
|
|
self.search_box.setPlaceholderText("搜索文本,按 Enter")
|
|
|
|
|
self.search_results.setAlternatingRowColors(True)
|
|
|
|
@@ -992,6 +994,10 @@ class MainWindow(QMainWindow):
|
|
|
|
|
self.dark_mode_action = QAction("深色模式", self)
|
|
|
|
|
self.dark_mode_action.setCheckable(True)
|
|
|
|
|
self.dark_mode_action.setChecked(self.dark_mode)
|
|
|
|
|
self.toggle_tools_action = QAction("工具", self)
|
|
|
|
|
self.toggle_tools_action.setCheckable(True)
|
|
|
|
|
self.toggle_tools_action.setChecked(True)
|
|
|
|
|
self._apply_action_icons()
|
|
|
|
|
|
|
|
|
|
file_menu = self.menuBar().addMenu("文件")
|
|
|
|
|
file_menu.addAction(self.open_action)
|
|
|
|
@@ -1071,6 +1077,60 @@ class MainWindow(QMainWindow):
|
|
|
|
|
help_menu.addAction(self.about_action)
|
|
|
|
|
self._build_right_tools_panel()
|
|
|
|
|
|
|
|
|
|
def _apply_action_icons(self) -> None:
|
|
|
|
|
icon_map = {
|
|
|
|
|
self.open_action: QStyle.StandardPixmap.SP_DialogOpenButton,
|
|
|
|
|
self.save_action: QStyle.StandardPixmap.SP_DialogSaveButton,
|
|
|
|
|
self.save_as_action: QStyle.StandardPixmap.SP_DialogSaveButton,
|
|
|
|
|
self.print_action: QStyle.StandardPixmap.SP_FileDialogDetailedView,
|
|
|
|
|
self.undo_action: QStyle.StandardPixmap.SP_ArrowBack,
|
|
|
|
|
self.redo_action: QStyle.StandardPixmap.SP_ArrowForward,
|
|
|
|
|
self.previous_action: QStyle.StandardPixmap.SP_ArrowUp,
|
|
|
|
|
self.next_action: QStyle.StandardPixmap.SP_ArrowDown,
|
|
|
|
|
self.zoom_out_action: QStyle.StandardPixmap.SP_TitleBarMinButton,
|
|
|
|
|
self.zoom_in_action: QStyle.StandardPixmap.SP_TitleBarMaxButton,
|
|
|
|
|
self.fit_width_action: QStyle.StandardPixmap.SP_ArrowLeft,
|
|
|
|
|
self.fit_page_action: QStyle.StandardPixmap.SP_FileDialogContentsView,
|
|
|
|
|
self.go_to_page_action: QStyle.StandardPixmap.SP_ArrowRight,
|
|
|
|
|
self.rotate_action: QStyle.StandardPixmap.SP_BrowserReload,
|
|
|
|
|
self.delete_action: QStyle.StandardPixmap.SP_TrashIcon,
|
|
|
|
|
self.move_page_action: QStyle.StandardPixmap.SP_FileDialogListView,
|
|
|
|
|
self.page_manager_action: QStyle.StandardPixmap.SP_FileDialogInfoView,
|
|
|
|
|
self.insert_blank_action: QStyle.StandardPixmap.SP_FileIcon,
|
|
|
|
|
self.insert_pdf_action: QStyle.StandardPixmap.SP_FileLinkIcon,
|
|
|
|
|
self.extract_pages_action: QStyle.StandardPixmap.SP_DialogSaveButton,
|
|
|
|
|
self.split_pdf_action: QStyle.StandardPixmap.SP_DialogResetButton,
|
|
|
|
|
self.merge_pdfs_action: QStyle.StandardPixmap.SP_DirIcon,
|
|
|
|
|
self.export_current_image_action: QStyle.StandardPixmap.SP_DialogSaveButton,
|
|
|
|
|
self.export_pages_images_action: QStyle.StandardPixmap.SP_DirOpenIcon,
|
|
|
|
|
self.images_to_pdf_action: QStyle.StandardPixmap.SP_FileIcon,
|
|
|
|
|
self.metadata_action: QStyle.StandardPixmap.SP_MessageBoxInformation,
|
|
|
|
|
self.form_fill_action: QStyle.StandardPixmap.SP_FileDialogDetailedView,
|
|
|
|
|
self.annotation_list_action: QStyle.StandardPixmap.SP_FileDialogListView,
|
|
|
|
|
self.highlight_action: QStyle.StandardPixmap.SP_DialogApplyButton,
|
|
|
|
|
self.underline_action: QStyle.StandardPixmap.SP_DialogApplyButton,
|
|
|
|
|
self.strikeout_action: QStyle.StandardPixmap.SP_DialogCancelButton,
|
|
|
|
|
self.note_action: QStyle.StandardPixmap.SP_MessageBoxInformation,
|
|
|
|
|
self.select_object_action: QStyle.StandardPixmap.SP_ArrowRight,
|
|
|
|
|
self.freehand_action: QStyle.StandardPixmap.SP_DialogApplyButton,
|
|
|
|
|
self.add_text_action: QStyle.StandardPixmap.SP_FileDialogDetailedView,
|
|
|
|
|
self.place_text_action: QStyle.StandardPixmap.SP_FileDialogDetailedView,
|
|
|
|
|
self.insert_image_action: QStyle.StandardPixmap.SP_FileIcon,
|
|
|
|
|
self.place_image_action: QStyle.StandardPixmap.SP_FileIcon,
|
|
|
|
|
self.signature_action: QStyle.StandardPixmap.SP_DialogApplyButton,
|
|
|
|
|
self.place_signature_action: QStyle.StandardPixmap.SP_DialogApplyButton,
|
|
|
|
|
self.draw_signature_action: QStyle.StandardPixmap.SP_DialogApplyButton,
|
|
|
|
|
self.rectangle_action: QStyle.StandardPixmap.SP_FileDialogContentsView,
|
|
|
|
|
self.circle_action: QStyle.StandardPixmap.SP_FileDialogContentsView,
|
|
|
|
|
self.line_action: QStyle.StandardPixmap.SP_ArrowRight,
|
|
|
|
|
self.arrow_action: QStyle.StandardPixmap.SP_ArrowRight,
|
|
|
|
|
self.cover_action: QStyle.StandardPixmap.SP_DialogCloseButton,
|
|
|
|
|
self.dark_mode_action: QStyle.StandardPixmap.SP_ComputerIcon,
|
|
|
|
|
self.toggle_tools_action: QStyle.StandardPixmap.SP_FileDialogDetailedView,
|
|
|
|
|
}
|
|
|
|
|
for action, standard_icon in icon_map.items():
|
|
|
|
|
action.setIcon(self.style().standardIcon(standard_icon))
|
|
|
|
|
|
|
|
|
|
def _build_right_tools_panel(self) -> None:
|
|
|
|
|
self.right_tools.add_section(
|
|
|
|
|
"编辑 PDF",
|
|
|
|
@@ -1151,7 +1211,7 @@ class MainWindow(QMainWindow):
|
|
|
|
|
toolbar.setFloatable(False)
|
|
|
|
|
toolbar.setAllowedAreas(Qt.ToolBarArea.TopToolBarArea)
|
|
|
|
|
toolbar.setIconSize(QSize(18, 18))
|
|
|
|
|
toolbar.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextOnly)
|
|
|
|
|
toolbar.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
|
|
|
|
self.addToolBar(Qt.ToolBarArea.TopToolBarArea, toolbar)
|
|
|
|
|
|
|
|
|
|
for action in [
|
|
|
|
@@ -1196,6 +1256,8 @@ class MainWindow(QMainWindow):
|
|
|
|
|
self.page_manager_action,
|
|
|
|
|
]:
|
|
|
|
|
toolbar.addAction(action)
|
|
|
|
|
toolbar.addSeparator()
|
|
|
|
|
toolbar.addAction(self.toggle_tools_action)
|
|
|
|
|
|
|
|
|
|
def _connect_signals(self) -> None:
|
|
|
|
|
self.open_action.triggered.connect(lambda: self.open_file())
|
|
|
|
@@ -1256,6 +1318,8 @@ class MainWindow(QMainWindow):
|
|
|
|
|
self.arrow_action.triggered.connect(self.add_arrow)
|
|
|
|
|
self.cover_action.triggered.connect(self.add_cover_area)
|
|
|
|
|
self.dark_mode_action.triggered.connect(self.toggle_dark_mode)
|
|
|
|
|
self.toggle_tools_action.toggled.connect(self.set_right_tools_visible)
|
|
|
|
|
self.right_tools.collapse_requested.connect(lambda: self.toggle_tools_action.setChecked(False))
|
|
|
|
|
self.tab_widget.currentChanged.connect(self._on_tab_changed)
|
|
|
|
|
self.tab_widget.tabCloseRequested.connect(self._close_tab)
|
|
|
|
|
|
|
|
|
@@ -1740,6 +1804,11 @@ class MainWindow(QMainWindow):
|
|
|
|
|
self.settings.setValue("darkMode", self.dark_mode)
|
|
|
|
|
self._apply_theme()
|
|
|
|
|
|
|
|
|
|
def set_right_tools_visible(self, visible: bool) -> None:
|
|
|
|
|
self.right_tools.setVisible(visible)
|
|
|
|
|
if self.main_splitter:
|
|
|
|
|
self.main_splitter.setSizes([self.width() - (280 if visible else 0), 280 if visible else 0])
|
|
|
|
|
|
|
|
|
|
def _apply_theme(self) -> None:
|
|
|
|
|
if self.dark_mode:
|
|
|
|
|
self.setStyleSheet(
|
|
|
|
@@ -1777,6 +1846,13 @@ class MainWindow(QMainWindow):
|
|
|
|
|
QTabBar::tab:selected { background: #26282b; border-bottom-color: #26282b; }
|
|
|
|
|
QSplitter::handle { background: #34373b; }
|
|
|
|
|
QWidget#rightToolsPanel { background: #2b2e31; border-left: 1px solid #44484d; }
|
|
|
|
|
QLabel#rightToolsTitle { color: #f1f1f1; font-weight: 600; padding-left: 4px; }
|
|
|
|
|
QToolButton#rightToolsCollapseButton {
|
|
|
|
|
color: #dfe3e7; background: transparent; border: 1px solid #555a60;
|
|
|
|
|
border-radius: 4px; padding: 2px 7px;
|
|
|
|
|
}
|
|
|
|
|
QToolButton#rightToolsCollapseButton:hover { background: #3c4045; }
|
|
|
|
|
QScrollArea#rightToolsScroll { background: transparent; border: none; }
|
|
|
|
|
QFrame#toolSection { background: #313438; border: 1px solid #44484d; border-radius: 6px; }
|
|
|
|
|
QToolButton#toolSectionTitle {
|
|
|
|
|
color: #f1f1f1; font-weight: 600; text-align: left;
|
|
|
|
@@ -1784,7 +1860,7 @@ class MainWindow(QMainWindow):
|
|
|
|
|
}
|
|
|
|
|
QToolButton#toolSectionTitle:hover { background: #3c4045; border-radius: 4px; }
|
|
|
|
|
QPushButton#rightToolButton {
|
|
|
|
|
color: #f1f1f1; text-align: left; padding: 6px 8px 6px 20px;
|
|
|
|
|
color: #f1f1f1; text-align: left; padding: 6px 8px 6px 14px;
|
|
|
|
|
border: 1px solid transparent; border-radius: 4px; background: transparent;
|
|
|
|
|
}
|
|
|
|
|
QListWidget, QListWidget#searchResults, QListWidget#thumbnailList {
|
|
|
|
@@ -1794,7 +1870,7 @@ class MainWindow(QMainWindow):
|
|
|
|
|
QListWidget::item:selected { background: #27384d; color: #ffffff; border: 2px solid #4f89c8; }
|
|
|
|
|
QListWidget#thumbnailList::item { margin: 4px 6px; padding: 8px; }
|
|
|
|
|
QListWidget#thumbnailList::item:selected { background: #26384d; border: 2px solid #5b9be3; }
|
|
|
|
|
QScrollArea#pdfCanvas { background: #1f2022; border: none; }
|
|
|
|
|
QScrollArea#pdfCanvas, QWidget#pdfContinuousContent { background: #181a1c; border: none; }
|
|
|
|
|
QLabel#emptyPage { background: #2d3034; color: #cfd3d8; padding: 28px; border: 1px solid #464a4f; }
|
|
|
|
|
QLabel#pdfPage { background: #ffffff; color: #202020; padding: 0; border: 1px solid #53575c; }
|
|
|
|
|
QStatusBar { background: #303235; color: #dfe3e7; border-top: 1px solid #45494d; }
|
|
|
|
@@ -1838,6 +1914,13 @@ class MainWindow(QMainWindow):
|
|
|
|
|
QTabBar::tab:selected { background: #f8f9fb; border-bottom-color: #f8f9fb; }
|
|
|
|
|
QSplitter::handle { background: #d2d5da; }
|
|
|
|
|
QWidget#rightToolsPanel { background: #f4f5f7; border-left: 1px solid #cfd2d7; }
|
|
|
|
|
QLabel#rightToolsTitle { color: #25272a; font-weight: 600; padding-left: 4px; }
|
|
|
|
|
QToolButton#rightToolsCollapseButton {
|
|
|
|
|
color: #4b5563; background: transparent; border: 1px solid #c9cdd3;
|
|
|
|
|
border-radius: 4px; padding: 2px 7px;
|
|
|
|
|
}
|
|
|
|
|
QToolButton#rightToolsCollapseButton:hover { background: #eceff3; }
|
|
|
|
|
QScrollArea#rightToolsScroll { background: transparent; border: none; }
|
|
|
|
|
QFrame#toolSection { background: #ffffff; border: 1px solid #d8dbe0; border-radius: 6px; }
|
|
|
|
|
QToolButton#toolSectionTitle {
|
|
|
|
|
color: #25272a; font-weight: 600; text-align: left;
|
|
|
|
@@ -1845,7 +1928,7 @@ class MainWindow(QMainWindow):
|
|
|
|
|
}
|
|
|
|
|
QToolButton#toolSectionTitle:hover { background: #f0f3f8; border-radius: 4px; }
|
|
|
|
|
QPushButton#rightToolButton {
|
|
|
|
|
color: #25272a; text-align: left; padding: 6px 8px 6px 20px;
|
|
|
|
|
color: #25272a; text-align: left; padding: 6px 8px 6px 14px;
|
|
|
|
|
border: 1px solid transparent; border-radius: 4px; background: transparent;
|
|
|
|
|
}
|
|
|
|
|
QListWidget, QListWidget#searchResults, QListWidget#thumbnailList {
|
|
|
|
@@ -1856,7 +1939,7 @@ class MainWindow(QMainWindow):
|
|
|
|
|
QListWidget::item:selected { background: #f8fbff; color: #0f3f7a; border: 2px solid #6aa3dc; }
|
|
|
|
|
QListWidget#thumbnailList::item { margin: 4px 6px; padding: 8px; }
|
|
|
|
|
QListWidget#thumbnailList::item:selected { background: #f8fbff; border: 2px solid #2d73c5; }
|
|
|
|
|
QScrollArea#pdfCanvas { background: #cfd2d7; border: none; }
|
|
|
|
|
QScrollArea#pdfCanvas, QWidget#pdfContinuousContent { background: #bfc4cb; border: none; }
|
|
|
|
|
QLabel#emptyPage { background: #f8f9fb; color: #5f6368; padding: 28px; border: 1px solid #d3d6dc; }
|
|
|
|
|
QLabel#pdfPage { background: #ffffff; color: #202020; padding: 0; border: 1px solid #b7bbc2; }
|
|
|
|
|
QStatusBar { background: #f7f8fa; color: #44484f; border-top: 1px solid #cfd2d7; }
|
|
|
|
|