Merge branch 'dev' into view_details
This commit is contained in:
@@ -32,7 +32,9 @@ from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtGui import QFont
|
||||
from PyQt5.QtWidgets import QFrame, QGridLayout, QLabel
|
||||
|
||||
from nw.constants import nwLabels, nwItemClass, nwItemType, nwUnicode
|
||||
from nw.constants import (
|
||||
nwLabels, nwItemClass, nwItemType, nwItemLayout, nwUnicode
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -143,27 +145,27 @@ class GuiDocDetails(QFrame):
|
||||
self.pCountData.setAlignment(Qt.AlignRight)
|
||||
|
||||
# Assemble
|
||||
self.mainBox.addWidget(self.labelName, 0, 0, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.labelFlag, 0, 1, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.labelData, 0, 2, 1, 3, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.labelName, 0, 0, 1, 1)
|
||||
self.mainBox.addWidget(self.labelFlag, 0, 1, 1, 1)
|
||||
self.mainBox.addWidget(self.labelData, 0, 2, 1, 3)
|
||||
|
||||
self.mainBox.addWidget(self.statusName, 1, 0, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.statusFlag, 1, 1, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.statusData, 1, 2, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.cCountName, 1, 3, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.cCountData, 1, 4, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.statusName, 1, 0, 1, 1)
|
||||
self.mainBox.addWidget(self.statusFlag, 1, 1, 1, 1)
|
||||
self.mainBox.addWidget(self.statusData, 1, 2, 1, 1)
|
||||
self.mainBox.addWidget(self.cCountName, 1, 3, 1, 1)
|
||||
self.mainBox.addWidget(self.cCountData, 1, 4, 1, 1)
|
||||
|
||||
self.mainBox.addWidget(self.className, 2, 0, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.classFlag, 2, 1, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.classData, 2, 2, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.wCountName, 2, 3, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.wCountData, 2, 4, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.className, 2, 0, 1, 1)
|
||||
self.mainBox.addWidget(self.classFlag, 2, 1, 1, 1)
|
||||
self.mainBox.addWidget(self.classData, 2, 2, 1, 1)
|
||||
self.mainBox.addWidget(self.wCountName, 2, 3, 1, 1)
|
||||
self.mainBox.addWidget(self.wCountData, 2, 4, 1, 1)
|
||||
|
||||
self.mainBox.addWidget(self.layoutName, 3, 0, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.layoutFlag, 3, 1, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.layoutData, 3, 2, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.pCountName, 3, 3, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.pCountData, 3, 4, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.layoutName, 3, 0, 1, 1)
|
||||
self.mainBox.addWidget(self.layoutFlag, 3, 1, 1, 1)
|
||||
self.mainBox.addWidget(self.layoutData, 3, 2, 1, 1)
|
||||
self.mainBox.addWidget(self.pCountName, 3, 3, 1, 1)
|
||||
self.mainBox.addWidget(self.pCountData, 3, 4, 1, 1)
|
||||
|
||||
self.mainBox.setColumnStretch(0,0)
|
||||
self.mainBox.setColumnStretch(1,0)
|
||||
@@ -221,7 +223,10 @@ class GuiDocDetails(QFrame):
|
||||
self.labelFlag.setText(exportFlag)
|
||||
self.statusFlag.setPixmap(flagIcon.pixmap(10, 10))
|
||||
self.classFlag.setText(nwLabels.CLASS_FLAG[nwItem.itemClass])
|
||||
self.layoutFlag.setText(nwLabels.LAYOUT_FLAG[nwItem.itemLayout])
|
||||
if nwItem.itemLayout == nwItemLayout.NO_LAYOUT:
|
||||
self.layoutFlag.setText("-")
|
||||
else:
|
||||
self.layoutFlag.setText(nwLabels.LAYOUT_FLAG[nwItem.itemLayout])
|
||||
|
||||
self.labelData.setText(theLabel)
|
||||
self.statusData.setText(nwItem.itemStatus)
|
||||
|
||||
@@ -85,7 +85,8 @@ class GuiDocEditor(QTextEdit):
|
||||
|
||||
# Document Title
|
||||
self.docTitle = GuiDocTitleBar(self, self.theProject)
|
||||
self.docTitle.setGeometry(0,0,self.docTitle.width(),self.docTitle.height())
|
||||
self.docTitle.setGeometry(0, 0, self.docTitle.width(), self.docTitle.height())
|
||||
self.setViewportMargins(0, self.docTitle.height(), 0, 0)
|
||||
|
||||
# Syntax
|
||||
self.hLight = GuiDocHighlighter(self.qDocument, self.theParent)
|
||||
@@ -227,7 +228,6 @@ class GuiDocEditor(QTextEdit):
|
||||
tHandle = self.theHandle
|
||||
self.clearEditor()
|
||||
self.loadText(tHandle, showStatus=False)
|
||||
self.updateDocMargins()
|
||||
return
|
||||
|
||||
def loadText(self, tHandle, tLine=None, showStatus=True):
|
||||
@@ -288,6 +288,7 @@ class GuiDocEditor(QTextEdit):
|
||||
"""
|
||||
self.setPlainText(theText)
|
||||
self.setDocumentChanged(True)
|
||||
self.updateDocMargins()
|
||||
return
|
||||
|
||||
def saveText(self):
|
||||
@@ -336,13 +337,17 @@ class GuiDocEditor(QTextEdit):
|
||||
tB = self.lineWidth()
|
||||
tW = self.width() - 2*tB
|
||||
tH = self.docTitle.height()
|
||||
tT = self.mainConf.textMargin - tH
|
||||
self.docTitle.setGeometry(tB, tB, tW, tH)
|
||||
self.setViewportMargins(0, tH, 0, 0)
|
||||
|
||||
docFormat = self.qDocument.rootFrame().frameFormat()
|
||||
docFormat.setLeftMargin(tM)
|
||||
docFormat.setRightMargin(tM)
|
||||
if docFormat.topMargin() < tH:
|
||||
docFormat.setTopMargin(tH + 2)
|
||||
if tT > 0:
|
||||
docFormat.setTopMargin(tT)
|
||||
else:
|
||||
docFormat.setTopMargin(0)
|
||||
|
||||
# Updating root frame triggers a QTextDocument->contentsChange
|
||||
# signal, which we do not want as it re-runs the syntax
|
||||
@@ -365,6 +370,7 @@ class GuiDocEditor(QTextEdit):
|
||||
"""
|
||||
if tHandle == self.theHandle:
|
||||
self.docTitle.setTitleFromHandle(self.theHandle)
|
||||
self.updateDocMargins()
|
||||
return
|
||||
|
||||
##
|
||||
|
||||
@@ -59,7 +59,8 @@ class GuiDocViewer(QTextBrowser):
|
||||
|
||||
# Document Title
|
||||
self.docTitle = GuiDocTitleBar(self, self.theProject)
|
||||
self.docTitle.setGeometry(0,0,self.docTitle.width(),self.docTitle.height())
|
||||
self.docTitle.setGeometry(0, 0, self.docTitle.width(), self.docTitle.height())
|
||||
self.setViewportMargins(0, self.docTitle.height(), 0, 0)
|
||||
|
||||
theOpt = QTextOption()
|
||||
if self.mainConf.doJustify:
|
||||
@@ -145,6 +146,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
self.theHandle = tHandle
|
||||
self.theProject.setLastViewed(tHandle)
|
||||
self.docTitle.setTitleFromHandle(self.theHandle)
|
||||
self.updateDocMargins()
|
||||
|
||||
# Make sure the main GUI knows we changed the content
|
||||
self.theParent.viewMeta.refreshReferences(tHandle)
|
||||
@@ -206,12 +208,37 @@ class GuiDocViewer(QTextBrowser):
|
||||
self.setSource(QUrl(navLink))
|
||||
return True
|
||||
|
||||
def updateDocMargins(self):
|
||||
"""Automatically adjust the margins so the text is centred if
|
||||
Config.textFixedW is enabled or we're in Zen mode. Otherwise,
|
||||
just ensure the margins are set correctly.
|
||||
"""
|
||||
tB = self.lineWidth()
|
||||
tW = self.width() - 2*tB
|
||||
tH = self.docTitle.height()
|
||||
tT = self.mainConf.textMargin - tH
|
||||
self.docTitle.setGeometry(tB, tB, tW, tH)
|
||||
self.setViewportMargins(0, tH, 0, 0)
|
||||
|
||||
docFormat = self.qDocument.rootFrame().frameFormat()
|
||||
if tT > 0:
|
||||
docFormat.setTopMargin(tT)
|
||||
else:
|
||||
docFormat.setTopMargin(0)
|
||||
|
||||
self.qDocument.blockSignals(True)
|
||||
self.qDocument.rootFrame().setFrameFormat(docFormat)
|
||||
self.qDocument.blockSignals(False)
|
||||
|
||||
return
|
||||
|
||||
def updateDocTitle(self, tHandle):
|
||||
"""Called when an item label is changed to check if the document
|
||||
title bar needs updating,
|
||||
"""
|
||||
if tHandle == self.theHandle:
|
||||
self.docTitle.setTitleFromHandle(self.theHandle)
|
||||
self.updateDocMargins()
|
||||
return
|
||||
|
||||
##
|
||||
@@ -249,16 +276,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
"""Make sure the document title is the same width as the window.
|
||||
"""
|
||||
QTextBrowser.resizeEvent(self, theEvent)
|
||||
|
||||
tB = self.lineWidth()
|
||||
tW = self.width() - 2*tB
|
||||
tH = self.docTitle.height()
|
||||
self.docTitle.setGeometry(tB, tB, tW, tH)
|
||||
|
||||
docFormat = self.qDocument.rootFrame().frameFormat()
|
||||
if docFormat.topMargin() < tH:
|
||||
docFormat.setTopMargin(tH + 2)
|
||||
|
||||
self.updateDocMargins()
|
||||
return
|
||||
|
||||
##
|
||||
|
||||
Reference in New Issue
Block a user