diff --git a/src/models/outlineModel.py b/src/models/outlineModel.py index e3b848ec..260b5386 100644 --- a/src/models/outlineModel.py +++ b/src/models/outlineModel.py @@ -497,7 +497,7 @@ class outlineItem(): e = QTextEdit() e.setHtml(self._data[Outline.text]) self._data[Outline.text] = e.toPlainText() - elif oldType in ["txt", "t2t"] and data == "html": + elif oldType in ["txt", "t2t"] and data == "html" and Outline.text in self._data: self._data[Outline.text] = self._data[Outline.text].replace("\n", "
") # Setting data diff --git a/src/settingsWindow.py b/src/settingsWindow.py index e5d51a17..af39bde1 100644 --- a/src/settingsWindow.py +++ b/src/settingsWindow.py @@ -334,7 +334,6 @@ class settingsWindow(QWidget, Ui_Settings): # Update font and defaultBlockFormat to all textEditView. Drastically. for w in mainWindow().findChildren(textEditView, QRegExp(".*")): - print(w.objectName(), w.parent().objectName()) w.loadFontSettings() def choseEditorFontColor(self): @@ -344,6 +343,7 @@ class settingsWindow(QWidget, Ui_Settings): if color.isValid(): settings.textEditor["fontColor"] = color.name() self.setButtonColor(self.btnEditorFontColor, color.name()) + self.updateEditorSettings() def choseEditorMisspelledColor(self): color = settings.textEditor["misspelled"] @@ -352,6 +352,7 @@ class settingsWindow(QWidget, Ui_Settings): if color.isValid(): settings.textEditor["misspelled"] = color.name() self.setButtonColor(self.btnEditorMisspelledColor, color.name()) + self.updateEditorSettings() #################################################################################################### # STATUS # diff --git a/src/ui/editors/basicHighlighter.py b/src/ui/editors/basicHighlighter.py index 6992df6e..e094cb93 100644 --- a/src/ui/editors/basicHighlighter.py +++ b/src/ui/editors/basicHighlighter.py @@ -43,7 +43,7 @@ class basicHighlighter(QSyntaxHighlighter): bf.setAlignment(QTextCursor(self.currentBlock()).blockFormat().alignment()) QTextCursor(self.currentBlock()).setBlockFormat(bf) - self.setFormat(0, len(text), self._defaultCharFormat) + #self.setFormat(0, len(text), self._defaultCharFormat) def highlightBlockAfter(self, text): """Highlighting to do after everything else. diff --git a/src/ui/editors/fullScreenEditor.py b/src/ui/editors/fullScreenEditor.py index 1d4f4962..245ff3ef 100644 --- a/src/ui/editors/fullScreenEditor.py +++ b/src/ui/editors/fullScreenEditor.py @@ -32,7 +32,6 @@ class fullScreenEditor(QWidget): self.editor.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.editor.installEventFilter(self) self.editor.setMouseTracking(True) - self.editor.setVerticalScrollBar(myScrollBar()) self.scrollBar = self.editor.verticalScrollBar() self.scrollBar.setParent(self) diff --git a/src/ui/editors/themes.py b/src/ui/editors/themes.py index 72f72175..3a5d9c89 100644 --- a/src/ui/editors/themes.py +++ b/src/ui/editors/themes.py @@ -185,13 +185,13 @@ def setThemeEditorDatas(editor, themeDatas, pixmap, screenRect): x, y, width, height = themeEditorGeometry(themeDatas, textRect) editor.setGeometry(x, y, width, height) - p = editor.palette() - #p.setBrush(QPalette.Base, QBrush(pixmap.copy(x, y, width, height))) - p.setBrush(QPalette.Base, QColor(Qt.transparent)) - p.setColor(QPalette.Text, QColor(themeDatas["Text/Color"])) - p.setColor(QPalette.Highlight, QColor(themeDatas["Text/Color"])) - p.setColor(QPalette.HighlightedText, Qt.black if qGray(QColor(themeDatas["Text/Color"]).rgb()) > 127 else Qt.white) - editor.setPalette(p) + #p = editor.palette() + ##p.setBrush(QPalette.Base, QBrush(pixmap.copy(x, y, width, height))) + #p.setBrush(QPalette.Base, QColor(Qt.transparent)) + #p.setColor(QPalette.Text, QColor(themeDatas["Text/Color"])) + #p.setColor(QPalette.Highlight, QColor(themeDatas["Text/Color"])) + #p.setColor(QPalette.HighlightedText, Qt.black if qGray(QColor(themeDatas["Text/Color"]).rgb()) > 127 else Qt.white) + #editor.setPalette(p) editor.setAttribute(Qt.WA_NoSystemBackground, True) @@ -215,13 +215,30 @@ def setThemeEditorDatas(editor, themeDatas, pixmap, screenRect): editor.highlighter.setMisspelledColor(QColor(themeDatas["Text/Misspelled"])) cf = QTextCharFormat() - f = QFont() - f.fromString(themeDatas["Text/Font"]) - cf.setFont(f) - editor.highlighter.setDefaultCharFormat(cf) #f = QFont() #f.fromString(themeDatas["Text/Font"]) - editor.setFont(f) + #cf.setFont(f) + editor.highlighter.setDefaultCharFormat(cf) + f = QFont() + f.fromString(themeDatas["Text/Font"]) + #editor.setFont(f) + + editor.setStyleSheet(""" + background: transparent; + color: {foreground}; + font-family: {ff}; + font-size: {fs}; + selection-color: {sc}; + selection-background-color: {sbc}; + """.format( + foreground=themeDatas["Text/Color"], + ff=f.family(), + fs="{}pt".format(str(f.pointSize())), + sc="black" if qGray(QColor(themeDatas["Text/Color"]).rgb()) > 127 else "white", + sbc=themeDatas["Text/Color"], + ) + ) + editor._fromTheme = True diff --git a/src/ui/views/textEditView.py b/src/ui/views/textEditView.py index a9bec30e..0d711a02 100644 --- a/src/ui/views/textEditView.py +++ b/src/ui/views/textEditView.py @@ -170,12 +170,19 @@ class textEditView(QTextEdit): opt = settings.textEditor f = QFont() f.fromString(opt["font"]) - self.setFont(f) - + #self.setFont(f) + self.setStyleSheet(""" + color: {foreground}; + font-family: {ff}; + font-size: {fs}; + """.format( + foreground=opt["fontColor"], + ff=f.family(), + fs="{}pt".format(str(f.pointSize())))) cf = QTextCharFormat() - cf.setFont(f) - cf.setForeground(QColor(opt["fontColor"])) + #cf.setFont(f) + #cf.setForeground(QColor(opt["fontColor"])) bf = QTextBlockFormat() bf.setLineHeight(opt["lineSpacing"], bf.ProportionalHeight) @@ -306,6 +313,7 @@ class textEditView(QTextEdit): # We don't store font settings html = re.sub(r"font-family:.*?;", "", html) html = re.sub(r"font-size:.*?;", "", html) + #print("Submitting:", html) self._model.setData(self._index, html) self._updating = False else: @@ -464,6 +472,8 @@ class textEditView(QTextEdit): def applyFormat(self, _format): + print(_format) + if self._textFormat == "html": if _format == "Clear":