mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-14 08:54:34 +12:00
Adds #206: Adjusting font size (CTRL+MouseWheelUp/Down)
This commit is contained in:
parent
c4d4f61702
commit
0f49bc7517
|
@ -41,13 +41,13 @@ class textEditView(QTextEdit):
|
||||||
|
|
||||||
self.spellcheck = spellcheck
|
self.spellcheck = spellcheck
|
||||||
self.currentDict = dict if dict else settings.dict
|
self.currentDict = dict if dict else settings.dict
|
||||||
|
self._defaultFontSize = qApp.font().pointSize()
|
||||||
self.highlighter = None
|
self.highlighter = None
|
||||||
self.setAutoResize(autoResize)
|
self.setAutoResize(autoResize)
|
||||||
self._defaultBlockFormat = QTextBlockFormat()
|
self._defaultBlockFormat = QTextBlockFormat()
|
||||||
self._defaultCharFormat = QTextCharFormat()
|
self._defaultCharFormat = QTextCharFormat()
|
||||||
self.highlightWord = ""
|
self.highlightWord = ""
|
||||||
self.highligtCS = False
|
self.highligtCS = False
|
||||||
self.defaultFontPointSize = qApp.font().pointSize()
|
|
||||||
self._dict = None
|
self._dict = None
|
||||||
# self.document().contentsChanged.connect(self.submit, F.AUC)
|
# self.document().contentsChanged.connect(self.submit, F.AUC)
|
||||||
|
|
||||||
|
@ -434,6 +434,31 @@ class textEditView(QTextEdit):
|
||||||
Qt.LeftButton, Qt.LeftButton, Qt.NoModifier)
|
Qt.LeftButton, Qt.LeftButton, Qt.NoModifier)
|
||||||
QTextEdit.mousePressEvent(self, event)
|
QTextEdit.mousePressEvent(self, event)
|
||||||
|
|
||||||
|
def wheelEvent(self, event):
|
||||||
|
"""
|
||||||
|
We catch wheelEvent if key modifier is CTRL to change font size.
|
||||||
|
Note: this should be in a class specific for main textEditView (#TODO).
|
||||||
|
"""
|
||||||
|
if event.modifiers() & Qt.ControlModifier:
|
||||||
|
# Get the wheel angle.
|
||||||
|
d = event.angleDelta().y() / 120
|
||||||
|
|
||||||
|
# Update settings
|
||||||
|
f = QFont()
|
||||||
|
f.fromString(settings.textEditor["font"])
|
||||||
|
f.setPointSizeF(f.pointSizeF() + d)
|
||||||
|
settings.textEditor["font"] = f.toString()
|
||||||
|
|
||||||
|
# Update font to all textEditView. Drastically.
|
||||||
|
for w in F.mainWindow().findChildren(textEditView, QRegExp(".*")):
|
||||||
|
w.loadFontSettings()
|
||||||
|
|
||||||
|
# We tell the world that we accepted this event
|
||||||
|
event.accept()
|
||||||
|
return
|
||||||
|
|
||||||
|
QTextEdit.wheelEvent(self, event)
|
||||||
|
|
||||||
class SpellAction(QAction):
|
class SpellAction(QAction):
|
||||||
"""A special QAction that returns the text in a signal. Used for spellckech."""
|
"""A special QAction that returns the text in a signal. Used for spellckech."""
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue