This commit is contained in:
恍兮惚兮 2024-05-27 22:26:00 +08:00
parent eadf1f3b9d
commit 844b47ac87
15 changed files with 67 additions and 4462 deletions

View File

@ -1,5 +1,4 @@
import time import time
import keeprefs
import os, threading import os, threading
from traceback import print_exc from traceback import print_exc
from myutils.config import ( from myutils.config import (

View File

@ -12,6 +12,7 @@ if __name__ == "__main__":
from myutils.config import _TR, static_data, globalconfig from myutils.config import _TR, static_data, globalconfig
sys.path.append("./")
sys.path.append("./userconfig") sys.path.append("./userconfig")
sys.path.insert( sys.path.insert(
0, "./LunaTranslator/network/" + ["winhttp", "libcurl"][globalconfig["network"]] 0, "./LunaTranslator/network/" + ["winhttp", "libcurl"][globalconfig["network"]]

View File

@ -14,7 +14,7 @@ from PyQt5.QtWidgets import (
) )
from PyQt5.QtGui import QResizeEvent, QFont, QFontMetrics from PyQt5.QtGui import QResizeEvent, QFont, QFontMetrics
from PyQt5.QtWidgets import QTabWidget from PyQt5.QtWidgets import QTabWidget
import qtawesome, gobject import qtawesome, gobject, importlib, sys
import functools, threading, windows, winsharedutils import functools, threading, windows, winsharedutils
from traceback import print_exc from traceback import print_exc
from winsharedutils import isDark from winsharedutils import isDark
@ -263,19 +263,25 @@ class Settin(closeashidewindow):
winsharedutils.SetTheme( winsharedutils.SetTheme(
int(widget.winId()), dark, globalconfig["WindowBackdrop"] int(widget.winId()), dark, globalconfig["WindowBackdrop"]
) )
for _ in (0,):
try: try:
idx = globalconfig[darklight + "theme"] - int(not dark) idx = globalconfig[darklight + "theme"] - int(not dark)
if idx == -1: if idx == -1:
raise Exception() 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( with open(
"./files/themes/{}".format( "./files/themes/{}".format(_fn),
static_data["themes"][darklight][idx]["file"]
),
"r", "r",
) as ff: ) as ff:
style = ff.read() style = ff.read()
except: except:
# print_exc() print_exc()
style = "" style = ""
style += ( style += (
"*{font: %spt '" % (globalconfig["settingfontsize"]) "*{font: %spt '" % (globalconfig["settingfontsize"])

View File

@ -6,3 +6,5 @@ import hashlib
import configparser import configparser
from wsgiref.handlers import format_date_time from wsgiref.handlers import format_date_time
from html.parser import HTMLParser from html.parser import HTMLParser
import qdarkstyle
import qdarktheme

View File

@ -2,21 +2,21 @@
"themes": { "themes": {
"dark": [ "dark": [
{ {
"file": "dark1.qss", "file": "dark1.py",
"name": "PyQtDarkTheme" "name": "PyQtDarkTheme"
}, },
{ {
"file": "dark2.qss", "file": "dark2.py",
"name": "QDarkStyleSheet" "name": "QDarkStyleSheet"
} }
], ],
"light": [ "light": [
{ {
"file": "light1.qss", "file": "light1.py",
"name": "PyQtDarkTheme" "name": "PyQtDarkTheme"
}, },
{ {
"file": "light2.qss", "file": "light2.py",
"name": "QDarkStyleSheet" "name": "QDarkStyleSheet"
} }
] ]

View 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

View 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

View 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

View 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

View File

@ -2,3 +2,5 @@ PyQt5==5.15.10
PyQt5-Qt5==5.15.2 PyQt5-Qt5==5.15.2
webviewpy==1.2.0 webviewpy==1.2.0
pefile pefile
qdarkstyle
pyqtdarktheme

View File

@ -178,6 +178,10 @@ copycheck(
os.path.join(py37Path, "Lib/site-packages/PyQt5/Qt5/bin/Qt5Core.dll"), os.path.join(py37Path, "Lib/site-packages/PyQt5/Qt5/bin/Qt5Core.dll"),
os.path.join(runtime, "PyQt5/Qt5/bin"), 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( copycheck(
os.path.join(py37Path, "Lib/site-packages/PyQt5/Qt5/bin/Qt5Gui.dll"), os.path.join(py37Path, "Lib/site-packages/PyQt5/Qt5/bin/Qt5Gui.dll"),
os.path.join(runtime, "PyQt5/Qt5/bin"), os.path.join(runtime, "PyQt5/Qt5/bin"),
@ -188,6 +192,10 @@ copycheck(
os.path.join(runtime, "PyQt5/Qt5/bin"), 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( copycheck(
os.path.join(py37Path, "Lib/site-packages/PyQt5/Qt5/plugins/imageformats"), os.path.join(py37Path, "Lib/site-packages/PyQt5/Qt5/plugins/imageformats"),
os.path.join(runtime, "PyQt5/Qt5/plugins"), os.path.join(runtime, "PyQt5/Qt5/plugins"),
@ -210,6 +218,18 @@ copycheck(
), ),
os.path.join(runtime, "PyQt5/Qt5/plugins/styles"), 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 = [] collect = []
for _dir, _, fs in os.walk(targetdir): for _dir, _, fs in os.walk(targetdir):