mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-12 08:52:30 +12:00
Merge a9a0208924
into 50b9fd4980
This commit is contained in:
commit
7e8005c129
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -16,6 +16,7 @@
|
|||
.settings/org.eclipse.core.resources.prefs
|
||||
.vscode
|
||||
.vimrc
|
||||
desktop.ini
|
||||
ExportTest
|
||||
Notes.t2t
|
||||
dist
|
||||
|
|
|
@ -13,6 +13,7 @@ from PyQt5.QtWidgets import QApplication, qApp, QStyleFactory
|
|||
|
||||
from manuskript.functions import appPath, writablePath
|
||||
from manuskript.version import getVersion
|
||||
from manuskript.ui import themes
|
||||
|
||||
try:
|
||||
faulthandler.enable()
|
||||
|
@ -56,6 +57,14 @@ def prepare(arguments, tests=False):
|
|||
style = settings.value("applicationStyle")
|
||||
app.setStyle(style)
|
||||
|
||||
# Set palette from QSettings
|
||||
app.setPalette(themes.light) # Start off with light theme
|
||||
if settings.contains("applicationPalette"):
|
||||
palette = settings.value("applicationPalette")
|
||||
if hasattr(themes, palette):
|
||||
# If settings has valid theme name, use requested
|
||||
app.setPalette(getattr(themes, palette))
|
||||
|
||||
# Translation process
|
||||
appTranslator = QTranslator(app)
|
||||
|
||||
|
|
|
@ -23,8 +23,7 @@ from manuskript.ui.editors.themes import loadThemeDatas
|
|||
from manuskript.ui.settings_ui import Ui_Settings
|
||||
from manuskript.ui.views.outlineView import outlineView
|
||||
from manuskript.ui.views.textEditView import textEditView
|
||||
from manuskript.ui.welcome import welcome
|
||||
from manuskript.ui import style as S
|
||||
from manuskript.ui import style as S, themes as T
|
||||
|
||||
|
||||
class settingsWindow(QWidget, Ui_Settings):
|
||||
|
@ -60,16 +59,31 @@ class settingsWindow(QWidget, Ui_Settings):
|
|||
self.lstMenu.setMinimumWidth(140)
|
||||
|
||||
lowerKeys = [i.lower() for i in list(QStyleFactory.keys())]
|
||||
palettes = [T.light, T.dark]
|
||||
paletteNames = [qApp.translate("Palette", "Light Theme"), qApp.translate("Palette", "Dark Theme")]
|
||||
|
||||
# General
|
||||
self.cmbStyle.addItems(list(QStyleFactory.keys()))
|
||||
self.cmbPalette.addItems(paletteNames)
|
||||
|
||||
try:
|
||||
self.cmbStyle.setCurrentIndex(lowerKeys.index(qApp.style().objectName()))
|
||||
except ValueError:
|
||||
self.cmbStyle.setCurrentIndex(0)
|
||||
|
||||
try:
|
||||
self.cmbPalette.setCurrentIndex(palettes.index(qApp.palette()))
|
||||
except ValueError:
|
||||
self.cmbPalette.setCurrentIndex(0)
|
||||
|
||||
def _setPaletteByName(paletteName: str):
|
||||
try:
|
||||
qApp.setPalette(palettes[paletteNames.index(paletteName)])
|
||||
except ValueError:
|
||||
return
|
||||
|
||||
self.cmbStyle.currentIndexChanged[str].connect(self.setStyle)
|
||||
self.cmbPalette.currentIndexChanged[str].connect(_setPaletteByName)
|
||||
|
||||
self.cmbTranslation.clear()
|
||||
tr = OrderedDict()
|
||||
|
|
|
@ -88,25 +88,37 @@ class Ui_Settings(object):
|
|||
font.setBold(False)
|
||||
self.label_57.setFont(font)
|
||||
self.label_57.setObjectName("label_57")
|
||||
self.formLayout_14.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label_57)
|
||||
self.formLayout_14.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.label_57)
|
||||
self.cmbTranslation = QtWidgets.QComboBox(self.groupBox_2)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(False)
|
||||
self.cmbTranslation.setFont(font)
|
||||
self.cmbTranslation.setObjectName("cmbTranslation")
|
||||
self.formLayout_14.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.cmbTranslation)
|
||||
self.formLayout_14.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.cmbTranslation)
|
||||
self.label_58 = QtWidgets.QLabel(self.groupBox_2)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(False)
|
||||
self.label_58.setFont(font)
|
||||
self.label_58.setObjectName("label_58")
|
||||
self.formLayout_14.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.label_58)
|
||||
self.formLayout_14.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.label_58)
|
||||
self.spnGeneralFontSize = QtWidgets.QSpinBox(self.groupBox_2)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(False)
|
||||
self.spnGeneralFontSize.setFont(font)
|
||||
self.spnGeneralFontSize.setObjectName("spnGeneralFontSize")
|
||||
self.formLayout_14.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.spnGeneralFontSize)
|
||||
self.formLayout_14.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.spnGeneralFontSize)
|
||||
self.cmbPalette = QtWidgets.QComboBox(self.groupBox_2)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(False)
|
||||
self.cmbPalette.setFont(font)
|
||||
self.cmbPalette.setObjectName("cmbPalette")
|
||||
self.formLayout_14.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.cmbPalette)
|
||||
self.label_59 = QtWidgets.QLabel(self.groupBox_2)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(False)
|
||||
self.label_59.setFont(font)
|
||||
self.label_59.setObjectName("label_59")
|
||||
self.formLayout_14.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label_59)
|
||||
self.horizontalLayout_12.addLayout(self.formLayout_14)
|
||||
self.formLayout_15 = QtWidgets.QFormLayout()
|
||||
self.formLayout_15.setObjectName("formLayout_15")
|
||||
|
@ -1785,6 +1797,7 @@ class Ui_Settings(object):
|
|||
self.label_56.setText(_translate("Settings", "Style:"))
|
||||
self.label_57.setText(_translate("Settings", "Language:"))
|
||||
self.label_58.setText(_translate("Settings", "Font size:"))
|
||||
self.label_59.setText(_translate("Settings", "Palette:"))
|
||||
self.chkProgressChars.setText(_translate("Settings", "Show progress in chars next\n"
|
||||
" to words"))
|
||||
self.groupBox_10.setTitle(_translate("Settings", "Loading"))
|
||||
|
|
|
@ -145,7 +145,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_57">
|
||||
<property name="font">
|
||||
<font>
|
||||
|
@ -157,7 +157,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="cmbTranslation">
|
||||
<property name="font">
|
||||
<font>
|
||||
|
@ -166,7 +166,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_58">
|
||||
<property name="font">
|
||||
<font>
|
||||
|
@ -178,7 +178,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="spnGeneralFontSize">
|
||||
<property name="font">
|
||||
<font>
|
||||
|
@ -187,6 +187,27 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="cmbPalette">
|
||||
<property name="font">
|
||||
<font>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_59">
|
||||
<property name="font">
|
||||
<font>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Palette:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
|
2
manuskript/ui/themes/__init__.py
Normal file
2
manuskript/ui/themes/__init__.py
Normal file
|
@ -0,0 +1,2 @@
|
|||
from .dark import palette as dark
|
||||
from .light import palette as light
|
23
manuskript/ui/themes/dark.py
Normal file
23
manuskript/ui/themes/dark.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
from PyQt5.QtGui import QColor, QPalette
|
||||
|
||||
__all__ = ("colors", "palette")
|
||||
|
||||
colors = {
|
||||
QPalette.Window: QColor(53, 53, 53),
|
||||
QPalette.WindowText: QColor("white"),
|
||||
QPalette.Base: QColor(25, 25, 25),
|
||||
QPalette.AlternateBase: QColor(53, 53, 53),
|
||||
QPalette.ToolTipBase: QColor("white"),
|
||||
QPalette.ToolTipText: QColor("white"),
|
||||
QPalette.Text: QColor("white"),
|
||||
QPalette.Button: QColor(53, 53, 53),
|
||||
QPalette.ButtonText: QColor("white"),
|
||||
QPalette.BrightText: QColor("red"),
|
||||
QPalette.Link: QColor(42, 130, 218),
|
||||
QPalette.Highlight: QColor(42, 130, 218),
|
||||
QPalette.HighlightedText: QColor("black"),
|
||||
}
|
||||
|
||||
palette = QPalette()
|
||||
for key, val in colors.items():
|
||||
palette.setColor(key, val)
|
23
manuskript/ui/themes/light.py
Normal file
23
manuskript/ui/themes/light.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
from PyQt5.QtGui import QColor, QPalette
|
||||
|
||||
__all__ = ("colors", "palette")
|
||||
|
||||
colors = {
|
||||
QPalette.Window: QColor("#f2f2f2"),
|
||||
QPalette.WindowText: QColor("black"),
|
||||
QPalette.Base: QColor("white"),
|
||||
QPalette.AlternateBase: QColor(202, 202, 202),
|
||||
QPalette.ToolTipBase: QColor("black"),
|
||||
QPalette.ToolTipText: QColor("black"),
|
||||
QPalette.Text: QColor("black"),
|
||||
QPalette.Button: QColor(202, 202, 202),
|
||||
QPalette.ButtonText: QColor("black"),
|
||||
QPalette.BrightText: QColor("red"),
|
||||
QPalette.Link: QColor(42, 130, 218),
|
||||
QPalette.Highlight: QColor(42, 130, 218),
|
||||
QPalette.HighlightedText: QColor("white"),
|
||||
}
|
||||
|
||||
palette = QPalette()
|
||||
for key, val in colors.items():
|
||||
palette.setColor(key, val)
|
Loading…
Reference in a new issue