Adds: Block insertion cursor. (#163)

This commit is contained in:
Olivier Keshavjee 2017-10-18 10:44:05 +02:00
parent 3eda56ed5a
commit f36abfd2e4
6 changed files with 580 additions and 453 deletions

View file

@ -67,6 +67,7 @@ textEditor = {
"spacingAbove": 5,
"spacingBelow": 5,
"textAlignment": 0, # 0: left, 1: center, 2: right, 3: justify
"cursorWidth": 1
}
revisions = {
@ -237,6 +238,9 @@ def load(string, fromString=False, protocol=None):
if not "textAlignment" in textEditor: # Added in 0.5.0
textEditor["textAlignment"] = 0
if not "cursorWidth" in textEditor: # Added in 0.5.0
textEditor["cursorWidth"] = 1
if "revisions" in allSettings:
global revisions

View file

@ -161,6 +161,11 @@ class settingsWindow(QWidget, Ui_Settings):
self.cmbEditorFontFamily.currentFontChanged.connect(self.updateEditorSettings)
self.spnEditorFontSize.setValue(f.pointSize())
self.spnEditorFontSize.valueChanged.connect(self.updateEditorSettings)
self.chkEditorCursorWidth.setChecked(opt["cursorWidth"] != 1)
self.chkEditorCursorWidth.stateChanged.connect(self.updateEditorSettings)
self.spnEditorCursorWidth.setValue(opt["cursorWidth"] if opt["cursorWidth"] != 1 else 9)
self.spnEditorCursorWidth.valueChanged.connect(self.updateEditorSettings)
self.spnEditorCursorWidth.setEnabled(opt["cursorWidth"] != 1)
self.cmbEditorAlignment.setCurrentIndex(opt["textAlignment"])
self.cmbEditorAlignment.currentIndexChanged.connect(self.updateEditorSettings)
self.cmbEditorLineSpacing.setCurrentIndex(
@ -405,6 +410,10 @@ class settingsWindow(QWidget, Ui_Settings):
f = self.cmbEditorFontFamily.currentFont()
f.setPointSize(self.spnEditorFontSize.value())
settings.textEditor["font"] = f.toString()
settings.textEditor["cursorWidth"] = \
1 if not self.chkEditorCursorWidth.isChecked() else \
self.spnEditorCursorWidth.value()
self.spnEditorCursorWidth.setEnabled(self.chkEditorCursorWidth.isChecked())
settings.textEditor["textAlignment"] = self.cmbEditorAlignment.currentIndex()
settings.textEditor["lineSpacing"] = \
100 if self.cmbEditorLineSpacing.currentIndex() == 0 else \

View file

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'manuskript/ui/settings_ui.ui'
#
# Created: Tue Oct 17 12:19:44 2017
# Created: Wed Oct 18 10:25:40 2017
# by: PyQt5 UI code generator 5.2.1
#
# WARNING! All changes made in this file will be lost!
@ -927,8 +927,12 @@ class Ui_Settings(object):
self.tabViews.addTab(self.tab_3, icon, "")
self.tab_4 = QtWidgets.QWidget()
self.tab_4.setObjectName("tab_4")
self.horizontalLayout_11 = QtWidgets.QHBoxLayout(self.tab_4)
self.horizontalLayout_11.setObjectName("horizontalLayout_11")
self.verticalLayout_22 = QtWidgets.QVBoxLayout(self.tab_4)
self.verticalLayout_22.setObjectName("verticalLayout_22")
self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
self.verticalLayout_21 = QtWidgets.QVBoxLayout()
self.verticalLayout_21.setObjectName("verticalLayout_21")
self.groupBox_12 = QtWidgets.QGroupBox(self.tab_4)
font = QtGui.QFont()
font.setBold(True)
@ -1034,7 +1038,34 @@ class Ui_Settings(object):
self.btnEditorBackgroundColor.setText("")
self.btnEditorBackgroundColor.setObjectName("btnEditorBackgroundColor")
self.formLayout_8.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.btnEditorBackgroundColor)
self.horizontalLayout_11.addWidget(self.groupBox_12)
self.verticalLayout_21.addWidget(self.groupBox_12)
self.groupBox_15 = QtWidgets.QGroupBox(self.tab_4)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.groupBox_15.setFont(font)
self.groupBox_15.setObjectName("groupBox_15")
self.formLayout_10 = QtWidgets.QFormLayout(self.groupBox_15)
self.formLayout_10.setObjectName("formLayout_10")
self.chkEditorCursorWidth = QtWidgets.QCheckBox(self.groupBox_15)
font = QtGui.QFont()
font.setBold(False)
font.setWeight(50)
self.chkEditorCursorWidth.setFont(font)
self.chkEditorCursorWidth.setObjectName("chkEditorCursorWidth")
self.formLayout_10.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.chkEditorCursorWidth)
self.spnEditorCursorWidth = QtWidgets.QSpinBox(self.groupBox_15)
font = QtGui.QFont()
font.setBold(False)
font.setWeight(50)
self.spnEditorCursorWidth.setFont(font)
self.spnEditorCursorWidth.setMinimum(0)
self.spnEditorCursorWidth.setMaximum(99)
self.spnEditorCursorWidth.setProperty("value", 9)
self.spnEditorCursorWidth.setObjectName("spnEditorCursorWidth")
self.formLayout_10.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.spnEditorCursorWidth)
self.verticalLayout_21.addWidget(self.groupBox_15)
self.horizontalLayout_4.addLayout(self.verticalLayout_21)
self.groupBox_13 = QtWidgets.QGroupBox(self.tab_4)
font = QtGui.QFont()
font.setBold(True)
@ -1170,7 +1201,8 @@ class Ui_Settings(object):
icon = QtGui.QIcon.fromTheme("format-justify-fill")
self.cmbEditorAlignment.addItem(icon, "")
self.formLayout_9.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.cmbEditorAlignment)
self.horizontalLayout_11.addWidget(self.groupBox_13)
self.horizontalLayout_4.addWidget(self.groupBox_13)
self.verticalLayout_22.addLayout(self.horizontalLayout_4)
icon = QtGui.QIcon.fromTheme("view-text")
self.tabViews.addTab(self.tab_4, icon, "")
self.verticalLayout_9.addWidget(self.tabViews)
@ -1831,6 +1863,9 @@ class Ui_Settings(object):
self.label_38.setText(_translate("Settings", "Size:"))
self.label_36.setText(_translate("Settings", "Misspelled:"))
self.label_43.setText(_translate("Settings", "Background:"))
self.groupBox_15.setTitle(_translate("Settings", "Cursor"))
self.chkEditorCursorWidth.setText(_translate("Settings", "Use block insertion of"))
self.spnEditorCursorWidth.setSuffix(_translate("Settings", " px"))
self.groupBox_13.setTitle(_translate("Settings", "Paragraphs"))
self.label_40.setText(_translate("Settings", "Line spacing:"))
self.cmbEditorLineSpacing.setItemText(0, _translate("Settings", "Single"))

File diff suppressed because it is too large Load diff

View file

@ -197,6 +197,8 @@ class textEditView(QTextEdit):
cf = QTextCharFormat()
# cf.setFont(f)
# cf.setForeground(QColor(opt["fontColor"]))
self.setCursorWidth(opt["cursorWidth"])
bf = QTextBlockFormat()
bf.setLineHeight(opt["lineSpacing"], bf.ProportionalHeight)

View file

@ -8,7 +8,8 @@
"image": "writingdesk.jpg"
},
"corkSizeFactor": 84,
"defaultTextType": "txt",
"corkStyle": "new",
"defaultTextType": "md",
"dict": "en_US",
"folderView": "cork",
"frequencyAnalyzer": {
@ -47,14 +48,16 @@
"spellcheck": false,
"textEditor": {
"background": "#fff",
"font": "Oxygen-Sans,10,-1,5,50,0,0,0,0,0",
"cursorWidth": 1,
"font": "DejaVu Sans,10,-1,5,50,0,0,0,0,0",
"fontColor": "#000",
"indent": true,
"lineSpacing": 100,
"misspelled": "#F00",
"spacingAbove": 5,
"spacingBelow": 5,
"tabWidth": 20
"tabWidth": 20,
"textAlignment": 0
},
"viewMode": "fiction",
"viewSettings": {