Refine status page controls
This commit is contained in:
@@ -8,9 +8,9 @@ PDFReaderLite 是一个面向 Windows 的轻量 PDF 阅读与编辑工具,目
|
||||
- 阅读、翻页、缩放
|
||||
- 连续阅读模式,页面上下自动衔接并保留页间缝隙
|
||||
- 鼠标滚轮优先在文档内容窗口内上下滚动
|
||||
- 状态栏页面缩放区:缩小、放大、缩放滑条、百分比输入、适应宽度、适应页面、跳转
|
||||
- 状态栏页面显示区:页码输入框、缩小、放大、10%-1000% 缩放输入、缩放滑条、适应宽度、适应页面
|
||||
- 适应宽度、适应页面
|
||||
- 页码跳转
|
||||
- 页码跳转(已支持状态栏页码输入框,失焦后自动跳转并校验非法输入)
|
||||
- 左侧缩略图
|
||||
- 文本搜索
|
||||
- 页面旋转
|
||||
@@ -68,7 +68,7 @@ PDFReaderLite 是一个面向 Windows 的轻量 PDF 阅读与编辑工具,目
|
||||
- exe 版本资源
|
||||
- 设置中注册 PDF 文件关联
|
||||
- Acrobat 风格右侧工具面板(已完成可折叠分类、搜索结果默认收起、整栏收起/展开)
|
||||
- 缩略图单列卡片式显示与克制选中态,支持随左侧栏拖拽宽度自适应缩放并限制最大栏宽
|
||||
- 缩略图单列卡片式显示与克制选中态,支持随左侧栏拖拽宽度自适应缩放并限制最大栏宽,缩略图间距已压缩
|
||||
- 顶部与右侧常用工具图标化,另存为/缩放/适应宽度图标已区分,状态栏页面按钮已加宽
|
||||
- 图片签名
|
||||
- 多标签页打开、切换、关闭 PDF
|
||||
|
||||
@@ -7,9 +7,9 @@ PDFReaderLite 是 Windows 平台的轻量 PDF 阅读与编辑工具。功能重
|
||||
## V1:基础可用版
|
||||
|
||||
- 打开 PDF
|
||||
- 阅读、翻页、缩放(已支持连续阅读、页间缝隙、鼠标滚轮页内/文档内滚动、状态栏页面缩放控件)
|
||||
- 阅读、翻页、缩放(已支持连续阅读、页间缝隙、鼠标滚轮页内/文档内滚动、状态栏页面缩放控件,缩放范围 10%-1000%)
|
||||
- 适应宽度、适应页面
|
||||
- 页码跳转
|
||||
- 页码跳转(已支持状态栏页码输入框,失焦后自动跳转并校验非法输入)
|
||||
- 左侧缩略图
|
||||
- 文本搜索
|
||||
- 高亮
|
||||
@@ -65,7 +65,7 @@ PDFReaderLite 是 Windows 平台的轻量 PDF 阅读与编辑工具。功能重
|
||||
|
||||
- 大文件性能优化(已完成缩略图可见区域懒加载与缩略图独立缓存)
|
||||
- Acrobat 风格右侧工具面板(已完成可折叠分类、搜索结果默认收起、整栏收起/展开)
|
||||
- 缩略图单列卡片式显示与克制选中态(已完成随左侧栏拖拽宽度自适应缩放,并限制最大栏宽)
|
||||
- 缩略图单列卡片式显示与克制选中态(已完成随左侧栏拖拽宽度自适应缩放、限制最大栏宽、压缩缩略图间距)
|
||||
- 顶部与右侧常用工具图标化(已完成另存为、缩小、放大、适应宽度图标区分,状态栏页面按钮已加宽)
|
||||
- 页面缓存(已完成基础缓存)
|
||||
- 后台渲染(已完成缩略图分批加载)
|
||||
|
||||
@@ -296,11 +296,36 @@ class MainWindow(QMainWindow):
|
||||
return
|
||||
if watched is not None and watched is not self._current_session():
|
||||
return
|
||||
percent = max(25, min(400, round(zoom * 100)))
|
||||
percent = max(10, min(1000, round(zoom * 100)))
|
||||
with QSignalBlocker(self.zoom_slider), QSignalBlocker(self.zoom_percent_input):
|
||||
self.zoom_slider.setValue(percent)
|
||||
self.zoom_percent_input.setValue(percent)
|
||||
|
||||
def _sync_page_controls(self) -> None:
|
||||
if not hasattr(self, "page_number_input"):
|
||||
return
|
||||
if not self.document.is_open:
|
||||
with QSignalBlocker(self.page_number_input):
|
||||
self.page_number_input.setRange(1, 1)
|
||||
self.page_number_input.setValue(1)
|
||||
self.page_number_input.setEnabled(False)
|
||||
self.page_total_label.setText("/ 0 页")
|
||||
return
|
||||
with QSignalBlocker(self.page_number_input):
|
||||
self.page_number_input.setEnabled(True)
|
||||
self.page_number_input.setRange(1, self.document.page_count)
|
||||
self.page_number_input.setValue(self.viewer.page_index + 1)
|
||||
self.page_total_label.setText(f"/ {self.document.page_count} 页")
|
||||
|
||||
def apply_page_number_input(self) -> None:
|
||||
if not self.document.is_open:
|
||||
self._sync_page_controls()
|
||||
return
|
||||
page = self.page_number_input.value()
|
||||
if 1 <= page <= self.document.page_count:
|
||||
self.viewer.go_to_page(page - 1)
|
||||
self._sync_page_controls()
|
||||
|
||||
def offer_restore_last_file(self) -> None:
|
||||
last_file = self.settings.value("lastOpenFile", "", str)
|
||||
if not last_file or self.document.is_open or not Path(last_file).exists():
|
||||
@@ -952,17 +977,25 @@ class MainWindow(QMainWindow):
|
||||
self.zoom_in_action = QAction("放大", self)
|
||||
self.zoom_in_action.setShortcut(QKeySequence.StandardKey.ZoomIn)
|
||||
self.zoom_slider = QSlider(Qt.Orientation.Horizontal)
|
||||
self.zoom_slider.setRange(25, 400)
|
||||
self.zoom_slider.setRange(10, 1000)
|
||||
self.zoom_slider.setSingleStep(5)
|
||||
self.zoom_slider.setPageStep(25)
|
||||
self.zoom_slider.setFixedWidth(150)
|
||||
self.zoom_slider.setToolTip("缩放")
|
||||
self.zoom_percent_input = QSpinBox()
|
||||
self.zoom_percent_input.setRange(25, 400)
|
||||
self.zoom_percent_input.setRange(10, 1000)
|
||||
self.zoom_percent_input.setSingleStep(5)
|
||||
self.zoom_percent_input.setSuffix("%")
|
||||
self.zoom_percent_input.setFixedWidth(78)
|
||||
self.zoom_percent_input.setToolTip("缩放百分比")
|
||||
self.page_number_input = QSpinBox()
|
||||
self.page_number_input.setRange(1, 1)
|
||||
self.page_number_input.setKeyboardTracking(False)
|
||||
self.page_number_input.setFixedWidth(64)
|
||||
self.page_number_input.setToolTip("当前页码")
|
||||
self.page_number_input.setEnabled(False)
|
||||
self.page_total_label = QLabel("/ 0 页")
|
||||
self.page_total_label.setObjectName("statusPageTotal")
|
||||
self.fit_width_action = QAction("适应宽度", self)
|
||||
self.fit_page_action = QAction("适应页面", self)
|
||||
self.go_to_page_action = QAction("跳转", self)
|
||||
@@ -1316,7 +1349,9 @@ class MainWindow(QMainWindow):
|
||||
for action in getattr(self, "_toolbar_page_size_actions", []):
|
||||
toolbar.removeAction(action)
|
||||
|
||||
zoom_label = QLabel("页面")
|
||||
page_label = QLabel("第")
|
||||
page_label.setObjectName("statusPageLabel")
|
||||
zoom_label = QLabel("缩放")
|
||||
zoom_label.setObjectName("statusZoomLabel")
|
||||
self.zoom_slider.setObjectName("statusZoomSlider")
|
||||
self.zoom_slider.setFixedWidth(132)
|
||||
@@ -1324,14 +1359,16 @@ class MainWindow(QMainWindow):
|
||||
self.zoom_percent_input.setFixedWidth(72)
|
||||
|
||||
for widget in [
|
||||
zoom_label,
|
||||
self._status_action_button(self.zoom_out_action, 66),
|
||||
self._status_action_button(self.zoom_in_action, 66),
|
||||
self.zoom_slider,
|
||||
zoom_label,
|
||||
self.zoom_percent_input,
|
||||
self.zoom_slider,
|
||||
self._status_action_button(self.fit_width_action, 92),
|
||||
self._status_action_button(self.fit_page_action, 92),
|
||||
self._status_action_button(self.go_to_page_action, 66),
|
||||
page_label,
|
||||
self.page_number_input,
|
||||
self.page_total_label,
|
||||
]:
|
||||
status.addPermanentWidget(widget)
|
||||
|
||||
@@ -1354,6 +1391,7 @@ class MainWindow(QMainWindow):
|
||||
self.zoom_in_action.triggered.connect(self.zoom_in)
|
||||
self.zoom_slider.valueChanged.connect(self.set_zoom_percent)
|
||||
self.zoom_percent_input.valueChanged.connect(self.set_zoom_percent)
|
||||
self.page_number_input.editingFinished.connect(self.apply_page_number_input)
|
||||
self.fit_width_action.triggered.connect(self.fit_width)
|
||||
self.fit_page_action.triggered.connect(self.fit_page)
|
||||
self.go_to_page_action.triggered.connect(self.go_to_page_dialog)
|
||||
@@ -1909,6 +1947,7 @@ class MainWindow(QMainWindow):
|
||||
QToolButton:checked, QPushButton#rightToolButton:checked { background: #244a78; border-color: #4f89c8; }
|
||||
QLabel#toolbarLabel { color: #cfd3d8; padding-left: 4px; }
|
||||
QLabel#statusZoomLabel { color: #cfd3d8; padding: 0 4px 0 10px; }
|
||||
QLabel#statusPageLabel, QLabel#statusPageTotal { color: #cfd3d8; padding: 0 4px; }
|
||||
QToolButton#statusToolButton {
|
||||
color: #f1f1f1; background: transparent; border: 1px solid transparent;
|
||||
border-radius: 4px; padding: 3px 7px;
|
||||
@@ -1982,6 +2021,7 @@ class MainWindow(QMainWindow):
|
||||
QToolButton:checked, QPushButton#rightToolButton:checked { background: #dbeafe; border-color: #6aa3dc; color: #0f3f7a; }
|
||||
QLabel#toolbarLabel { color: #5b6067; padding-left: 4px; }
|
||||
QLabel#statusZoomLabel { color: #5b6067; padding: 0 4px 0 10px; }
|
||||
QLabel#statusPageLabel, QLabel#statusPageTotal { color: #5b6067; padding: 0 4px; }
|
||||
QToolButton#statusToolButton {
|
||||
color: #25272a; background: transparent; border: 1px solid transparent;
|
||||
border-radius: 4px; padding: 3px 7px;
|
||||
@@ -2112,10 +2152,8 @@ class MainWindow(QMainWindow):
|
||||
|
||||
def _update_status(self) -> None:
|
||||
self._update_current_tab_title()
|
||||
self._sync_page_controls()
|
||||
if not self.document.is_open:
|
||||
self.statusBar().showMessage("就绪")
|
||||
return
|
||||
self.statusBar().showMessage(
|
||||
f"第 {self.viewer.page_index + 1} / {self.document.page_count} 页 "
|
||||
f"缩放 {int(self.viewer.zoom * 100)}%"
|
||||
)
|
||||
self.statusBar().showMessage("就绪")
|
||||
|
||||
@@ -222,13 +222,13 @@ class PdfViewer(QScrollArea):
|
||||
self.page_changed.emit(self.page_index)
|
||||
|
||||
def zoom_in(self) -> None:
|
||||
self.set_zoom(min(4.0, self.zoom + 0.15))
|
||||
self.set_zoom(min(10.0, self.zoom + 0.15))
|
||||
|
||||
def zoom_out(self) -> None:
|
||||
self.set_zoom(max(0.25, self.zoom - 0.15))
|
||||
self.set_zoom(max(0.1, self.zoom - 0.15))
|
||||
|
||||
def set_zoom(self, zoom: float) -> None:
|
||||
self.zoom = max(0.25, min(4.0, zoom))
|
||||
self.zoom = max(0.1, min(10.0, zoom))
|
||||
self.render()
|
||||
|
||||
def wheelEvent(self, event: QWheelEvent) -> None:
|
||||
|
||||
@@ -41,7 +41,7 @@ class ThumbnailList(QListWidget):
|
||||
viewport_width = max(120, self.viewport().width())
|
||||
thumbnail_width = max(92, min(self.MAX_THUMBNAIL_WIDTH, viewport_width - 34))
|
||||
thumbnail_height = int(thumbnail_width * 1.34)
|
||||
gap = max(2, round(self.fontMetrics().height() * 0.5))
|
||||
gap = max(1, round(self.fontMetrics().height() * 0.25))
|
||||
label_height = self.fontMetrics().height() + 8
|
||||
grid_size = QSize(thumbnail_width + 26, thumbnail_height + label_height + gap)
|
||||
if thumbnail_width != self._last_thumbnail_width:
|
||||
|
||||
Reference in New Issue
Block a user