Many changes. One step closer to mastering the world.

This commit is contained in:
Olivier Keshavjee 2015-06-24 18:39:38 +02:00
parent ae698e000c
commit a14351956b
15 changed files with 488 additions and 76 deletions

View file

@ -581,27 +581,27 @@
<message> <message>
<location filename="../src/ui/mainWindow.ui" line="2161"/> <location filename="../src/ui/mainWindow.ui" line="2161"/>
<source>Close project</source> <source>Close project</source>
<translation type="unfinished"></translation> <translation>Fermer le projet</translation>
</message> </message>
<message> <message>
<location filename="../src/mainWindow.py" line="315"/> <location filename="../src/mainWindow.py" line="315"/>
<source>The file {} does not exist. Try again.</source> <source>The file {} does not exist. Try again.</source>
<translation type="unfinished"></translation> <translation>Le fichier {} n&apos;existe pas. Essayez encore.</translation>
</message> </message>
<message> <message>
<location filename="../src/mainWindow.py" line="555"/> <location filename="../src/mainWindow.py" line="555"/>
<source>Project {} loaded with some errors:</source> <source>Project {} loaded with some errors:</source>
<translation type="unfinished"></translation> <translation>Le projet {} a é chargé, avec des erreurs:</translation>
</message> </message>
<message> <message>
<location filename="../src/mainWindow.py" line="557"/> <location filename="../src/mainWindow.py" line="557"/>
<source> * {} wasn&apos;t found in project file.</source> <source> * {} wasn&apos;t found in project file.</source>
<translation type="unfinished"></translation> <translation>* {} n&apos;a pas é trouvé dans le fichier du projet.</translation>
</message> </message>
<message> <message>
<location filename="../src/mainWindow.py" line="558"/> <location filename="../src/mainWindow.py" line="558"/>
<source>Project {} loaded with some errors.</source> <source>Project {} loaded with some errors.</source>
<translation type="unfinished"></translation> <translation>Le projet {} a é chargé avec des erreurs.</translation>
</message> </message>
</context> </context>
<context> <context>
@ -1425,12 +1425,12 @@ des lignes:</translation>
<message> <message>
<location filename="../src/ui/welcome_ui.ui" line="14"/> <location filename="../src/ui/welcome_ui.ui" line="14"/>
<source>Form</source> <source>Form</source>
<translation type="unfinished">Form</translation> <translation>Form</translation>
</message> </message>
<message> <message>
<location filename="../src/ui/welcome_ui.ui" line="50"/> <location filename="../src/ui/welcome_ui.ui" line="50"/>
<source>1</source> <source>1</source>
<translation type="unfinished"></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../src/ui/welcome.py" line="286"/> <location filename="../src/ui/welcome.py" line="286"/>
@ -1510,97 +1510,97 @@ des lignes:</translation>
<message> <message>
<location filename="../src/ui/welcome.py" line="123"/> <location filename="../src/ui/welcome.py" line="123"/>
<source>Save project as...</source> <source>Save project as...</source>
<translation type="unfinished"></translation> <translation>Enregistrer le projer sous...</translation>
</message> </message>
<message> <message>
<location filename="../src/ui/welcome.py" line="135"/> <location filename="../src/ui/welcome.py" line="135"/>
<source>Create New Project</source> <source>Create New Project</source>
<translation type="unfinished"></translation> <translation>Créer un nouveau projet</translation>
</message> </message>
<message> <message>
<location filename="../src/ui/welcome.py" line="316"/> <location filename="../src/ui/welcome.py" line="316"/>
<source>Chapter</source> <source>Chapter</source>
<translation type="unfinished">Chapitre</translation> <translation>Chapitre</translation>
</message> </message>
<message> <message>
<location filename="../src/ui/welcome.py" line="317"/> <location filename="../src/ui/welcome.py" line="317"/>
<source>Scene</source> <source>Scene</source>
<translation type="unfinished">Scène</translation> <translation>Scène</translation>
</message> </message>
<message> <message>
<location filename="../src/ui/welcome.py" line="166"/> <location filename="../src/ui/welcome.py" line="166"/>
<source>Trilogy</source> <source>Trilogy</source>
<translation type="unfinished"></translation> <translation>Trilogie</translation>
</message> </message>
<message> <message>
<location filename="../src/ui/welcome.py" line="166"/> <location filename="../src/ui/welcome.py" line="166"/>
<source>Book</source> <source>Book</source>
<translation type="unfinished"></translation> <translation>Livre</translation>
</message> </message>
<message> <message>
<location filename="../src/ui/welcome.py" line="173"/> <location filename="../src/ui/welcome.py" line="173"/>
<source>Section</source> <source>Section</source>
<translation type="unfinished"></translation> <translation>Section</translation>
</message> </message>
<message> <message>
<location filename="../src/ui/welcome.py" line="213"/> <location filename="../src/ui/welcome.py" line="213"/>
<source>words each.</source> <source>words each.</source>
<translation type="unfinished"></translation> <translation>mots chacun(e).</translation>
</message> </message>
<message> <message>
<location filename="../src/ui/welcome.py" line="216"/> <location filename="../src/ui/welcome.py" line="216"/>
<source>of</source> <source>of</source>
<translation type="unfinished"></translation> <translation>de</translation>
</message> </message>
<message> <message>
<location filename="../src/ui/welcome.py" line="240"/> <location filename="../src/ui/welcome.py" line="240"/>
<source>Text</source> <source>Text</source>
<translation type="unfinished">Texte</translation> <translation>Texte</translation>
</message> </message>
<message> <message>
<location filename="../src/ui/welcome.py" line="243"/> <location filename="../src/ui/welcome.py" line="243"/>
<source>Something</source> <source>Something</source>
<translation type="unfinished"></translation> <translation>Quelque chose</translation>
</message> </message>
<message> <message>
<location filename="../src/ui/welcome.py" line="265"/> <location filename="../src/ui/welcome.py" line="265"/>
<source>&lt;b&gt;Total:&lt;/b&gt; {} words (~ {} pages)</source> <source>&lt;b&gt;Total:&lt;/b&gt; {} words (~ {} pages)</source>
<translation type="unfinished"></translation> <translation>&lt;b&gt;Total:&lt;/b&gt; {} mots (~ {} pages)</translation>
</message> </message>
<message> <message>
<location filename="../src/ui/welcome.py" line="314"/> <location filename="../src/ui/welcome.py" line="314"/>
<source>Idea</source> <source>Idea</source>
<translation type="unfinished">Idée</translation> <translation>Idée</translation>
</message> </message>
<message> <message>
<location filename="../src/ui/welcome.py" line="315"/> <location filename="../src/ui/welcome.py" line="315"/>
<source>Note</source> <source>Note</source>
<translation type="unfinished">Note</translation> <translation>Note</translation>
</message> </message>
<message> <message>
<location filename="../src/ui/welcome.py" line="318"/> <location filename="../src/ui/welcome.py" line="318"/>
<source>Research</source> <source>Research</source>
<translation type="unfinished">Recherche</translation> <translation>Recherche</translation>
</message> </message>
<message> <message>
<location filename="../src/ui/welcome.py" line="326"/> <location filename="../src/ui/welcome.py" line="326"/>
<source>TODO</source> <source>TODO</source>
<translation type="unfinished">TODO</translation> <translation>TODO</translation>
</message> </message>
<message> <message>
<location filename="../src/ui/welcome.py" line="327"/> <location filename="../src/ui/welcome.py" line="327"/>
<source>First draft</source> <source>First draft</source>
<translation type="unfinished">Premier brouillon</translation> <translation>Premier brouillon</translation>
</message> </message>
<message> <message>
<location filename="../src/ui/welcome.py" line="328"/> <location filename="../src/ui/welcome.py" line="328"/>
<source>Second draft</source> <source>Second draft</source>
<translation type="unfinished">Second brouillon</translation> <translation>Second brouillon</translation>
</message> </message>
<message> <message>
<location filename="../src/ui/welcome.py" line="329"/> <location filename="../src/ui/welcome.py" line="329"/>
<source>Final</source> <source>Final</source>
<translation type="unfinished">Final</translation> <translation>Final</translation>
</message> </message>
</context> </context>
</TS> </TS>

