diff --git a/.gitignore b/.gitignore index 79678f2..b52ec43 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ app/bin64 app/bin_ios app/lib app/logs +app/data/plugins/project/*.bak pre-dev/templates/android/.gradle pre-dev/templates/android/**/build diff --git a/CHANGELOG.md b/CHANGELOG.md index 51660b5..f9b1128 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [2025.04.29] - v2.1.0.0 +### [new feature] Add independent software packaging function + +## [2025.04.19] - v2.0.0.0 +### [Optimize] User interface redesign + ## [2025.04.13] - v1.1.6.0 ### [Optimize] tools scripts diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index f01b5eb..0ebcd53 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -32,7 +32,7 @@ message("CMAKE_TOOLCHAIN_ROOT = ${CMAKE_TOOLCHAIN_ROOT} ") message("include(${CMAKE_TOOLCHAIN_ROOT}/cmake-core/global.cmake) ") -project(${PROJECT_NAME} VERSION 1.1.6.0) +project(${PROJECT_NAME} VERSION 2.1.0.0) # set(CMAKE_DEBUG_POSTFIX d) set(LIB_TYPE SHARED) # SHARED STATIC # set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) diff --git a/app/data/plugins/project/module/template/cmake/bin-deps-qt.cmake b/app/data/plugins/project/module/template/cmake/bin-deps-qt.cmake index e67a4f8..27c48dd 100644 --- a/app/data/plugins/project/module/template/cmake/bin-deps-qt.cmake +++ b/app/data/plugins/project/module/template/cmake/bin-deps-qt.cmake @@ -78,6 +78,7 @@ target_link_libraries(${BIN_NAME} PUBLIC ${LIB_FMWKs} ${LIB_DEPS} # set_target_properties(${BIN_NAME} PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) # add app res +# APP_ADD_RES("${PROJ_ROOT}/conf/project.json" "conf/") if(OSX) APP_ADD_RES_RECURSE("${CONF_DIR}/" "conf/" "${CONF_DIR}/*") APP_ADD_RES_RECURSE("${DATA_DIR}/" "data/" "${DATA_DIR}/*") diff --git a/app/data/plugins/project/pkg.json b/app/data/plugins/project/pkg.json new file mode 100644 index 0000000..ab378e0 --- /dev/null +++ b/app/data/plugins/project/pkg.json @@ -0,0 +1,6 @@ +{ + "proj_name":"_PROJ_NAME_", + "root_dir":"_ROOT_DIR_", + "script_dir":"_SCRIPT_DIR_", + "pkg_dirs":["bin64", "conf", "data", "tools"] +} \ No newline at end of file diff --git a/app/data/plugins/project/project/pkg-rpm/SPECS/app.spec b/app/data/plugins/project/proj_pkg/pkg-rpm/SPECS/app.spec similarity index 100% rename from app/data/plugins/project/project/pkg-rpm/SPECS/app.spec rename to app/data/plugins/project/proj_pkg/pkg-rpm/SPECS/app.spec diff --git a/app/data/plugins/project/project/pkg-rpm/app-action.xml b/app/data/plugins/project/proj_pkg/pkg-rpm/app-action.xml similarity index 100% rename from app/data/plugins/project/project/pkg-rpm/app-action.xml rename to app/data/plugins/project/proj_pkg/pkg-rpm/app-action.xml diff --git a/app/data/plugins/project/project/pkg-rpm/app-desktop b/app/data/plugins/project/proj_pkg/pkg-rpm/app-desktop similarity index 100% rename from app/data/plugins/project/project/pkg-rpm/app-desktop rename to app/data/plugins/project/proj_pkg/pkg-rpm/app-desktop diff --git a/app/data/plugins/project/project/pkg-rpm/app_loader b/app/data/plugins/project/proj_pkg/pkg-rpm/app_loader similarity index 100% rename from app/data/plugins/project/project/pkg-rpm/app_loader rename to app/data/plugins/project/proj_pkg/pkg-rpm/app_loader diff --git a/app/data/plugins/project/project/pkg-rpm/pkg-rpm.sh b/app/data/plugins/project/proj_pkg/pkg-rpm/pkg-rpm.sh similarity index 100% rename from app/data/plugins/project/project/pkg-rpm/pkg-rpm.sh rename to app/data/plugins/project/proj_pkg/pkg-rpm/pkg-rpm.sh diff --git a/app/data/plugins/project/project/pkg-win/Note.md b/app/data/plugins/project/proj_pkg/pkg-win/Note.md similarity index 100% rename from app/data/plugins/project/project/pkg-win/Note.md rename to app/data/plugins/project/proj_pkg/pkg-win/Note.md diff --git a/app/data/plugins/project/project/pkg-win/PkgFunc_Win.nsh b/app/data/plugins/project/proj_pkg/pkg-win/PkgFunc_Win.nsh similarity index 100% rename from app/data/plugins/project/project/pkg-win/PkgFunc_Win.nsh rename to app/data/plugins/project/proj_pkg/pkg-win/PkgFunc_Win.nsh diff --git a/app/data/plugins/project/project/pkg-win/nsis-3.11/Plugins/x64-ansi/ExecDos.dll b/app/data/plugins/project/proj_pkg/pkg-win/nsis-3.11/Plugins/x64-ansi/ExecDos.dll similarity index 100% rename from app/data/plugins/project/project/pkg-win/nsis-3.11/Plugins/x64-ansi/ExecDos.dll rename to app/data/plugins/project/proj_pkg/pkg-win/nsis-3.11/Plugins/x64-ansi/ExecDos.dll diff --git a/app/data/plugins/project/project/pkg-win/nsis-3.11/Plugins/x64-unicode/ExecDos.dll b/app/data/plugins/project/proj_pkg/pkg-win/nsis-3.11/Plugins/x64-unicode/ExecDos.dll similarity index 100% rename from app/data/plugins/project/project/pkg-win/nsis-3.11/Plugins/x64-unicode/ExecDos.dll rename to app/data/plugins/project/proj_pkg/pkg-win/nsis-3.11/Plugins/x64-unicode/ExecDos.dll diff --git a/app/data/plugins/project/project/pkg-win/nsis-3.11/Plugins/x86-ansi/ExecDos.dll b/app/data/plugins/project/proj_pkg/pkg-win/nsis-3.11/Plugins/x86-ansi/ExecDos.dll similarity index 100% rename from app/data/plugins/project/project/pkg-win/nsis-3.11/Plugins/x86-ansi/ExecDos.dll rename to app/data/plugins/project/proj_pkg/pkg-win/nsis-3.11/Plugins/x86-ansi/ExecDos.dll diff --git a/app/data/plugins/project/project/pkg-win/nsis-3.11/Plugins/x86-ansi/ShellLink.dll b/app/data/plugins/project/proj_pkg/pkg-win/nsis-3.11/Plugins/x86-ansi/ShellLink.dll similarity index 100% rename from app/data/plugins/project/project/pkg-win/nsis-3.11/Plugins/x86-ansi/ShellLink.dll rename to app/data/plugins/project/proj_pkg/pkg-win/nsis-3.11/Plugins/x86-ansi/ShellLink.dll diff --git a/app/data/plugins/project/project/pkg-win/nsis-3.11/Plugins/x86-unicode/ExecDos.dll b/app/data/plugins/project/proj_pkg/pkg-win/nsis-3.11/Plugins/x86-unicode/ExecDos.dll similarity index 100% rename from app/data/plugins/project/project/pkg-win/nsis-3.11/Plugins/x86-unicode/ExecDos.dll rename to app/data/plugins/project/proj_pkg/pkg-win/nsis-3.11/Plugins/x86-unicode/ExecDos.dll diff --git a/app/data/plugins/project/project/pkg-win/nsis-3.11/Plugins/x86-unicode/ShellLink.dll b/app/data/plugins/project/proj_pkg/pkg-win/nsis-3.11/Plugins/x86-unicode/ShellLink.dll similarity index 100% rename from app/data/plugins/project/project/pkg-win/nsis-3.11/Plugins/x86-unicode/ShellLink.dll rename to app/data/plugins/project/proj_pkg/pkg-win/nsis-3.11/Plugins/x86-unicode/ShellLink.dll diff --git a/app/data/plugins/project/project/pkg-win/nsis-3.11/nsis-3.11-setup.exe b/app/data/plugins/project/proj_pkg/pkg-win/nsis-3.11/nsis-3.11-setup.exe similarity index 100% rename from app/data/plugins/project/project/pkg-win/nsis-3.11/nsis-3.11-setup.exe rename to app/data/plugins/project/proj_pkg/pkg-win/nsis-3.11/nsis-3.11-setup.exe diff --git a/app/data/plugins/project/project/pkg-win/pkg-win-nsis.bat b/app/data/plugins/project/proj_pkg/pkg-win/pkg-win-nsis.bat similarity index 97% rename from app/data/plugins/project/project/pkg-win/pkg-win-nsis.bat rename to app/data/plugins/project/proj_pkg/pkg-win/pkg-win-nsis.bat index d7d9902..8af9205 100644 --- a/app/data/plugins/project/project/pkg-win/pkg-win-nsis.bat +++ b/app/data/plugins/project/proj_pkg/pkg-win/pkg-win-nsis.bat @@ -31,4 +31,6 @@ makensis /INPUTCHARSET UTF8 /DPRODUCT_NAME=%PROJ_NAME% /DPRODUCT_VERSION=%VERSIO move "%SCRIPT_DIR%\%PROJ_NAME%*.exe" "%ROOT_DIR%" -echo. & pause \ No newline at end of file +if "%~1"=="" ( + echo. & pause +) \ No newline at end of file diff --git a/app/data/plugins/project/project/pkg-win/pkg-win-nsis.nsi b/app/data/plugins/project/proj_pkg/pkg-win/pkg-win-nsis.nsi similarity index 99% rename from app/data/plugins/project/project/pkg-win/pkg-win-nsis.nsi rename to app/data/plugins/project/proj_pkg/pkg-win/pkg-win-nsis.nsi index 630fa93..abef9e0 100644 --- a/app/data/plugins/project/project/pkg-win/pkg-win-nsis.nsi +++ b/app/data/plugins/project/proj_pkg/pkg-win/pkg-win-nsis.nsi @@ -111,7 +111,7 @@ Section "${PRODUCT_NAME}" SEC_MAIN ;Installer File /r "${BIN_DIR}\bin64" File /r "${BIN_DIR}\conf" File /r "${BIN_DIR}\data" - File /r "${BIN_DIR}\tools" + ;File /r "${BIN_DIR}\tools" ;RMDir /r "$INSTDIR\lib" ;RMDir /r "$INSTDIR\logs" ;Rename "$INSTDIR\Release" "$INSTDIR\bin64" diff --git a/app/data/plugins/project/project/pkg-win/vs-env.bat b/app/data/plugins/project/proj_pkg/pkg-win/vs-env.bat similarity index 100% rename from app/data/plugins/project/project/pkg-win/vs-env.bat rename to app/data/plugins/project/proj_pkg/pkg-win/vs-env.bat diff --git a/app/data/plugins/project/proj_pkg/proj_pkg.py b/app/data/plugins/project/proj_pkg/proj_pkg.py new file mode 100644 index 0000000..0ae2299 --- /dev/null +++ b/app/data/plugins/project/proj_pkg/proj_pkg.py @@ -0,0 +1,116 @@ +# coding=UTF-8 +# Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869) + +import os +import sys +import platform + +PROJECT_BASE_DIR = os.path.dirname( os.path.abspath(__file__) ) +PYTOOL_DIR = os.path.dirname( os.path.dirname(PROJECT_BASE_DIR) ) +sys.path.append( PYTOOL_DIR ) +from pytool import pyt_file +from pytool import pyt_json + +PROJECT_PKG_WIN_DIR = PROJECT_BASE_DIR + "/pkg-win" +PROJECT_PKG_RPM_DIR = PROJECT_BASE_DIR + "/pkg-rpm" +PKG_WIN_NSIS = "/pkg-win-nsis.bat" +PKG_WIN_NSIS_PATH = "/pkg-win/pkg-win-nsis.bat" +PKG_RPM = "/pkg-rpm.sh" +PKG_RPM_PATH = "/pkg-rpm/pkg-rpm.sh" + +class ProjPkg(object): + @staticmethod + def pkg_run(json_config): + dic = pyt_json.PytJson.load_config(json_config) + if not dic: + return None + + root_dir = dic["root_dir"] + if not os.path.exists(root_dir): + print("root—dir not exist: " + root_dir) + return None + + script_dir = dic["script_dir"] + script_abs_dir = root_dir + "/" + script_dir + if not os.path.exists(script_abs_dir): + print("script_dir not exist: " + script_abs_dir) + return None + + os_type = platform.system() + if os_type == "Windows": + print("pkg exe for Windows") + pkg_script = root_dir + PKG_WIN_NSIS + if not os.path.exists(pkg_script): + print("pkg_script not exist: " + pkg_script) + return None + os.system(pkg_script + " pkg > " + root_dir + "/pkg_win.log") + elif os_type == "Linux": + print("pkg rpm for Linux") + pkg_script = root_dir + PKG_RPM + if not os.path.exists(pkg_script): + print("pkg_script not exist: " + pkg_script) + return None + os.system(pkg_script + " pkg > " + root_dir + "/pkg_rpm.log") + elif os_type == "Darwin": # macOS + print("pkg app for Darwin") + + @staticmethod + def pkg_gen(json_config): + dic = pyt_json.PytJson.load_config(json_config) + if not dic: + return None + proj_name = dic["proj_name"] + root_dir = dic["root_dir"] + script_dir = dic["script_dir"] + pkg_dirs = dic["pkg_dirs"] + # pkg_version = dic["pkg_version"] + # pkg_arch = dic["pkg_arch"] + + if not os.path.exists(root_dir): + print("root—dir not exist: " + root_dir) + return None + + ProjPkg.add_pkg_scripts(proj_name, root_dir, script_dir) + ProjPkg.update_pkg_dirs(root_dir, script_dir, pkg_dirs) + + @staticmethod + def add_pkg_scripts(proj_name:str, root_dir:str, scripts_dir:str): + script_abs_dir = root_dir + "/" + scripts_dir + + # prapare ${scripts_dir}/pkg-win + pkg_win_dir = script_abs_dir + "/pkg-win" + pyt_file.File.copy_dir(PROJECT_PKG_WIN_DIR, pkg_win_dir ) + pkglist = os.listdir(pkg_win_dir) + for fitem in pkglist: + file = pkg_win_dir + "/" + fitem + print(file) + if os.path.isfile(file) and file.endswith("bat"): + pyt_file.File.replace_string(file, "_PROJ_NAME_", proj_name) # Set ${PROJECT_NAME} + pyt_file.File.copy_to_file(script_abs_dir + PKG_WIN_NSIS_PATH, root_dir + PKG_WIN_NSIS) + os.remove(script_abs_dir + PKG_WIN_NSIS_PATH) + + # prapare ${scripts_dir}/pkg-rpm + pkg_rpm_dir = script_abs_dir + "/pkg-rpm" + pyt_file.File.copy_dir(PROJECT_PKG_RPM_DIR, pkg_rpm_dir) + pkglist = os.listdir(pkg_rpm_dir) + for fitem in pkglist: + file = pkg_rpm_dir + "/" + fitem + print(file) + if os.path.isfile(file): + pyt_file.File.replace_string(file, "_PROJ_NAME_", proj_name) # Set ${PROJECT_NAME} + elif os.path.isdir(file): + sublist = os.listdir(file) + for it in pkglist: + subfile = file + "/" + it + print(subfile) + if os.path.isfile(subfile): + pyt_file.File.replace_string(subfile, "_PROJ_NAME_", proj_name) # Set ${PROJECT_NAME} + pyt_file.File.copy_to_file(script_abs_dir + PKG_RPM_PATH, root_dir + PKG_RPM) + os.remove(script_abs_dir + PKG_RPM_PATH) + + @staticmethod + def update_pkg_dirs(root_dir:str, scripts_dir:str, pkg_dirs:list): + script_abs_dir = root_dir + "/" + scripts_dir + # TODO::update pkg dirs + for it in pkg_dirs: + print("add_pkg_dirs: " + it) diff --git a/app/data/plugins/project/proj_pkg/run_pkg.py b/app/data/plugins/project/proj_pkg/run_pkg.py new file mode 100644 index 0000000..00fa3bd --- /dev/null +++ b/app/data/plugins/project/proj_pkg/run_pkg.py @@ -0,0 +1,36 @@ +# coding=UTF-8 +# Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869) + +import os +import sys +from argparse import ArgumentParser + +PROJECT_BASE_DIR = os.path.dirname( os.path.abspath(__file__) ) +PYTOOL_DIR = os.path.dirname( os.path.dirname(PROJECT_BASE_DIR) ) +sys.path.append( PYTOOL_DIR ) + +import proj_pkg + +# python run_pkg.py --config ../pkg.json.bak +# root_dir +# |- bin64 +# |- conf +# |- data +# |- resources +# |- ... +# |_ scripts(_SCRIPT_DIR_) +# pkg.json: +# { +# "proj_name":"_PROJ_NAME_", +# "root_dir":"_ROOT_DIR_", +# "script_dir":"_SCRIPT_DIR_", +# "pkg_dirs":["bin64", "conf", "data", "tools"] +# } +parser = ArgumentParser() +parser.add_argument('--config', dest='config', type=str, default=PROJECT_BASE_DIR + "/pkg.json", help="app binary pkg.json") +args = parser.parse_args() + +if __name__ == '__main__': + print("json = ", args.config) + proj_pkg.ProjPkg.pkg_gen(args.config) + proj_pkg.ProjPkg.pkg_run(args.config) \ No newline at end of file diff --git a/app/data/plugins/project/project/build/run_android.bat b/app/data/plugins/project/project/build/run_android.bat index 0904512..2636bb8 100644 --- a/app/data/plugins/project/project/build/run_android.bat +++ b/app/data/plugins/project/project/build/run_android.bat @@ -28,7 +28,7 @@ md %BUILD_DIR% if exist %BIN_DIR% rd /s /q %BIN_DIR% :: clean py cache -SET PLUGIN_DIR=%ROOT_DIR%\app\data\plugins +SET PLUGIN_DIR=%ROOT_DIR%\data\plugins echo PLUGIN_DIR = %PLUGIN_DIR% for /f "delims=" %%i in ('dir /ad/b/s "%PLUGIN_DIR%"') do ( if exist %%i\.DS_Store rd /s /q %%i\.DS_Store diff --git a/app/data/plugins/project/project/build/run_win.bat b/app/data/plugins/project/project/build/run_win.bat index 09da2bc..f25cb68 100644 --- a/app/data/plugins/project/project/build/run_win.bat +++ b/app/data/plugins/project/project/build/run_win.bat @@ -42,7 +42,7 @@ echo QT_INSTALL_DIR = %QT_INSTALL_DIR% echo PY_INSTALL_DIR = %PY_INSTALL_DIR% :: clean py cache -SET PLUGIN_DIR=%ROOT_DIR%\app\data\plugins +SET PLUGIN_DIR=%ROOT_DIR%\data\plugins echo PLUGIN_DIR = %PLUGIN_DIR% for /f "delims=" %%i in ('dir /ad/b/s "%PLUGIN_DIR%"') do ( if exist %%i\.DS_Store rd /s /q %%i\.DS_Store diff --git a/app/data/plugins/project/project/project.py b/app/data/plugins/project/project/project.py index d4e75a4..626064d 100644 --- a/app/data/plugins/project/project/project.py +++ b/app/data/plugins/project/project/project.py @@ -15,13 +15,7 @@ PROJECT_CMAKE_DIR = PROJECT_BASE_DIR + "/cmake" PROJECT_RES_DIR = PROJECT_BASE_DIR + "/resource" PROJECT_DOC_DIR = PROJECT_BASE_DIR + "/doc" -PROJECT_PKG_WIN_DIR = PROJECT_BASE_DIR + "/pkg-win" -PROJECT_PKG_RPM_DIR = PROJECT_BASE_DIR + "/pkg-rpm" MODULE_TEMPLATE_DIR = PROJECT_BASE_DIR + "/template" -PKG_WIN_NSIS = "/pkg-win-nsis.bat" -PKG_WIN_NSIS_PATH = "/pkg-win/pkg-win-nsis.bat" -PKG_RPM = "/pkg-rpm.sh" -PKG_RPM_PATH = "/pkg-rpm/pkg-rpm.sh" OPTION_STR_SIZE:int = 20 OPTION_TEMPLATE:str = "# option(MODULE_OPTION \"Build with MODULE_OPTION\" ON)" @@ -78,6 +72,13 @@ def add_help_dirs(root_dir:str, help_dirs:list, proj_name:str): os.makedirs(help_dir) if k.lower() == "scripts": Project.add_scripts_dir(root_dir, help_dirs[k], proj_name) + file = PROJECT_BASE_DIR + "/../pkg.json" + file_bak = PROJECT_BASE_DIR + "/../pkg.json.bak" + pyt_file.File.copy_to_file(file, file_bak) + print(file_bak) + pyt_file.File.replace_string(file_bak, "_PROJ_NAME_", proj_name) # Set ${PROJECT_NAME} + pyt_file.File.replace_string(file_bak, "_ROOT_DIR_", root_dir) # Set ${_ROOT_DIR_} + pyt_file.File.replace_string(file_bak, "_SCRIPT_DIR_", help_dirs[k]) # Set ${_ROOT_DIR_} @staticmethod def add_scripts_dir(root_dir:str, scripts_dir:str, proj_name:str): @@ -96,37 +97,6 @@ def add_scripts_dir(root_dir:str, scripts_dir:str, proj_name:str): if os.path.isfile(file): pyt_file.File.replace_string(file, "_PROJ_NAME_", proj_name) # Set ${PROJECT_NAME} - # prapare ${scripts_dir}/pkg-win - pkg_win_dir = script_abs_dir + "/pkg-win" - pyt_file.File.copy_dir(PROJECT_PKG_WIN_DIR, pkg_win_dir ) - pkglist = os.listdir(pkg_win_dir) - for fitem in pkglist: - file = pkg_win_dir + "/" + fitem - print(file) - if os.path.isfile(file) and file.endswith("bat"): - pyt_file.File.replace_string(file, "_PROJ_NAME_", proj_name) # Set ${PROJECT_NAME} - pyt_file.File.copy_to_file(script_abs_dir + PKG_WIN_NSIS_PATH, root_dir + PKG_WIN_NSIS) - os.remove(script_abs_dir + PKG_WIN_NSIS_PATH) - - # prapare ${scripts_dir}/pkg-rpm - pkg_rpm_dir = script_abs_dir + "/pkg-rpm" - pyt_file.File.copy_dir(PROJECT_PKG_RPM_DIR, pkg_rpm_dir) - pkglist = os.listdir(pkg_rpm_dir) - for fitem in pkglist: - file = pkg_rpm_dir + "/" + fitem - print(file) - if os.path.isfile(file): - pyt_file.File.replace_string(file, "_PROJ_NAME_", proj_name) # Set ${PROJECT_NAME} - elif os.path.isdir(file): - sublist = os.listdir(file) - for it in pkglist: - subfile = file + "/" + it - print(subfile) - if os.path.isfile(subfile): - pyt_file.File.replace_string(subfile, "_PROJ_NAME_", proj_name) # Set ${PROJECT_NAME} - pyt_file.File.copy_to_file(script_abs_dir + PKG_RPM_PATH, root_dir + PKG_RPM) - os.remove(script_abs_dir + PKG_RPM_PATH) - @staticmethod def add_options(root_dir:str, options:object): for opt in options.keys(): diff --git a/app/data/plugins/project/run.py b/app/data/plugins/project/run.py index f39f803..fc57f6c 100644 --- a/app/data/plugins/project/run.py +++ b/app/data/plugins/project/run.py @@ -11,6 +11,7 @@ from project import project from module import module +from proj_pkg import proj_pkg # python3 run.py --type project [--config ./DevKits.json] # python3 run.py --type module --root_dir ../../DevKits --module_type 1 --module_name QtKit @@ -29,6 +30,7 @@ if args.type == "project": print("json = ", args.config) project.Project.create(args.config) + proj_pkg.ProjPkg.pkg_gen(BASE_DIR + "/pkg.json.bak") elif args.type == "module": module.Module.MOUDLE_DIR = "/src-app/" module.Module.add(args.root_dir, module.ModuleType(args.module_type), args.module_name, has_main=True, deps=[]) diff --git a/app/pkg-win-nsis.bat b/app/pkg-win-nsis.bat index 715995f..51c5980 100644 --- a/app/pkg-win-nsis.bat +++ b/app/pkg-win-nsis.bat @@ -21,7 +21,7 @@ start /wait %QT_HOME%\bin\windeployqt.exe -qmldir %QT_HOME%/qml %BIN_DIR%\%PROJ_ call %SCRIPT_DIR%\vs-env.bat -set VERSION="1.1.6.0" +set VERSION="2.1.0.0" echo packaging %VERSION% for "x64" makensis /INPUTCHARSET UTF8 /DPRODUCT_NAME=%PROJ_NAME% /DPRODUCT_VERSION=%VERSION% /DOS_ARCH="x64" %SCRIPT_DIR%/pkg-win-nsis.nsi echo packaging %VERSION% for "x86" @@ -31,4 +31,6 @@ makensis /INPUTCHARSET UTF8 /DPRODUCT_NAME=%PROJ_NAME% /DPRODUCT_VERSION=%VERSIO move "%SCRIPT_DIR%\%PROJ_NAME%*.exe" "%ROOT_DIR%" -echo. & pause \ No newline at end of file +if "%~1"=="" ( + echo. & pause +) \ No newline at end of file diff --git a/app/run_android.bat b/app/run_android.bat index 0b52d01..0004425 100644 --- a/app/run_android.bat +++ b/app/run_android.bat @@ -28,7 +28,7 @@ md %BUILD_DIR% if exist %BIN_DIR% rd /s /q %BIN_DIR% :: clean py cache -SET PLUGIN_DIR=%ROOT_DIR%\app\data\plugins +SET PLUGIN_DIR=%ROOT_DIR%\data\plugins echo PLUGIN_DIR = %PLUGIN_DIR% for /f "delims=" %%i in ('dir /ad/b/s "%PLUGIN_DIR%"') do ( if exist %%i\.DS_Store rd /s /q %%i\.DS_Store diff --git a/app/run_win.bat b/app/run_win.bat index 5d00336..2408c4b 100644 --- a/app/run_win.bat +++ b/app/run_win.bat @@ -42,7 +42,7 @@ echo QT_INSTALL_DIR = %QT_INSTALL_DIR% echo PY_INSTALL_DIR = %PY_INSTALL_DIR% :: clean py cache -SET PLUGIN_DIR=%ROOT_DIR%\app\data\plugins +SET PLUGIN_DIR=%ROOT_DIR%\data\plugins echo PLUGIN_DIR = %PLUGIN_DIR% for /f "delims=" %%i in ('dir /ad/b/s "%PLUGIN_DIR%"') do ( if exist %%i\.DS_Store rd /s /q %%i\.DS_Store diff --git a/app/scripts/pkg-rpm/SPECS/app.spec b/app/scripts/pkg-rpm/SPECS/app.spec index 60d634d..0ed4dd6 100644 --- a/app/scripts/pkg-rpm/SPECS/app.spec +++ b/app/scripts/pkg-rpm/SPECS/app.spec @@ -1,5 +1,5 @@ Name: _PROJ_NAME_ -Version: 1.1.6.0 +Version: 2.1.0.0 Release: 1%{?dist} Summary: Client Application License: "" diff --git a/app/scripts/pkg-win/pkg-win-nsis.nsi b/app/scripts/pkg-win/pkg-win-nsis.nsi index 1bd8736..630fa93 100644 --- a/app/scripts/pkg-win/pkg-win-nsis.nsi +++ b/app/scripts/pkg-win/pkg-win-nsis.nsi @@ -112,7 +112,7 @@ Section "${PRODUCT_NAME}" SEC_MAIN ;Installer File /r "${BIN_DIR}\conf" File /r "${BIN_DIR}\data" File /r "${BIN_DIR}\tools" - RMDir /r "$INSTDIR\src" + ;RMDir /r "$INSTDIR\lib" ;RMDir /r "$INSTDIR\logs" ;Rename "$INSTDIR\Release" "$INSTDIR\bin64" diff --git a/app/src/app/DevAssistant/AppLoader.cpp b/app/src/app/DevAssistant/AppLoader.cpp index 6a9f170..f7f2edf 100644 --- a/app/src/app/DevAssistant/AppLoader.cpp +++ b/app/src/app/DevAssistant/AppLoader.cpp @@ -22,7 +22,6 @@ void InitAppConfig(const char *bin_path) { #if WIN CU::String::LastNCharSubStr(app_path, '\\', 2, root_dir); CKAppConf::GetInstance()->SetRootDir(root_dir); - CKAppConf::GetInstance()->SetRelativePath("app_icon", "data/Resource/AppIcon.ico"); #elif OSX CKAppConf::GetInstance()->SetRootDir(app_path + "/Contents"); #else // LINUX @@ -32,26 +31,4 @@ void InitAppConfig(const char *bin_path) { LOGI("root_dir = %s, app_dir = %s, app_path = %s", root_dir.c_str(), app_dir.c_str(), app_path.c_str()); } -int SetInitStart(const char * bin_path) { -#if WIN - std::string app_bin_abs = std::string(bin_path) + " %1"; - std::string app_icon_abs = CKAppConf::GetInstance()->GetRelativePath("app_icon"); - LOGI("app_bin_abs = %s", app_bin_abs.c_str()); - LOGI("app_icon_abs = %s", app_icon_abs.c_str()); - CE::RightAction::AddAction("DevAssist", app_bin_abs, "DevAssist", app_icon_abs, - CE::RightAction::Mode::FIX_SUFFIX, "batfile", true); - //CE::RightAction::DelAction("DevAssist", CE::RightAction::Mode::FIX_SUFFIX, "batfile"); - - // Auto Start - return CE::AppLoader::RunAsOSStart("DevTools", bin_path); - -//#elif defined(OSX) -// std::string app_path; -// CE::AppLoader::GetAppPath(bin_path, app_path); -// return CE::AppLoader::RunAsOSStart("dev.coder4869.assistant", bin_path); -#else - return 0; -#endif -} - } diff --git a/app/src/app/DevAssistant/AppLoader.h b/app/src/app/DevAssistant/AppLoader.h index 7ddc96b..be0d304 100644 --- a/app/src/app/DevAssistant/AppLoader.h +++ b/app/src/app/DevAssistant/AppLoader.h @@ -5,5 +5,4 @@ namespace App { void InitAppConfig(const char *bin_path); -int SetInitStart(const char *bin_path); } diff --git a/app/src/app/DevAssistant/Forms/QDAMainWindow.ui b/app/src/app/DevAssistant/Forms/QDAMainWindow.ui index ccad694..ba0bfdc 100644 --- a/app/src/app/DevAssistant/Forms/QDAMainWindow.ui +++ b/app/src/app/DevAssistant/Forms/QDAMainWindow.ui @@ -6,21 +6,448 @@ 0 0 - 800 - 600 + 1319 + 1118 MainWindow - + + + + + + + + + Agency FB + 20 + 50 + false + + + + background-color: rgb(170, 170, 127); + + + 基础功能 + + + Qt::AlignCenter + + + + + + + + + + 0 + 0 + + + + + 120 + 110 + + + + + 120 + 110 + + + + + 11 + + + + 检查环境 + + + + + + + + 0 + 0 + + + + + 200 + 110 + + + + + 16777215 + 110 + + + + + 10 + + + + false + + + background-color: rgb(255, 255, 255); + + + + 5 + + + 0 + + + 检查开发环境 + + + true + + + + + + + + 0 + 0 + + + + + 200 + 110 + + + + + 16777215 + 110 + + + + + 10 + + + + false + + + background-color: rgb(255, 255, 255); + + + + 5 + + + 0 + + + 基于CMake的C/C++跨平台框架生成,默认支持Windows、MacOS、Linux(Ubuntu、Debian)、Android、iOS等平台的编译,工程使用C++版Qt开发。 + + + true + + + + + + + + 0 + 0 + + + + + 120 + 110 + + + + + 120 + 110 + + + + + 11 + + + + 跨平台C/C++ + +工程框架生成 + + + + + + + + 0 + 0 + + + + + 120 + 110 + + + + + 120 + 110 + + + + + 11 + + + + 多平台 + +安装包制作 + + + + + + + + 0 + 0 + + + + + 200 + 110 + + + + + 16777215 + 110 + + + + + 10 + + + + background-color: rgb(255, 255, 255); + + + 编译产物的安装包制作功能,支持提供多个平台的打包脚本模板,能满足基本打包需求,现阶段支持Windows平台(基于nsis打包exe安装包)、Linux平台(rpm安装包制作),用户可以自定义修改。 + + + true + + + + + + + + + + Agency FB + 20 + 50 + false + + + + background-color: rgb(170, 170, 127); + + + 扩展功能 + + + Qt::AlignCenter + + + + + + + + + + + + + 0 + 0 + + + + + 200 + 110 + + + + + 16777215 + 110 + + + + + 10 + + + + background-color: rgb(255, 255, 255); + + + 规划中 + + + true + + + + + + + + 0 + 0 + + + + + 200 + 110 + + + + + 16777215 + 110 + + + + + 10 + + + + background-color: rgb(255, 255, 255); + + + 规划中 + + + true + + + + + + + + 0 + 0 + + + + + 120 + 110 + + + + + 120 + 110 + + + + + 11 + + + + 数据解密 + + + + + + + + 0 + 0 + + + + + 120 + 110 + + + + + 120 + 110 + + + + + 11 + + + + 数据加密 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + 0 0 - 800 - 24 + 1319 + 26 @@ -31,8 +458,6 @@ - - @@ -40,19 +465,6 @@ - - - Practical(实用功能) - - - - - - - Custom(自定义) - - - Plan(计划) @@ -63,12 +475,11 @@ Help(帮助) + - - @@ -138,6 +549,11 @@ Preview(示例预览) + + + Welcome(主页) + + diff --git a/app/src/app/DevAssistant/QDAMainWindow.cpp b/app/src/app/DevAssistant/QDAMainWindow.cpp index 689b659..a1c6a12 100644 --- a/app/src/app/DevAssistant/QDAMainWindow.cpp +++ b/app/src/app/DevAssistant/QDAMainWindow.cpp @@ -5,12 +5,14 @@ #include #include +#include #include #if WIN #include #endif // WIN +#include #include #include @@ -26,11 +28,12 @@ #define LOG_TAG "TAG_DevAssistant" QDAMainWindow::QDAMainWindow(QWidget *parent) - : QMainWindow(parent), ui(new Ui::QDAMainWindow) + : QMainWindow(parent), ui(new Ui::QDAMainWindow), trayIcon(new QSystemTrayIcon(this)) { ui->setupUi(this); setMinimumSize(1280, 720); - QUI::Style::SetMainWindow(this); + setStyleSheet(QUI::Style::MainWindowStyle()); + initWidget = centralWidget(); // QDAProjectDialog project = new QDAProjectDialog(); @@ -39,9 +42,10 @@ QDAMainWindow::QDAMainWindow(QWidget *parent) connect(ui->actionProjectNew, SIGNAL(triggered()), project, SLOT(OnProjectCreate())); connect(ui->actionProjectOpen, SIGNAL(triggered()), project, SLOT(OnProjectOpen())); connect(ui->actionProjectReview, SIGNAL(triggered()), project, SLOT(OnProjectView())); - connect(ui->actionModuleAdd, SIGNAL(triggered()), project, SLOT(OnProjectAddModule())); - connect(ui->actionClassAdd, SIGNAL(triggered()), project, SLOT(OnModuleAddClass())); - + + proj_pkg = new QDAProjectPkg(); + connect(proj_pkg, SIGNAL(SigShowWidget(QWidget*)), this, SLOT(OnSetCentralWidget(QWidget*))); + // QDAExampleDialog example = new QDAExampleDialog(); connect(example, SIGNAL(SigShowWidget(QWidget *)), this, SLOT(OnSetCentralWidget(QWidget *))); @@ -50,13 +54,13 @@ QDAMainWindow::QDAMainWindow(QWidget *parent) // QDAPracticalDialog practical = new QDAPracticalDialog(); connect(practical, SIGNAL(SigShowWidget(QWidget *)), this, SLOT(OnSetCentralWidget(QWidget *))); - connect(ui->actionEncrypt, SIGNAL(triggered()), practical, SLOT(OnPracticalEncrypt())); - connect(ui->actionDecrypt, SIGNAL(triggered()), practical, SLOT(OnPracticalDecrypt())); + //connect(ui->actionEncrypt, SIGNAL(triggered()), practical, SLOT(OnPracticalEncrypt())); + //connect(ui->actionDecrypt, SIGNAL(triggered()), practical, SLOT(OnPracticalDecrypt())); // QDACustomDialog custom = new QDACustomDialog(); connect(custom, SIGNAL(SigShowWidget(QWidget *)), this, SLOT(OnSetCentralWidget(QWidget *))); - connect(ui->actionCustom, SIGNAL(triggered()), custom, SLOT(OnCustomShow())); + //connect(ui->actionCustom, SIGNAL(triggered()), custom, SLOT(OnCustomShow())); // QDAPlanDialog plan = new QDAPlanDialog(); @@ -67,23 +71,49 @@ QDAMainWindow::QDAMainWindow(QWidget *parent) help = new QDAHelpDialog(); //connect(help, SIGNAL(SigShowWidget(QWidget *)), this, SLOT(OnSetCentralWidget(QWidget *))); connect(ui->actionVersion, SIGNAL(triggered()), help, SLOT(OnShowVersion())); + connect(ui->actionWelcome, SIGNAL(triggered()), this, SLOT(OnSetWelcome())); + + // Basic Functions + ui->envCheckButton->setStyleSheet(QUI::Style::PushButtonCyan()); + ui->projGenButton->setStyleSheet(QUI::Style::PushButtonCyan()); + ui->pkgGenButton->setStyleSheet(QUI::Style::PushButtonCyan()); + //ui->envCheckButton->setIcon(style()->standardIcon(QStyle::SP_FileDialogListView)); + //ui->projGenButton->setIcon(style()->standardIcon(QStyle::SP_FileDialogListView)); + connect(ui->envCheckButton, SIGNAL(clicked(bool)), project, SLOT(OnCheckEnv())); + connect(ui->projGenButton, SIGNAL(clicked(bool)), project, SLOT(OnProjectCreate())); + connect(ui->pkgGenButton, SIGNAL(clicked(bool)), proj_pkg, SLOT(OnProjectPkg())); + + // Extend Functions + ui->dataEncryptButton->setStyleSheet(QUI::Style::PushButtonCyan()); + ui->dataDecryptButton->setStyleSheet(QUI::Style::PushButtonCyan()); + connect(ui->dataEncryptButton, SIGNAL(clicked(bool)), practical, SLOT(OnPracticalEncrypt())); + connect(ui->dataDecryptButton, SIGNAL(clicked(bool)), practical, SLOT(OnPracticalDecrypt())); QDAAppConfig::GetInstance()->LoadConfig(); - CE::TrayIcon::SetIcon(winId(), "IDI_ICON1", "开发助手", 0); + //CE::TrayIcon::SetIcon(winId(), "IDI_ICON1", "开发助手", 0); + setupTrayIcon(); } QDAMainWindow::~QDAMainWindow() { + delete trayIcon; + delete project; + delete proj_pkg; delete example; delete practical; delete custom; delete plan; - //delete help; + delete help; delete ui; } +void QDAMainWindow::OnSetWelcome() +{ + OnSetCentralWidget(initWidget); +} + void QDAMainWindow::OnSetCentralWidget(QWidget *widget) { // remove old @@ -95,50 +125,113 @@ void QDAMainWindow::OnSetCentralWidget(QWidget *widget) widget->show(); } -void QDAMainWindow::LoadWelcome() -{ - project->OnCheckEnv(); -} /////////////////////////////////////// TrayIcon Section /////////////////////////////////////// -bool QDAMainWindow::nativeEvent(const QByteArray& eventType, void* message, long* result) +//bool QDAMainWindow::nativeEvent(const QByteArray& eventType, void* message, long* result) +//{ +//#if WIN +// MSG* msg = (MSG*)message; +// if (msg->message == WM_TO_TRAY) { +// LOGI("eventType = %s", QString(eventType).toStdString().c_str()); +// if (msg->lParam == WM_LBUTTONUP) { // Left Button Double Click +// CE::TrayIcon::ShowWindow(winId(), true); +// showMaximized(); // Required +// } +// //else if (msg->lParam == WM_LBUTTONDBLCLK) { // Left Button Double Click +// // //CE::TrayIcon::DelIcon(winId()); +// //} +// } +//#endif // WIN +// +// return QWidget::nativeEvent(eventType, message, result); +//} +// +//void QDAMainWindow::changeEvent(QEvent * event) +//{ +// LOGI("event->type() = %d", event->type()); +// if (QEvent::WindowStateChange == event->type()) +// { +// QWindowStateChangeEvent * stateEvent = dynamic_cast(event); +// if (Q_NULLPTR != stateEvent) { +// Qt::WindowStates x = stateEvent->oldState(); +// if (Qt::WindowMinimized == stateEvent->oldState()) { +// CE::TrayIcon::ShowWindow(winId(), true); +// showMaximized(); // Required +// } +// else if (Qt::WindowMaximized == stateEvent->oldState()) { +// CE::TrayIcon::ShowWindow(winId(), false); +// } +// } +// } +// else if (QEvent::Quit == event->type()) { +// CE::TrayIcon::DelIcon(winId()); +// } +//} + +void QDAMainWindow::setupTrayIcon() { -#if WIN - MSG* msg = (MSG*)message; - if (msg->message == WM_TO_TRAY) { - LOGI("eventType = %s", QString(eventType).toStdString().c_str()); - if (msg->lParam == WM_LBUTTONUP) { // Left Button Double Click - CE::TrayIcon::ShowWindow(winId(), true); - showMaximized(); // Required + QMenu* trayIconMenu = new QMenu(this); + QAction* restoreAction = trayIconMenu->addAction(u8"恢复窗口"); + QAction* quitAction = trayIconMenu->addAction(u8"退出程序"); + + connect(restoreAction, &QAction::triggered, this, &QDAMainWindow::showNormal); + connect(quitAction, &QAction::triggered, qApp, &QApplication::quit); + connect(trayIcon, &QSystemTrayIcon::activated, this, &QDAMainWindow::onTrayIconActivated); + + QString rootDir = QString::fromStdString(CKAppConf::GetInstance()->GetRootDir()); + LOGI("root_dir = %s", rootDir.toStdString().c_str()); + trayIcon->setContextMenu(trayIconMenu); + trayIcon->setIcon(QIcon(rootDir + "/data/Resource/logo.ico")); + + trayIcon->show(); + if (!trayIcon->isVisible()) { + qApp->quit(); + QMessageBox msgBox; + int ret = QUI::Style::ShowMsgBox(msgBox, QMessageBox::Critical, u8"提示", u8"系统托盘不支持图标!"); + if (ret == QMessageBox::Ok) { + qApp->quit(); } - //else if (msg->lParam == WM_LBUTTONDBLCLK) { // Left Button Double Click - // //CE::TrayIcon::DelIcon(winId()); - //} } -#endif // WIN - - return QWidget::nativeEvent(eventType, message, result); } -void QDAMainWindow::changeEvent(QEvent * event) +void QDAMainWindow::onTrayIconActivated(QSystemTrayIcon::ActivationReason reason) { - LOGI("event->type() = %d", event->type()); - if (QEvent::WindowStateChange == event->type()) - { - QWindowStateChangeEvent * stateEvent = dynamic_cast(event); - if (Q_NULLPTR != stateEvent) { - Qt::WindowStates x = stateEvent->oldState(); - if (Qt::WindowMinimized == stateEvent->oldState()) { - CE::TrayIcon::ShowWindow(winId(), true); - showMaximized(); // Required - } - else if (Qt::WindowMaximized == stateEvent->oldState()) { - CE::TrayIcon::ShowWindow(winId(), false); - } - } + if (reason == QSystemTrayIcon::Trigger) { + showNormal(); + activateWindow(); + raise(); } - else if (QEvent::Quit == event->type()) { - CE::TrayIcon::DelIcon(winId()); +} + +void QDAMainWindow::changeEvent(QEvent* event) { + QMainWindow::changeEvent(event); + + if (event->type() == QEvent::WindowStateChange) { + QWindowStateChangeEvent* changEvent = static_cast(event); + LOGI("event->type() = %d, changEvent->oldState() = %d, windowState() = %d", + event->type(), changEvent->oldState(), windowState()); + + if (changEvent->oldState() == Qt::WindowNoState && windowState() == Qt::WindowMaximized) { // Normal -> Maximized + hide(); + showMaximized(); + } + else if (changEvent->oldState() == Qt::WindowMaximized && windowState() == Qt::WindowNoState) { // Maximized -> Normal + hide(); + showNormal(); + } + else if (windowState() == Qt::WindowMinimized) { + //showMinimized(); + hide(); + } + else if (windowState() == Qt::WindowActive) { // e.g. Minimized to Normal + hide(); + showNormal(); + } } } + +void QDAMainWindow::closeEvent(QCloseEvent* event) { + hide(); + event->ignore(); +} diff --git a/app/src/app/DevAssistant/QDAMainWindow.h b/app/src/app/DevAssistant/QDAMainWindow.h index 0a6f1c8..8b0e63c 100644 --- a/app/src/app/DevAssistant/QDAMainWindow.h +++ b/app/src/app/DevAssistant/QDAMainWindow.h @@ -1,4 +1,4 @@ -// Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869) +// Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869) #ifndef QDA_MAINWINDOW_H #define QDA_MAINWINDOW_H @@ -7,11 +7,13 @@ #include #include +#include namespace Ui { class QDAMainWindow; } class QDAProjectDialog; +class QDAProjectPkg; class QDAExampleDialog; class QDAPracticalDialog; class QDACustomDialog; @@ -26,24 +28,33 @@ class QDAMainWindow : public QMainWindow QDAMainWindow(QWidget *parent = nullptr); virtual ~QDAMainWindow(); - void LoadWelcome(); - public Q_SLOTS: + void OnSetWelcome(); void OnSetCentralWidget(QWidget *widget); private: Ui::QDAMainWindow *ui; QDAProjectDialog *project; + QDAProjectPkg* proj_pkg; QDAExampleDialog *example; QDAPracticalDialog *practical; QDACustomDialog *custom; QDAPlanDialog *plan; QDAHelpDialog *help; + QWidget* initWidget; -protected: ////////////////////////// TrayIcon Section ////////////////////////// - virtual bool nativeEvent(const QByteArray& eventType, void* message, long* result) override; - virtual void changeEvent(QEvent* event) override; +protected: + //virtual bool nativeEvent(const QByteArray& eventType, void* message, long* result) override; + //virtual void changeEvent(QEvent* event) override; + void setupTrayIcon(); + void changeEvent(QEvent* event) override; + void closeEvent(QCloseEvent* event) override; + +protected slots: + void onTrayIconActivated(QSystemTrayIcon::ActivationReason reason); +private: + QSystemTrayIcon* trayIcon; }; #endif // QDA_MAINWINDOW_H diff --git a/app/src/app/DevAssistant/main.cpp b/app/src/app/DevAssistant/main.cpp index 8d23fe6..a71ac9c 100644 --- a/app/src/app/DevAssistant/main.cpp +++ b/app/src/app/DevAssistant/main.cpp @@ -60,8 +60,7 @@ int LoadApp(int argc, char* argv[]) { QDAMainWindow window; window.setWindowTitle("DevAssistant"); - window.showMaximized(); - window.LoadWelcome(); + window.showNormal(); return app.exec(); } @@ -69,16 +68,22 @@ int LoadApp(int argc, char* argv[]) { int main(int argc, char *argv[]) { QString root_dir = GetRootDir(argv[0]); - Logger::SetLogWriter(root_dir.toStdString() + "/logs"); + + // Init logger + QString log_dir = root_dir + "/logs"; + QDir dir(log_dir); + if (!dir.exists()) { + dir.mkpath(log_dir); + } + Logger::SetLogWriter(log_dir.toStdString()); App::InitAppConfig(argv[0]); - //App::SetInitStart(argv[0]); for (size_t idx = 0; idx < argc; idx++) { LOGI("argv[%d] = %s", (int)idx, argv[idx]); } - if (argc >= 2) { + if (argc >= 2) { // RightAction // Update run_win.bat / run_arm.sh / run_unix.sh return QEK::BuildScript::GetInstance()->FixBuildScript(argv[1]); } diff --git a/app/src/kits/COSEnv/CETrayIcon.cpp b/app/src/kits/COSEnv/CETrayIcon.cpp index b1bec76..045c20c 100644 --- a/app/src/kits/COSEnv/CETrayIcon.cpp +++ b/app/src/kits/COSEnv/CETrayIcon.cpp @@ -52,7 +52,6 @@ void TrayIcon::SetIcon(int winid, const std::string& icon_name, const std::strin Shell_NotifyIcon(NIM_SETVERSION, &tray_icon); //ShowWindow(hwnd, SW_HIDE); } - #else #endif // WIN diff --git a/app/src/qtmodules/QtCustom/QDACustomDialog.cpp b/app/src/qtmodules/QtCustom/QDACustomDialog.cpp index d009a80..4adabc6 100644 --- a/app/src/qtmodules/QtCustom/QDACustomDialog.cpp +++ b/app/src/qtmodules/QtCustom/QDACustomDialog.cpp @@ -13,7 +13,7 @@ QDACustomDialog::QDACustomDialog(QWidget *parent) : { ui->setupUi(this); ui->titleLabel->setStyleSheet("QLabel { color:white; font:25px; }"); - QUI::Style::SetPushButton(ui->customScriptBtn); + ui->customScriptBtn->setStyleSheet(QUI::Style::PushButton()); } QDACustomDialog::~QDACustomDialog() diff --git a/app/src/qtmodules/QtEnvKit/QDACheckEnvDialog.cpp b/app/src/qtmodules/QtEnvKit/QDACheckEnvDialog.cpp index e97e21e..7c10dc0 100644 --- a/app/src/qtmodules/QtEnvKit/QDACheckEnvDialog.cpp +++ b/app/src/qtmodules/QtEnvKit/QDACheckEnvDialog.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869) +// Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869) #include "QDACheckEnvDialog.h" @@ -31,10 +31,10 @@ QDACheckEnvDialog::QDACheckEnvDialog(QWidget *parent) : ui->setupUi(this); QUI::Style::SetTreeWidget(ui->envTreeWidget); - QUI::Style::SetPushButton(ui->checkEnvBtn); + ui->checkEnvBtn->setStyleSheet(QUI::Style::PushButton()); connect(ui->checkEnvBtn, SIGNAL(clicked(bool)), this, SLOT(OnCheckEnv())); - QUI::Style::SetPushButton(ui->tryFixBtn); + ui->tryFixBtn->setStyleSheet(QUI::Style::PushButton()); connect(ui->tryFixBtn, SIGNAL(clicked(bool)), this, SLOT(OnTryFixEnvValue())); } diff --git a/app/src/qtmodules/QtHelp/QDAHelpDialog.cpp b/app/src/qtmodules/QtHelp/QDAHelpDialog.cpp index 5007931..d750eca 100644 --- a/app/src/qtmodules/QtHelp/QDAHelpDialog.cpp +++ b/app/src/qtmodules/QtHelp/QDAHelpDialog.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869) +// Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869) #include "QDAHelpDialog.h" @@ -13,7 +13,7 @@ QDAHelpDialog::QDAHelpDialog(QWidget *parent) : { ui->setupUi(this); ui->titleLabel->setStyleSheet("QLabel { color:white; font:25px; }"); - QUI::Style::SetPushButton(ui->versionButton); + ui->versionButton->setStyleSheet(QUI::Style::PushButton()); } QDAHelpDialog::~QDAHelpDialog() @@ -30,9 +30,9 @@ void QDAHelpDialog::OnHelpShow() void QDAHelpDialog::OnShowVersion() { std::string version = u8R"( -版本号(Version) : v1.1.6.0 +版本号(Version) : v2.1.0.0 -日期(Date) : 2025/04/13 +日期(Date) : 2025/04/29 )"; QMessageBox::information(NULL, QStringLiteral("Version"), QString::fromStdString(version)); } diff --git a/app/src/qtmodules/QtPlan/QDAPlanDialog.cpp b/app/src/qtmodules/QtPlan/QDAPlanDialog.cpp index 9b3297d..66c7088 100644 --- a/app/src/qtmodules/QtPlan/QDAPlanDialog.cpp +++ b/app/src/qtmodules/QtPlan/QDAPlanDialog.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869) +// Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869) #include "QDAPlanDialog.h" @@ -18,8 +18,8 @@ QDAPlanDialog::QDAPlanDialog(QWidget *parent) : { ui->setupUi(this); ui->titleLabel->setStyleSheet("QLabel { color:white; font:25px; }"); - QUI::Style::SetPushButton(ui->loadPlanBtn); - QUI::Style::SetPushButton(ui->savePlanBtn); + ui->loadPlanBtn->setStyleSheet(QUI::Style::PushButton()); + ui->savePlanBtn->setStyleSheet(QUI::Style::PushButton()); connect(ui->loadPlanBtn, SIGNAL(clicked(bool)), this, SLOT(OnLoadPlan())); connect(ui->savePlanBtn, SIGNAL(clicked(bool)), this, SLOT(OnSavePlan())); diff --git a/app/src/qtmodules/QtProject/Forms/QDAProjectDialog.ui b/app/src/qtmodules/QtProject/Forms/QDAProjectDialog.ui index 06ddeaf..dd855a1 100644 --- a/app/src/qtmodules/QtProject/Forms/QDAProjectDialog.ui +++ b/app/src/qtmodules/QtProject/Forms/QDAProjectDialog.ui @@ -49,16 +49,6 @@ 预览项目(View Project) - - - 添加模块(Add Module) - - - - - 添加类(Add Class) - - diff --git a/app/src/qtmodules/QtProject/Forms/QDAProjectPkg.ui b/app/src/qtmodules/QtProject/Forms/QDAProjectPkg.ui new file mode 100644 index 0000000..bb1fbf8 --- /dev/null +++ b/app/src/qtmodules/QtProject/Forms/QDAProjectPkg.ui @@ -0,0 +1,503 @@ + + + QDAProjectPkg + + + + 0 + 0 + 714 + 710 + + + + Dialog + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 40 + + + + + + + + + + + 0 + 0 + + + + + Agency FB + 10 + + + + false + + + color: rgb(255, 255, 255); + + + 软件名称: + + + + + + + + 0 + 35 + + + + + 16777215 + 35 + + + + + Times New Roman + 10 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 0 + 0 + + + + + Agency FB + 10 + + + + false + + + color: rgb(255, 255, 255); + + + 打包资源子目录: + + + + + + + + 0 + 35 + + + + + 16777215 + 35 + + + + + Times New Roman + 10 + + + + bin64, conf, data + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + + Agency FB + 18 + 75 + true + + + + color: rgb(255, 255, 255); + + + 打包配置 + + + Qt::AlignCenter + + + + + + + + + + 0 + 0 + + + + + Agency FB + 10 + + + + false + + + color: rgb(255, 255, 255); + + + 打包资源根目录: + + + + + + + + 0 + 35 + + + + + 16777215 + 35 + + + + + Times New Roman + 10 + + + + + + + + + 0 + 0 + + + + + Agency FB + 10 + + + + 浏览 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 40 + + + + + + + + + + + 0 + 0 + + + + + Agency FB + 10 + + + + false + + + color: rgb(255, 255, 255); + + + 软件介绍: + + + + + + + + + + + + + + + 0 + 0 + + + + + Agency FB + 10 + + + + false + + + color: rgb(255, 255, 255); + + + 软件版本: + + + + + + + + 0 + 35 + + + + + 16777215 + 35 + + + + + Times New Roman + 10 + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 200 + 45 + + + + + 200 + 45 + + + + + Agency FB + 12 + + + + 制作安装包 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + diff --git a/app/src/qtmodules/QtProject/QDAProjectAddDialog.cpp b/app/src/qtmodules/QtProject/QDAProjectAddDialog.cpp index baafcf1..860df3b 100644 --- a/app/src/qtmodules/QtProject/QDAProjectAddDialog.cpp +++ b/app/src/qtmodules/QtProject/QDAProjectAddDialog.cpp @@ -12,7 +12,7 @@ QDAProjectAddDialog::QDAProjectAddDialog(QWidget *parent) : { ui->setupUi(this); - QUI::Style::SetPushButton(ui->createProjectBtn); + ui->createProjectBtn->setStyleSheet(QUI::Style::PushButton()); } QDAProjectAddDialog::~QDAProjectAddDialog() diff --git a/app/src/qtmodules/QtProject/QDAProjectDetailDialog.cpp b/app/src/qtmodules/QtProject/QDAProjectDetailDialog.cpp index 7ddfaeb..e685b92 100644 --- a/app/src/qtmodules/QtProject/QDAProjectDetailDialog.cpp +++ b/app/src/qtmodules/QtProject/QDAProjectDetailDialog.cpp @@ -23,13 +23,13 @@ QDAProjectDetailDialog::QDAProjectDetailDialog(QWidget *parent) : ui->setupUi(this); - QUI::Style::SetPushButton(ui->createProjectBtn); + ui->createProjectBtn->setStyleSheet(QUI::Style::PushButton()); connect(ui->createProjectBtn, SIGNAL(clicked(bool)), this, SLOT(OnCreate())); - QUI::Style::SetPushButton(ui->loadProjectConfigBtn); + ui->loadProjectConfigBtn->setStyleSheet(QUI::Style::PushButton()); connect(ui->loadProjectConfigBtn, SIGNAL(clicked(bool)), this, SLOT(OnLoadConfig())); - QUI::Style::SetPushButton(ui->saveProjectConfigBtn); + ui->saveProjectConfigBtn->setStyleSheet(QUI::Style::PushButton()); connect(ui->saveProjectConfigBtn, SIGNAL(clicked(bool)), this, SLOT(OnSaveConfig())); } @@ -118,11 +118,12 @@ void QDAProjectDetailDialog::OnCreate() QMessageBox::information(NULL, "pycmd", pycmd); bool ret = QCKCmd::ExecCmd(pycmd, QStringList(), output); if (!ret) { - LOGE("pycmd = %s \n output=%s", pycmd.toUtf8().constData(), output.data()); + LOGE("project gen pycmd = %s \n output=%s", pycmd.toUtf8().constData(), output.data()); QMessageBox::critical(NULL, QStringLiteral("Project Create"), output.data()); return; } + LOGI("project gen pycmd = %s", pycmd.toUtf8().constData()); // Note:: update build scripts QEK::BuildScript::GetInstance()->FixBuildScripts(config.proj_dir.toUtf8().constData()); QMessageBox::information(NULL, QStringLiteral("Project Create"), "Succeed!"); diff --git a/app/src/qtmodules/QtProject/QDAProjectDialog.h b/app/src/qtmodules/QtProject/QDAProjectDialog.h index f78e812..2d26c28 100644 --- a/app/src/qtmodules/QtProject/QDAProjectDialog.h +++ b/app/src/qtmodules/QtProject/QDAProjectDialog.h @@ -1,4 +1,4 @@ -// Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869) +// Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869) #ifndef QDA_PROJECT_DIALOG_H #define QDA_PROJECT_DIALOG_H @@ -35,8 +35,8 @@ public Q_SLOTS: void OnProjectCreate(); void OnProjectOpen(); void OnProjectView(); - void OnProjectAddModule(); - void OnModuleAddClass(); + void OnProjectAddModule(); // unused + void OnModuleAddClass(); // unused private: Ui::QDAProjectDialog *ui; diff --git a/app/src/qtmodules/QtProject/QDAProjectPkg.cpp b/app/src/qtmodules/QtProject/QDAProjectPkg.cpp new file mode 100644 index 0000000..7d3473b --- /dev/null +++ b/app/src/qtmodules/QtProject/QDAProjectPkg.cpp @@ -0,0 +1,159 @@ +// Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869) + +#include "QDAProjectPkg.h" + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include "ui_QDAProjectPkg.h" + +static const char* MSG_BOX_TIPS = u8"提示"; +static const char* MSG_BOX_SET_ROOT_DIR = u8"请设置打包根目录!"; +static const char* MSG_BOX_SET_SUB_DIRS = u8"请正确设置打包子目录!"; +static const char* MSG_BOX_SET_SOFT_NAME = u8"请设置软件名称!"; +static const char* MSG_BOX_PKG_SUCCESS = u8"安装包制作成功,即将打开根目录!"; + +QDAProjectPkg::QDAProjectPkg(QWidget *parent) : + QDialog(parent), ui(new Ui::QDAProjectPkg) +{ + ui->setupUi(this); + + ui->rootDirEdit->setEnabled(false); + ui->rootDirButton->setStyleSheet(QUI::Style::PushButton()); + connect(ui->rootDirButton, SIGNAL(clicked(bool)), this, SLOT(OnSelectPkgRootDir(bool))); + + ui->pkgButton->setStyleSheet(QUI::Style::PushButton()); + connect(ui->pkgButton, SIGNAL(clicked(bool)), this, SLOT(OnPkgProcess(bool))); +} + +QDAProjectPkg::~QDAProjectPkg() +{ + delete ui; +} + +void QDAProjectPkg::OnProjectPkg() +{ + emit SigShowWidget(this); +} + +void QDAProjectPkg::OnSelectPkgRootDir(bool) +{ + QStringList list = QCKFile::SelectDirectory(false); + if (list.size() == 1) { + LOGI("select dir: %s", list[0].toStdString().c_str()); + ui->rootDirEdit->setText(list[0]); + } else { + LOGI("not select any dir!"); + } +} + +void QDAProjectPkg::OnPkgProcess(bool) +{ + // ui->rootDirEdit + if (ui->rootDirEdit->text().isEmpty()) { + QMessageBox msgBox; + int ret = QUI::Style::ShowMsgBox(msgBox, QMessageBox::Critical, MSG_BOX_TIPS, MSG_BOX_SET_ROOT_DIR, true); + return; + } + + // ui->subDirsEdit + QJsonArray sub_dirs; + if (!CheckSubDirs(sub_dirs)) { + QMessageBox msgBox; + int ret = QUI::Style::ShowMsgBox(msgBox, QMessageBox::Critical, MSG_BOX_TIPS, MSG_BOX_SET_SUB_DIRS, true); + return; + } + + // ui->softNameEdit + if (ui->softNameEdit->text().isEmpty()) { + QMessageBox msgBox; + int ret = QUI::Style::ShowMsgBox(msgBox, QMessageBox::Critical, MSG_BOX_TIPS, MSG_BOX_SET_SOFT_NAME, true); + return; + } + + QJsonObject cfg_obj; + cfg_obj["root_dir"] = ui->rootDirEdit->text(); + cfg_obj["pkg_dirs"] = sub_dirs; + cfg_obj["proj_name"] = ui->softNameEdit->text(); + cfg_obj["script_dir"] = u8"scripts"; + + QString script_dir_path = ui->rootDirEdit->text() + "/scripts"; + QDir script_dir(script_dir_path); + if (!script_dir.exists()) { + script_dir.mkpath(script_dir_path); + } + + // ui->softVersionEdit + if (!ui->softVersionEdit->text().isEmpty()) { + cfg_obj["version"] = ui->softVersionEdit->text(); + } + + // ui->softDescEdit + if (!ui->softDescEdit->toPlainText().isEmpty()) { + cfg_obj["describe"] = ui->softDescEdit->toPlainText(); + } + + QString pkg_json_path = ui->rootDirEdit->text() + "/pkg.json"; + QString json_str = QString(QJsonDocument(cfg_obj).toJson()); + if (!QCKFile::SaveFile(pkg_json_path, json_str.toUtf8())) { + QMessageBox::warning(NULL, "Save Pkg Json Config", "Save Json Config File Failed !"); + } + + // TODO::显示旋转框 + // call pkg python + QString dirPath = QCoreApplication::applicationDirPath(); + LOGI("App Dir Path = %s", dirPath.toUtf8().constData()); + QString pycmd = QCKCmd::GetPyBin() + "\"" + dirPath + "/../data/plugins/project/proj_pkg/run_pkg.py\" --config \"" + pkg_json_path + "\""; + + QByteArray output; + QMessageBox::information(NULL, "pycmd", pycmd); + bool ret = QCKCmd::ExecCmd(pycmd, QStringList(), output); + // TODO::关闭旋转框 + if (!ret) { + LOGE("project pkg pycmd = %s \n output=%s", pycmd.toUtf8().constData(), output.data()); + QMessageBox::critical(NULL, QStringLiteral("Project Pkg"), output.data()); + return; + } + + LOGI("project pkg pycmd = %s", pycmd.toUtf8().constData()); + QMessageBox msgBox; + int ret1 = QUI::Style::ShowMsgBox(msgBox, QMessageBox::Information, MSG_BOX_TIPS, MSG_BOX_PKG_SUCCESS, true); + if (ret1 == QMessageBox::Ok) { + QUrl url = QUrl::fromLocalFile(ui->rootDirEdit->text()); + QDesktopServices::openUrl(url); + } +} + +bool QDAProjectPkg::CheckSubDirs(QJsonArray &sub_dirs) +{ + QString str = ui->subDirsEdit->text(); + if (str.isEmpty()) { + return false; + } + + QString root_dir = ui->rootDirEdit->text(); + // seperate && check subdirs + QStringList dirs = str.split(","); + for (size_t idx = 0; idx < dirs.size(); idx++) { + QString dir_name = dirs[idx].trimmed(); + QDir dir(root_dir + "/" + dir_name); + if (dir.exists()) { + sub_dirs.append(dir_name); + } else { + LOGI("dir %s not exist!", (root_dir + "/" + dir_name).toStdString().c_str()); + } + } + return !sub_dirs.empty(); +} diff --git a/app/src/qtmodules/QtProject/QDAProjectPkg.h b/app/src/qtmodules/QtProject/QDAProjectPkg.h new file mode 100644 index 0000000..627e136 --- /dev/null +++ b/app/src/qtmodules/QtProject/QDAProjectPkg.h @@ -0,0 +1,39 @@ +// Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869) + +#ifndef QDA_PROJECT_PKG_H +#define QDA_PROJECT_PKG_H + +#include +#include + +#include + +namespace Ui { +class QDAProjectPkg; +} +class QJsonArray; + +class QDAProjectPkg : public QDialog +{ + Q_OBJECT + +public: + explicit QDAProjectPkg(QWidget *parent = nullptr); + ~QDAProjectPkg(); + +Q_SIGNALS: + void SigShowWidget(QWidget *widget); + +public Q_SLOTS: + void OnProjectPkg(); + void OnSelectPkgRootDir(bool); + void OnPkgProcess(bool); + +protected: + bool CheckSubDirs(QJsonArray& sub_dirs); + +private: + Ui::QDAProjectPkg *ui; +}; + +#endif // QDA_PROJECT_PKG_H diff --git a/app/src/qtmodules/QtProject/QtProject.h b/app/src/qtmodules/QtProject/QtProject.h index b56f23c..73c2403 100644 --- a/app/src/qtmodules/QtProject/QtProject.h +++ b/app/src/qtmodules/QtProject/QtProject.h @@ -1,8 +1,9 @@ -// Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869) +// Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869) #ifndef QTPROJECT_H #define QTPROJECT_H #include +#include #endif /* QTPROJECT_H */ diff --git a/app/src/qtmodules/QtUIInfra/QUIStyle.cpp b/app/src/qtmodules/QtUIInfra/QUIStyle.cpp index 7b26378..4fd87bc 100644 --- a/app/src/qtmodules/QtUIInfra/QUIStyle.cpp +++ b/app/src/qtmodules/QtUIInfra/QUIStyle.cpp @@ -2,22 +2,41 @@ #include "QUIStyle.h" -#include #include -#include -#include #include -#include #include +#include + NS_QUI_BEGIN -void Style::SetMainWindow(QMainWindow* window) + +int Style::ShowMsgBox(QMessageBox& msgBox, QMessageBox::Icon icn, const QString& title, const QString& text, bool onlyOK) { - if (!window) { - return; - } + msgBox.setIcon(icn); + msgBox.setText(text); + //msgBox.setInformativeText(text); + msgBox.setWindowTitle(title); + + QPushButton* okButton = (QPushButton*)msgBox.addButton(QMessageBox::Ok); + if (okButton) { + okButton->setText(u8"确定"); + } + + if (!onlyOK) { + QPushButton* cancelButton = (QPushButton*)msgBox.addButton(QMessageBox::Cancel); + if (cancelButton) { + cancelButton->setText(u8"取消"); + } + } + + return msgBox.exec(); +} - window->setStyleSheet("QMainWindow { background-color: rgb(49, 53, 64); }"); +QString Style::MainWindowStyle() +{ + return R"( + QMainWindow { background-color: rgb(49, 53, 64); } + )"; } void Style::SetDockWidget(QDockWidget* widget) @@ -31,62 +50,74 @@ void Style::SetDockWidget(QDockWidget* widget) widget->setStyleSheet("QDockWidget { background-color: rgb(49, 53, 64); }"); } -void Style::SetListView(QListView* view) +void Style::SetTreeWidget(QTreeWidget* widget) { - if (!view) { + if (!widget) { return; } - view->setStyleSheet("\ - QListView::item { font: 14px; color: white; height: 50px;} \ - QListView::item:hover{ color:gray; } \ - QListView::item::selected, QListView::branch::selected { background-color: blue; } \ - QListView { background-color: rgb(49, 53, 64); } \ - "); + widget->setStyle(QStyleFactory::create("windows")); + //widget->setStyleSheet("QTreeWidget::item{ height: 50px; background-color: rgb(49, 53, 64); }"); + widget->setStyleSheet(R"( + QHeaderView::section { font: 20px; color:#CCCCCC; height: 50px; background-color: rgb(49, 53, 64);} + QTreeView { background-color: rgb(49, 53, 64); } + QTreeView::item { font: 14px; color:#CCCCCC; height: 50px; } + QTreeView::item:hover{ color:white; } + QTreeView::item::selected, QTreeView::branch::selected { color:#17A387; border:1px solid #797979; } + )"); } -void Style::SetListWidget(QListWidget* widget) +QString Style::ListView() { - if (!widget) { - return; - } - - widget->setStyleSheet("\ - QListView::item { font: 14px; color: white; height: 50px; border:1px solid #797979; } \ - QListView::item:hover{ color:gray; } \ - QListView::item::selected, QListView::branch::selected { background-color: blue; } \ - QListView { background-color: rgb(49, 53, 64); } \ - "); - + return R"( + QListView::item { font: 14px; color: white; height: 50px;} + QListView::item:hover{ color:gray; } + QListView::item::selected, QListView::branch::selected { background-color: blue; } + QListView { background-color: rgb(49, 53, 64); } + )"; } -void Style::SetTreeWidget(QTreeWidget* widget) +QString Style::ListWidget() { - if (!widget) { - return; - } - - widget->setStyle(QStyleFactory::create("windows")); - //widget->setStyleSheet("QTreeWidget::item{ height: 50px; background-color: rgb(49, 53, 64); }"); - widget->setStyleSheet("\ - QHeaderView::section { font: 20px; color:#CCCCCC; height: 50px; background-color: rgb(49, 53, 64);} \ - QTreeView { background-color: rgb(49, 53, 64); } \ - QTreeView::item { font: 14px; color:#CCCCCC; height: 50px; } \ - QTreeView::item:hover{ color:white; } \ - QTreeView::item::selected, QTreeView::branch::selected { color:#17A387; border:1px solid #797979; } \ - "); + return R"( + QListView::item { font: 14px; color: white; height: 50px; border:1px solid #797979; } + QListView::item:hover{ color:gray; } + QListView::item::selected, QListView::branch::selected { background-color: blue; } + QListView { background-color: rgb(49, 53, 64); } + )"; } -void Style::SetPushButton(QPushButton* btn) +QString Style::PushButton() { - if (!btn) { - return; - } + return R"( + QPushButton{ border-radius:6px; background-color: white; width:150px; height:44px;} + QPushButton::hover{ color:white; background-color: #17A387; } + )"; +} - btn->setStyleSheet("\ - QPushButton{ border-radius:6px; background-color: white; width:150px; height:44px;} \ - QPushButton::hover{ color:white; background-color: #17A387; } \ - "); +QString Style::PushButtonCyan() +{ + return R"( + QPushButton { + border: 1px solid gray; + border-radius: 5px; + background-color: rgb(0, 159, 170); + padding:8px; + color:rgb(255, 255, 255); + } + + QPushButton:hover { + border: 1px solid #005566; + background-color: rgb(0, 191, 203); + } + + QPushButton:pressed { + border: 1px solid #00333F; + background-color: rgb(0, 119, 130); + padding-top: 9px; + padding-bottom: 7px; + } + )"; } NS_QUI_END \ No newline at end of file diff --git a/app/src/qtmodules/QtUIInfra/QUIStyle.h b/app/src/qtmodules/QtUIInfra/QUIStyle.h index cd6791b..6910596 100644 --- a/app/src/qtmodules/QtUIInfra/QUIStyle.h +++ b/app/src/qtmodules/QtUIInfra/QUIStyle.h @@ -1,4 +1,4 @@ -// Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869) +// Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869) #pragma once @@ -6,12 +6,11 @@ #include #include "QtUIInfraDef.h" -class QMainWindow; +#include + class QDockWidget; -class QListView; -class QListWidget; class QTreeWidget; -class QPushButton; +class QString; NS_QUI_BEGIN @@ -19,17 +18,21 @@ NS_QUI_BEGIN //{ //public: namespace Style { - void SetMainWindow(QMainWindow* window); + int ShowMsgBox(QMessageBox& msgBox, QMessageBox::Icon icn, const QString& title, const QString& text, bool onlyOK = false); + + QString MainWindowStyle(); void SetDockWidget(QDockWidget* widget); - void SetListView(QListView* view); + void SetTreeWidget(QTreeWidget* widget); - void SetListWidget(QListWidget* widget); + QString ListView(); - void SetTreeWidget(QTreeWidget* widget); + QString ListWidget(); + + QString PushButton(); + QString PushButtonCyan(); - void SetPushButton(QPushButton* btn); }; NS_QUI_END