Refine PDF reader interface
This commit is contained in:
@@ -20,7 +20,7 @@ PDFReaderLite 是一个面向 Windows 的轻量 PDF 阅读与编辑工具,目
|
||||
- 最近打开文件
|
||||
- 拖拽 PDF 文件到软件窗口打开
|
||||
- 中文界面
|
||||
- Acrobat 风格布局(已完成首轮界面整理:顶部工具分组、灰色阅读画布、右侧工具面板)
|
||||
- Acrobat 风格布局(已完成界面精简:高频顶部工具栏、灰色阅读画布、可折叠右侧工具面板)
|
||||
|
||||
## 已加入的增强功能
|
||||
|
||||
@@ -67,7 +67,8 @@ PDFReaderLite 是一个面向 Windows 的轻量 PDF 阅读与编辑工具,目
|
||||
- 打开日志目录
|
||||
- exe 版本资源
|
||||
- 设置中注册 PDF 文件关联
|
||||
- Acrobat 风格右侧工具面板(已完成首轮视觉整理)
|
||||
- Acrobat 风格右侧工具面板(已完成可折叠分类、搜索结果默认收起)
|
||||
- 缩略图单列卡片式显示与克制选中态
|
||||
- 图片签名
|
||||
- 多标签页打开、切换、关闭 PDF
|
||||
- 未保存更改星号提示,关闭标签/窗口时保存确认
|
||||
|
||||
@@ -23,7 +23,7 @@ PDFReaderLite 是 Windows 平台的轻量 PDF 阅读与编辑工具。功能重
|
||||
- 最近打开文件
|
||||
- 拖拽 PDF 文件到软件窗口打开(已完成)
|
||||
- 中文界面
|
||||
- Acrobat 风格布局(已完成首轮界面整理:顶部工具分组、灰色阅读画布、右侧工具面板)
|
||||
- Acrobat 风格布局(已完成界面精简:高频顶部工具栏、灰色阅读画布、可折叠右侧工具面板)
|
||||
|
||||
## V2:编辑增强版
|
||||
|
||||
@@ -64,7 +64,8 @@ PDFReaderLite 是 Windows 平台的轻量 PDF 阅读与编辑工具。功能重
|
||||
## V4:打包与体验优化
|
||||
|
||||
- 大文件性能优化(已完成缩略图可见区域懒加载与缩略图独立缓存)
|
||||
- Acrobat 风格右侧工具面板(已完成首轮视觉整理)
|
||||
- Acrobat 风格右侧工具面板(已完成可折叠分类、搜索结果默认收起)
|
||||
- 缩略图单列卡片式显示与克制选中态(已完成)
|
||||
- 页面缓存(已完成基础缓存)
|
||||
- 后台渲染(已完成缩略图分批加载)
|
||||
- 快捷键(已完成常用快捷键与说明)
|
||||
|
||||
@@ -868,12 +868,14 @@ class MainWindow(QMainWindow):
|
||||
query = self.search_box.text().strip()
|
||||
self.search_results.clear()
|
||||
if not self._ensure_document() or not query:
|
||||
self.right_tools.set_search_results_visible(False)
|
||||
return
|
||||
matches = self.document.search(query)
|
||||
for match in matches:
|
||||
item = QListWidgetItem(f"第 {match.page_index + 1} 页 {match.text}")
|
||||
item.setData(Qt.ItemDataRole.UserRole, match)
|
||||
self.search_results.addItem(item)
|
||||
self.right_tools.set_search_results_visible(bool(matches))
|
||||
self.statusBar().showMessage(f"找到 {len(matches)} 个页面匹配", 3000)
|
||||
|
||||
def _build_window(self) -> None:
|
||||
@@ -1185,39 +1187,13 @@ class MainWindow(QMainWindow):
|
||||
toolbar.addSeparator()
|
||||
for action in [
|
||||
self.highlight_action,
|
||||
self.underline_action,
|
||||
self.strikeout_action,
|
||||
self.note_action,
|
||||
self.select_object_action,
|
||||
self.freehand_action,
|
||||
]:
|
||||
toolbar.addAction(action)
|
||||
toolbar.addSeparator()
|
||||
for action in [
|
||||
self.add_text_action,
|
||||
self.place_text_action,
|
||||
self.insert_image_action,
|
||||
self.place_image_action,
|
||||
self.signature_action,
|
||||
self.place_signature_action,
|
||||
self.draw_signature_action,
|
||||
]:
|
||||
toolbar.addAction(action)
|
||||
toolbar.addSeparator()
|
||||
for action in [
|
||||
self.rectangle_action,
|
||||
self.circle_action,
|
||||
self.arrow_action,
|
||||
]:
|
||||
toolbar.addAction(action)
|
||||
toolbar.addSeparator()
|
||||
for action in [
|
||||
self.rotate_action,
|
||||
self.delete_action,
|
||||
self.move_page_action,
|
||||
self.page_manager_action,
|
||||
self.insert_blank_action,
|
||||
self.export_current_image_action,
|
||||
]:
|
||||
toolbar.addAction(action)
|
||||
|
||||
@@ -1802,16 +1778,22 @@ class MainWindow(QMainWindow):
|
||||
QSplitter::handle { background: #34373b; }
|
||||
QWidget#rightToolsPanel { background: #2b2e31; border-left: 1px solid #44484d; }
|
||||
QFrame#toolSection { background: #313438; border: 1px solid #44484d; border-radius: 6px; }
|
||||
QLabel#toolSectionTitle { color: #f1f1f1; font-weight: 600; padding: 2px 4px 6px 4px; }
|
||||
QToolButton#toolSectionTitle {
|
||||
color: #f1f1f1; font-weight: 600; text-align: left;
|
||||
padding: 6px 4px; border: none; background: transparent;
|
||||
}
|
||||
QToolButton#toolSectionTitle:hover { background: #3c4045; border-radius: 4px; }
|
||||
QPushButton#rightToolButton {
|
||||
color: #f1f1f1; text-align: left; padding: 7px 8px;
|
||||
color: #f1f1f1; text-align: left; padding: 6px 8px 6px 20px;
|
||||
border: 1px solid transparent; border-radius: 4px; background: transparent;
|
||||
}
|
||||
QListWidget, QListWidget#searchResults, QListWidget#thumbnailList {
|
||||
background: #202225; color: #f1f1f1; border: 1px solid #45494d; border-radius: 4px;
|
||||
}
|
||||
QListWidget::item { padding: 6px; border-radius: 4px; }
|
||||
QListWidget::item:selected { background: #244a78; color: #ffffff; }
|
||||
QListWidget::item { padding: 6px; border-radius: 4px; border: 1px solid transparent; }
|
||||
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; }
|
||||
QLabel#emptyPage { background: #2d3034; color: #cfd3d8; padding: 28px; border: 1px solid #464a4f; }
|
||||
QLabel#pdfPage { background: #ffffff; color: #202020; padding: 0; border: 1px solid #53575c; }
|
||||
@@ -1857,17 +1839,23 @@ class MainWindow(QMainWindow):
|
||||
QSplitter::handle { background: #d2d5da; }
|
||||
QWidget#rightToolsPanel { background: #f4f5f7; border-left: 1px solid #cfd2d7; }
|
||||
QFrame#toolSection { background: #ffffff; border: 1px solid #d8dbe0; border-radius: 6px; }
|
||||
QLabel#toolSectionTitle { color: #25272a; font-weight: 600; padding: 2px 4px 6px 4px; }
|
||||
QToolButton#toolSectionTitle {
|
||||
color: #25272a; font-weight: 600; text-align: left;
|
||||
padding: 6px 4px; border: none; background: transparent;
|
||||
}
|
||||
QToolButton#toolSectionTitle:hover { background: #f0f3f8; border-radius: 4px; }
|
||||
QPushButton#rightToolButton {
|
||||
color: #25272a; text-align: left; padding: 7px 8px;
|
||||
color: #25272a; text-align: left; padding: 6px 8px 6px 20px;
|
||||
border: 1px solid transparent; border-radius: 4px; background: transparent;
|
||||
}
|
||||
QListWidget, QListWidget#searchResults, QListWidget#thumbnailList {
|
||||
background: #ffffff; color: #202124; border: 1px solid #cfd2d7; border-radius: 4px;
|
||||
}
|
||||
QListWidget::item { padding: 6px; border-radius: 4px; }
|
||||
QListWidget::item { padding: 6px; border-radius: 4px; border: 1px solid transparent; }
|
||||
QListWidget::item:hover { background: #f0f3f8; }
|
||||
QListWidget::item:selected { background: #dbeafe; color: #0f3f7a; }
|
||||
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; }
|
||||
QLabel#emptyPage { background: #f8f9fb; color: #5f6368; padding: 28px; border: 1px solid #d3d6dc; }
|
||||
QLabel#pdfPage { background: #ffffff; color: #202020; padding: 0; border: 1px solid #b7bbc2; }
|
||||
|
||||
@@ -161,8 +161,8 @@ class PdfViewer(QScrollArea):
|
||||
self.content_widget = QWidget()
|
||||
self.content_widget.setObjectName("pdfContinuousContent")
|
||||
self.content_layout = QVBoxLayout(self.content_widget)
|
||||
self.content_layout.setContentsMargins(24, 24, 24, 24)
|
||||
self.content_layout.setSpacing(12)
|
||||
self.content_layout.setContentsMargins(32, 28, 32, 28)
|
||||
self.content_layout.setSpacing(18)
|
||||
self.content_layout.setAlignment(Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignTop)
|
||||
|
||||
self.page_label = self._make_empty_label()
|
||||
@@ -325,9 +325,9 @@ class PdfViewer(QScrollArea):
|
||||
|
||||
def _apply_page_shadow(self, label: PageLabel) -> None:
|
||||
shadow = QGraphicsDropShadowEffect(label)
|
||||
shadow.setBlurRadius(18)
|
||||
shadow.setOffset(0, 2)
|
||||
shadow.setColor(QColor(0, 0, 0, 80))
|
||||
shadow.setBlurRadius(22)
|
||||
shadow.setOffset(0, 3)
|
||||
shadow.setColor(QColor(0, 0, 0, 58))
|
||||
label.setGraphicsEffect(shadow)
|
||||
|
||||
def _connect_page_label(self, label: PageLabel, page_index: int) -> None:
|
||||
|
||||
@@ -2,15 +2,16 @@ from __future__ import annotations
|
||||
|
||||
from collections.abc import Iterable
|
||||
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtGui import QAction
|
||||
from PySide6.QtWidgets import (
|
||||
QFrame,
|
||||
QLabel,
|
||||
QLineEdit,
|
||||
QListWidget,
|
||||
QPushButton,
|
||||
QScrollArea,
|
||||
QSizePolicy,
|
||||
QToolButton,
|
||||
QVBoxLayout,
|
||||
QWidget,
|
||||
)
|
||||
@@ -20,14 +21,26 @@ class ToolSection(QFrame):
|
||||
def __init__(self, title: str, actions: Iterable[QAction]) -> None:
|
||||
super().__init__()
|
||||
self.setObjectName("toolSection")
|
||||
self.actions_container = QWidget()
|
||||
self.actions_container.setObjectName("toolSectionActions")
|
||||
|
||||
layout = QVBoxLayout(self)
|
||||
layout.setContentsMargins(10, 10, 10, 10)
|
||||
layout.setSpacing(5)
|
||||
layout.setContentsMargins(8, 8, 8, 8)
|
||||
layout.setSpacing(4)
|
||||
|
||||
title_label = QLabel(title)
|
||||
title_label.setObjectName("toolSectionTitle")
|
||||
layout.addWidget(title_label)
|
||||
self.title_button = QToolButton()
|
||||
self.title_button.setObjectName("toolSectionTitle")
|
||||
self.title_button.setText(title)
|
||||
self.title_button.setCheckable(True)
|
||||
self.title_button.setChecked(True)
|
||||
self.title_button.setArrowType(Qt.ArrowType.DownArrow)
|
||||
self.title_button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
||||
self.title_button.clicked.connect(self._set_expanded)
|
||||
layout.addWidget(self.title_button)
|
||||
|
||||
actions_layout = QVBoxLayout(self.actions_container)
|
||||
actions_layout.setContentsMargins(0, 2, 0, 0)
|
||||
actions_layout.setSpacing(3)
|
||||
|
||||
for action in actions:
|
||||
button = QPushButton(action.text())
|
||||
@@ -40,7 +53,13 @@ class ToolSection(QFrame):
|
||||
action.toggled.connect(button.setChecked)
|
||||
button.clicked.connect(action.trigger)
|
||||
button.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
|
||||
layout.addWidget(button)
|
||||
actions_layout.addWidget(button)
|
||||
|
||||
layout.addWidget(self.actions_container)
|
||||
|
||||
def _set_expanded(self, expanded: bool) -> None:
|
||||
self.actions_container.setVisible(expanded)
|
||||
self.title_button.setArrowType(Qt.ArrowType.DownArrow if expanded else Qt.ArrowType.RightArrow)
|
||||
|
||||
|
||||
class RightToolsPanel(QWidget):
|
||||
@@ -65,8 +84,10 @@ class RightToolsPanel(QWidget):
|
||||
layout.setContentsMargins(8, 8, 8, 8)
|
||||
layout.setSpacing(8)
|
||||
layout.addWidget(search_box)
|
||||
layout.addWidget(search_results, 1)
|
||||
layout.addWidget(scroll, 2)
|
||||
layout.addWidget(search_results)
|
||||
layout.addWidget(scroll, 1)
|
||||
search_results.setVisible(False)
|
||||
search_results.setMaximumHeight(170)
|
||||
self.setMinimumWidth(300)
|
||||
|
||||
def add_section(self, title: str, actions: Iterable[QAction]) -> None:
|
||||
@@ -74,3 +95,6 @@ class RightToolsPanel(QWidget):
|
||||
|
||||
def finish(self) -> None:
|
||||
self.sections_layout.addStretch(1)
|
||||
|
||||
def set_search_results_visible(self, visible: bool) -> None:
|
||||
self.search_results.setVisible(visible)
|
||||
|
||||
@@ -24,8 +24,12 @@ class ThumbnailList(QListWidget):
|
||||
self.verticalScrollBar().valueChanged.connect(lambda _: self.schedule_visible_thumbnails())
|
||||
|
||||
self.setIconSize(QSize(132, 176))
|
||||
self.setViewMode(QListWidget.ViewMode.ListMode)
|
||||
self.setSpacing(8)
|
||||
self.setViewMode(QListWidget.ViewMode.IconMode)
|
||||
self.setFlow(QListWidget.Flow.TopToBottom)
|
||||
self.setWrapping(False)
|
||||
self.setResizeMode(QListWidget.ResizeMode.Adjust)
|
||||
self.setGridSize(QSize(188, 222))
|
||||
self.setSpacing(6)
|
||||
self.itemClicked.connect(self._emit_page)
|
||||
|
||||
def load_document(self, document: PdfDocument) -> None:
|
||||
|
||||
Reference in New Issue
Block a user