mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-28 08:04:13 +08:00
style
This commit is contained in:
parent
eadf1f3b9d
commit
844b47ac87
@ -1,5 +1,4 @@
|
||||
import time
|
||||
import keeprefs
|
||||
import os, threading
|
||||
from traceback import print_exc
|
||||
from myutils.config import (
|
||||
|
@ -11,7 +11,8 @@ if __name__ == "__main__":
|
||||
) # win7 no vcredist2015
|
||||
|
||||
from myutils.config import _TR, static_data, globalconfig
|
||||
|
||||
|
||||
sys.path.append("./")
|
||||
sys.path.append("./userconfig")
|
||||
sys.path.insert(
|
||||
0, "./LunaTranslator/network/" + ["winhttp", "libcurl"][globalconfig["network"]]
|
||||
|
@ -14,7 +14,7 @@ from PyQt5.QtWidgets import (
|
||||
)
|
||||
from PyQt5.QtGui import QResizeEvent, QFont, QFontMetrics
|
||||
from PyQt5.QtWidgets import QTabWidget
|
||||
import qtawesome, gobject
|
||||
import qtawesome, gobject, importlib, sys
|
||||
import functools, threading, windows, winsharedutils
|
||||
from traceback import print_exc
|
||||
from winsharedutils import isDark
|
||||
@ -263,20 +263,26 @@ class Settin(closeashidewindow):
|
||||
winsharedutils.SetTheme(
|
||||
int(widget.winId()), dark, globalconfig["WindowBackdrop"]
|
||||
)
|
||||
try:
|
||||
idx = globalconfig[darklight + "theme"] - int(not dark)
|
||||
if idx == -1:
|
||||
raise Exception()
|
||||
with open(
|
||||
"./files/themes/{}".format(
|
||||
static_data["themes"][darklight][idx]["file"]
|
||||
),
|
||||
"r",
|
||||
) as ff:
|
||||
style = ff.read()
|
||||
except:
|
||||
# print_exc()
|
||||
style = ""
|
||||
for _ in (0,):
|
||||
try:
|
||||
idx = globalconfig[darklight + "theme"] - int(not dark)
|
||||
if idx == -1:
|
||||
break
|
||||
_fn = static_data["themes"][darklight][idx]["file"]
|
||||
|
||||
if _fn.endswith(".py"):
|
||||
style = importlib.import_module(
|
||||
"files.themes." + _fn[:-3]
|
||||
).stylesheet()
|
||||
elif _fn.endswith(".qss"):
|
||||
with open(
|
||||
"./files/themes/{}".format(_fn),
|
||||
"r",
|
||||
) as ff:
|
||||
style = ff.read()
|
||||
except:
|
||||
print_exc()
|
||||
style = ""
|
||||
style += (
|
||||
"*{font: %spt '" % (globalconfig["settingfontsize"])
|
||||
+ (globalconfig["settingfonttype"])
|
||||
|
@ -5,4 +5,6 @@ import xml.etree.ElementTree as ET
|
||||
import hashlib
|
||||
import configparser
|
||||
from wsgiref.handlers import format_date_time
|
||||
from html.parser import HTMLParser
|
||||
from html.parser import HTMLParser
|
||||
import qdarkstyle
|
||||
import qdarktheme
|
@ -2,21 +2,21 @@
|
||||
"themes": {
|
||||
"dark": [
|
||||
{
|
||||
"file": "dark1.qss",
|
||||
"file": "dark1.py",
|
||||
"name": "PyQtDarkTheme"
|
||||
},
|
||||
{
|
||||
"file": "dark2.qss",
|
||||
"file": "dark2.py",
|
||||
"name": "QDarkStyleSheet"
|
||||
}
|
||||
],
|
||||
"light": [
|
||||
{
|
||||
"file": "light1.qss",
|
||||
"file": "light1.py",
|
||||
"name": "PyQtDarkTheme"
|
||||
},
|
||||
{
|
||||
"file": "light2.qss",
|
||||
"file": "light2.py",
|
||||
"name": "QDarkStyleSheet"
|
||||
}
|
||||
]
|
||||
|
3
LunaTranslator/files/themes/dark1.py
Normal file
3
LunaTranslator/files/themes/dark1.py
Normal file
@ -0,0 +1,3 @@
|
||||
import qdarktheme
|
||||
def stylesheet():
|
||||
return qdarktheme.load_stylesheet(theme='dark')
|
File diff suppressed because one or more lines are too long
4
LunaTranslator/files/themes/dark2.py
Normal file
4
LunaTranslator/files/themes/dark2.py
Normal file
@ -0,0 +1,4 @@
|
||||
import qdarkstyle
|
||||
|
||||
def stylesheet():
|
||||
return qdarkstyle.load_stylesheet(palette=qdarkstyle.DarkPalette)
|
File diff suppressed because it is too large
Load Diff
3
LunaTranslator/files/themes/light1.py
Normal file
3
LunaTranslator/files/themes/light1.py
Normal file
@ -0,0 +1,3 @@
|
||||
import qdarktheme
|
||||
def stylesheet():
|
||||
return qdarktheme.load_stylesheet(theme='light')
|
File diff suppressed because one or more lines are too long
4
LunaTranslator/files/themes/light2.py
Normal file
4
LunaTranslator/files/themes/light2.py
Normal file
@ -0,0 +1,4 @@
|
||||
import qdarkstyle
|
||||
|
||||
def stylesheet():
|
||||
return qdarkstyle.load_stylesheet(palette=qdarkstyle.LightPalette)
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,6 @@
|
||||
PyQt5==5.15.10
|
||||
PyQt5-Qt5==5.15.2
|
||||
webviewpy==1.2.0
|
||||
pefile
|
||||
pefile
|
||||
qdarkstyle
|
||||
pyqtdarktheme
|
@ -178,6 +178,10 @@ copycheck(
|
||||
os.path.join(py37Path, "Lib/site-packages/PyQt5/Qt5/bin/Qt5Core.dll"),
|
||||
os.path.join(runtime, "PyQt5/Qt5/bin"),
|
||||
)
|
||||
copycheck(
|
||||
os.path.join(py37Path, "Lib/site-packages/PyQt5/Qt5/bin/Qt5Svg.dll"),
|
||||
os.path.join(runtime, "PyQt5/Qt5/bin"),
|
||||
)
|
||||
copycheck(
|
||||
os.path.join(py37Path, "Lib/site-packages/PyQt5/Qt5/bin/Qt5Gui.dll"),
|
||||
os.path.join(runtime, "PyQt5/Qt5/bin"),
|
||||
@ -188,6 +192,10 @@ copycheck(
|
||||
os.path.join(runtime, "PyQt5/Qt5/bin"),
|
||||
)
|
||||
|
||||
copycheck(
|
||||
os.path.join(py37Path, "Lib/site-packages/PyQt5/Qt5/plugins/iconengines"),
|
||||
os.path.join(runtime, "PyQt5/Qt5/plugins"),
|
||||
)
|
||||
copycheck(
|
||||
os.path.join(py37Path, "Lib/site-packages/PyQt5/Qt5/plugins/imageformats"),
|
||||
os.path.join(runtime, "PyQt5/Qt5/plugins"),
|
||||
@ -210,6 +218,18 @@ copycheck(
|
||||
),
|
||||
os.path.join(runtime, "PyQt5/Qt5/plugins/styles"),
|
||||
)
|
||||
copycheck(
|
||||
os.path.join(
|
||||
py37Path, "Lib/site-packages/qdarktheme"
|
||||
),
|
||||
os.path.join(runtime),
|
||||
)
|
||||
copycheck(
|
||||
os.path.join(
|
||||
py37Path, "Lib/site-packages/qdarkstyle"
|
||||
),
|
||||
os.path.join(runtime),
|
||||
)
|
||||
|
||||
collect = []
|
||||
for _dir, _, fs in os.walk(targetdir):
|
||||
|
Loading…
x
Reference in New Issue
Block a user