View file

@ -6,7 +6,7 @@ from qt import *
_version = "0.1" _version = "0.1"
import faulthandler import faulthandler
#faulthandler.enable() faulthandler.enable()
def run(): def run():

View file

@ -13,6 +13,7 @@ from models.persosProxyModel import *
from functions import * from functions import *
from settingsWindow import * from settingsWindow import *
import settings import settings
import imp
# Spell checker support # Spell checker support
try: try:
@ -321,7 +322,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.currentProject = project self.currentProject = project
# Load empty settings # Load empty settings
import settings imp.reload(settings)
QSettings().setValue("lastProject", project) QSettings().setValue("lastProject", project)
# Load data # Load data

View file

@ -91,8 +91,11 @@ class outlineModel(QAbstractItemModel):
if item.data(index.column(), role) != value: if item.data(index.column(), role) != value:
item.setData(index.column(), value, role) item.setData(index.column(), value, role)
self.dataChanged.emit(index.sibling(index.row(), 0), #self.dataChanged.emit(index.sibling(index.row(), 0),
index.sibling(index.row(), max([i.value for i in Outline]))) #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 return True
@ -485,7 +488,8 @@ class outlineItem():
else: else:
self.setData(Outline.goalPercentage.value, "") self.setData(Outline.goalPercentage.value, "")
self.emitDataChanged() self.emitDataChanged([Outline.goal.value, Outline.setGoal.value,
Outline.wordCount.value, Outline.goalPercentage.value])
if self.parent(): if self.parent():
self.parent().updateWordCount() self.parent().updateWordCount()
@ -514,10 +518,16 @@ class outlineItem():
else: else:
return QModelIndex() return QModelIndex()
def emitDataChanged(self): def emitDataChanged(self, cols=None):
idx = self.index() idx = self.index()
if idx and self._model: 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): def removeChild(self, row):
self.childItems.pop(row) self.childItems.pop(row)

