Fixes #232: Add markdown support of other tabs

This commit is contained in:
Olivier Keshavjee 2017-11-25 14:43:30 +01:00
parent 7940cdb336
commit d27ce4dec6
4 changed files with 30 additions and 41 deletions

View file

@ -1415,4 +1415,3 @@ class MainWindow(QMainWindow, Ui_MainWindow):
r = self.dialog.geometry() r = self.dialog.geometry()
r2 = self.geometry() r2 = self.geometry()
self.dialog.move(r2.center() - r.center()) self.dialog.move(r2.center() - r.center())

View file

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'manuskript/ui/mainWindow.ui' # Form implementation generated from reading ui file 'manuskript/ui/mainWindow.ui'
# #
# Created by: PyQt5 UI code generator 5.9 # Created by: PyQt5 UI code generator 5.5.1
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
@ -24,7 +24,6 @@ class Ui_MainWindow(object):
self.welcomePage = QtWidgets.QWidget() self.welcomePage = QtWidgets.QWidget()
self.welcomePage.setObjectName("welcomePage") self.welcomePage.setObjectName("welcomePage")
self.gridLayout = QtWidgets.QGridLayout(self.welcomePage) self.gridLayout = QtWidgets.QGridLayout(self.welcomePage)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout") self.gridLayout.setObjectName("gridLayout")
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.gridLayout.addItem(spacerItem, 1, 0, 1, 1) self.gridLayout.addItem(spacerItem, 1, 0, 1, 1)
@ -161,7 +160,6 @@ class Ui_MainWindow(object):
self.tabSummaryPage1 = QtWidgets.QWidget() self.tabSummaryPage1 = QtWidgets.QWidget()
self.tabSummaryPage1.setObjectName("tabSummaryPage1") self.tabSummaryPage1.setObjectName("tabSummaryPage1")
self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.tabSummaryPage1) self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.tabSummaryPage1)
self.verticalLayout_5.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_5.setObjectName("verticalLayout_5") self.verticalLayout_5.setObjectName("verticalLayout_5")
self.label = QtWidgets.QLabel(self.tabSummaryPage1) self.label = QtWidgets.QLabel(self.tabSummaryPage1)
self.label.setObjectName("label") self.label.setObjectName("label")
@ -184,7 +182,6 @@ class Ui_MainWindow(object):
self.tabSummaryPage2 = QtWidgets.QWidget() self.tabSummaryPage2 = QtWidgets.QWidget()
self.tabSummaryPage2.setObjectName("tabSummaryPage2") self.tabSummaryPage2.setObjectName("tabSummaryPage2")
self.horizontalLayout_4 = QtWidgets.QHBoxLayout(self.tabSummaryPage2) self.horizontalLayout_4 = QtWidgets.QHBoxLayout(self.tabSummaryPage2)
self.horizontalLayout_4.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_4.setObjectName("horizontalLayout_4") self.horizontalLayout_4.setObjectName("horizontalLayout_4")
self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout") self.verticalLayout.setObjectName("verticalLayout")
@ -227,7 +224,6 @@ class Ui_MainWindow(object):
self.tabSummaryPage3 = QtWidgets.QWidget() self.tabSummaryPage3 = QtWidgets.QWidget()
self.tabSummaryPage3.setObjectName("tabSummaryPage3") self.tabSummaryPage3.setObjectName("tabSummaryPage3")
self.horizontalLayout_7 = QtWidgets.QHBoxLayout(self.tabSummaryPage3) self.horizontalLayout_7 = QtWidgets.QHBoxLayout(self.tabSummaryPage3)
self.horizontalLayout_7.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_7.setObjectName("horizontalLayout_7") self.horizontalLayout_7.setObjectName("horizontalLayout_7")
self.verticalLayout_6 = QtWidgets.QVBoxLayout() self.verticalLayout_6 = QtWidgets.QVBoxLayout()
self.verticalLayout_6.setObjectName("verticalLayout_6") self.verticalLayout_6.setObjectName("verticalLayout_6")
@ -263,7 +259,6 @@ class Ui_MainWindow(object):
self.tabSummaryPage4 = QtWidgets.QWidget() self.tabSummaryPage4 = QtWidgets.QWidget()
self.tabSummaryPage4.setObjectName("tabSummaryPage4") self.tabSummaryPage4.setObjectName("tabSummaryPage4")
self.horizontalLayout_8 = QtWidgets.QHBoxLayout(self.tabSummaryPage4) self.horizontalLayout_8 = QtWidgets.QHBoxLayout(self.tabSummaryPage4)
self.horizontalLayout_8.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_8.setObjectName("horizontalLayout_8") self.horizontalLayout_8.setObjectName("horizontalLayout_8")
self.verticalLayout_7 = QtWidgets.QVBoxLayout() self.verticalLayout_7 = QtWidgets.QVBoxLayout()
self.verticalLayout_7.setObjectName("verticalLayout_7") self.verticalLayout_7.setObjectName("verticalLayout_7")
@ -387,7 +382,6 @@ class Ui_MainWindow(object):
self.scrollAreaPersoInfosWidget.setObjectName("scrollAreaPersoInfosWidget") self.scrollAreaPersoInfosWidget.setObjectName("scrollAreaPersoInfosWidget")
self.formLayout_8 = QtWidgets.QFormLayout(self.scrollAreaPersoInfosWidget) self.formLayout_8 = QtWidgets.QFormLayout(self.scrollAreaPersoInfosWidget)
self.formLayout_8.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow) self.formLayout_8.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow)
self.formLayout_8.setContentsMargins(0, 0, 0, 0)
self.formLayout_8.setObjectName("formLayout_8") self.formLayout_8.setObjectName("formLayout_8")
self.label_4 = QtWidgets.QLabel(self.scrollAreaPersoInfosWidget) self.label_4 = QtWidgets.QLabel(self.scrollAreaPersoInfosWidget)
self.label_4.setObjectName("label_4") self.label_4.setObjectName("label_4")
@ -467,7 +461,7 @@ class Ui_MainWindow(object):
self.tab_11.setObjectName("tab_11") self.tab_11.setObjectName("tab_11")
self.verticalLayout_17 = QtWidgets.QVBoxLayout(self.tab_11) self.verticalLayout_17 = QtWidgets.QVBoxLayout(self.tab_11)
self.verticalLayout_17.setObjectName("verticalLayout_17") self.verticalLayout_17.setObjectName("verticalLayout_17")
self.txtPersoSummaryFull = textEditView(self.tab_11) self.txtPersoSummaryFull = textEditCompleter(self.tab_11)
self.txtPersoSummaryFull.setObjectName("txtPersoSummaryFull") self.txtPersoSummaryFull.setObjectName("txtPersoSummaryFull")
self.verticalLayout_17.addWidget(self.txtPersoSummaryFull) self.verticalLayout_17.addWidget(self.txtPersoSummaryFull)
self.horizontalLayout_22 = QtWidgets.QHBoxLayout() self.horizontalLayout_22 = QtWidgets.QHBoxLayout()
@ -485,7 +479,7 @@ class Ui_MainWindow(object):
self.tab_19.setObjectName("tab_19") self.tab_19.setObjectName("tab_19")
self.horizontalLayout_30 = QtWidgets.QHBoxLayout(self.tab_19) self.horizontalLayout_30 = QtWidgets.QHBoxLayout(self.tab_19)
self.horizontalLayout_30.setObjectName("horizontalLayout_30") self.horizontalLayout_30.setObjectName("horizontalLayout_30")
self.txtPersoNotes = textEditView(self.tab_19) self.txtPersoNotes = textEditCompleter(self.tab_19)
self.txtPersoNotes.setObjectName("txtPersoNotes") self.txtPersoNotes.setObjectName("txtPersoNotes")
self.horizontalLayout_30.addWidget(self.txtPersoNotes) self.horizontalLayout_30.addWidget(self.txtPersoNotes)
self.tabPersos.addTab(self.tab_19, "") self.tabPersos.addTab(self.tab_19, "")
@ -632,10 +626,10 @@ class Ui_MainWindow(object):
self.sldPlotImportance.setSizePolicy(sizePolicy) self.sldPlotImportance.setSizePolicy(sizePolicy)
self.sldPlotImportance.setObjectName("sldPlotImportance") self.sldPlotImportance.setObjectName("sldPlotImportance")
self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.sldPlotImportance) self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.sldPlotImportance)
self.txtPlotDescription = textEditView(self.infos_2) self.txtPlotDescription = textEditCompleter(self.infos_2)
self.txtPlotDescription.setObjectName("txtPlotDescription") self.txtPlotDescription.setObjectName("txtPlotDescription")
self.formLayout_2.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.txtPlotDescription) self.formLayout_2.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.txtPlotDescription)
self.txtPlotResult = textEditView(self.infos_2) self.txtPlotResult = textEditCompleter(self.infos_2)
self.txtPlotResult.setObjectName("txtPlotResult") self.txtPlotResult.setObjectName("txtPlotResult")
self.formLayout_2.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.txtPlotResult) self.formLayout_2.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.txtPlotResult)
self.tabPlot.addTab(self.infos_2, "") self.tabPlot.addTab(self.infos_2, "")
@ -703,7 +697,6 @@ class Ui_MainWindow(object):
self.page = QtWidgets.QWidget() self.page = QtWidgets.QWidget()
self.page.setObjectName("page") self.page.setObjectName("page")
self.horizontalLayout_6 = QtWidgets.QHBoxLayout(self.page) self.horizontalLayout_6 = QtWidgets.QHBoxLayout(self.page)
self.horizontalLayout_6.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_6.setObjectName("horizontalLayout_6") self.horizontalLayout_6.setObjectName("horizontalLayout_6")
self.txtPlotSummaryPara = textEditView(self.page) self.txtPlotSummaryPara = textEditView(self.page)
self.txtPlotSummaryPara.setObjectName("txtPlotSummaryPara") self.txtPlotSummaryPara.setObjectName("txtPlotSummaryPara")
@ -712,7 +705,6 @@ class Ui_MainWindow(object):
self.page_2 = QtWidgets.QWidget() self.page_2 = QtWidgets.QWidget()
self.page_2.setObjectName("page_2") self.page_2.setObjectName("page_2")
self.horizontalLayout_10 = QtWidgets.QHBoxLayout(self.page_2) self.horizontalLayout_10 = QtWidgets.QHBoxLayout(self.page_2)
self.horizontalLayout_10.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_10.setObjectName("horizontalLayout_10") self.horizontalLayout_10.setObjectName("horizontalLayout_10")
self.txtPlotSummaryPage = textEditView(self.page_2) self.txtPlotSummaryPage = textEditView(self.page_2)
self.txtPlotSummaryPage.setObjectName("txtPlotSummaryPage") self.txtPlotSummaryPage.setObjectName("txtPlotSummaryPage")
@ -721,7 +713,6 @@ class Ui_MainWindow(object):
self.page_3 = QtWidgets.QWidget() self.page_3 = QtWidgets.QWidget()
self.page_3.setObjectName("page_3") self.page_3.setObjectName("page_3")
self.horizontalLayout_13 = QtWidgets.QHBoxLayout(self.page_3) self.horizontalLayout_13 = QtWidgets.QHBoxLayout(self.page_3)
self.horizontalLayout_13.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_13.setObjectName("horizontalLayout_13") self.horizontalLayout_13.setObjectName("horizontalLayout_13")
self.txtPlotSummaryFull = textEditView(self.page_3) self.txtPlotSummaryFull = textEditView(self.page_3)
self.txtPlotSummaryFull.setObjectName("txtPlotSummaryFull") self.txtPlotSummaryFull.setObjectName("txtPlotSummaryFull")
@ -839,7 +830,6 @@ class Ui_MainWindow(object):
self.layoutWidget = QtWidgets.QWidget(self.splitterOutlineH) self.layoutWidget = QtWidgets.QWidget(self.splitterOutlineH)
self.layoutWidget.setObjectName("layoutWidget") self.layoutWidget.setObjectName("layoutWidget")
self.verticalLayout_14 = QtWidgets.QVBoxLayout(self.layoutWidget) self.verticalLayout_14 = QtWidgets.QVBoxLayout(self.layoutWidget)
self.verticalLayout_14.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_14.setObjectName("verticalLayout_14") self.verticalLayout_14.setObjectName("verticalLayout_14")
self.splitterOutlineV = QtWidgets.QSplitter(self.layoutWidget) self.splitterOutlineV = QtWidgets.QSplitter(self.layoutWidget)
self.splitterOutlineV.setOrientation(QtCore.Qt.Vertical) self.splitterOutlineV.setOrientation(QtCore.Qt.Vertical)
@ -1265,8 +1255,8 @@ class Ui_MainWindow(object):
self.stack.setCurrentIndex(1) self.stack.setCurrentIndex(1)
self.tabMain.setCurrentIndex(3) self.tabMain.setCurrentIndex(3)
self.tabSummary.setCurrentIndex(0) self.tabSummary.setCurrentIndex(0)
self.tabPersos.setCurrentIndex(0) self.tabPersos.setCurrentIndex(2)
self.tabPlot.setCurrentIndex(0) self.tabPlot.setCurrentIndex(1)
self.comboBox_2.setCurrentIndex(0) self.comboBox_2.setCurrentIndex(0)
self.stkPlotSummary.setCurrentIndex(0) self.stkPlotSummary.setCurrentIndex(0)
self.tabWorld.setCurrentIndex(0) self.tabWorld.setCurrentIndex(0)

