mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-15 02:12:29 +12:00
Cleaning up a bit
This commit is contained in:
parent
2c0e3074ce
commit
b676d126ba
|
@ -12,7 +12,7 @@ from PyQt5.QtGui import QBrush, QIcon, QPainter
|
|||
from PyQt5.QtGui import QColor
|
||||
from PyQt5.QtGui import QImage
|
||||
from PyQt5.QtGui import QPixmap
|
||||
from PyQt5.QtWidgets import qApp
|
||||
from PyQt5.QtWidgets import qApp, QTextEdit
|
||||
|
||||
from manuskript.enums import Outline
|
||||
|
||||
|
@ -235,4 +235,15 @@ def findFirstFile(regex, path="resources"):
|
|||
lst = os.listdir(p)
|
||||
for l in lst:
|
||||
if re.match(regex, l):
|
||||
return os.path.join(p, l)
|
||||
return os.path.join(p, l)
|
||||
|
||||
|
||||
def HTML2PlainText(html):
|
||||
"""
|
||||
Ressource-inefficient way to convert HTML to plain text.
|
||||
@param html:
|
||||
@return:
|
||||
"""
|
||||
e = QTextEdit()
|
||||
e.setHtml(html)
|
||||
return e.toPlainText()
|
|
@ -15,7 +15,7 @@ from manuskript import settings
|
|||
from lxml import etree as ET
|
||||
|
||||
from manuskript.enums import Outline
|
||||
from manuskript.functions import mainWindow, toInt, wordCount
|
||||
from manuskript.functions import mainWindow, toInt, wordCount, HTML2PlainText
|
||||
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
import time, os
|
||||
|
@ -531,9 +531,7 @@ class outlineItem():
|
|||
oldType = self._data[Outline.type]
|
||||
if oldType == "html" and data in ["txt", "t2t", "md"]:
|
||||
# Resource inneficient way to convert HTML to plain text
|
||||
e = QTextEdit()
|
||||
e.setHtml(self._data[Outline.text])
|
||||
self._data[Outline.text] = e.toPlainText()
|
||||
self._data[Outline.text] = HTML2PlainText(self._data[Outline.text])
|
||||
elif oldType in ["txt", "t2t", "md"] and data == "html" and Outline.text in self._data:
|
||||
self._data[Outline.text] = self._data[Outline.text].replace("\n", "<br>")
|
||||
|
||||
|
|
|
@ -243,7 +243,6 @@ class settingsWindow(QWidget, Ui_Settings):
|
|||
|
||||
sttgs = QSettings()
|
||||
sttgs.setValue("autoLoad", True if self.chkAutoLoad.checkState() else False)
|
||||
print("Setting Value:", True if self.chkAutoLoad.checkState() else False)
|
||||
sttgs.sync()
|
||||
|
||||
settings.autoSave = True if self.chkAutoSave.checkState() else False
|
||||
|
|
Loading…
Reference in a new issue