mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-18 02:44:35 +12:00
Delete some objects when necessary
This commit is contained in:
parent
fc3d178acf
commit
3a8062f710
|
@ -8,6 +8,7 @@ import os
|
||||||
|
|
||||||
# Used to detect multiple connections
|
# Used to detect multiple connections
|
||||||
AUC = Qt.AutoConnection | Qt.UniqueConnection
|
AUC = Qt.AutoConnection | Qt.UniqueConnection
|
||||||
|
MW = None
|
||||||
|
|
||||||
def wordCount(text):
|
def wordCount(text):
|
||||||
return len(text.strip().replace(" ", "\n").split("\n")) if text else 0
|
return len(text.strip().replace(" ", "\n").split("\n")) if text else 0
|
||||||
|
@ -58,10 +59,15 @@ def colorFromProgress(progress):
|
||||||
return c3
|
return c3
|
||||||
|
|
||||||
def mainWindow():
|
def mainWindow():
|
||||||
for i in qApp.topLevelWidgets():
|
global MW
|
||||||
if i.objectName() == "MainWindow":
|
if not MW:
|
||||||
return i
|
for i in qApp.topLevelWidgets():
|
||||||
return None
|
if i.objectName() == "MainWindow":
|
||||||
|
MW = i
|
||||||
|
return MW
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return MW
|
||||||
|
|
||||||
def iconColor(icon):
|
def iconColor(icon):
|
||||||
"Returns a QRgb from a QIcon, assuming its all the same color"
|
"Returns a QRgb from a QIcon, assuming its all the same color"
|
||||||
|
@ -165,4 +171,10 @@ def allPaths(suffix=None):
|
||||||
return paths
|
return paths
|
||||||
|
|
||||||
def lightBlue():
|
def lightBlue():
|
||||||
return QColor(Qt.blue).lighter(190)
|
return QColor(Qt.blue).lighter(190)
|
||||||
|
|
||||||
|
def totalObjects():
|
||||||
|
return len(mainWindow().findChildren(QObject))
|
||||||
|
|
||||||
|
def printObjects():
|
||||||
|
print("Objects:", str(totalObjects()))
|
|
@ -106,6 +106,7 @@ class editorWidget(QWidget, Ui_editorWidget_ui):
|
||||||
highlighting=True,
|
highlighting=True,
|
||||||
autoResize=True)
|
autoResize=True)
|
||||||
edt.setFrameShape(QFrame.NoFrame)
|
edt.setFrameShape(QFrame.NoFrame)
|
||||||
|
edt.setStyleSheet("background: {};".format(settings.textEditor["background"]))
|
||||||
edt.setStatusTip("{} ({})".format(itm.path(), itm.type()))
|
edt.setStatusTip("{} ({})".format(itm.path(), itm.type()))
|
||||||
self.toggledSpellcheck.connect(edt.toggleSpellcheck, AUC)
|
self.toggledSpellcheck.connect(edt.toggleSpellcheck, AUC)
|
||||||
self.dictChanged.connect(edt.setDict, 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":
|
if item and item.isFolder() and self.folderView == "text":
|
||||||
self.stack.setCurrentIndex(1)
|
self.stack.setCurrentIndex(1)
|
||||||
|
|
||||||
w = QWidget()
|
w = QWidget()
|
||||||
l = QVBoxLayout(w)
|
l = QVBoxLayout(w)
|
||||||
|
w.setStyleSheet("background: {};".format(settings.textEditor["background"]))
|
||||||
#self.scroll.setWidgetResizable(False)
|
#self.scroll.setWidgetResizable(False)
|
||||||
|
|
||||||
self.txtEdits = []
|
self.txtEdits = []
|
||||||
|
|
|
@ -66,7 +66,9 @@ class mainEditor(QWidget, Ui_mainEditor):
|
||||||
|
|
||||||
def closeTab(self, index):
|
def closeTab(self, index):
|
||||||
#FIXME: submit data if textedit?
|
#FIXME: submit data if textedit?
|
||||||
|
w = self.tab.widget(index)
|
||||||
self.tab.removeTab(index)
|
self.tab.removeTab(index)
|
||||||
|
w.deleteLater()
|
||||||
|
|
||||||
def allTabs(self):
|
def allTabs(self):
|
||||||
return [self.tab.widget(i) for i in range(self.tab.count())]
|
return [self.tab.widget(i) for i in range(self.tab.count())]
|
||||||
|
|
|
@ -21,7 +21,6 @@ class textEditView(QTextEdit):
|
||||||
|
|
||||||
def __init__(self, parent=None, index=None, html=None, spellcheck=True, highlighting=False, dict="", autoResize=False):
|
def __init__(self, parent=None, index=None, html=None, spellcheck=True, highlighting=False, dict="", autoResize=False):
|
||||||
QTextEdit.__init__(self, parent)
|
QTextEdit.__init__(self, parent)
|
||||||
|
|
||||||
self._column = Outline.text.value
|
self._column = Outline.text.value
|
||||||
self._index = None
|
self._index = None
|
||||||
self._indexes = None
|
self._indexes = None
|
||||||
|
@ -38,7 +37,7 @@ class textEditView(QTextEdit):
|
||||||
self.spellcheck = spellcheck
|
self.spellcheck = spellcheck
|
||||||
self.currentDict = dict if dict else settings.dict
|
self.currentDict = dict if dict else settings.dict
|
||||||
self.highlighter = None
|
self.highlighter = None
|
||||||
self._autoResize = autoResize
|
self.setAutoResize(autoResize)
|
||||||
self._defaultBlockFormat = QTextBlockFormat()
|
self._defaultBlockFormat = QTextBlockFormat()
|
||||||
self._defaultCharFormat = QTextCharFormat()
|
self._defaultCharFormat = QTextCharFormat()
|
||||||
self.highlightWord = ""
|
self.highlightWord = ""
|
||||||
|
@ -69,8 +68,6 @@ class textEditView(QTextEdit):
|
||||||
elif html:
|
elif html:
|
||||||
self.document().setHtml(html)
|
self.document().setHtml(html)
|
||||||
self.setReadOnly(True)
|
self.setReadOnly(True)
|
||||||
|
|
||||||
self.setAutoResize(self._autoResize)
|
|
||||||
|
|
||||||
# Spellchecking
|
# Spellchecking
|
||||||
if enchant and self.spellcheck:
|
if enchant and self.spellcheck:
|
||||||
|
|
Loading…
Reference in a new issue