View file

@ -10,6 +10,7 @@ class basicHighlighter(QSyntaxHighlighter):
QSyntaxHighlighter.__init__(self, editor.document()) QSyntaxHighlighter.__init__(self, editor.document())
self.editor = editor self.editor = editor
self._misspelledColor = Qt.red
def setDefaultBlockFormat(self, bf): def setDefaultBlockFormat(self, bf):
self._defaultBlockFormat = bf self._defaultBlockFormat = bf
@ -17,6 +18,12 @@ class basicHighlighter(QSyntaxHighlighter):
def setMisspelledColor(self, color): def setMisspelledColor(self, color):
self._misspelledColor = 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): def highlightBlock(self, text):
"""Apply syntax highlighting to the given block of text. """Apply syntax highlighting to the given block of text.

View file

@ -5,6 +5,7 @@ from qt import *
from enums import * from enums import *
from ui.editors.editorWidget_ui import * from ui.editors.editorWidget_ui import *
from ui.editors.fullScreenEditor import * from ui.editors.fullScreenEditor import *
from ui.editors.textFormat import *
from ui.views.textEditView import * from ui.views.textEditView import *
from functions import * from functions import *
import settings import settings

View file

@ -5,6 +5,8 @@ from qt import *
from enums import * from enums import *
from ui.views.textEditView import * from ui.views.textEditView import *
from ui.editors.themes import * from ui.editors.themes import *
from ui.editors.textFormat import *
from functions import * from functions import *
import settings import settings
@ -17,13 +19,15 @@ class fullScreenEditor(QWidget):
self._theme = findThemePath(settings.fullScreenTheme) self._theme = findThemePath(settings.fullScreenTheme)
self._themeDatas = loadThemeDatas(self._theme) self._themeDatas = loadThemeDatas(self._theme)
self.setMouseTracking(True) self.setMouseTracking(True)
self._geometries = {}
# Text editor # 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) 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.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.editor.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.editor.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.editor.installEventFilter(self) self.editor.installEventFilter(self)
@ -35,8 +39,9 @@ class fullScreenEditor(QWidget):
# Top Panel # Top Panel
self.topPanel = myPanel(parent=self) self.topPanel = myPanel(parent=self)
self.topPanel.layout().addStretch(1) #self.topPanel.layout().addStretch(1)
# Spell checking
self.btnSpellCheck = QPushButton() self.btnSpellCheck = QPushButton()
self.btnSpellCheck.setFlat(True) self.btnSpellCheck.setFlat(True)
self.btnSpellCheck.setIcon(QIcon.fromTheme("tools-check-spelling")) self.btnSpellCheck.setIcon(QIcon.fromTheme("tools-check-spelling"))
@ -46,6 +51,11 @@ class fullScreenEditor(QWidget):
self.topPanel.layout().addWidget(self.btnSpellCheck) self.topPanel.layout().addWidget(self.btnSpellCheck)
self.topPanel.layout().addStretch(1) 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 = QPushButton(self)
b.setIcon(qApp.style().standardIcon(QStyle.SP_DialogCloseButton)) b.setIcon(qApp.style().standardIcon(QStyle.SP_DialogCloseButton))
b.clicked.connect(self.close) b.clicked.connect(self.close)
@ -95,6 +105,8 @@ class fullScreenEditor(QWidget):
self.updateTheme() self.updateTheme()
def updateTheme(self): def updateTheme(self):
# Reinit stored geometries for hiding widgets
self._geometries = {}
rect = self.geometry() rect = self.geometry()
self._background = generateTheme(self._themeDatas, rect) self._background = generateTheme(self._themeDatas, rect)
@ -118,7 +130,8 @@ class fullScreenEditor(QWidget):
r.setWidth(w) r.setWidth(w)
r.moveRight(rect.right() - rect.left()) r.moveRight(rect.right() - rect.left())
self.scrollBar.setGeometry(r) self.scrollBar.setGeometry(r)
self.scrollBar.setVisible(False) #self.scrollBar.setVisible(False)
self.hideWidget(self.scrollBar)
p = self.scrollBar.palette() p = self.scrollBar.palette()
b = QBrush(self._background.copy(self.scrollBar.geometry())) b = QBrush(self._background.copy(self.scrollBar.geometry()))
p.setBrush(QPalette.Base, b) p.setBrush(QPalette.Base, b)
@ -131,10 +144,12 @@ class fullScreenEditor(QWidget):
r.setWidth(rect.width()) r.setWidth(rect.width())
#r.moveLeft(rect.center().x() - r.width() / 2) #r.moveLeft(rect.center().x() - r.width() / 2)
self.topPanel.setGeometry(r) self.topPanel.setGeometry(r)
self.topPanel.setVisible(False) #self.topPanel.setVisible(False)
self.hideWidget(self.topPanel)
r.moveBottom(rect.bottom() - rect.top()) r.moveBottom(rect.bottom() - rect.top())
self.bottomPanel.setGeometry(r) self.bottomPanel.setGeometry(r)
self.bottomPanel.setVisible(False) #self.bottomPanel.setVisible(False)
self.hideWidget(self.bottomPanel)
self.topPanel.setColor(self._bgcolor) self.topPanel.setColor(self._bgcolor)
self.bottomPanel.setColor(self._bgcolor) self.bottomPanel.setColor(self._bgcolor)
@ -175,12 +190,26 @@ class fullScreenEditor(QWidget):
r = self.geometry() r = self.geometry()
for w in [self.scrollBar, self.topPanel, self.bottomPanel]: 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): def eventFilter(self, obj, event):
if obj == self.editor and event.type() == QEvent.Enter: if obj == self.editor and event.type() == QEvent.Enter:
for w in [self.scrollBar, self.topPanel, self.bottomPanel]: for w in [self.scrollBar, self.topPanel, self.bottomPanel]:
w.setVisible(False) #w.setVisible(False)
self.hideWidget(w)
return QWidget.eventFilter(self, obj, event) return QWidget.eventFilter(self, obj, event)
def dataChanged(self, topLeft, bottomRight): def dataChanged(self, topLeft, bottomRight):
@ -219,9 +248,9 @@ class myScrollBar(QScrollBar):
self.timer = QTimer() self.timer = QTimer()
self.timer.setInterval(500) self.timer.setInterval(500)
self.timer.setSingleShot(True) 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(lambda v: self.timer.start())
self.valueChanged.connect(self.show) self.valueChanged.connect(lambda: self.parent().showWidget(self))
def setColor(self, color): def setColor(self, color):
self._color = color self._color = color
@ -233,11 +262,11 @@ class myScrollBar(QScrollBar):
painter = QPainter(self) painter = QPainter(self)
# Background (Necessary with Qt 5.2 it seems, not with 5.4) # Background (Necessary with Qt 5.2 it seems, not with 5.4)
painter.save() #painter.save()
painter.setPen(Qt.NoPen) #painter.setPen(Qt.NoPen)
painter.setBrush(self.palette().brush(QPalette.Base)) #painter.setBrush(self.palette().brush(QPalette.Base))
painter.drawRect(event.rect()) #painter.drawRect(event.rect())
painter.restore() #painter.restore()
#slider #slider
r = style.subControlRect(style.CC_ScrollBar, opt, style.SC_ScrollBarSlider) r = style.subControlRect(style.CC_ScrollBar, opt, style.SC_ScrollBarSlider)