View file

@ -774,7 +774,7 @@
</widget> </widget>
<widget class="QTabWidget" name="tabPersos"> <widget class="QTabWidget" name="tabPersos">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="info"> <widget class="QWidget" name="info">
<attribute name="title"> <attribute name="title">
@ -964,7 +964,7 @@
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_17"> <layout class="QVBoxLayout" name="verticalLayout_17">
<item> <item>
<widget class="textEditView" name="txtPersoSummaryFull"/> <widget class="textEditCompleter" name="txtPersoSummaryFull"/>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_22"> <layout class="QHBoxLayout" name="horizontalLayout_22">
@ -1002,7 +1002,7 @@
</attribute> </attribute>
<layout class="QHBoxLayout" name="horizontalLayout_30"> <layout class="QHBoxLayout" name="horizontalLayout_30">
<item> <item>
<widget class="textEditView" name="txtPersoNotes"/> <widget class="textEditCompleter" name="txtPersoNotes"/>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -1173,7 +1173,7 @@
</widget> </widget>
<widget class="QTabWidget" name="tabPlot"> <widget class="QTabWidget" name="tabPlot">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<property name="documentMode"> <property name="documentMode">
<bool>true</bool> <bool>true</bool>
@ -1303,10 +1303,10 @@
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="textEditView" name="txtPlotDescription"/> <widget class="textEditCompleter" name="txtPlotDescription"/>
</item> </item>
<item row="4" column="1"> <item row="4" column="1">
<widget class="textEditView" name="txtPlotResult"/> <widget class="textEditCompleter" name="txtPlotResult"/>
</item> </item>
</layout> </layout>
</widget> </widget>

View file

@ -7,7 +7,7 @@ from PyQt5.QtGui import QTextBlockFormat, QTextCharFormat, QFont, QColor, QIcon,
from PyQt5.QtWidgets import QWidget, QTextEdit, qApp, QAction, QMenu from PyQt5.QtWidgets import QWidget, QTextEdit, qApp, QAction, QMenu
from manuskript import settings from manuskript import settings
from manuskript.enums import Outline from manuskript.enums import Outline, World, Character, Plot
from manuskript import functions as F from manuskript import functions as F
from manuskript.models.outlineModel import outlineModel from manuskript.models.outlineModel import outlineModel
from manuskript.ui.editors.MDFunctions import MDFormatSelection from manuskript.ui.editors.MDFunctions import MDFormatSelection
@ -175,25 +175,25 @@ class textEditView(QTextEdit):
self.updateText() self.updateText()
def setupEditorForIndex(self, index): def setupEditorForIndex(self, index):
# In which model are we editing? # Let's say we use markdown everywhere...
if type(index.model()) != outlineModel: self._textFormat = "md"
self._textFormat = "text"
return
# what type of text are we editing?
if self._column not in [Outline.text.value, Outline.notes.value]:
self._textFormat = "text"
else:
self._textFormat = "md"
# Setting highlighter # Setting highlighter
if self._highlighting: if self._highlighting:
item = index.internalPointer() # # item = index.internalPointer()
if self._column in [Outline.text.value, Outline.notes.value]: # if self._column in [
self.highlighter = MarkdownHighlighter(self) # Outline.text.value,
else: # Outline.notes.value,
self.highlighter = BasicHighlighter(self) # Character.summaryFull.value,
# Character.notes.value,
# World.description.value,
# World.passion.value,
# World.conflict.value,
# ]:
#FIXME: subclass textEdit instad of doing stuff like that
self.highlighter = MarkdownHighlighter(self)
# else:
# self.highlighter = BasicHighlighter(self)
self.highlighter.setDefaultBlockFormat(self._defaultBlockFormat) self.highlighter.setDefaultBlockFormat(self._defaultBlockFormat)
self.highlighter.updateColorScheme() self.highlighter.updateColorScheme()