Fix a few minor issues related to opening and resizing of window panes
This commit is contained in:
@@ -185,6 +185,7 @@ class GuiDocEditor(QTextEdit):
|
||||
tHandle = self.theHandle
|
||||
self.clearEditor()
|
||||
self.loadText(tHandle)
|
||||
self.updateDocMargins()
|
||||
else:
|
||||
self.clearEditor()
|
||||
|
||||
@@ -241,6 +242,35 @@ class GuiDocEditor(QTextEdit):
|
||||
|
||||
return True
|
||||
|
||||
def updateDocMargins(self):
|
||||
"""Automatically adjust the margins so the text is centred, but
|
||||
only if Config.textFixedW is set to True.
|
||||
"""
|
||||
|
||||
if self.mainConf.textFixedW or self.theParent.isZenMode:
|
||||
vBar = self.verticalScrollBar()
|
||||
if vBar.isVisible():
|
||||
sW = vBar.width()
|
||||
else:
|
||||
sW = 0
|
||||
if self.theParent.isZenMode:
|
||||
tW = self.mainConf.zenWidth
|
||||
else:
|
||||
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
|
||||
|
||||
##
|
||||
# Setters and Getters
|
||||
##
|
||||
@@ -403,33 +433,11 @@ class GuiDocEditor(QTextEdit):
|
||||
return
|
||||
|
||||
def resizeEvent(self, theEvent):
|
||||
"""Automatically adjust the margins so the text is centred, but
|
||||
only if Config.textFixedW is set to True.
|
||||
"""If the text editor is resize, we must make sure the document
|
||||
has its margins adjusted according to user preferences.
|
||||
"""
|
||||
QTextEdit.resizeEvent(self, theEvent)
|
||||
|
||||
if self.mainConf.textFixedW or self.theParent.isZenMode:
|
||||
vBar = self.verticalScrollBar()
|
||||
if vBar.isVisible():
|
||||
sW = vBar.width()
|
||||
else:
|
||||
sW = 0
|
||||
if self.theParent.isZenMode:
|
||||
tW = self.mainConf.zenWidth
|
||||
else:
|
||||
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)
|
||||
|
||||
self.updateDocMargins()
|
||||
return
|
||||
|
||||
##
|
||||
|
||||
+10
-3
@@ -707,6 +707,10 @@ class GuiMain(QMainWindow):
|
||||
statusbar and menu.
|
||||
"""
|
||||
|
||||
if self.docEditor.theHandle is None:
|
||||
logger.error("No document open, so not activating Zen Mode")
|
||||
return False
|
||||
|
||||
self.isZenMode = not self.isZenMode
|
||||
if self.isZenMode:
|
||||
logger.debug("Activating Zen mode")
|
||||
@@ -714,12 +718,15 @@ class GuiMain(QMainWindow):
|
||||
logger.debug("Deactivating Zen mode")
|
||||
|
||||
isVisible = not self.isZenMode
|
||||
self.viewPane.setVisible(isVisible)
|
||||
self.treePane.setVisible(isVisible)
|
||||
self.statusBar.setVisible(isVisible)
|
||||
# self.mainMenu.setVisible(isVisible)
|
||||
|
||||
return
|
||||
if self.viewPane.isVisible():
|
||||
self.viewPane.setVisible(False)
|
||||
elif self.docViewer.theHandle is not None:
|
||||
self.viewPane.setVisible(True)
|
||||
|
||||
return True
|
||||
|
||||
def toggleFullScreenMode(self):
|
||||
"""Main GUI full screen mode. The mode is tracked by the flag
|
||||
|
||||
Reference in New Issue
Block a user