View file

@ -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())

View file

@ -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"))

View file

@ -0,0 +1,172 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>textFormat</class>
<widget class="QWidget" name="textFormat">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>507</width>
<height>34</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="format" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="btnBold">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnItalic">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normaloff/>
</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnUnderlined">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normaloff/>
</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnClear">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normaloff>../</normaloff>../</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="align" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="btnLeft">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normaloff/>
</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnCenter">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normaloff/>
</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnRight">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normaloff/>
</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -11,7 +11,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object): class Ui_MainWindow(object):
def setupUi(self, MainWindow): def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow") MainWindow.setObjectName("MainWindow")
MainWindow.resize(1089, 803) MainWindow.resize(1145, 801)
MainWindow.setWindowTitle("Manuskript") MainWindow.setWindowTitle("Manuskript")
self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget") self.centralwidget.setObjectName("centralwidget")
@ -1007,7 +1007,7 @@ class Ui_MainWindow(object):
self.horizontalLayout_12.addWidget(self.stack) self.horizontalLayout_12.addWidget(self.stack)
MainWindow.setCentralWidget(self.centralwidget) MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow) 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.menubar.setObjectName("menubar")
self.menuFile = QtWidgets.QMenu(self.menubar) self.menuFile = QtWidgets.QMenu(self.menubar)
self.menuFile.setObjectName("menuFile") self.menuFile.setObjectName("menuFile")
@ -1106,8 +1106,8 @@ class Ui_MainWindow(object):
self.menubar.addAction(self.menuHelp.menuAction()) self.menubar.addAction(self.menuHelp.menuAction())
self.retranslateUi(MainWindow) self.retranslateUi(MainWindow)
self.stack.setCurrentIndex(0) self.stack.setCurrentIndex(1)
self.tabMain.setCurrentIndex(5) self.tabMain.setCurrentIndex(6)
self.tabSummary.setCurrentIndex(0) self.tabSummary.setCurrentIndex(0)
self.tabPersos.setCurrentIndex(0) self.tabPersos.setCurrentIndex(0)
self.tabPlot.setCurrentIndex(1) self.tabPlot.setCurrentIndex(1)
@ -1256,8 +1256,8 @@ from ui.views.basicItemView import basicItemView
from ui.views.plotTreeView import plotTreeView from ui.views.plotTreeView import plotTreeView
from ui.views.metadataView import metadataView from ui.views.metadataView import metadataView
from ui.views.treeView import treeView 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.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

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1089</width> <width>1145</width>
<height>803</height> <height>801</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -30,7 +30,7 @@
<item> <item>
<widget class="QStackedWidget" name="stack"> <widget class="QStackedWidget" name="stack">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="welcomePage"> <widget class="QWidget" name="welcomePage">
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
@ -109,7 +109,7 @@
<item> <item>
<widget class="QTabWidget" name="tabMain"> <widget class="QTabWidget" name="tabMain">
<property name="currentIndex"> <property name="currentIndex">
<number>5</number> <number>6</number>
</property> </property>
<property name="documentMode"> <property name="documentMode">
<bool>true</bool> <bool>true</bool>
@ -1941,7 +1941,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1089</width> <width>1145</width>
<height>31</height> <height>31</height>
</rect> </rect>
</property> </property>
@ -2168,6 +2168,11 @@
<extends>QTextEdit</extends> <extends>QTextEdit</extends>
<header>ui.views.textEditView.h</header> <header>ui.views.textEditView.h</header>
</customwidget> </customwidget>
<customwidget>
<class>lineEditView</class>
<extends>QLineEdit</extends>
<header>ui.views.lineEditView.h</header>
</customwidget>
<customwidget> <customwidget>
<class>outlineView</class> <class>outlineView</class>
<extends>QTreeView</extends> <extends>QTreeView</extends>
@ -2190,11 +2195,6 @@
<extends>QTreeView</extends> <extends>QTreeView</extends>
<header>ui.views.treeView.h</header> <header>ui.views.treeView.h</header>
</customwidget> </customwidget>
<customwidget>
<class>lineEditView</class>
<extends>QLineEdit</extends>
<header>ui.views.lineEditView.h</header>
</customwidget>
<customwidget> <customwidget>
<class>metadataView</class> <class>metadataView</class>
<extends>QWidget</extends> <extends>QWidget</extends>

