Fix set/unset of bold text
This commit is contained in:
parent
f9d92811dc
commit
39c0cb61da
2 changed files with 6 additions and 4 deletions
|
|
@ -28,9 +28,11 @@ class Editor(QTextEdit):
|
|||
cursor.mergeCharFormat(fmt)
|
||||
self.mergeCurrentCharFormat(fmt)
|
||||
|
||||
@Slot(QFont.Weight)
|
||||
def apply_weight(self, weight):
|
||||
@Slot()
|
||||
def apply_weight(self):
|
||||
cur = self.currentCharFormat()
|
||||
fmt = QTextCharFormat()
|
||||
weight = QFont.Weight.Normal if cur.fontWeight() == QFont.Weight.Bold else QFont.Weight.Bold
|
||||
fmt.setFontWeight(weight)
|
||||
self.merge_on_sel(fmt)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from PySide6.QtWidgets import QToolBar
|
|||
|
||||
|
||||
class ToolBar(QToolBar):
|
||||
boldRequested = Signal(QFont.Weight)
|
||||
boldRequested = Signal()
|
||||
italicRequested = Signal()
|
||||
underlineRequested = Signal()
|
||||
strikeRequested = Signal()
|
||||
|
|
@ -24,7 +24,7 @@ class ToolBar(QToolBar):
|
|||
# Bold
|
||||
bold = QAction("Bold", self)
|
||||
bold.setShortcut("Ctrl+B")
|
||||
bold.triggered.connect(lambda: self.boldRequested.emit(QFont.Weight.Bold))
|
||||
bold.triggered.connect(self.boldRequested)
|
||||
|
||||
italic = QAction("Italic", self)
|
||||
italic.setShortcut("Ctrl+I")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue