Polish Acrobat-style interface
This commit is contained in:
@@ -18,7 +18,7 @@ PDFReaderLite 是一个面向 Windows 的轻量 PDF 阅读与编辑工具,目
|
||||
- 另存为
|
||||
- 最近打开文件
|
||||
- 中文界面
|
||||
- Acrobat 风格布局
|
||||
- Acrobat 风格布局(已完成首轮界面整理:顶部工具分组、灰色阅读画布、右侧工具面板)
|
||||
|
||||
## 已加入的增强功能
|
||||
|
||||
@@ -65,7 +65,7 @@ PDFReaderLite 是一个面向 Windows 的轻量 PDF 阅读与编辑工具,目
|
||||
- 打开日志目录
|
||||
- exe 版本资源
|
||||
- 设置中注册 PDF 文件关联
|
||||
- Acrobat 风格右侧工具面板
|
||||
- Acrobat 风格右侧工具面板(已完成首轮视觉整理)
|
||||
- 图片签名
|
||||
- 多标签页打开、切换、关闭 PDF
|
||||
- 未保存更改星号提示,关闭标签/窗口时保存确认
|
||||
|
||||
@@ -22,7 +22,7 @@ PDFReaderLite 是 Windows 平台的轻量 PDF 阅读与编辑工具。功能重
|
||||
- 另存为
|
||||
- 最近打开文件
|
||||
- 中文界面
|
||||
- Acrobat 风格布局
|
||||
- Acrobat 风格布局(已完成首轮界面整理:顶部工具分组、灰色阅读画布、右侧工具面板)
|
||||
|
||||
## V2:编辑增强版
|
||||
|
||||
@@ -63,7 +63,7 @@ PDFReaderLite 是 Windows 平台的轻量 PDF 阅读与编辑工具。功能重
|
||||
## V4:打包与体验优化
|
||||
|
||||
- 大文件性能优化(已完成缩略图可见区域懒加载与缩略图独立缓存)
|
||||
- Acrobat 风格右侧工具面板(已完成)
|
||||
- Acrobat 风格右侧工具面板(已完成首轮视觉整理)
|
||||
- 页面缓存(已完成基础缓存)
|
||||
- 后台渲染(已完成缩略图分批加载)
|
||||
- 快捷键(已完成常用快捷键与说明)
|
||||
|
||||
+141
-19
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
from PySide6.QtCore import QSignalBlocker, QSettings, QStandardPaths, Qt, QUrl
|
||||
from PySide6.QtCore import QSize, QSignalBlocker, QSettings, QStandardPaths, Qt, QUrl
|
||||
from PySide6.QtGui import QAction, QDesktopServices, QIcon, QKeySequence, QPainter
|
||||
from PySide6.QtPrintSupport import QPrintDialog, QPrinter
|
||||
from PySide6.QtWidgets import (
|
||||
@@ -854,8 +854,13 @@ class MainWindow(QMainWindow):
|
||||
self.setWindowIcon(QIcon(software_icon_path().as_posix()))
|
||||
self.resize(1320, 860)
|
||||
self.setStatusBar(QStatusBar())
|
||||
self.search_box.setObjectName("searchBox")
|
||||
self.search_results.setObjectName("searchResults")
|
||||
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])
|
||||
@@ -1111,36 +1116,63 @@ class MainWindow(QMainWindow):
|
||||
|
||||
def _build_toolbar(self) -> None:
|
||||
toolbar = QToolBar("主工具栏")
|
||||
toolbar.setObjectName("mainToolBar")
|
||||
toolbar.setMovable(False)
|
||||
toolbar.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
||||
toolbar.setFloatable(False)
|
||||
toolbar.setAllowedAreas(Qt.ToolBarArea.TopToolBarArea)
|
||||
toolbar.setIconSize(QSize(18, 18))
|
||||
toolbar.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextOnly)
|
||||
self.addToolBar(Qt.ToolBarArea.TopToolBarArea, toolbar)
|
||||
|
||||
for action in [
|
||||
self.open_action,
|
||||
self.save_action,
|
||||
self.save_as_action,
|
||||
self.print_action,
|
||||
]:
|
||||
toolbar.addAction(action)
|
||||
toolbar.addSeparator()
|
||||
for action in [
|
||||
self.undo_action,
|
||||
self.redo_action,
|
||||
self.print_action,
|
||||
self.export_current_image_action,
|
||||
]:
|
||||
toolbar.addAction(action)
|
||||
toolbar.addSeparator()
|
||||
for action in [
|
||||
self.previous_action,
|
||||
self.next_action,
|
||||
]:
|
||||
toolbar.addAction(action)
|
||||
toolbar.addSeparator()
|
||||
for action in [
|
||||
self.zoom_out_action,
|
||||
self.zoom_in_action,
|
||||
]:
|
||||
toolbar.addAction(action)
|
||||
zoom_label = QLabel("缩放")
|
||||
zoom_label.setObjectName("toolbarLabel")
|
||||
toolbar.addWidget(zoom_label)
|
||||
toolbar.addWidget(self.zoom_slider)
|
||||
toolbar.addWidget(self.zoom_percent_input)
|
||||
toolbar.addSeparator()
|
||||
for action in [
|
||||
self.fit_width_action,
|
||||
self.fit_page_action,
|
||||
self.go_to_page_action,
|
||||
]:
|
||||
toolbar.addAction(action)
|
||||
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,
|
||||
@@ -1148,14 +1180,23 @@ class MainWindow(QMainWindow):
|
||||
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)
|
||||
|
||||
@@ -1706,29 +1747,110 @@ class MainWindow(QMainWindow):
|
||||
if self.dark_mode:
|
||||
self.setStyleSheet(
|
||||
"""
|
||||
QMainWindow { background: #242424; color: #eeeeee; }
|
||||
QMenuBar, QMenu, QToolBar {
|
||||
background: #303030; color: #eeeeee; border-color: #444444;
|
||||
QMainWindow { background: #242628; color: #f1f1f1; }
|
||||
QMenuBar, QMenu {
|
||||
background: #2f3235; color: #f1f1f1; border-color: #464a4f;
|
||||
}
|
||||
QToolButton { padding: 6px 8px; color: #eeeeee; }
|
||||
QLineEdit {
|
||||
padding: 7px; background: #1f1f1f; color: #eeeeee;
|
||||
border: 1px solid #565656; border-radius: 3px;
|
||||
QMenuBar::item:selected, QMenu::item:selected { background: #3f6fb5; color: #ffffff; }
|
||||
QToolBar#mainToolBar {
|
||||
background: #303235; border-bottom: 1px solid #45494d;
|
||||
padding: 4px 8px; spacing: 2px;
|
||||
}
|
||||
QListWidget, QTabWidget::pane {
|
||||
background: #1f1f1f; color: #eeeeee; border: 1px solid #4a4a4a;
|
||||
QToolBar#mainToolBar::separator {
|
||||
background: #50545a; width: 1px; margin: 6px 8px;
|
||||
}
|
||||
QStatusBar { background: #303030; color: #eeeeee; }
|
||||
QToolButton {
|
||||
color: #f1f1f1; background: transparent; border: 1px solid transparent;
|
||||
border-radius: 4px; padding: 5px 9px;
|
||||
}
|
||||
QToolButton:hover, QPushButton#rightToolButton:hover { background: #3c4045; border-color: #555a60; }
|
||||
QToolButton:checked, QPushButton#rightToolButton:checked { background: #244a78; border-color: #4f89c8; }
|
||||
QLabel#toolbarLabel { color: #cfd3d8; padding-left: 4px; }
|
||||
QLineEdit, QSpinBox {
|
||||
padding: 6px 8px; background: #202225; color: #f1f1f1;
|
||||
border: 1px solid #555a60; border-radius: 4px;
|
||||
}
|
||||
QSlider::groove:horizontal { height: 4px; background: #555a60; border-radius: 2px; }
|
||||
QSlider::handle:horizontal { background: #5b9be3; width: 14px; margin: -5px 0; border-radius: 7px; }
|
||||
QTabWidget::pane { background: #26282b; border: 1px solid #45494d; }
|
||||
QTabBar::tab {
|
||||
background: #303235; color: #dfe3e7; border: 1px solid #45494d;
|
||||
padding: 7px 14px; margin-right: 2px;
|
||||
}
|
||||
QTabBar::tab:selected { background: #26282b; border-bottom-color: #26282b; }
|
||||
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; }
|
||||
QPushButton#rightToolButton {
|
||||
color: #f1f1f1; text-align: left; padding: 7px 8px;
|
||||
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; }
|
||||
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; }
|
||||
QStatusBar { background: #303235; color: #dfe3e7; border-top: 1px solid #45494d; }
|
||||
"""
|
||||
)
|
||||
else:
|
||||
self.setStyleSheet(
|
||||
"""
|
||||
QMainWindow { background: #ededed; }
|
||||
QToolBar { background: #f8f8f8; border-bottom: 1px solid #d2d2d2; spacing: 4px; }
|
||||
QToolButton { padding: 6px 8px; }
|
||||
QLineEdit { padding: 7px; border: 1px solid #b9b9b9; border-radius: 3px; }
|
||||
QListWidget { background: #ffffff; border: 1px solid #d0d0d0; }
|
||||
QMainWindow { background: #e6e7e9; color: #202124; }
|
||||
QMenuBar, QMenu {
|
||||
background: #ffffff; color: #202124; border-color: #d6d8dc;
|
||||
}
|
||||
QMenuBar::item:selected, QMenu::item:selected { background: #dbeafe; color: #0f3f7a; }
|
||||
QToolBar#mainToolBar {
|
||||
background: #f7f8fa; border-bottom: 1px solid #cfd2d7;
|
||||
padding: 4px 8px; spacing: 2px;
|
||||
}
|
||||
QToolBar#mainToolBar::separator {
|
||||
background: #c7cad0; width: 1px; margin: 6px 8px;
|
||||
}
|
||||
QToolButton {
|
||||
color: #25272a; background: transparent; border: 1px solid transparent;
|
||||
border-radius: 4px; padding: 5px 9px;
|
||||
}
|
||||
QToolButton:hover, QPushButton#rightToolButton:hover { background: #eceff3; border-color: #c9cdd3; }
|
||||
QToolButton:pressed, QPushButton#rightToolButton:pressed { background: #dfe6f1; }
|
||||
QToolButton:checked, QPushButton#rightToolButton:checked { background: #dbeafe; border-color: #6aa3dc; color: #0f3f7a; }
|
||||
QLabel#toolbarLabel { color: #5b6067; padding-left: 4px; }
|
||||
QLineEdit, QSpinBox {
|
||||
padding: 6px 8px; background: #ffffff; color: #202124;
|
||||
border: 1px solid #b9bec6; border-radius: 4px;
|
||||
}
|
||||
QLineEdit:focus, QSpinBox:focus { border-color: #4f8bd3; }
|
||||
QSlider::groove:horizontal { height: 4px; background: #c6cbd2; border-radius: 2px; }
|
||||
QSlider::handle:horizontal { background: #2d73c5; width: 14px; margin: -5px 0; border-radius: 7px; }
|
||||
QTabWidget::pane { background: #f1f2f4; border: 1px solid #cfd2d7; }
|
||||
QTabBar::tab {
|
||||
background: #e8eaed; color: #303236; border: 1px solid #cfd2d7;
|
||||
padding: 7px 14px; margin-right: 2px;
|
||||
}
|
||||
QTabBar::tab:selected { background: #f8f9fb; border-bottom-color: #f8f9fb; }
|
||||
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; }
|
||||
QPushButton#rightToolButton {
|
||||
color: #25272a; text-align: left; padding: 7px 8px;
|
||||
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:hover { background: #f0f3f8; }
|
||||
QListWidget::item:selected { background: #dbeafe; color: #0f3f7a; }
|
||||
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; }
|
||||
QStatusBar { background: #f7f8fa; color: #44484f; border-top: 1px solid #cfd2d7; }
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from PySide6.QtCore import QPointF, QRectF, Qt, Signal
|
||||
from PySide6.QtGui import QContextMenuEvent, QMouseEvent, QPainter, QPen, QPixmap, QWheelEvent
|
||||
from PySide6.QtWidgets import QLabel, QScrollArea, QSizePolicy
|
||||
from PySide6.QtGui import QColor, QContextMenuEvent, QMouseEvent, QPainter, QPen, QPixmap, QWheelEvent
|
||||
from PySide6.QtWidgets import QGraphicsDropShadowEffect, QLabel, QScrollArea, QSizePolicy
|
||||
|
||||
from pdfreaderlite.core.document import PdfDocument
|
||||
|
||||
@@ -154,12 +154,16 @@ class PdfViewer(QScrollArea):
|
||||
self.zoom = 1.2
|
||||
|
||||
self.page_label = PageLabel("打开一个 PDF 文件开始阅读")
|
||||
self.page_label.setObjectName("emptyPage")
|
||||
self.page_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
self.page_label.setSizePolicy(QSizePolicy.Policy.Ignored, QSizePolicy.Policy.Ignored)
|
||||
self.page_label.setStyleSheet(
|
||||
"QLabel { background: #f4f4f4; color: #575757; padding: 24px; }"
|
||||
)
|
||||
shadow = QGraphicsDropShadowEffect(self.page_label)
|
||||
shadow.setBlurRadius(18)
|
||||
shadow.setOffset(0, 2)
|
||||
shadow.setColor(QColor(0, 0, 0, 80))
|
||||
self.page_label.setGraphicsEffect(shadow)
|
||||
|
||||
self.setObjectName("pdfCanvas")
|
||||
self.setWidget(self.page_label)
|
||||
self.setWidgetResizable(True)
|
||||
self.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
@@ -176,12 +180,17 @@ class PdfViewer(QScrollArea):
|
||||
|
||||
def render(self) -> None:
|
||||
if not self.document or not self.document.is_open:
|
||||
self.page_label.setObjectName("emptyPage")
|
||||
self.page_label.setText("打开一个 PDF 文件开始阅读")
|
||||
self.page_label.style().unpolish(self.page_label)
|
||||
self.page_label.style().polish(self.page_label)
|
||||
return
|
||||
|
||||
image = self.document.render_page(self.page_index, self.zoom)
|
||||
self.page_label.setObjectName("pdfPage")
|
||||
self.page_label.setPixmap(QPixmap.fromImage(image))
|
||||
self.page_label.setStyleSheet("QLabel { background: #f4f4f4; color: #575757; padding: 0; }")
|
||||
self.page_label.style().unpolish(self.page_label)
|
||||
self.page_label.style().polish(self.page_label)
|
||||
self.page_label.adjustSize()
|
||||
self._refresh_overlay_zoom()
|
||||
self.page_label.update()
|
||||
|
||||
@@ -5,6 +5,7 @@ from collections.abc import Iterable
|
||||
from PySide6.QtGui import QAction
|
||||
from PySide6.QtWidgets import (
|
||||
QFrame,
|
||||
QLabel,
|
||||
QLineEdit,
|
||||
QListWidget,
|
||||
QPushButton,
|
||||
@@ -21,17 +22,22 @@ class ToolSection(QFrame):
|
||||
self.setObjectName("toolSection")
|
||||
|
||||
layout = QVBoxLayout(self)
|
||||
layout.setContentsMargins(8, 8, 8, 8)
|
||||
layout.setSpacing(6)
|
||||
layout.setContentsMargins(10, 10, 10, 10)
|
||||
layout.setSpacing(5)
|
||||
|
||||
title_button = QPushButton(title)
|
||||
title_button.setObjectName("toolSectionTitle")
|
||||
title_button.setEnabled(False)
|
||||
layout.addWidget(title_button)
|
||||
title_label = QLabel(title)
|
||||
title_label.setObjectName("toolSectionTitle")
|
||||
layout.addWidget(title_label)
|
||||
|
||||
for action in actions:
|
||||
button = QPushButton(action.text())
|
||||
button.setObjectName("rightToolButton")
|
||||
button.setToolTip(action.toolTip() or action.text())
|
||||
button.setFlat(True)
|
||||
button.setCheckable(action.isCheckable())
|
||||
button.setChecked(action.isChecked())
|
||||
if action.isCheckable():
|
||||
action.toggled.connect(button.setChecked)
|
||||
button.clicked.connect(action.trigger)
|
||||
button.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
|
||||
layout.addWidget(button)
|
||||
@@ -42,12 +48,15 @@ class RightToolsPanel(QWidget):
|
||||
super().__init__()
|
||||
self.search_box = search_box
|
||||
self.search_results = search_results
|
||||
self.setObjectName("rightToolsPanel")
|
||||
self.sections_container = QWidget()
|
||||
self.sections_container.setObjectName("rightToolsSections")
|
||||
self.sections_layout = QVBoxLayout(self.sections_container)
|
||||
self.sections_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.sections_layout.setSpacing(8)
|
||||
|
||||
scroll = QScrollArea()
|
||||
scroll.setObjectName("rightToolsScroll")
|
||||
scroll.setWidgetResizable(True)
|
||||
scroll.setFrameShape(QFrame.Shape.NoFrame)
|
||||
scroll.setWidget(self.sections_container)
|
||||
|
||||
@@ -14,6 +14,7 @@ class ThumbnailList(QListWidget):
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.setObjectName("thumbnailList")
|
||||
self.document: PdfDocument | None = None
|
||||
self._thumbnail_queue: deque[int] = deque()
|
||||
self._queued_pages: set[int] = set()
|
||||
@@ -109,6 +110,7 @@ class Sidebar(QTabWidget):
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.setObjectName("leftSidebar")
|
||||
self.thumbnails = ThumbnailList()
|
||||
self.thumbnails.page_selected.connect(self.page_selected.emit)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user