Skip to content
This repository was archived by the owner on Mar 27, 2026. It is now read-only.

Commit c15af65

Browse files
nelsonduarteclaude
andcommitted
fix: painel direito do editor com largura fixa e botão abrir PDF na toolbar
Substituir QSplitter por QHBoxLayout para o painel de controlos ter largura fixa de 400px sem ultrapassar os limites da janela. Adicionar botão "Abrir PDF" permanente na barra de workspace. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ed11f95 commit c15af65

2 files changed

Lines changed: 25 additions & 15 deletions

File tree

app/editor/tab.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from PySide6.QtCore import Qt, QEvent
66
from PySide6.QtWidgets import (
77
QWidget, QVBoxLayout, QHBoxLayout, QLabel, QPushButton,
8-
QScrollArea, QFrame, QSplitter, QStackedWidget, QGroupBox,
8+
QScrollArea, QFrame, QStackedWidget, QGroupBox,
99
QGridLayout, QLayout, QSizePolicy, QListWidget, QTableWidget,
1010
QTableWidgetItem, QHeaderView, QTextEdit, QComboBox, QFileDialog,
1111
QMessageBox, QDialog, QApplication,
@@ -49,7 +49,9 @@ def __init__(self, status_fn):
4949
"Clica ou arrasta directamente no PDF para editar."))
5050

5151
# body: canvas esquerda | controlos direita
52-
body = QSplitter(Qt.Orientation.Horizontal)
52+
body = QWidget()
53+
body_h = QHBoxLayout(body)
54+
body_h.setContentsMargins(0, 0, 0, 0); body_h.setSpacing(0)
5355

5456
self._canvas = PdfEditCanvas()
5557
self._canvas.rect_selected.connect(self._on_rect)
@@ -61,13 +63,12 @@ def __init__(self, status_fn):
6163
canvas_scroll.setMinimumWidth(320)
6264
canvas_scroll.viewport().installEventFilter(self)
6365
self._canvas_scroll = canvas_scroll
64-
body.addWidget(canvas_scroll)
66+
body_h.addWidget(canvas_scroll, 1)
6567

6668
# painel de controlos (scrollavel)
6769
ctrl_inner = QWidget(); ctrl_inner.setObjectName("scroll_inner")
68-
ctrl_inner.setMinimumWidth(0)
70+
ctrl_inner.setFixedWidth(380)
6971
cv = QVBoxLayout(ctrl_inner); cv.setContentsMargins(10, 10, 10, 10); cv.setSpacing(8)
70-
cv.setSizeConstraint(QLayout.SizeConstraint.SetNoConstraint)
7172

7273
# -- Ficheiro PDF --
7374
grp_file = QGroupBox("Ficheiro PDF")
@@ -229,20 +230,14 @@ def __init__(self, status_fn):
229230
cv.addWidget(grp_save)
230231
cv.addStretch()
231232

232-
# forçar largura mínima zero em todos os groupboxes do painel direito
233-
for gb in ctrl_inner.findChildren(QGroupBox):
234-
gb.setMinimumWidth(0)
235-
236233
ctrl_scroll = QScrollArea()
237234
ctrl_scroll.setWidgetResizable(True)
238235
ctrl_scroll.setFrameShape(QFrame.Shape.NoFrame)
239-
ctrl_scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded)
236+
ctrl_scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
240237
ctrl_scroll.setWidget(ctrl_inner)
241-
ctrl_scroll.setMinimumWidth(180)
242-
body.addWidget(ctrl_scroll)
243-
body.setSizes([800, 360])
244-
body.setStretchFactor(0, 1)
245-
body.setStretchFactor(1, 0)
238+
ctrl_scroll.setFixedWidth(400)
239+
ctrl_scroll.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Expanding)
240+
body_h.addWidget(ctrl_scroll)
246241
root.addWidget(body, 1)
247242

248243
action_bar, _ = ActionBar("Aplicar e Guardar", self._run)

app/window.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ def __init__(self):
8585
wb_col.addWidget(wb_title); wb_col.addWidget(wb_hint)
8686
wb_h.addLayout(wb_col, 1)
8787

88+
self._open_pdf_btn = QPushButton()
89+
self._open_pdf_btn.setIcon(qta.icon("fa5s.folder-open", color=TEXT_PRI))
90+
self._open_pdf_btn.setObjectName("viewer_nav_btn")
91+
self._open_pdf_btn.setFixedSize(28, 28)
92+
self._open_pdf_btn.setToolTip("Abrir PDF")
93+
self._open_pdf_btn.clicked.connect(self._open_pdf)
94+
wb_h.addWidget(self._open_pdf_btn)
95+
8896
self._quick_merge_btn = QPushButton("Juntar"); self._quick_merge_btn.setObjectName("quick_btn")
8997
self._quick_ocr_btn = QPushButton("OCR"); self._quick_ocr_btn.setObjectName("quick_btn")
9098
self._quick_edit_btn = QPushButton("Editar"); self._quick_edit_btn.setObjectName("quick_btn")
@@ -264,6 +272,13 @@ def _on_nav_clicked(self, item):
264272
if row == edit_idx:
265273
self._setup_zoom_bar(True)
266274

275+
def _open_pdf(self):
276+
from PySide6.QtWidgets import QFileDialog
277+
path, _ = QFileDialog.getOpenFileName(
278+
self, "Abrir PDF", "", "PDF Files (*.pdf);;All (*.*)")
279+
if path:
280+
self._viewer.load(path)
281+
267282
def _set_status(self, msg: str):
268283
self._sb.showMessage(msg)
269284

0 commit comments

Comments
 (0)