Add an option to make Bold and Italic buttons mutually exclusive.
This commit is contained in:
parent
3f48f68b46
commit
ae7b06052a
3 changed files with 20 additions and 5 deletions
|
|
@ -18,6 +18,8 @@ from confire import Configuration as BaseConfiguration
|
||||||
|
|
||||||
|
|
||||||
class Configuration(BaseConfiguration):
|
class Configuration(BaseConfiguration):
|
||||||
|
allow_bold_italic = True
|
||||||
|
|
||||||
min_body_height = 10
|
min_body_height = 10
|
||||||
|
|
||||||
diacritic_box_left = -3
|
diacritic_box_left = -3
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,12 @@ class StyleButton(QToolButton):
|
||||||
|
|
||||||
class GlyphEdit(QWidget):
|
class GlyphEdit(QWidget):
|
||||||
glyphEntered = signal([str, bool, bool])
|
glyphEntered = signal([str, bool, bool])
|
||||||
|
allowBoldItalic = True
|
||||||
|
|
||||||
|
def __init__(self, parent, document):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.document = document
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
self.layout = QHBoxLayout(self)
|
self.layout = QHBoxLayout(self)
|
||||||
self.layout.setSpacing(0)
|
self.layout.setSpacing(0)
|
||||||
self.layout.setContentsMargins(0, 0, 0, 0)
|
self.layout.setContentsMargins(0, 0, 0, 0)
|
||||||
|
|
@ -54,10 +57,10 @@ class GlyphEdit(QWidget):
|
||||||
self.italic.setText('I')
|
self.italic.setText('I')
|
||||||
self.italic.setShortcut('Ctrl+i')
|
self.italic.setShortcut('Ctrl+i')
|
||||||
|
|
||||||
|
self.setAllowBoldItalic(self.document.config.allow_bold_italic)
|
||||||
|
|
||||||
self.text = QLineEdit(self)
|
self.text = QLineEdit(self)
|
||||||
self.text.returnPressed.connect(self.sendGlyph)
|
self.text.returnPressed.connect(self.sendGlyph)
|
||||||
self.italic.pressed.connect(self.bold.release)
|
|
||||||
self.bold.pressed.connect(self.italic.release)
|
|
||||||
|
|
||||||
self.layout.addWidget(self.bold)
|
self.layout.addWidget(self.bold)
|
||||||
self.layout.addWidget(self.italic)
|
self.layout.addWidget(self.italic)
|
||||||
|
|
@ -65,3 +68,13 @@ class GlyphEdit(QWidget):
|
||||||
|
|
||||||
def sendGlyph(self):
|
def sendGlyph(self):
|
||||||
self.glyphEntered.emit(self.text.text(), self.bold.isChecked(), self.italic.isChecked())
|
self.glyphEntered.emit(self.text.text(), self.bold.isChecked(), self.italic.isChecked())
|
||||||
|
|
||||||
|
def setAllowBoldItalic(self, allow=True):
|
||||||
|
if not allow and self.allowBoldItalic:
|
||||||
|
self.italic.pressed.connect(self.bold.release)
|
||||||
|
self.bold.pressed.connect(self.italic.release)
|
||||||
|
self.allowBoldItalic = False
|
||||||
|
elif allow and not self.allowBoldItalic:
|
||||||
|
self.italic.pressed.disconnect(self.bold.release)
|
||||||
|
self.bold.pressed.disconnect(self.italic.release)
|
||||||
|
self.allowBoldItalic = True
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ class MainWindow(QMainWindow):
|
||||||
self.setCentralWidget(centralWidget)
|
self.setCentralWidget(centralWidget)
|
||||||
self.pageScene = PageScene(self)
|
self.pageScene = PageScene(self)
|
||||||
self.page = PageView(self.pageScene, centralWidget)
|
self.page = PageView(self.pageScene, centralWidget)
|
||||||
self.glyphEdit = GlyphEdit(centralWidget)
|
self.glyphEdit = GlyphEdit(centralWidget, document)
|
||||||
self.glyphEdit.setEnabled(False)
|
self.glyphEdit.setEnabled(False)
|
||||||
self.glyphDBEdit = GlyphDBEdit(self.document.glyphdb)
|
self.glyphDBEdit = GlyphDBEdit(self.document.glyphdb)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue