Refine PDF reader interface

This commit is contained in:
2026-06-30 00:01:34 +08:00
parent 83ae720e9c
commit 04b1e9edf4
6 changed files with 72 additions and 54 deletions
+33 -9
View File
@@ -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)