|
24 | 24 | from markups.common import MODULE_HOME_PAGE
|
25 | 25 | from PyQt6.QtCore import QDir, QFile, QFileInfo, QPoint, Qt, QTimer, QUrl, pyqtSignal
|
26 | 26 | from PyQt6.QtGui import QPalette, QTextCursor, QTextDocument
|
27 |
| -from PyQt6.QtWidgets import QApplication, QMessageBox, QSplitter, QTextEdit |
| 27 | +from PyQt6.QtWidgets import ( |
| 28 | + QApplication, |
| 29 | + QFrame, |
| 30 | + QMessageBox, |
| 31 | + QSplitter, |
| 32 | + QTextEdit, |
| 33 | + QVBoxLayout, |
| 34 | +) |
28 | 35 |
|
29 | 36 | from ReText import app_version, converterprocess, globalSettings
|
30 | 37 | from ReText.editor import ReTextEdit
|
@@ -57,7 +64,7 @@ def __init__(self, parent, fileName, previewState=PreviewDisabled):
|
57 | 64 | self.p = parent
|
58 | 65 | self._fileName = fileName
|
59 | 66 | self.editBox = ReTextEdit(self)
|
60 |
| - self.previewBox = self.createPreviewBox(self.editBox) |
| 67 | + self.previewBox, self.previewBoxWidget = self.createPreviewBox(self.editBox) |
61 | 68 | self.activeMarkupClass = None
|
62 | 69 | self.markup = None
|
63 | 70 | self.converted = None
|
@@ -85,7 +92,7 @@ def __init__(self, parent, fileName, previewState=PreviewDisabled):
|
85 | 92 |
|
86 | 93 | # Give both boxes a minimum size so the minimumSizeHint will be
|
87 | 94 | # ignored when splitter.setSizes is called below
|
88 |
| - for widget in self.editBox, self.previewBox: |
| 95 | + for widget in self.editBox, self.previewBoxWidget: |
89 | 96 | widget.setMinimumWidth(125)
|
90 | 97 | self.addWidget(widget)
|
91 | 98 | self.setSizes((50, 50))
|
@@ -116,13 +123,18 @@ def sourceLineToEditorPosition(sourceLine):
|
116 | 123 | return rect.top()
|
117 | 124 |
|
118 | 125 | if ReTextWebEnginePreview and globalSettings.useWebEngine:
|
| 126 | + frame = QFrame() |
| 127 | + frame.setFrameStyle(QFrame.Shape.StyledPanel | QFrame.Shadow.Sunken) |
| 128 | + layout = QVBoxLayout(frame) |
| 129 | + layout.setContentsMargins(0, 0, 0, 0) |
119 | 130 | preview = ReTextWebEnginePreview(self,
|
120 | 131 | editorPositionToSourceLine,
|
121 | 132 | sourceLineToEditorPosition)
|
122 |
| - else: |
123 |
| - preview = ReTextPreview(self) |
| 133 | + layout.addWidget(preview) |
| 134 | + return preview, frame |
124 | 135 |
|
125 |
| - return preview |
| 136 | + preview = ReTextPreview(self) |
| 137 | + return preview, preview |
126 | 138 |
|
127 | 139 | def getActiveMarkupClass(self):
|
128 | 140 | '''
|
@@ -292,15 +304,15 @@ def startPendingConversion(self):
|
292 | 304 |
|
293 | 305 | def updateBoxesVisibility(self):
|
294 | 306 | self.editBox.setVisible(self.previewState < PreviewNormal)
|
295 |
| - self.previewBox.setVisible(self.previewState > PreviewDisabled) |
| 307 | + self.previewBoxWidget.setVisible(self.previewState > PreviewDisabled) |
296 | 308 |
|
297 | 309 | def rebuildPreviewBox(self):
|
298 | 310 | self.previewBox.disconnectExternalSignals()
|
299 |
| - self.previewBox.setParent(None) |
300 |
| - self.previewBox.deleteLater() |
301 |
| - self.previewBox = self.createPreviewBox(self.editBox) |
| 311 | + self.previewBoxWidget.setParent(None) |
| 312 | + self.previewBoxWidget.deleteLater() |
| 313 | + self.previewBox, self.previewBoxWidget = self.createPreviewBox(self.editBox) |
302 | 314 | self.previewBox.setMinimumWidth(125)
|
303 |
| - self.addWidget(self.previewBox) |
| 315 | + self.addWidget(self.previewBoxWidget) |
304 | 316 | self.setSizes((50, 50))
|
305 | 317 | self.triggerPreviewUpdate()
|
306 | 318 | self.updateBoxesVisibility()
|
|
0 commit comments