View file

@ -15,6 +15,9 @@ class Ui_metadataView(object):
self.verticalLayout = QtWidgets.QVBoxLayout(metadataView) self.verticalLayout = QtWidgets.QVBoxLayout(metadataView)
self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setObjectName("verticalLayout") self.verticalLayout.setObjectName("verticalLayout")
self.textFormat = textFormat(metadataView)
self.textFormat.setObjectName("textFormat")
self.verticalLayout.addWidget(self.textFormat)
self.groupBox_4 = collapsibleGroupBox2(metadataView) self.groupBox_4 = collapsibleGroupBox2(metadataView)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0) sizePolicy.setHorizontalStretch(0)
@ -70,7 +73,8 @@ class Ui_metadataView(object):
self.txtSummarySentance.setPlaceholderText(_translate("metadataView", "One line summary")) self.txtSummarySentance.setPlaceholderText(_translate("metadataView", "One line summary"))
self.groupBox_6.setTitle(_translate("metadataView", "Notes")) 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.lineEditView import lineEditView
from ui.views.textEditView import textEditView from ui.views.textEditView import textEditView
from ui.collapsibleGroupBox2 import collapsibleGroupBox2
from ui.views.propertiesView import propertiesView from ui.views.propertiesView import propertiesView

View file

@ -17,6 +17,9 @@
<property name="margin"> <property name="margin">
<number>0</number> <number>0</number>
</property> </property>
<item>
<widget class="textFormat" name="textFormat" native="true"/>
</item>
<item> <item>
<widget class="collapsibleGroupBox2" name="groupBox_4"> <widget class="collapsibleGroupBox2" name="groupBox_4">
<property name="sizePolicy"> <property name="sizePolicy">
@ -128,6 +131,12 @@
<extends>QLineEdit</extends> <extends>QLineEdit</extends>
<header>ui.views.lineEditView.h</header> <header>ui.views.lineEditView.h</header>
</customwidget> </customwidget>
<customwidget>
<class>textFormat</class>
<extends>QWidget</extends>
<header>ui.editors.textFormat.h</header>
<container>1</container>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections/> <connections/>

