diff --git a/i18n/manuskript_fr.ts b/i18n/manuskript_fr.ts
index 6a3a5a7e..846db3ee 100644
--- a/i18n/manuskript_fr.ts
+++ b/i18n/manuskript_fr.ts
@@ -581,27 +581,27 @@
Close project
-
+ Fermer le projet
The file {} does not exist. Try again.
-
+ Le fichier {} n'existe pas. Essayez encore.
Project {} loaded with some errors:
-
+ Le projet {} a été chargé, avec des erreurs:
* {} wasn't found in project file.
-
+ * {} n'a pas été trouvé dans le fichier du projet.
Project {} loaded with some errors.
-
+ Le projet {} a été chargé avec des erreurs.
@@ -1425,12 +1425,12 @@ des lignes:
Form
- Form
+ Form
1
-
+
@@ -1510,97 +1510,97 @@ des lignes:
Save project as...
-
+ Enregistrer le projer sous...
Create New Project
-
+ Créer un nouveau projet
Chapter
- Chapitre
+ Chapitre
Scene
- Scène
+ Scène
Trilogy
-
+ Trilogie
Book
-
+ Livre
Section
-
+ Section
words each.
-
+ mots chacun(e).
of
-
+ de
Text
- Texte
+ Texte
Something
-
+ Quelque chose
<b>Total:</b> {} words (~ {} pages)
-
+ <b>Total:</b> {} mots (~ {} pages)
Idea
- Idée
+ Idée
Note
- Note
+ Note
Research
- Recherche
+ Recherche
TODO
- TODO
+ TODO
First draft
- Premier brouillon
+ Premier brouillon
Second draft
- Second brouillon
+ Second brouillon
Final
- Final
+ Final
diff --git a/src/main.py b/src/main.py
index 79c1a744..0417fd62 100644
--- a/src/main.py
+++ b/src/main.py
@@ -6,7 +6,7 @@ from qt import *
_version = "0.1"
import faulthandler
-#faulthandler.enable()
+faulthandler.enable()
def run():
diff --git a/src/mainWindow.py b/src/mainWindow.py
index 074d6f19..360f2193 100644
--- a/src/mainWindow.py
+++ b/src/mainWindow.py
@@ -13,6 +13,7 @@ from models.persosProxyModel import *
from functions import *
from settingsWindow import *
import settings
+import imp
# Spell checker support
try:
@@ -321,7 +322,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.currentProject = project
# Load empty settings
- import settings
+ imp.reload(settings)
QSettings().setValue("lastProject", project)
# Load data
diff --git a/src/models/outlineModel.py b/src/models/outlineModel.py
index 03fef8c1..4f3646ef 100644
--- a/src/models/outlineModel.py
+++ b/src/models/outlineModel.py
@@ -91,8 +91,11 @@ class outlineModel(QAbstractItemModel):
if item.data(index.column(), role) != value:
item.setData(index.column(), value, role)
- self.dataChanged.emit(index.sibling(index.row(), 0),
- index.sibling(index.row(), max([i.value for i in Outline])))
+ #self.dataChanged.emit(index.sibling(index.row(), 0),
+ #index.sibling(index.row(), max([i.value for i in Outline])))
+ self.dataChanged.emit(index.sibling(index.row(), index.column()),
+ index.sibling(index.row(), index.column()))
+
return True
@@ -485,7 +488,8 @@ class outlineItem():
else:
self.setData(Outline.goalPercentage.value, "")
- self.emitDataChanged()
+ self.emitDataChanged([Outline.goal.value, Outline.setGoal.value,
+ Outline.wordCount.value, Outline.goalPercentage.value])
if self.parent():
self.parent().updateWordCount()
@@ -514,10 +518,16 @@ class outlineItem():
else:
return QModelIndex()
- def emitDataChanged(self):
+ def emitDataChanged(self, cols=None):
idx = self.index()
if idx and self._model:
- self._model.dataChanged.emit(idx, self.index(len(Outline)))
+ if not cols:
+ # Emit data changed for the whole item (all columns)
+ self._model.dataChanged.emit(idx, self.index(len(Outline)))
+ else:
+ # Emit only for the specified columns
+ for c in cols:
+ self._model.dataChanged.emit(self.index(c), self.index(c))
def removeChild(self, row):
self.childItems.pop(row)
diff --git a/src/ui/editors/basicHighlighter.py b/src/ui/editors/basicHighlighter.py
index 3f32ebc9..c389040c 100644
--- a/src/ui/editors/basicHighlighter.py
+++ b/src/ui/editors/basicHighlighter.py
@@ -10,6 +10,7 @@ class basicHighlighter(QSyntaxHighlighter):
QSyntaxHighlighter.__init__(self, editor.document())
self.editor = editor
+ self._misspelledColor = Qt.red
def setDefaultBlockFormat(self, bf):
self._defaultBlockFormat = bf
@@ -17,6 +18,12 @@ class basicHighlighter(QSyntaxHighlighter):
def setMisspelledColor(self, color):
self._misspelledColor = color
+
+ def setStyle(self):
+ """t2tHighlighter needs to reupdates styles on some occasions (see themes.py).
+ This lazy function allow to update without checking the type of highlighter.
+ """
+ pass
def highlightBlock(self, text):
"""Apply syntax highlighting to the given block of text.
diff --git a/src/ui/editors/editorWidget.py b/src/ui/editors/editorWidget.py
index 85cc608a..1cf35396 100644
--- a/src/ui/editors/editorWidget.py
+++ b/src/ui/editors/editorWidget.py
@@ -5,6 +5,7 @@ from qt import *
from enums import *
from ui.editors.editorWidget_ui import *
from ui.editors.fullScreenEditor import *
+from ui.editors.textFormat import *
from ui.views.textEditView import *
from functions import *
import settings
diff --git a/src/ui/editors/fullScreenEditor.py b/src/ui/editors/fullScreenEditor.py
index 770f49fa..f539c7dd 100644
--- a/src/ui/editors/fullScreenEditor.py
+++ b/src/ui/editors/fullScreenEditor.py
@@ -5,6 +5,8 @@ from qt import *
from enums import *
from ui.views.textEditView import *
from ui.editors.themes import *
+from ui.editors.textFormat import *
+
from functions import *
import settings
@@ -17,13 +19,15 @@ class fullScreenEditor(QWidget):
self._theme = findThemePath(settings.fullScreenTheme)
self._themeDatas = loadThemeDatas(self._theme)
self.setMouseTracking(True)
+ self._geometries = {}
# Text editor
- self.editor = textEditView(self, index=index, spellcheck=settings.spellcheck, dict=settings.dict)
+ self.editor = textEditView(self,
+ index=index,
+ spellcheck=settings.spellcheck,
+ highlighting=True,
+ dict=settings.dict)
self.editor.setFrameStyle(QFrame.NoFrame)
- #f = QFile(appPath("resources/themes/preview.txt"))
- #f.open(QIODevice.ReadOnly)
- #self.editor.setPlainText(QTextStream(f).readAll()*5)
self.editor.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.editor.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.editor.installEventFilter(self)
@@ -35,8 +39,9 @@ class fullScreenEditor(QWidget):
# Top Panel
self.topPanel = myPanel(parent=self)
- self.topPanel.layout().addStretch(1)
+ #self.topPanel.layout().addStretch(1)
+ # Spell checking
self.btnSpellCheck = QPushButton()
self.btnSpellCheck.setFlat(True)
self.btnSpellCheck.setIcon(QIcon.fromTheme("tools-check-spelling"))
@@ -46,6 +51,11 @@ class fullScreenEditor(QWidget):
self.topPanel.layout().addWidget(self.btnSpellCheck)
self.topPanel.layout().addStretch(1)
+ # Formatting
+ self.textFormat = textFormat(self)
+ self.topPanel.layout().addWidget(self.textFormat)
+ self.topPanel.layout().addStretch(1)
+
b = QPushButton(self)
b.setIcon(qApp.style().standardIcon(QStyle.SP_DialogCloseButton))
b.clicked.connect(self.close)
@@ -95,6 +105,8 @@ class fullScreenEditor(QWidget):
self.updateTheme()
def updateTheme(self):
+ # Reinit stored geometries for hiding widgets
+ self._geometries = {}
rect = self.geometry()
self._background = generateTheme(self._themeDatas, rect)
@@ -118,7 +130,8 @@ class fullScreenEditor(QWidget):
r.setWidth(w)
r.moveRight(rect.right() - rect.left())
self.scrollBar.setGeometry(r)
- self.scrollBar.setVisible(False)
+ #self.scrollBar.setVisible(False)
+ self.hideWidget(self.scrollBar)
p = self.scrollBar.palette()
b = QBrush(self._background.copy(self.scrollBar.geometry()))
p.setBrush(QPalette.Base, b)
@@ -131,10 +144,12 @@ class fullScreenEditor(QWidget):
r.setWidth(rect.width())
#r.moveLeft(rect.center().x() - r.width() / 2)
self.topPanel.setGeometry(r)
- self.topPanel.setVisible(False)
+ #self.topPanel.setVisible(False)
+ self.hideWidget(self.topPanel)
r.moveBottom(rect.bottom() - rect.top())
self.bottomPanel.setGeometry(r)
- self.bottomPanel.setVisible(False)
+ #self.bottomPanel.setVisible(False)
+ self.hideWidget(self.bottomPanel)
self.topPanel.setColor(self._bgcolor)
self.bottomPanel.setColor(self._bgcolor)
@@ -175,12 +190,26 @@ class fullScreenEditor(QWidget):
r = self.geometry()
for w in [self.scrollBar, self.topPanel, self.bottomPanel]:
- w.setVisible(w.geometry().contains(event.pos()))
+ #w.setVisible(w.geometry().contains(event.pos()))
+ if self._geometries[w].contains(event.pos()):
+ self.showWidget(w)
+ else:
+ self.hideWidget(w)
+
+ def hideWidget(self, widget):
+ if widget not in self._geometries:
+ self._geometries[widget] = widget.geometry()
+ widget.move(self.geometry().bottomRight())
+
+ def showWidget(self, widget):
+ if widget in self._geometries:
+ widget.move(self._geometries[widget].topLeft())
def eventFilter(self, obj, event):
if obj == self.editor and event.type() == QEvent.Enter:
for w in [self.scrollBar, self.topPanel, self.bottomPanel]:
- w.setVisible(False)
+ #w.setVisible(False)
+ self.hideWidget(w)
return QWidget.eventFilter(self, obj, event)
def dataChanged(self, topLeft, bottomRight):
@@ -219,9 +248,9 @@ class myScrollBar(QScrollBar):
self.timer = QTimer()
self.timer.setInterval(500)
self.timer.setSingleShot(True)
- self.timer.timeout.connect(self.hide)
+ self.timer.timeout.connect(lambda: self.parent().hideWidget(self))
self.valueChanged.connect(lambda v: self.timer.start())
- self.valueChanged.connect(self.show)
+ self.valueChanged.connect(lambda: self.parent().showWidget(self))
def setColor(self, color):
self._color = color
@@ -233,11 +262,11 @@ class myScrollBar(QScrollBar):
painter = QPainter(self)
# Background (Necessary with Qt 5.2 it seems, not with 5.4)
- painter.save()
- painter.setPen(Qt.NoPen)
- painter.setBrush(self.palette().brush(QPalette.Base))
- painter.drawRect(event.rect())
- painter.restore()
+ #painter.save()
+ #painter.setPen(Qt.NoPen)
+ #painter.setBrush(self.palette().brush(QPalette.Base))
+ #painter.drawRect(event.rect())
+ #painter.restore()
#slider
r = style.subControlRect(style.CC_ScrollBar, opt, style.SC_ScrollBarSlider)
diff --git a/src/ui/editors/textFormat.py b/src/ui/editors/textFormat.py
new file mode 100644
index 00000000..6c2fce20
--- /dev/null
+++ b/src/ui/editors/textFormat.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+#--!-- coding: utf8 --!--
+
+from qt import *
+from enums import *
+from models.outlineModel import *
+from ui.editors.textFormat_ui import *
+from functions import *
+
+class textFormat(QWidget, Ui_textFormat):
+
+ def __init__(self, parent=None):
+ QWidget.__init__(self, parent)
+ self.setupUi(self)
+ self._textEdit = None
+
+ formats = {
+ "Bold": [self.btnBold, "format-text-bold", self.tr("CTRL+B")],
+ "Italic": [self.btnItalic, "format-text-italic", self.tr("CTRL+I")],
+ "Underline": [self.btnUnderlined, "format-text-underline", self.tr("CTRL+U")],
+ "Clear": [self.btnClear, "edit-clear", self.tr("CTRL+P")],
+ "Left": [self.btnLeft, "format-justify-left", self.tr("CTRL+L")],
+ "Center": [self.btnCenter, "format-justify-center", self.tr("CTRL+E")],
+ "Right": [self.btnRight, "format-justify-right", self.tr("CTRL+R")],
+ }
+
+ for f in formats:
+ val = formats[f]
+ a = QAction(QIcon.fromTheme(val[1]), f, self)
+ a.setShortcut(val[2])
+ a.triggered.connect(self.setFormat)
+ val[0].setDefaultAction(a)
+
+ def setTextEdit(self, textEdit):
+ self._textEdit = textEdit
+
+ def updateFromIndex(self, index):
+ if not index.isValid():
+ self.setVisible(False)
+ return
+
+ if type(index.model()) != outlineModel:
+ self.setVisible(False)
+ return
+
+ self.setVisible(True)
+ item = index.internalPointer()
+
+ self.align.setVisible(True)
+ self.format.setVisible(True)
+
+ if item.isFolder():
+ self.setVisible(False)
+ return
+
+ elif item.isText():
+ self.align.setVisible(False)
+ self.format.setVisible(False)
+ elif item.isT2T():
+ self.align.setVisible(False)
+
+
+ def setFormat(self):
+ act = self.sender()
+ if self._textEdit:
+ self._textEdit.applyFormat(act.text())
\ No newline at end of file
diff --git a/src/ui/editors/textFormat_ui.py b/src/ui/editors/textFormat_ui.py
new file mode 100644
index 00000000..b580ede9
--- /dev/null
+++ b/src/ui/editors/textFormat_ui.py
@@ -0,0 +1,83 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file 'src/ui/editors/textFormat_ui.ui'
+#
+# Created by: PyQt5 UI code generator 5.4.1
+#
+# WARNING! All changes made in this file will be lost!
+
+from PyQt5 import QtCore, QtGui, QtWidgets
+
+class Ui_textFormat(object):
+ def setupUi(self, textFormat):
+ textFormat.setObjectName("textFormat")
+ textFormat.resize(507, 34)
+ self.horizontalLayout_3 = QtWidgets.QHBoxLayout(textFormat)
+ self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0)
+ self.horizontalLayout_3.setObjectName("horizontalLayout_3")
+ self.format = QtWidgets.QWidget(textFormat)
+ self.format.setObjectName("format")
+ self.horizontalLayout = QtWidgets.QHBoxLayout(self.format)
+ self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
+ self.horizontalLayout.setObjectName("horizontalLayout")
+ spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.horizontalLayout.addItem(spacerItem)
+ self.btnBold = QtWidgets.QToolButton(self.format)
+ self.btnBold.setText("")
+ self.btnBold.setObjectName("btnBold")
+ self.horizontalLayout.addWidget(self.btnBold)
+ self.btnItalic = QtWidgets.QToolButton(self.format)
+ self.btnItalic.setText("")
+ icon = QtGui.QIcon()
+ icon.addPixmap(QtGui.QPixmap(), QtGui.QIcon.Normal, QtGui.QIcon.Off)
+ self.btnItalic.setIcon(icon)
+ self.btnItalic.setObjectName("btnItalic")
+ self.horizontalLayout.addWidget(self.btnItalic)
+ self.btnUnderlined = QtWidgets.QToolButton(self.format)
+ self.btnUnderlined.setText("")
+ self.btnUnderlined.setIcon(icon)
+ self.btnUnderlined.setObjectName("btnUnderlined")
+ self.horizontalLayout.addWidget(self.btnUnderlined)
+ self.btnClear = QtWidgets.QToolButton(self.format)
+ self.btnClear.setText("")
+ icon1 = QtGui.QIcon()
+ icon1.addPixmap(QtGui.QPixmap("../"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
+ self.btnClear.setIcon(icon1)
+ self.btnClear.setObjectName("btnClear")
+ self.horizontalLayout.addWidget(self.btnClear)
+ spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.horizontalLayout.addItem(spacerItem1)
+ self.horizontalLayout_3.addWidget(self.format)
+ self.align = QtWidgets.QWidget(textFormat)
+ self.align.setObjectName("align")
+ self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.align)
+ self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
+ self.horizontalLayout_2.setObjectName("horizontalLayout_2")
+ spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.horizontalLayout_2.addItem(spacerItem2)
+ self.btnLeft = QtWidgets.QToolButton(self.align)
+ self.btnLeft.setText("")
+ self.btnLeft.setIcon(icon)
+ self.btnLeft.setObjectName("btnLeft")
+ self.horizontalLayout_2.addWidget(self.btnLeft)
+ self.btnCenter = QtWidgets.QToolButton(self.align)
+ self.btnCenter.setText("")
+ self.btnCenter.setIcon(icon)
+ self.btnCenter.setObjectName("btnCenter")
+ self.horizontalLayout_2.addWidget(self.btnCenter)
+ self.btnRight = QtWidgets.QToolButton(self.align)
+ self.btnRight.setText("")
+ self.btnRight.setIcon(icon)
+ self.btnRight.setObjectName("btnRight")
+ self.horizontalLayout_2.addWidget(self.btnRight)
+ spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.horizontalLayout_2.addItem(spacerItem3)
+ self.horizontalLayout_3.addWidget(self.align)
+
+ self.retranslateUi(textFormat)
+ QtCore.QMetaObject.connectSlotsByName(textFormat)
+
+ def retranslateUi(self, textFormat):
+ _translate = QtCore.QCoreApplication.translate
+ textFormat.setWindowTitle(_translate("textFormat", "Form"))
+
diff --git a/src/ui/editors/textFormat_ui.ui b/src/ui/editors/textFormat_ui.ui
new file mode 100644
index 00000000..c85feeee
--- /dev/null
+++ b/src/ui/editors/textFormat_ui.ui
@@ -0,0 +1,172 @@
+
+
+ textFormat
+
+
+
+ 0
+ 0
+ 507
+ 34
+
+
+
+ Form
+
+
+
+ 0
+
+ -
+
+
+
+ 0
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+ ../../
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+
+ -
+
+
+
+ 0
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ui/mainWindow.py b/src/ui/mainWindow.py
index 0efa9324..66dae7df 100644
--- a/src/ui/mainWindow.py
+++ b/src/ui/mainWindow.py
@@ -11,7 +11,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
- MainWindow.resize(1089, 803)
+ MainWindow.resize(1145, 801)
MainWindow.setWindowTitle("Manuskript")
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
@@ -1007,7 +1007,7 @@ class Ui_MainWindow(object):
self.horizontalLayout_12.addWidget(self.stack)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
- self.menubar.setGeometry(QtCore.QRect(0, 0, 1089, 31))
+ self.menubar.setGeometry(QtCore.QRect(0, 0, 1145, 31))
self.menubar.setObjectName("menubar")
self.menuFile = QtWidgets.QMenu(self.menubar)
self.menuFile.setObjectName("menuFile")
@@ -1106,8 +1106,8 @@ class Ui_MainWindow(object):
self.menubar.addAction(self.menuHelp.menuAction())
self.retranslateUi(MainWindow)
- self.stack.setCurrentIndex(0)
- self.tabMain.setCurrentIndex(5)
+ self.stack.setCurrentIndex(1)
+ self.tabMain.setCurrentIndex(6)
self.tabSummary.setCurrentIndex(0)
self.tabPersos.setCurrentIndex(0)
self.tabPlot.setCurrentIndex(1)
@@ -1256,8 +1256,8 @@ from ui.views.basicItemView import basicItemView
from ui.views.plotTreeView import plotTreeView
from ui.views.metadataView import metadataView
from ui.views.treeView import treeView
-from ui.sldImportance import sldImportance
-from ui.views.lineEditView import lineEditView
-from ui.views.textEditView import textEditView
-from ui.views.outlineView import outlineView
from ui.editors.editorWidget import editorWidget
+from ui.views.outlineView import outlineView
+from ui.views.textEditView import textEditView
+from ui.views.lineEditView import lineEditView
+from ui.sldImportance import sldImportance
diff --git a/src/ui/mainWindow.ui b/src/ui/mainWindow.ui
index 45b56c92..03c687cc 100644
--- a/src/ui/mainWindow.ui
+++ b/src/ui/mainWindow.ui
@@ -6,8 +6,8 @@
0
0
- 1089
- 803
+ 1145
+ 801
@@ -30,7 +30,7 @@
-
- 0
+ 1
@@ -109,7 +109,7 @@
-
- 5
+ 6
true
@@ -1941,7 +1941,7 @@
0
0
- 1089
+ 1145
31
@@ -2168,6 +2168,11 @@
QTextEdit
+
+ lineEditView
+ QLineEdit
+
+
outlineView
QTreeView
@@ -2190,11 +2195,6 @@
QTreeView
-
- lineEditView
- QLineEdit
-
-
metadataView
QWidget
diff --git a/src/ui/views/metadataView_ui.py b/src/ui/views/metadataView_ui.py
index ace0eb31..24e604d5 100644
--- a/src/ui/views/metadataView_ui.py
+++ b/src/ui/views/metadataView_ui.py
@@ -15,6 +15,9 @@ class Ui_metadataView(object):
self.verticalLayout = QtWidgets.QVBoxLayout(metadataView)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setObjectName("verticalLayout")
+ self.textFormat = textFormat(metadataView)
+ self.textFormat.setObjectName("textFormat")
+ self.verticalLayout.addWidget(self.textFormat)
self.groupBox_4 = collapsibleGroupBox2(metadataView)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
@@ -70,7 +73,8 @@ class Ui_metadataView(object):
self.txtSummarySentance.setPlaceholderText(_translate("metadataView", "One line summary"))
self.groupBox_6.setTitle(_translate("metadataView", "Notes"))
+from ui.editors.textFormat import textFormat
+from ui.collapsibleGroupBox2 import collapsibleGroupBox2
from ui.views.lineEditView import lineEditView
from ui.views.textEditView import textEditView
-from ui.collapsibleGroupBox2 import collapsibleGroupBox2
from ui.views.propertiesView import propertiesView
diff --git a/src/ui/views/metadataView_ui.ui b/src/ui/views/metadataView_ui.ui
index 02d89b88..564bd593 100644
--- a/src/ui/views/metadataView_ui.ui
+++ b/src/ui/views/metadataView_ui.ui
@@ -17,6 +17,9 @@
0
+
-
+
+
-
@@ -128,6 +131,12 @@
QLineEdit
+
+ textFormat
+ QWidget
+
+ 1
+
diff --git a/src/ui/views/textEditView.py b/src/ui/views/textEditView.py
index 27a28cb1..316337e0 100644
--- a/src/ui/views/textEditView.py
+++ b/src/ui/views/textEditView.py
@@ -5,6 +5,7 @@ from qt import *
from enums import *
from ui.editors.t2tHighlighter import *
from ui.editors.basicHighlighter import *
+from ui.editors.textFormat import *
from models.outlineModel import *
from functions import *
@@ -36,7 +37,15 @@ class textEditView(QTextEdit):
self.highligtCS = False
self.defaultFontPointSize = qApp.font().pointSize()
self._dict = None
- self.document().contentsChanged.connect(self.submit, AUC)
+ #self.document().contentsChanged.connect(self.submit, AUC)
+
+
+ # Submit text changed only after 500ms without modifications
+ self.updateTimer = QTimer()
+ self.updateTimer.setInterval(500)
+ self.updateTimer.setSingleShot(True)
+ self.updateTimer.timeout.connect(self.submit)
+ self.document().contentsChanged.connect(self.updateTimer.start, AUC)
if index:
self.setCurrentModelIndex(index)
@@ -99,6 +108,7 @@ class textEditView(QTextEdit):
#self._model.dataChanged.disconnect(self.update)
except:
pass
+
self.setPlainText("")
def setupEditorForIndex(self, index):
@@ -137,13 +147,14 @@ class textEditView(QTextEdit):
elif self._index:
if topLeft.row() <= self._index.row() <= bottomRight.row():
-
if topLeft.column() <= Outline.type.value <= bottomRight.column():
# If item type change, we reset the index to set the proper
# highlighter and other defaults
self.setupEditorForIndex(self._index)
+ self.updateText()
- self.updateText()
+ elif topLeft.column() <= self._column <= bottomRight.column():
+ self.updateText()
elif self._indexes:
update = False
@@ -192,7 +203,6 @@ class textEditView(QTextEdit):
self._updating = False
def submit(self):
-
if self._updating:
return
@@ -251,8 +261,10 @@ class textEditView(QTextEdit):
self.heightMax = 65000
self.sizeChange()
- # -----------------------------------------------------------------------------------------------------
- # Spellchecking based on http://john.nachtimwald.com/2009/08/22/qplaintextedit-with-in-line-spell-check/
+###############################################################################
+# SPELLCHECKING
+###############################################################################
+# Based on http://john.nachtimwald.com/2009/08/22/qplaintextedit-with-in-line-spell-check/
def setDict(self, d):
self.currentDict = d
@@ -332,4 +344,22 @@ class textEditView(QTextEdit):
cursor.endEditBlock()
- # -----------------------------------------------------------------------------------------------------
\ No newline at end of file
+###############################################################################
+# FORMATTING
+###############################################################################
+
+ def focusInEvent(self, event):
+ "Finds textFormatter and attach them to that view."
+ QTextEdit.focusInEvent(self, event)
+
+ p = self.parent()
+ while p.parent():
+ p = p.parent()
+
+ if self._index:
+ for tF in p.findChildren(textFormat, QRegExp(".*"), Qt.FindChildrenRecursively):
+ tF.updateFromIndex(self._index)
+ tF.setTextEdit(self)
+
+ def applyFormat(self, _format):
+ print(_format)
\ No newline at end of file