mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-12 17:02:36 +12:00
This commit is contained in:
parent
bffe17f9f0
commit
b81a571b2e
|
@ -68,6 +68,9 @@ def launch():
|
|||
from .mainWindow import MainWindow
|
||||
|
||||
main = MainWindow()
|
||||
# We store the system default cursor flash time to be able to restore it
|
||||
# later if necessary
|
||||
main._defaultCursorFlashTime = qApp.cursorFlashTime()
|
||||
main.show()
|
||||
|
||||
qApp.exec_()
|
||||
|
|
|
@ -67,7 +67,11 @@ textEditor = {
|
|||
"spacingAbove": 5,
|
||||
"spacingBelow": 5,
|
||||
"textAlignment": 0, # 0: left, 1: center, 2: right, 3: justify
|
||||
"cursorWidth": 1
|
||||
"cursorWidth": 1,
|
||||
"cursorNotBlinking": False,
|
||||
"maxWidth": 0,
|
||||
"marginsLR": 0,
|
||||
"marginsTB": 0,
|
||||
}
|
||||
|
||||
revisions = {
|
||||
|
@ -235,12 +239,24 @@ def load(string, fromString=False, protocol=None):
|
|||
if "textEditor" in allSettings:
|
||||
global textEditor
|
||||
textEditor = allSettings["textEditor"]
|
||||
|
||||
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
|
||||
|
||||
added = {
|
||||
"textAlignment": 0, # Added in 0.5.0
|
||||
"cursorWidth": 1,
|
||||
"cursorNotBlinking": False, # Added in 0.6.0
|
||||
"maxWidth": 0,
|
||||
"marginsLR": 0,
|
||||
"marginsTB": 0,
|
||||
}
|
||||
|
||||
for k in added:
|
||||
if not k in textEditor: textEditor[k] = added[k]
|
||||
|
||||
if textEditor["cursorNotBlinking"]:
|
||||
qApp.setCursorFlashTime(0)
|
||||
else:
|
||||
from manuskript.functions import mainWindow
|
||||
qApp.setCursorFlashTime(mainWindow()._defaultCursorFlashTime)
|
||||
|
||||
if "revisions" in allSettings:
|
||||
global revisions
|
||||
|
|
|
@ -6,6 +6,7 @@ from collections import OrderedDict
|
|||
from PyQt5.QtCore import QSize, QSettings, QRegExp, QTranslator, QObject
|
||||
from PyQt5.QtCore import Qt, QTimer
|
||||
from PyQt5.QtGui import QIntValidator, QIcon, QFont, QColor, QPixmap, QStandardItem, QPainter
|
||||
from PyQt5.QtGui import QStyleHints
|
||||
from PyQt5.QtWidgets import QStyleFactory, QWidget, QStyle, QColorDialog, QListWidgetItem, QMessageBox
|
||||
from PyQt5.QtWidgets import qApp
|
||||
|
||||
|
@ -149,6 +150,7 @@ class settingsWindow(QWidget, Ui_Settings):
|
|||
|
||||
# Text editor
|
||||
opt = settings.textEditor
|
||||
# Font
|
||||
self.setButtonColor(self.btnEditorFontColor, opt["fontColor"])
|
||||
self.btnEditorFontColor.clicked.connect(self.choseEditorFontColor)
|
||||
self.setButtonColor(self.btnEditorMisspelledColor, opt["misspelled"])
|
||||
|
@ -161,11 +163,25 @@ class settingsWindow(QWidget, Ui_Settings):
|
|||
self.cmbEditorFontFamily.currentFontChanged.connect(self.updateEditorSettings)
|
||||
self.spnEditorFontSize.setValue(f.pointSize())
|
||||
self.spnEditorFontSize.valueChanged.connect(self.updateEditorSettings)
|
||||
# Cursor
|
||||
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.chkEditorNoBlinking.setChecked(opt["cursorNotBlinking"])
|
||||
self.chkEditorNoBlinking.stateChanged.connect(self.setApplicationCursorBlinking)
|
||||
# Text areas
|
||||
self.chkEditorMaxWidth.setChecked(opt["maxWidth"] != 0)
|
||||
self.chkEditorMaxWidth.stateChanged.connect(self.updateEditorSettings)
|
||||
self.spnEditorMaxWidth.setEnabled(opt["maxWidth"] != 0)
|
||||
self.spnEditorMaxWidth.setValue(500 if opt["maxWidth"] == 0 else opt["maxWidth"])
|
||||
self.spnEditorMaxWidth.valueChanged.connect(self.updateEditorSettings)
|
||||
self.spnEditorMarginsLR.setValue(opt["marginsLR"])
|
||||
self.spnEditorMarginsLR.valueChanged.connect(self.updateEditorSettings)
|
||||
self.spnEditorMarginsTB.setValue(opt["marginsTB"])
|
||||
self.spnEditorMarginsTB.valueChanged.connect(self.updateEditorSettings)
|
||||
# Paragraphs
|
||||
self.cmbEditorAlignment.setCurrentIndex(opt["textAlignment"])
|
||||
self.cmbEditorAlignment.currentIndexChanged.connect(self.updateEditorSettings)
|
||||
self.cmbEditorLineSpacing.setCurrentIndex(
|
||||
|
@ -411,13 +427,26 @@ class settingsWindow(QWidget, Ui_Settings):
|
|||
|
||||
def updateEditorSettings(self):
|
||||
# Store settings
|
||||
# Font
|
||||
f = self.cmbEditorFontFamily.currentFont()
|
||||
f.setPointSize(self.spnEditorFontSize.value())
|
||||
settings.textEditor["font"] = f.toString()
|
||||
|
||||
# Cursor
|
||||
settings.textEditor["cursorWidth"] = \
|
||||
1 if not self.chkEditorCursorWidth.isChecked() else \
|
||||
self.spnEditorCursorWidth.value()
|
||||
self.spnEditorCursorWidth.setEnabled(self.chkEditorCursorWidth.isChecked())
|
||||
|
||||
# Text area
|
||||
settings.textEditor["maxWidth"] = \
|
||||
0 if not self.chkEditorMaxWidth.isChecked() else \
|
||||
self.spnEditorMaxWidth.value()
|
||||
self.spnEditorMaxWidth.setEnabled(self.chkEditorMaxWidth.isChecked())
|
||||
settings.textEditor["marginsLR"] = self.spnEditorMarginsLR.value()
|
||||
settings.textEditor["marginsTB"] = self.spnEditorMarginsTB.value()
|
||||
|
||||
# Paragraphs
|
||||
settings.textEditor["textAlignment"] = self.cmbEditorAlignment.currentIndex()
|
||||
settings.textEditor["lineSpacing"] = \
|
||||
100 if self.cmbEditorLineSpacing.currentIndex() == 0 else \
|
||||
|
@ -429,7 +458,7 @@ class settingsWindow(QWidget, Ui_Settings):
|
|||
settings.textEditor["indent"] = True if self.chkEditorIndent.checkState() else False
|
||||
settings.textEditor["spacingAbove"] = self.spnEditorParaAbove.value()
|
||||
settings.textEditor["spacingBelow"] = self.spnEditorParaBelow.value()
|
||||
|
||||
|
||||
self.timerUpdateWidgets.start()
|
||||
|
||||
def updateAllWidgets(self):
|
||||
|
@ -446,6 +475,14 @@ class settingsWindow(QWidget, Ui_Settings):
|
|||
for w in mainWindow().findChildren(QWidget, QRegExp("editorWidgetFolderText")):
|
||||
w.setStyleSheet("background: {};".format(settings.textEditor["background"]))
|
||||
|
||||
def setApplicationCursorBlinking(self):
|
||||
settings.textEditor["cursorNotBlinking"] = self.chkEditorNoBlinking.isChecked()
|
||||
if settings.textEditor["cursorNotBlinking"]:
|
||||
qApp.setCursorFlashTime(0)
|
||||
else:
|
||||
# Load default system value, that we cached at startup
|
||||
qApp.setCursorFlashTime(mw._defaultCursorFlashTime)
|
||||
|
||||
def choseEditorFontColor(self):
|
||||
color = settings.textEditor["fontColor"]
|
||||
self.colorDialog = QColorDialog(QColor(color), self)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Form implementation generated from reading ui file 'manuskript/ui/settings_ui.ui'
|
||||
#
|
||||
# Created: Wed Oct 18 10:25:40 2017
|
||||
# Created: Thu Oct 19 12:06:37 2017
|
||||
# by: PyQt5 UI code generator 5.2.1
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
@ -1064,7 +1064,69 @@ class Ui_Settings(object):
|
|||
self.spnEditorCursorWidth.setProperty("value", 9)
|
||||
self.spnEditorCursorWidth.setObjectName("spnEditorCursorWidth")
|
||||
self.formLayout_10.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.spnEditorCursorWidth)
|
||||
self.chkEditorNoBlinking = QtWidgets.QCheckBox(self.groupBox_15)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(False)
|
||||
font.setWeight(50)
|
||||
self.chkEditorNoBlinking.setFont(font)
|
||||
self.chkEditorNoBlinking.setObjectName("chkEditorNoBlinking")
|
||||
self.formLayout_10.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.chkEditorNoBlinking)
|
||||
self.verticalLayout_21.addWidget(self.groupBox_15)
|
||||
self.groupBox_16 = QtWidgets.QGroupBox(self.tab_4)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(True)
|
||||
font.setWeight(75)
|
||||
self.groupBox_16.setFont(font)
|
||||
self.groupBox_16.setObjectName("groupBox_16")
|
||||
self.formLayout_11 = QtWidgets.QFormLayout(self.groupBox_16)
|
||||
self.formLayout_11.setObjectName("formLayout_11")
|
||||
self.chkEditorMaxWidth = QtWidgets.QCheckBox(self.groupBox_16)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(False)
|
||||
font.setWeight(50)
|
||||
self.chkEditorMaxWidth.setFont(font)
|
||||
self.chkEditorMaxWidth.setObjectName("chkEditorMaxWidth")
|
||||
self.formLayout_11.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.chkEditorMaxWidth)
|
||||
self.spnEditorMaxWidth = QtWidgets.QSpinBox(self.groupBox_16)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(False)
|
||||
font.setWeight(50)
|
||||
self.spnEditorMaxWidth.setFont(font)
|
||||
self.spnEditorMaxWidth.setMaximum(4096)
|
||||
self.spnEditorMaxWidth.setProperty("value", 500)
|
||||
self.spnEditorMaxWidth.setObjectName("spnEditorMaxWidth")
|
||||
self.formLayout_11.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.spnEditorMaxWidth)
|
||||
self.label_54 = QtWidgets.QLabel(self.groupBox_16)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(False)
|
||||
font.setWeight(50)
|
||||
self.label_54.setFont(font)
|
||||
self.label_54.setObjectName("label_54")
|
||||
self.formLayout_11.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label_54)
|
||||
self.label_55 = QtWidgets.QLabel(self.groupBox_16)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(False)
|
||||
font.setWeight(50)
|
||||
self.label_55.setFont(font)
|
||||
self.label_55.setObjectName("label_55")
|
||||
self.formLayout_11.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.label_55)
|
||||
self.spnEditorMarginsLR = QtWidgets.QSpinBox(self.groupBox_16)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(False)
|
||||
font.setWeight(50)
|
||||
self.spnEditorMarginsLR.setFont(font)
|
||||
self.spnEditorMarginsLR.setMaximum(2048)
|
||||
self.spnEditorMarginsLR.setObjectName("spnEditorMarginsLR")
|
||||
self.formLayout_11.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.spnEditorMarginsLR)
|
||||
self.spnEditorMarginsTB = QtWidgets.QSpinBox(self.groupBox_16)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(False)
|
||||
font.setWeight(50)
|
||||
self.spnEditorMarginsTB.setFont(font)
|
||||
self.spnEditorMarginsTB.setMaximum(2048)
|
||||
self.spnEditorMarginsTB.setObjectName("spnEditorMarginsTB")
|
||||
self.formLayout_11.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.spnEditorMarginsTB)
|
||||
self.verticalLayout_21.addWidget(self.groupBox_16)
|
||||
self.horizontalLayout_4.addLayout(self.verticalLayout_21)
|
||||
self.groupBox_13 = QtWidgets.QGroupBox(self.tab_4)
|
||||
font = QtGui.QFont()
|
||||
|
@ -1866,6 +1928,14 @@ class Ui_Settings(object):
|
|||
self.groupBox_15.setTitle(_translate("Settings", "Cursor"))
|
||||
self.chkEditorCursorWidth.setText(_translate("Settings", "Use block insertion of"))
|
||||
self.spnEditorCursorWidth.setSuffix(_translate("Settings", " px"))
|
||||
self.chkEditorNoBlinking.setText(_translate("Settings", "Disable blinking"))
|
||||
self.groupBox_16.setTitle(_translate("Settings", "Text area"))
|
||||
self.chkEditorMaxWidth.setText(_translate("Settings", "Max width"))
|
||||
self.spnEditorMaxWidth.setSuffix(_translate("Settings", " px"))
|
||||
self.label_54.setText(_translate("Settings", "Left/Right margins:"))
|
||||
self.label_55.setText(_translate("Settings", "Top/Bottom margins:"))
|
||||
self.spnEditorMarginsLR.setSuffix(_translate("Settings", " px"))
|
||||
self.spnEditorMarginsTB.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"))
|
||||
|
|
|
@ -2162,6 +2162,124 @@ text-align:center;</string>
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="chkEditorNoBlinking">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Disable blinking</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_16">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Text area</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_11">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="chkEditorMaxWidth">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Max width</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="spnEditorMaxWidth">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> px</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>4096</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>500</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_54">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Left/Right margins:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="spnEditorMarginsLR">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> px</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2048</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_55">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Top/Bottom margins:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spnEditorMarginsTB">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> px</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2048</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -187,13 +187,21 @@ class textEditView(QTextEdit):
|
|||
color: {foreground};
|
||||
font-family: {ff};
|
||||
font-size: {fs};
|
||||
margin: {mTB}px {mLR}px;
|
||||
{maxWidth}
|
||||
}}
|
||||
""".format(
|
||||
bg=opt["background"],
|
||||
foreground=opt["fontColor"],
|
||||
ff=f.family(),
|
||||
fs="{}pt".format(str(f.pointSize()))))
|
||||
fs="{}pt".format(str(f.pointSize())),
|
||||
mTB = opt["marginsTB"],
|
||||
mLR = opt["marginsLR"],
|
||||
maxWidth = "max-width: {}px;".format(opt["maxWidth"]) if opt["maxWidth"] else "",
|
||||
)
|
||||
)
|
||||
|
||||
self.parent().setStyleSheet("background: {bg};".format(bg=opt["background"]))
|
||||
cf = QTextCharFormat()
|
||||
# cf.setFont(f)
|
||||
# cf.setForeground(QColor(opt["fontColor"]))
|
||||
|
|
Loading…
Reference in a new issue