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)
|
cursor.mergeCharFormat(fmt)
|
||||||
self.mergeCurrentCharFormat(fmt)
|
self.mergeCurrentCharFormat(fmt)
|
||||||
|
|
||||||
@Slot(QFont.Weight)
|
@Slot()
|
||||||
def apply_weight(self, weight):
|
def apply_weight(self):
|
||||||
|
cur = self.currentCharFormat()
|
||||||
fmt = QTextCharFormat()
|
fmt = QTextCharFormat()
|
||||||
|
weight = QFont.Weight.Normal if cur.fontWeight() == QFont.Weight.Bold else QFont.Weight.Bold
|
||||||
fmt.setFontWeight(weight)
|
fmt.setFontWeight(weight)
|
||||||
self.merge_on_sel(fmt)
|
self.merge_on_sel(fmt)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ from PySide6.QtWidgets import QToolBar
|
||||||
|
|
||||||
|
|
||||||
class ToolBar(QToolBar):
|
class ToolBar(QToolBar):
|
||||||
boldRequested = Signal(QFont.Weight)
|
boldRequested = Signal()
|
||||||
italicRequested = Signal()
|
italicRequested = Signal()
|
||||||
underlineRequested = Signal()
|
underlineRequested = Signal()
|
||||||
strikeRequested = Signal()
|
strikeRequested = Signal()
|
||||||
|
|
@ -24,7 +24,7 @@ class ToolBar(QToolBar):
|
||||||
# Bold
|
# Bold
|
||||||
bold = QAction("Bold", self)
|
bold = QAction("Bold", self)
|
||||||
bold.setShortcut("Ctrl+B")
|
bold.setShortcut("Ctrl+B")
|
||||||
bold.triggered.connect(lambda: self.boldRequested.emit(QFont.Weight.Bold))
|
bold.triggered.connect(self.boldRequested)
|
||||||
|
|
||||||
italic = QAction("Italic", self)
|
italic = QAction("Italic", self)
|
||||||
italic.setShortcut("Ctrl+I")
|
italic.setShortcut("Ctrl+I")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue