Moved the document title element into the document instead of main GUI
This commit is contained in:
@@ -32,7 +32,7 @@ from time import time
|
||||
|
||||
from PyQt5.QtCore import Qt, QTimer
|
||||
from PyQt5.QtWidgets import (
|
||||
qApp, QTextEdit, QAction, QMenu, QShortcut, QMessageBox
|
||||
qApp, QTextEdit, QAction, QMenu, QShortcut, QMessageBox, QLabel
|
||||
)
|
||||
from PyQt5.QtGui import (
|
||||
QTextCursor, QTextOption, QKeySequence, QFont, QColor, QPalette,
|
||||
@@ -41,6 +41,7 @@ from PyQt5.QtGui import (
|
||||
|
||||
from nw.project import NWDoc
|
||||
from nw.gui.tools import GuiDocHighlighter, WordCounter
|
||||
from nw.gui.elements.doctitlebar import GuiDocTitleBar
|
||||
from nw.tools import NWSpellSimple
|
||||
from nw.constants import nwUnicode, nwDocAction
|
||||
|
||||
@@ -82,6 +83,10 @@ class GuiDocEditor(QTextEdit):
|
||||
self.qDocument.setDocumentMargin(self.mainConf.textMargin)
|
||||
self.qDocument.contentsChange.connect(self._docChange)
|
||||
|
||||
# Document Title
|
||||
self.docTitle = GuiDocTitleBar(self, self.theProject)
|
||||
self.docTitle.setGeometry(0,0,self.docTitle.width(),self.docTitle.height())
|
||||
|
||||
# Syntax
|
||||
self.hLight = GuiDocHighlighter(self.qDocument, self.theParent)
|
||||
|
||||
@@ -150,7 +155,7 @@ class GuiDocEditor(QTextEdit):
|
||||
|
||||
self.setDocumentChanged(False)
|
||||
self.theParent.noticeBar.hideNote()
|
||||
self.theParent.updateEditTitle()
|
||||
self.docTitle.setTitleFromHandle(self.theHandle)
|
||||
|
||||
return True
|
||||
|
||||
@@ -265,7 +270,7 @@ class GuiDocEditor(QTextEdit):
|
||||
else:
|
||||
self.theParent.noticeBar.showNote("This document is read only.")
|
||||
|
||||
self.theParent.updateEditTitle()
|
||||
self.docTitle.setTitleFromHandle(self.theHandle)
|
||||
self.hLight.spellCheck = spTemp
|
||||
qApp.restoreOverrideCursor()
|
||||
|
||||
@@ -321,9 +326,16 @@ class GuiDocEditor(QTextEdit):
|
||||
else:
|
||||
tM = self.mainConf.textMargin
|
||||
|
||||
tB = self.lineWidth()
|
||||
tW = self.width() - 2*tB
|
||||
tH = self.docTitle.height()
|
||||
self.docTitle.setGeometry(tB, tB, tW, tH)
|
||||
|
||||
docFormat = self.qDocument.rootFrame().frameFormat()
|
||||
docFormat.setLeftMargin(tM)
|
||||
docFormat.setRightMargin(tM)
|
||||
if docFormat.topMargin() < tH:
|
||||
docFormat.setTopMargin(tH + 2)
|
||||
|
||||
# Updating root frame triggers a QTextDocument->contentsChange
|
||||
# signal, which we do not want as it re-runs the syntax
|
||||
|
||||
Reference in New Issue
Block a user