Refine thumbnail and status controls
This commit is contained in:
@@ -1097,12 +1097,9 @@ class MainWindow(QMainWindow):
|
||||
painter = QPainter(pixmap)
|
||||
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
|
||||
pen_color = color or QColor("#2d73c5")
|
||||
painter.setPen(QPen(pen_color, 2))
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.drawRoundedRect(3, 3, 18, 18, 4, 4)
|
||||
font = QFont()
|
||||
font.setBold(True)
|
||||
font.setPixelSize(12 if len(text) <= 1 else 9)
|
||||
font.setPixelSize(18 if len(text) <= 1 else 13)
|
||||
painter.setFont(font)
|
||||
painter.setPen(pen_color)
|
||||
painter.drawText(pixmap.rect(), Qt.AlignmentFlag.AlignCenter, text)
|
||||
@@ -1293,12 +1290,14 @@ class MainWindow(QMainWindow):
|
||||
toolbar.addSeparator()
|
||||
toolbar.addAction(self.toggle_tools_action)
|
||||
|
||||
def _status_action_button(self, action: QAction) -> QToolButton:
|
||||
def _status_action_button(self, action: QAction, width: int = 64) -> QToolButton:
|
||||
button = QToolButton()
|
||||
button.setObjectName("statusToolButton")
|
||||
button.setDefaultAction(action)
|
||||
button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonIconOnly)
|
||||
button.setIconSize(QSize(16, 16))
|
||||
button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
||||
button.setIconSize(QSize(20, 20))
|
||||
button.setMinimumWidth(width)
|
||||
button.setMinimumHeight(24)
|
||||
button.setAutoRaise(True)
|
||||
return button
|
||||
|
||||
@@ -1326,13 +1325,13 @@ class MainWindow(QMainWindow):
|
||||
|
||||
for widget in [
|
||||
zoom_label,
|
||||
self._status_action_button(self.zoom_out_action),
|
||||
self._status_action_button(self.zoom_in_action),
|
||||
self._status_action_button(self.zoom_out_action, 66),
|
||||
self._status_action_button(self.zoom_in_action, 66),
|
||||
self.zoom_slider,
|
||||
self.zoom_percent_input,
|
||||
self._status_action_button(self.fit_width_action),
|
||||
self._status_action_button(self.fit_page_action),
|
||||
self._status_action_button(self.go_to_page_action),
|
||||
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),
|
||||
]:
|
||||
status.addPermanentWidget(widget)
|
||||
|
||||
@@ -1912,7 +1911,7 @@ class MainWindow(QMainWindow):
|
||||
QLabel#statusZoomLabel { color: #cfd3d8; padding: 0 4px 0 10px; }
|
||||
QToolButton#statusToolButton {
|
||||
color: #f1f1f1; background: transparent; border: 1px solid transparent;
|
||||
border-radius: 4px; padding: 3px;
|
||||
border-radius: 4px; padding: 3px 7px;
|
||||
}
|
||||
QToolButton#statusToolButton:hover { background: #3c4045; border-color: #555a60; }
|
||||
QLineEdit, QSpinBox {
|
||||
@@ -1985,7 +1984,7 @@ class MainWindow(QMainWindow):
|
||||
QLabel#statusZoomLabel { color: #5b6067; padding: 0 4px 0 10px; }
|
||||
QToolButton#statusToolButton {
|
||||
color: #25272a; background: transparent; border: 1px solid transparent;
|
||||
border-radius: 4px; padding: 3px;
|
||||
border-radius: 4px; padding: 3px 7px;
|
||||
}
|
||||
QToolButton#statusToolButton:hover { background: #eceff3; border-color: #c9cdd3; }
|
||||
QLineEdit, QSpinBox {
|
||||
|
||||
@@ -11,6 +11,7 @@ from pdfreaderlite.core.document import PdfDocument
|
||||
|
||||
class ThumbnailList(QListWidget):
|
||||
page_selected = Signal(int)
|
||||
MAX_THUMBNAIL_WIDTH = 170
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
@@ -38,7 +39,7 @@ class ThumbnailList(QListWidget):
|
||||
|
||||
def _update_thumbnail_metrics(self) -> None:
|
||||
viewport_width = max(120, self.viewport().width())
|
||||
thumbnail_width = max(92, min(170, viewport_width - 34))
|
||||
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))
|
||||
label_height = self.fontMetrics().height() + 8
|
||||
@@ -143,7 +144,7 @@ class Sidebar(QTabWidget):
|
||||
|
||||
self.addTab(thumb_page, "缩略图")
|
||||
self.setMinimumWidth(150)
|
||||
self.setMaximumWidth(340)
|
||||
self.setMaximumWidth(224)
|
||||
|
||||
def load_document(self, document: PdfDocument) -> None:
|
||||
self.thumbnails.load_document(document)
|
||||
|
||||
Reference in New Issue
Block a user