From f36abfd2e4545b0c8f7f90db797f9226ad8e0664 Mon Sep 17 00:00:00 2001 From: Olivier Keshavjee Date: Wed, 18 Oct 2017 10:44:05 +0200 Subject: [PATCH] Adds: Block insertion cursor. (#163) --- manuskript/settings.py | 4 + manuskript/settingsWindow.py | 9 + manuskript/ui/settings_ui.py | 45 +- manuskript/ui/settings_ui.ui | 964 ++++++++++++---------- manuskript/ui/views/textEditView.py | 2 + sample-projects/book-of-acts/settings.txt | 9 +- 6 files changed, 580 insertions(+), 453 deletions(-) diff --git a/manuskript/settings.py b/manuskript/settings.py index 0010489..f028e88 100644 --- a/manuskript/settings.py +++ b/manuskript/settings.py @@ -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 diff --git a/manuskript/settingsWindow.py b/manuskript/settingsWindow.py index 102494d..7da77af 100644 --- a/manuskript/settingsWindow.py +++ b/manuskript/settingsWindow.py @@ -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 \ diff --git a/manuskript/ui/settings_ui.py b/manuskript/ui/settings_ui.py index d32d119..fe3942d 100644 --- a/manuskript/ui/settings_ui.py +++ b/manuskript/ui/settings_ui.py @@ -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")) diff --git a/manuskript/ui/settings_ui.ui b/manuskript/ui/settings_ui.ui index cf12d3f..3b092cd 100644 --- a/manuskript/ui/settings_ui.ui +++ b/manuskript/ui/settings_ui.ui @@ -1932,457 +1932,523 @@ text-align:center; Text editor - + - - - - 75 - true - - - - Font - - - - - - - 50 - false - - - - Color: - - - - - - - - 0 - 0 - - - - - 50 - false - - - - - - - - - - - - 50 - false - - - - Family: - - - - - - - - 0 - 0 - - - - - 150 - 16777215 - - - - - 50 - false - - - - - - - - - 50 - false - - - - Size: - - - - - - - - 50 - false - - - - Misspelled: - - - - - - - - 0 - 0 - - - - - 50 - false - - - - - - - - - - - - 50 - false - - - - 4 - - - 299 - - - 10 - - - - - - - - 50 - false - - - - Background: - - - - - - - - 0 - 0 - - - - - 50 - false - - - - - - - - - - - - - - - 75 - true - - - - Paragraphs - - - - - - - 50 - false - - - - Line spacing: - - - - - - - - 50 - false - - - - - Single + + + + + + + + 75 + true + + + Font + + + + + + + 50 + false + + + + Color: + + + + + + + + 0 + 0 + + + + + 50 + false + + + + + + + + + + + + 50 + false + + + + Family: + + + + + + + + 0 + 0 + + + + + 150 + 16777215 + + + + + 50 + false + + + + + + + + + 50 + false + + + + Size: + + + + + + + + 50 + false + + + + Misspelled: + + + + + + + + 0 + 0 + + + + + 50 + false + + + + + + + + + + + + 50 + false + + + + 4 + + + 299 + + + 10 + + + + + + + + 50 + false + + + + Background: + + + + + + + + 0 + 0 + + + + + 50 + false + + + + + + + + + + + + + + + 75 + true + + + + Cursor + + + + + + + 50 + false + + + + Use block insertion of + + + + + + + + 50 + false + + + + px + + + 0 + + + 99 + + + 9 + + + + + + + + + + + + + 75 + true + + + + Paragraphs + + + + + + + 50 + false + + + + Line spacing: + + - - - 1.5 lines - + + + + + 50 + false + + + + + Single + + + + + 1.5 lines + + + + + Double + + + + + Proportional + + + - - - Double - + + + + false + + + + 0 + 0 + + + + + 50 + false + + + + % + + + 50 + + + 999 + + + 100 + + - - - Proportional - + + + + + 50 + false + + + + Tab width: + + - - - - - - false - - - - 0 - 0 - - - - - 50 - false - - - - % - - - 50 - - - 999 - - - 100 - - - - - - - - 50 - false - - - - Tab width: - - - - - - - - 0 - 0 - - - - - 50 - false - - - - px - - - 0 - - - 199 - - - 20 - - - - - - - - 0 - 0 - - - - - 50 - false - - - - Indent 1st line - - - - - - - - 50 - false - - - - Spacing: - - - - - - - - 0 - 0 - - - - - 50 - false - - - - px - - - 0 - - - 199 - - - 5 - - - - - - - - 0 - 0 - - - - - 50 - false - - - - px - - - 0 - - - 199 - - - 5 - - - - - - - - 50 - false - - - - Alignment: - - - - - - - - 50 - false - - - - - Left - - - - + + + + + 0 + 0 + + + + + 50 + false + + + + px + + + 0 + + + 199 + + + 20 + + - - - Center - - - - + + + + + 0 + 0 + + + + + 50 + false + + + + Indent 1st line + + - - - Right - - - - + + + + + 50 + false + + + + Spacing: + + - - - Justify - - - - + + + + + 0 + 0 + + + + + 50 + false + + + + px + + + 0 + + + 199 + + + 5 + + - - - - + + + + + 0 + 0 + + + + + 50 + false + + + + px + + + 0 + + + 199 + + + 5 + + + + + + + + 50 + false + + + + Alignment: + + + + + + + + 50 + false + + + + + Left + + + + + + + + + + Center + + + + + + + + + + Right + + + + + + + + + + Justify + + + + + + + + + + + + + @@ -3362,7 +3428,9 @@ text-align:center; Left - + + + @@ -3370,7 +3438,9 @@ text-align:center; Center - + + + @@ -3378,7 +3448,9 @@ text-align:center; Right - + + + @@ -3386,7 +3458,9 @@ text-align:center; Justify - + + + diff --git a/manuskript/ui/views/textEditView.py b/manuskript/ui/views/textEditView.py index 05f16f3..a0692cd 100644 --- a/manuskript/ui/views/textEditView.py +++ b/manuskript/ui/views/textEditView.py @@ -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) diff --git a/sample-projects/book-of-acts/settings.txt b/sample-projects/book-of-acts/settings.txt index 3485637..e98661f 100644 --- a/sample-projects/book-of-acts/settings.txt +++ b/sample-projects/book-of-acts/settings.txt @@ -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": {