Finished the zen mode functionality, and added full screen F11 shortcut

This commit is contained in:
Veronica K. B. Olsen
2019-11-09 13:52:08 +01:00
parent fedcf247e0
commit 90613b857b
5 changed files with 73 additions and 36 deletions
+27 -27
View File
@@ -297,33 +297,6 @@ class GuiDocEditor(QTextEdit):
# General Class Methods
##
def resizeEvent(self, theEvent):
"""Automatically adjust the margins so the text is centred, but
only if Config.textFixedW is set to True.
"""
QTextEdit.resizeEvent(self, theEvent)
if self.mainConf.textFixedW or self.theParent.isZenMode:
vBar = self.verticalScrollBar()
if vBar.isVisible():
sW = vBar.width()
else:
sW = 0
tW = self.mainConf.textWidth
wW = self.width()
tM = int((wW - sW - tW)/2)
if tM < self.mainConf.textMargin:
tM = self.mainConf.textMargin
else:
tM = self.mainConf.textMargin
docFormat = self.qDocument.rootFrame().frameFormat()
docFormat.setLeftMargin(tM)
docFormat.setRightMargin(tM)
self.qDocument.rootFrame().setFrameFormat(docFormat)
return
def docAction(self, theAction):
logger.verbose("Requesting action: %s" % theAction.name)
if not self.theParent.hasProject:
@@ -429,6 +402,33 @@ class GuiDocEditor(QTextEdit):
QTextEdit.mouseReleaseEvent(self, mEvent)
return
def resizeEvent(self, theEvent):
"""Automatically adjust the margins so the text is centred, but
only if Config.textFixedW is set to True.
"""
QTextEdit.resizeEvent(self, theEvent)
if self.mainConf.textFixedW or self.theParent.isZenMode:
vBar = self.verticalScrollBar()
if vBar.isVisible():
sW = vBar.width()
else:
sW = 0
tW = self.mainConf.textWidth
wW = self.width()
tM = int((wW - sW - tW)/2)
if tM < self.mainConf.textMargin:
tM = self.mainConf.textMargin
else:
tM = self.mainConf.textMargin
docFormat = self.qDocument.rootFrame().frameFormat()
docFormat.setLeftMargin(tM)
docFormat.setRightMargin(tM)
self.qDocument.rootFrame().setFrameFormat(docFormat)
return
##
# Internal Functions
##
+8 -1
View File
@@ -411,7 +411,7 @@ class GuiMainMenu(QMenuBar):
self.viewMenu.addSeparator()
# View > Toggle Distraction Free Mode
menuItem = QAction("Distraction Free Mode", self)
menuItem = QAction("Zen Mode", self)
menuItem.setStatusTip("Toggles distraction free mode, only showing text editor")
menuItem.setShortcut("F8")
menuItem.setCheckable(True)
@@ -419,6 +419,13 @@ class GuiMainMenu(QMenuBar):
menuItem.toggled.connect(self.theParent.toggleZenMode)
self.viewMenu.addAction(menuItem)
# View > Toggle Full Screen
menuItem = QAction("Full Screen Mode", self)
menuItem.setStatusTip("Maximises the main window")
menuItem.setShortcut("F11")
menuItem.triggered.connect(self.theParent.toggleFullScreenMode)
self.viewMenu.addAction(menuItem)
# View > Separator
self.viewMenu.addSeparator()