View file

@ -5,6 +5,7 @@ from qt import *
from enums import * from enums import *
from ui.editors.t2tHighlighter import * from ui.editors.t2tHighlighter import *
from ui.editors.basicHighlighter import * from ui.editors.basicHighlighter import *
from ui.editors.textFormat import *
from models.outlineModel import * from models.outlineModel import *
from functions import * from functions import *
@ -36,7 +37,15 @@ class textEditView(QTextEdit):
self.highligtCS = False self.highligtCS = False
self.defaultFontPointSize = qApp.font().pointSize() self.defaultFontPointSize = qApp.font().pointSize()
self._dict = None 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: if index:
self.setCurrentModelIndex(index) self.setCurrentModelIndex(index)
@ -99,6 +108,7 @@ class textEditView(QTextEdit):
#self._model.dataChanged.disconnect(self.update) #self._model.dataChanged.disconnect(self.update)
except: except:
pass pass
self.setPlainText("") self.setPlainText("")
def setupEditorForIndex(self, index): def setupEditorForIndex(self, index):
@ -137,13 +147,14 @@ class textEditView(QTextEdit):
elif self._index: elif self._index:
if topLeft.row() <= self._index.row() <= bottomRight.row(): if topLeft.row() <= self._index.row() <= bottomRight.row():
if topLeft.column() <= Outline.type.value <= bottomRight.column(): if topLeft.column() <= Outline.type.value <= bottomRight.column():
# If item type change, we reset the index to set the proper # If item type change, we reset the index to set the proper
# highlighter and other defaults # highlighter and other defaults
self.setupEditorForIndex(self._index) self.setupEditorForIndex(self._index)
self.updateText()
self.updateText() elif topLeft.column() <= self._column <= bottomRight.column():
self.updateText()
elif self._indexes: elif self._indexes:
update = False update = False
@ -192,7 +203,6 @@ class textEditView(QTextEdit):
self._updating = False self._updating = False
def submit(self): def submit(self):
if self._updating: if self._updating:
return return
@ -251,8 +261,10 @@ class textEditView(QTextEdit):
self.heightMax = 65000 self.heightMax = 65000
self.sizeChange() 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): def setDict(self, d):
self.currentDict = d self.currentDict = d
@ -332,4 +344,22 @@ class textEditView(QTextEdit):
cursor.endEditBlock() cursor.endEditBlock()
# ----------------------------------------------------------------------------------------------------- ###############################################################################
# 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)