mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-18 11:52:25 +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
|
||||
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)
|
||||
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,
|
||||
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 = []
|
||||
|
|
|
@ -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())]
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue