From c8edc14c1d88ea3f036ba0ad4f11240c89e78bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Wed, 29 May 2024 02:09:31 +0800 Subject: [PATCH] shrink --- .../LunaTranslator/LunaTranslator.py | 2 +- LunaTranslator/LunaTranslator/keeprefs.py | 4 +- .../files/defaultconfig/static_data.json | 16 +++---- LunaTranslator/requirements.txt | 4 +- LunaTranslator/retrieval.py | 12 ------ build.py | 43 ++++++++++--------- 6 files changed, 33 insertions(+), 48 deletions(-) diff --git a/LunaTranslator/LunaTranslator/LunaTranslator.py b/LunaTranslator/LunaTranslator/LunaTranslator.py index cd06b24d..f2aa0f35 100644 --- a/LunaTranslator/LunaTranslator/LunaTranslator.py +++ b/LunaTranslator/LunaTranslator/LunaTranslator.py @@ -859,7 +859,7 @@ class MAINUI: if _fn.endswith(".py"): style = importlib.import_module( - "files.themes." + _fn[:-3] + "files.themes." + _fn[:-3].replace("/", ".") ).stylesheet() elif _fn.endswith(".qss"): with open( diff --git a/LunaTranslator/LunaTranslator/keeprefs.py b/LunaTranslator/LunaTranslator/keeprefs.py index 11802e17..fd43faf7 100644 --- a/LunaTranslator/LunaTranslator/keeprefs.py +++ b/LunaTranslator/LunaTranslator/keeprefs.py @@ -5,6 +5,4 @@ import xml.etree.ElementTree as ET import hashlib import configparser from wsgiref.handlers import format_date_time -from html.parser import HTMLParser -import qdarkstyle -import qdarktheme \ No newline at end of file +from html.parser import HTMLParser \ No newline at end of file diff --git a/LunaTranslator/files/defaultconfig/static_data.json b/LunaTranslator/files/defaultconfig/static_data.json index e2afe470..9e6ba530 100644 --- a/LunaTranslator/files/defaultconfig/static_data.json +++ b/LunaTranslator/files/defaultconfig/static_data.json @@ -2,37 +2,37 @@ "themes": { "dark": [ { - "file": "dark1.py", + "file": "PyQtDarkTheme/dark.py", "name": "PyQtDarkTheme" }, { - "file": "dark2.py", + "file": "QDarkStyleSheet/dark.py", "name": "QDarkStyleSheet" }, { - "file": "dark3.py", + "file": "BreezeStyleSheets/dark.py", "name": "BreezeStyleSheets" }, { - "file": "dark_win11like.py", + "file": "QTWin11/dark.py", "name": "QTWin11" } ], "light": [ { - "file": "light1.py", + "file": "PyQtDarkTheme/light.py", "name": "PyQtDarkTheme" }, { - "file": "light2.py", + "file": "QDarkStyleSheet/light.py", "name": "QDarkStyleSheet" }, { - "file": "light3.py", + "file": "BreezeStyleSheets/light.py", "name": "BreezeStyleSheets" }, { - "file": "light_win11like.py", + "file": "QTWin11/light.py", "name": "QTWin11" } ] diff --git a/LunaTranslator/requirements.txt b/LunaTranslator/requirements.txt index 2562d1dd..90fe72e0 100644 --- a/LunaTranslator/requirements.txt +++ b/LunaTranslator/requirements.txt @@ -1,6 +1,4 @@ PyQt5==5.15.10 PyQt5-Qt5==5.15.2 webviewpy==1.2.0 -pefile -qdarkstyle -pyqtdarktheme \ No newline at end of file +pefile \ No newline at end of file diff --git a/LunaTranslator/retrieval.py b/LunaTranslator/retrieval.py index 0dd504f7..c7368f8b 100644 --- a/LunaTranslator/retrieval.py +++ b/LunaTranslator/retrieval.py @@ -218,18 +218,6 @@ 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): diff --git a/build.py b/build.py index 8781a310..01a70d51 100644 --- a/build.py +++ b/build.py @@ -92,6 +92,22 @@ def downloadlr(): ) +def move_directory_contents(source_dir, destination_dir): + contents = os.listdir(source_dir) + + for item in contents: + if item == ".git": + continue + item_path = os.path.join(source_dir, item) + try: + shutil.move(item_path, destination_dir) + except: + for k in os.listdir(item_path): + shutil.move( + os.path.join(item_path, k), os.path.join(destination_dir, item) + ) + + def downloadcommon(): os.chdir(rootDir + "\\temp") downloadlr() @@ -108,19 +124,6 @@ def downloadcommon(): ) subprocess.run(f"7z x magpie.zip -oALL") - def move_directory_contents(source_dir, destination_dir): - contents = os.listdir(source_dir) - - for item in contents: - item_path = os.path.join(source_dir, item) - try: - shutil.move(item_path, destination_dir) - except: - for k in os.listdir(item_path): - shutil.move( - os.path.join(item_path, k), os.path.join(destination_dir, item) - ) - move_directory_contents("ALL/ALL", f"{rootDir}/LunaTranslator/files/plugins") @@ -192,8 +195,6 @@ def get_url_as_json(url): except: time.sleep(3) - - def buildLunaHook(): for ass in get_url_as_json( @@ -238,13 +239,13 @@ def buildPlugins(): ) subprocess.run(f"python copytarget.py 0") + def downloadsomething(): os.chdir(rootDir + "\\temp") - os.system('git clone https://github.com/HIllya51/stylesheets') - for f in os.listdir('stylesheets'): - if os.path.isfile(os.path.join('stylesheets',f)): - shutil.copy(os.path.join('stylesheets',f),rootDir + "\\LunaTranslator\\files\\themes") - + os.system("git clone https://github.com/HIllya51/stylesheets") + move_directory_contents("stylesheets", rootDir + "\\LunaTranslator\\files\\themes") + + if __name__ == "__main__": if sys.argv[1] == "loadversion": os.chdir(rootDir) @@ -258,7 +259,7 @@ if __name__ == "__main__": arch = sys.argv[1] isdebug = len(sys.argv) > 2 and int(sys.argv[2]) os.chdir(rootDir) - os.system('git submodule update --init --recursive') + os.system("git submodule update --init --recursive") os.makedirs("temp", exist_ok=True) createPluginDirs()