diff --git a/src/functions.py b/src/functions.py index 6a78d7f6..acc2c587 100644 --- a/src/functions.py +++ b/src/functions.py @@ -8,6 +8,7 @@ import os # Used to detect multiple connections AUC = Qt.AutoConnection | Qt.UniqueConnection +MW = None def wordCount(text): return len(text.strip().replace(" ", "\n").split("\n")) if text else 0 @@ -58,10 +59,15 @@ def colorFromProgress(progress): return c3 def mainWindow(): - for i in qApp.topLevelWidgets(): - if i.objectName() == "MainWindow": - return i - return None + global MW + if not MW: + for i in qApp.topLevelWidgets(): + if i.objectName() == "MainWindow": + MW = i + return MW + return None + else: + return MW def iconColor(icon): "Returns a QRgb from a QIcon, assuming its all the same color" @@ -165,4 +171,10 @@ def allPaths(suffix=None): return paths def lightBlue(): - return QColor(Qt.blue).lighter(190) \ No newline at end of file + return QColor(Qt.blue).lighter(190) + +def totalObjects(): + return len(mainWindow().findChildren(QObject)) + +def printObjects(): + print("Objects:", str(totalObjects())) \ No newline at end of file diff --git a/src/ui/editors/editorWidget.py b/src/ui/editors/editorWidget.py index 64b67b16..db468ab2 100644 --- a/src/ui/editors/editorWidget.py +++ b/src/ui/editors/editorWidget.py @@ -106,6 +106,7 @@ class editorWidget(QWidget, Ui_editorWidget_ui): highlighting=True, autoResize=True) edt.setFrameShape(QFrame.NoFrame) + edt.setStyleSheet("background: {};".format(settings.textEditor["background"])) edt.setStatusTip("{} ({})".format(itm.path(), itm.type())) self.toggledSpellcheck.connect(edt.toggleSpellcheck, AUC) self.dictChanged.connect(edt.setDict, AUC) @@ -147,9 +148,9 @@ class editorWidget(QWidget, Ui_editorWidget_ui): if item and item.isFolder() and self.folderView == "text": self.stack.setCurrentIndex(1) - w = QWidget() l = QVBoxLayout(w) + w.setStyleSheet("background: {};".format(settings.textEditor["background"])) #self.scroll.setWidgetResizable(False) self.txtEdits = [] diff --git a/src/ui/editors/mainEditor.py b/src/ui/editors/mainEditor.py index bb2768bd..f9e4e300 100644 --- a/src/ui/editors/mainEditor.py +++ b/src/ui/editors/mainEditor.py @@ -66,7 +66,9 @@ class mainEditor(QWidget, Ui_mainEditor): def closeTab(self, index): #FIXME: submit data if textedit? + w = self.tab.widget(index) self.tab.removeTab(index) + w.deleteLater() def allTabs(self): return [self.tab.widget(i) for i in range(self.tab.count())] diff --git a/src/ui/views/textEditView.py b/src/ui/views/textEditView.py index 1366b5bf..f1c2ac04 100644 --- a/src/ui/views/textEditView.py +++ b/src/ui/views/textEditView.py @@ -21,7 +21,6 @@ class textEditView(QTextEdit): def __init__(self, parent=None, index=None, html=None, spellcheck=True, highlighting=False, dict="", autoResize=False): QTextEdit.__init__(self, parent) - self._column = Outline.text.value self._index = None self._indexes = None @@ -38,7 +37,7 @@ class textEditView(QTextEdit): self.spellcheck = spellcheck self.currentDict = dict if dict else settings.dict self.highlighter = None - self._autoResize = autoResize + self.setAutoResize(autoResize) self._defaultBlockFormat = QTextBlockFormat() self._defaultCharFormat = QTextCharFormat() self.highlightWord = "" @@ -69,8 +68,6 @@ class textEditView(QTextEdit): elif html: self.document().setHtml(html) self.setReadOnly(True) - - self.setAutoResize(self._autoResize) # Spellchecking if enchant and self.spellcheck: