Skip to content

Commit

Permalink
Adds optimization of fullscreen's theme thumbnail generation in setti…
Browse files Browse the repository at this point in the history
…ngs, and corrects a small stylesheet bug
  • Loading branch information
olivierkes committed Oct 19, 2017
1 parent b81a571 commit eb89d2f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
10 changes: 7 additions & 3 deletions manuskript/settingsWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ def __init__(self, mainWindow):
self.btnThemeAdd.clicked.connect(self.newTheme)
self.btnThemeEdit.clicked.connect(self.editTheme)
self.btnThemeRemove.clicked.connect(self.removeTheme)
self.timerUpdateFSPreview = QTimer()
self.timerUpdateFSPreview.setSingleShot(True)
self.timerUpdateFSPreview.setInterval(250)
self.timerUpdateFSPreview.timeout.connect(self.updatePreview)

def setTab(self, tab):

Expand Down Expand Up @@ -700,7 +704,7 @@ def loadTheme(self, theme):

def setSetting(self, key, val):
self._themeData[key] = val
self.updatePreview()
self.timerUpdateFSPreview.start()

def updateUIFromTheme(self):
self.txtThemeName.setText(self._themeData["Name"])
Expand Down Expand Up @@ -765,7 +769,7 @@ def updateThemeFont(self, v):
f.setPointSize(int(s))

self._themeData["Text/Font"] = f.toString()
self.updatePreview()
self.timerUpdateFSPreview.start()

def updateLineSpacing(self, i):
if i == 0:
Expand All @@ -777,7 +781,7 @@ def updateLineSpacing(self, i):
elif i == 3:
self._themeData["Spacings/LineSpacing"] = self.spnThemeLineSpacing.value()
self.spnThemeLineSpacing.setEnabled(i == 3)
self.updatePreview()
self.timerUpdateFSPreview.start()

def updateThemeBackground(self, i):
img = self.cmbCorkImage.itemData(i)
Expand Down
24 changes: 12 additions & 12 deletions manuskript/ui/settings_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Form implementation generated from reading ui file 'manuskript/ui/settings_ui.ui'
#
# Created: Thu Oct 19 12:06:37 2017
# Created: Thu Oct 19 12:16:24 2017
# by: PyQt5 UI code generator 5.2.1
#
# WARNING! All changes made in this file will be lost!
Expand Down Expand Up @@ -1102,30 +1102,30 @@ def setupUi(self, Settings):
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.formLayout_11.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.label_54)
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.formLayout_11.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.spnEditorMarginsLR)
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(1, QtWidgets.QFormLayout.LabelRole, self.label_55)
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.formLayout_11.setWidget(1, 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)
Expand Down Expand Up @@ -1933,8 +1933,8 @@ def retranslateUi(self, Settings):
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.label_55.setText(_translate("Settings", "Top/Bottom margins:"))
self.spnEditorMarginsTB.setSuffix(_translate("Settings", " px"))
self.groupBox_13.setTitle(_translate("Settings", "Paragraphs"))
self.label_40.setText(_translate("Settings", "Line spacing:"))
Expand Down
11 changes: 9 additions & 2 deletions manuskript/ui/views/textEditView.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from PyQt5.QtCore import QTimer, QModelIndex, Qt, QEvent, pyqtSignal, QRegExp
from PyQt5.QtGui import QTextBlockFormat, QTextCharFormat, QFont, QColor, QIcon, QMouseEvent, QTextCursor
from PyQt5.QtWidgets import QTextEdit, qApp, QAction, QMenu
from PyQt5.QtWidgets import QWidget, QTextEdit, qApp, QAction, QMenu

from manuskript import settings
from manuskript.enums import Outline
Expand Down Expand Up @@ -201,7 +201,14 @@ def loadFontSettings(self):
)
)

self.parent().setStyleSheet("background: {bg};".format(bg=opt["background"]))
# We set the parent background to the editor's background in case
# there are margins. We check that the parent class is a QWidget because
# if textEditView is used in fullScreenEditor, then we don't want to
# set the background
if self.parent().__class__ == QWidget:
self.parent().setStyleSheet("background: {bg};".format(
bg=opt["background"]))

cf = QTextCharFormat()
# cf.setFont(f)
# cf.setForeground(QColor(opt["fontColor"]))
Expand Down

0 comments on commit eb89d2f

Please sign in to comment.