Skip to content

Commit

Permalink
修复在mac上运行错误,调整项目文件
Browse files Browse the repository at this point in the history
  • Loading branch information
molihuan committed Jul 25, 2023
1 parent eeaabd6 commit 7b5693e
Show file tree
Hide file tree
Showing 75 changed files with 540 additions and 35,681 deletions.
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,5 @@ __pycache__/
!/script/uiConnectResources.py
!/script/appDetails.py

/test/py/
/test/download/*
!/test/download/666666/
!/test/download/999999/
/test/bilibili/*
!/test/bilibili/666666/
!/test/bilibili/999999/
/test/
/config.json
2 changes: 1 addition & 1 deletion BilibiliCacheVideoMergePython.pyproject
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"files": ["main.py","modules/main.ui","modules/resources.qrc","res"]
"files": ["main.py","modules/main.ui","modules/resources.qrc","res","modules/player/player.ui"]
}
2 changes: 1 addition & 1 deletion BilibiliCacheVideoMergePython.pyproject.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 8.0.1, 2023-07-22T09:37:59. -->
<!-- Written by QtCreator 8.0.1, 2023-07-24T07:50:36. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
33 changes: 17 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,19 @@ https://github.com/molihuan/BilibiliCacheVideoMergePython/releases

#### 第一步

在你的平台上安装python3.8.0以上(推荐安装和我一样的版本python3.8.6,避免一些为止的错误
在你的平台上安装python3.8.0以上(推荐安装和我一样的版本python3.8.6,避免一些未知的错误

安装依赖库

```sh
#图形库依赖
pip install pyside6 -i https://pypi.tuna.tsinghua.edu.cn/simple

#打包依赖(任选其一,或者都安装,推荐新手使用pyinstaller,nuitka还需要其他的配置比较麻烦)
#如果只选择一个则打包时需要修改script下面的packagescript.py,把另一个打包依赖的代码删掉。
pip install nuitka
#打包依赖(任选其一,或者都安装,推荐新手使用pyinstaller。nuitka还需要其他的配置比较麻烦)
#推荐
pip install pyinstaller
#可选
pip install nuitka
```

#### 第二步
Expand All @@ -106,7 +107,7 @@ pip install pyinstaller

没成功就自己看哪里有问题(该导库的导库,该引入依赖的引入依赖,自己解决)

编译打包:运行script下面的packagescript.py,自行打包,打包后的文件在script下面
编译打包:运行script下面的packagescript.py,自行打包,打包后的文件在script下面(作者分别在Win10,Ubuntu22,Mac14.3.1打包成功)

## 开发环境

Expand All @@ -121,8 +122,8 @@ python3.8.6
pip install pyside6 -i https://pypi.tuna.tsinghua.edu.cn/simple

#打包依赖
pip install nuitka
pip install pyinstaller
pip install nuitka
```

## 更新日志:
Expand All @@ -140,19 +141,19 @@ pip install pyinstaller
## LICENSE

```
Copyright [2023] molihuan
Copyright [2023] molihuan
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```


Expand Down
60 changes: 44 additions & 16 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,45 @@
#
# ///////////////////////////////////////////////////////////////

import sys
import os
import time

# IMPORT / GUI AND MODULES AND WIDGETS
# ///////////////////////////////////////////////////////////////
import os
import sys

from PySide6.QtCore import Qt
from PySide6.QtGui import QIcon
from PySide6.QtWidgets import QMainWindow, QHeaderView, QApplication

from modules.framework import *
from modules.framework.ui_main import Ui_MainWindow

from modules import *
from modules import Settings
from modules.service.manager.ConfigManager import ConfigManager, ConfigKey
from modules.player.PlayerPage import PlayerPage
from modules.framework.manager.ConfigManager import ConfigManager, ConfigKey
from modules.utils.Log import Log
from modules.utils.PathUtils import PathUtils

from modules.utils.SysUtils import SysUtils, SysType
from modules.widgets.WorkPage import WorkPage
from modules.widgets.settings.BaseSettingsPage import BaseSettingsPage
from modules.home.WorkPage import WorkPage
from modules.settings.BaseSettingsPage import BaseSettingsPage
from script.appDetails import APP_NAME, APP_VERSION

os.environ["QT_FONT_DPI"] = "96" # FIX Problem for High DPI and Scale above 100%

# SET AS GLOBAL WIDGETS
# ///////////////////////////////////////////////////////////////
widgets = None
widgets: Ui_MainWindow = None

appVersion = None


class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
# 是否开启调试,mac打包下必须关闭
Log.setDebug(True)

# 程序所在的路径
self.selfPath = os.getcwd()
self.selfPath = PathUtils.getcwd()
configJsonPath = os.path.join(self.selfPath, 'config.json')
# 配置管理者
self.ConfigManager = ConfigManager(configJsonPath)
Expand Down Expand Up @@ -118,6 +127,7 @@ def openCloseRightBox():
# absPath = os.path.dirname(os.path.abspath(sys.executable))
# elif __file__:
# absPath = os.path.dirname(os.path.abspath(__file__))
# themeFile = os.path.abspath(os.path.join(absPath, "themes/py_dracula_light.qss"))

self.useCustomTheme = True

Expand All @@ -129,8 +139,16 @@ def openCloseRightBox():

# SET THEME AND HACKS
if self.useCustomTheme:

# LOAD AND APPLY STYLE
UIFunctions.theme(self, self.themeFile, True)
if not UIFunctions.theme(self, self.themeFile, True):
os.remove(configJsonPath)
self.ConfigManager.removeAll()
themesPath = os.path.join(self.selfPath, "themes/py_dracula_dark.qss")
self.ConfigManager.add(ConfigKey.THEMES_PATH, themesPath)
self.ConfigManager.save()
UIFunctions.theme(self, self.themeFile, True)

# SET HACKS
AppFunctions.setThemeHack(self)

Expand Down Expand Up @@ -163,7 +181,7 @@ def buttonClick(self):
widgets.stackedWidget.setCurrentWidget(widgets.widgets)
UIFunctions.resetStyle(self, btnName)
btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet()))
print(self.workPage.DataShowManage.selectedCacheList)
Log.i(self.workPage.DataShowManage.selectedCacheList)
pass

# 改变主题
Expand All @@ -183,6 +201,16 @@ def buttonClick(self):
# 退出
if btnName == "btn_exit":
self.close()
# # 实例化视图
# self.playerPage: PlayerPage = PlayerPage(self.ConfigManager)
# # 添加到StackedWidget中
# widgets.stackedWidget.addWidget(self.playerPage)
# # 设置为当前显示页
# widgets.stackedWidget.setCurrentWidget(self.playerPage)
# # 设置选中按钮样式
# widgets.btn_exit.setStyleSheet(UIFunctions.selectMenu(widgets.btn_exit.styleSheet()))

pass
# 基础设置按钮
if btnName == "btn_base_settings":
# 实例化视图
Expand All @@ -197,7 +225,7 @@ def buttonClick(self):
pass

# PRINT BTN NAME
print(f'按钮 "{btnName}" 点击!')
Log.i(f'按钮 "{btnName}" 点击!')

# 加载ui后要进行的处理
def afterLoadUi(self):
Expand All @@ -219,9 +247,9 @@ def mousePressEvent(self, event):

# PRINT MOUSE EVENTS
if event.buttons() == Qt.LeftButton:
print('Mouse click: LEFT CLICK')
Log.i('Mouse click: LEFT CLICK')
if event.buttons() == Qt.RightButton:
print('Mouse click: RIGHT CLICK')
Log.i('Mouse click: RIGHT CLICK')

# 关闭之前调用
def closeEvent(self, event):
Expand Down
30 changes: 0 additions & 30 deletions modules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,30 +0,0 @@
# ///////////////////////////////////////////////////////////////
#
# BY: WANDERSON M.PIMENTA
# PROJECT MADE WITH: Qt Designer and PySide6
# V: 1.0.0
#
# This project can be used freely for all uses, as long as they maintain the
# respective credits only in the Python scripts, any information in the visual
# interface (GUI) can be modified without any implication.
#
# There are limitations on Qt licenses if you want to use your products
# commercially, I recommend reading them on the official website:
# https://doc.qt.io/qtforpython/licenses.html
#
# ///////////////////////////////////////////////////////////////
from PySide6.QtCore import *
from PySide6.QtGui import *
from PySide6.QtWidgets import *

# GUI FILE
from .ui_main import Ui_MainWindow

# APP SETTINGS
from .app_settings import Settings

# IMPORT FUNCTIONS
from .ui_functions import *

# APP FUNCTIONS
from .app_functions import *
26 changes: 26 additions & 0 deletions modules/framework/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# ///////////////////////////////////////////////////////////////
#
# BY: WANDERSON M.PIMENTA
# PROJECT MADE WITH: Qt Designer and PySide6
# V: 1.0.0
#
# This project can be used freely for all uses, as long as they maintain the
# respective credits only in the Python scripts, any information in the visual
# interface (GUI) can be modified without any implication.
#
# There are limitations on Qt licenses if you want to use your products
# commercially, I recommend reading them on the official website:
# https://doc.qt.io/qtforpython/licenses.html
#
# ///////////////////////////////////////////////////////////////

# GUI FILE

# APP SETTINGS
from .app_settings import Settings

# IMPORT FUNCTIONS
from .ui_functions import *

# APP FUNCTIONS
from .app_functions import *
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import json
import os

from modules.utils.Log import Log


class ConfigKey():
Expand All @@ -19,14 +22,18 @@ def __init__(self, configPath):

def loadConfig(self):
try:
#TODO 判断文件路径是否存在
if not os.path.exists(self.configPath):
Log.i("配置文件路径存不存在")
return {}
with open(self.configPath, "r", encoding='utf-8') as file:
config_str = file.read()
return json.loads(config_str)
except json.JSONDecodeError as e:
print("配置文件不是一个有效的JSON文件:", e)
Log.i("配置文件不是一个有效的JSON文件:", e)
return {}
except Exception as e:
print("加载配置文件时出现错误:", e)
Log.i("加载配置文件时出现错误:", e)
return {}

def save(self):
Expand Down Expand Up @@ -59,6 +66,8 @@ def updateByDict(self, dictObj):
def remove(self, key):
if key in self.config:
del self.config[key]
def removeAll(self):
self.config={}

def update(self, key, value):
if key in self.config:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 7 additions & 4 deletions modules/ui_functions.py → modules/framework/ui_functions.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# MAIN FILE
# ///////////////////////////////////////////////////////////////
from PySide6.QtCore import QTimer, QEvent, QParallelAnimationGroup, QEasingCurve, QPropertyAnimation
from PySide6.QtCore import QPropertyAnimation, QEasingCurve, QParallelAnimationGroup, QEvent, QTimer
from PySide6.QtGui import QColor
from PySide6.QtWidgets import QGraphicsDropShadowEffect, QSizeGrip, QPushButton
from PySide6.QtWidgets import QPushButton, QGraphicsDropShadowEffect, QSizeGrip

from main import *

# GLOBALS
# ///////////////////////////////////////////////////////////////
from modules import Settings
from modules.widgets import CustomGrip

from modules.framework.widgets import CustomGrip

GLOBAL_STATE = False
GLOBAL_TITLE_BAR = True
Expand Down Expand Up @@ -200,8 +200,11 @@ def resetStyle(self, widget):
# ///////////////////////////////////////////////////////////////
def theme(self, file, useCustomTheme):
if useCustomTheme:
if not os.path.exists(file):
return False
str = open(file, 'r').read()
self.ui.styleSheet.setStyleSheet(str)
return True

# START - GUI DEFINITIONS
# ///////////////////////////////////////////////////////////////
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import json
import os

# 数据获取抽象窗口
from PySide6.QtWidgets import QWidget
# 这里可能有循环依赖的问题注意全包名
from modules.service.manager.ConfigManager import ConfigKey
from modules.service.init.DataManager import DataManager
from modules.widgets.ui_WorkPage import Ui_WorkPageWidget
from modules.framework.manager.ConfigManager import ConfigKey
from modules.home.init.DataManager import DataManager
from modules.home.ui_WorkPage import Ui_WorkPageWidget
from modules.utils.PathUtils import PathUtils


class BaseDataWorkPage(QWidget):
Expand Down Expand Up @@ -38,7 +38,7 @@ def closeSubWindow(self):
# 获取配置路径字典
def getConfigPathDict(self):
allPath = {
"SelfPath": os.getcwd(),
"SelfPath": PathUtils.getcwd(),
ConfigKey.CACHE_PATH: self.getCachePath(),
ConfigKey.COMPLETE_PATH: self.getCompletePath(),
}
Expand Down
Loading

0 comments on commit 7b5693e

Please sign in to comment.