diff options
author | Saturn&Eric <[email protected]> | 2021-12-08 15:32:41 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-12-08 15:32:41 +0000 |
commit | 6044d5706d88e3995ff2162d86e1f06bf70d0894 (patch) | |
tree | fa483d7d8e00d42ba77c43c1223b27793f20d0f9 | |
parent | Merge pull request #28 from saturneric/develop (diff) | |
parent | Update CI for Release and Debug. (diff) | |
download | GpgFrontend-6044d5706d88e3995ff2162d86e1f06bf70d0894.tar.gz GpgFrontend-6044d5706d88e3995ff2162d86e1f06bf70d0894.zip |
Merge pull request #29 from saturneric/developv2.0.1
v2.0.1-beta.3
-rw-r--r-- | .github/workflows/debug.yml | 14 | ||||
-rw-r--r-- | .github/workflows/release-ci.yml | 41 | ||||
-rw-r--r-- | .github/workflows/release.yml | 20 | ||||
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/CMakeLists.txt | 11 | ||||
-rw-r--r-- | src/main.cpp | 30 | ||||
-rw-r--r-- | src/ui/widgets/FilePage.cpp | 13 |
7 files changed, 77 insertions, 56 deletions
diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 0be5e6ec..2a0f6319 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -25,7 +25,7 @@ jobs: build: strategy: matrix: - os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ] + os: [ 'ubuntu-latest', 'macos-10.15', 'windows-latest' ] runs-on: ${{ matrix.os }} steps: @@ -54,7 +54,7 @@ jobs: security import certificate.p12 -k build.keychain -P ${{secrets.MAOS_CERTIFICATE_PWD}} -T /usr/bin/codesign security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k gpgfrontend build.keychain security set-keychain-settings -lut 3600 - if: matrix.os == 'macos-latest' + if: matrix.os == 'macos-10.15' - name: Install Dependence (macOS) run: | @@ -64,7 +64,7 @@ jobs: brew link qt@5 brew link gcc brew link openssl --force - if: matrix.os == 'macos-latest' + if: matrix.os == 'macos-10.15' - name: Cache Qt id: cache-qt @@ -119,7 +119,7 @@ jobs: ./configure --enable-maintainer-mode --enable-static=yes --enable-languages=cpp && make -j2 sudo make install cd ${{github.workspace}} - if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-10.15' - name: Build GpgME (Windows) shell: msys2 {0} @@ -135,12 +135,12 @@ jobs: # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DEXECUTABLE_OUTPUT_PATH=${{env.EXECUTABLE_OUTPUT_PATH}} -DBUILD_CONFIG="test_ui" - if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-10.15' - name: Build GpgFrontend # Build your program with the given configuration run: cmake --build ${{github.workspace}}/build --config $env.BUILD_TYPE}} -- -j 2 - if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-10.15' - name: Configure CMake & Build Binary(Windows) shell: msys2 {0} @@ -168,7 +168,7 @@ jobs: with: name: gpgfrontend-${{matrix.os}}-${{env.BUILD_TYPE}}-${{steps.vars.outputs.sha_short}} path: ${{github.workspace}}/build/release/* - if: matrix.os == 'macos-latest' + if: matrix.os == 'macos-10.15' - name: Upload Artifact(Windows) uses: actions/upload-artifact@master diff --git a/.github/workflows/release-ci.yml b/.github/workflows/release-ci.yml index 1609a9c5..92a12869 100644 --- a/.github/workflows/release-ci.yml +++ b/.github/workflows/release-ci.yml @@ -2,19 +2,19 @@ name: Build & Package CI Test on: push: - branches: [ develop-ci ] + branches: [develop-ci] paths-ignore: - - '**/README.md' - - '**/README_CN.md' - - 'resource/ts/**' - - 'docs/**' + - "**/README.md" + - "**/README_CN.md" + - "resource/ts/**" + - "docs/**" pull_request: - branches: [ develop-ci ] + branches: [develop-ci] paths-ignore: - - '**/README.md' - - '**/README_CN.md' - - 'resource/ts/**' - - 'docs/**' + - "**/README.md" + - "**/README_CN.md" + - "resource/ts/**" + - "docs/**" env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) @@ -25,10 +25,9 @@ jobs: build: strategy: matrix: - os: [ 'ubuntu-18.04', 'macos-latest', 'windows-latest' ] + os: ["ubuntu-18.04", "macos-10.15", "windows-latest"] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 with: submodules: recursive @@ -57,7 +56,7 @@ jobs: security import certificate.p12 -k build.keychain -P ${{secrets.MAOS_CERTIFICATE_PWD}} -T /usr/bin/codesign security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k gpgfrontend build.keychain security set-keychain-settings -lut 3600 - if: matrix.os == 'macos-latest' + if: matrix.os == 'macos-10.15' - name: Install Dependence (macOS) run: | @@ -67,7 +66,7 @@ jobs: brew link qt@5 brew link gcc brew link openssl --force - if: matrix.os == 'macos-latest' + if: matrix.os == 'macos-10.15' - name: Cache Qt id: cache-qt @@ -122,7 +121,7 @@ jobs: ./configure --enable-maintainer-mode --enable-static=yes --enable-languages=cpp && make -j2 sudo make install cd ${{github.workspace}} - if: matrix.os == 'ubuntu-18.04' || matrix.os == 'macos-latest' + if: matrix.os == 'ubuntu-18.04' || matrix.os == 'macos-10.15' - name: Build GpgME (Windows) shell: msys2 {0} @@ -138,12 +137,12 @@ jobs: # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DEXECUTABLE_OUTPUT_PATH=${{env.EXECUTABLE_OUTPUT_PATH}} - if: matrix.os == 'ubuntu-18.04' || matrix.os == 'macos-latest' + if: matrix.os == 'ubuntu-18.04' || matrix.os == 'macos-10.15' - name: Build GpgFrontend # Build your program with the given configuration run: cmake --build ${{github.workspace}}/build --config $env.BUILD_TYPE}} -- -j 2 - if: matrix.os == 'ubuntu-18.04' || matrix.os == 'macos-latest' + if: matrix.os == 'ubuntu-18.04' || matrix.os == 'macos-10.15' - name: Build & Sign App Bundle (macOS) run: | @@ -151,7 +150,7 @@ jobs: macdeployqt ${{github.workspace}}/build/release/GpgFrontend.app codesign --deep --force --options=runtime -s "Developer ID Application: Yu Hu (4279AWUL3X)" ${{github.workspace}}/build/release/GpgFrontend.app -v mkdir ${{github.workspace}}/build/tmp/ - if: matrix.os == 'macos-latest' + if: matrix.os == 'macos-10.15' - name: Package & Sign App Bundle (macOS) run: | @@ -161,12 +160,12 @@ jobs: hdiutil convert ${{github.workspace}}/build/tmp/tmp.dmg -format UDZO -o ${{github.workspace}}/build/artifactOut/GpgFrontend.dmg codesign -s "Developer ID Application: Yu Hu (4279AWUL3X)" ${{github.workspace}}/build/artifactOut/GpgFrontend.dmg mv ${{github.workspace}}/build/artifactOut/GpgFrontend.dmg ${{github.workspace}}/build/artifactOut/GpgFrontend-${{steps.vars.outputs.sha_short}}-x86_64.dmg - if: matrix.os == 'macos-latest' + if: matrix.os == 'macos-10.15' - name: Notarize Release Build (macOS) run: | xcrun altool --notarize-app -f ${{github.workspace}}/build/artifactOut/GpgFrontend-${{steps.vars.outputs.sha_short}}-x86_64.dmg --primary-bundle-id pub.gpgfrontend.gpgfrontend -u ${{secrets.APPLE_DEVELOPER_ID}} -p ${{secrets.APPLE_DEVELOPER_ID_SECRET}} - if: matrix.os == 'macos-latest' + if: matrix.os == 'macos-10.15' - name: Package App Image (Linux) run: | @@ -203,7 +202,7 @@ jobs: with: name: gpgfrontend-${{matrix.os}}-${{env.BUILD_TYPE}}-${{steps.vars.outputs.sha_short}} path: ${{github.workspace}}/build/artifactOut/* - if: matrix.os == 'macos-latest' + if: matrix.os == 'macos-10.15' - name: Upload Artifact(Windows) uses: actions/upload-artifact@master diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1231d9cd..c707ac2a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: build: strategy: matrix: - os: [ 'ubuntu-18.04', 'macos-latest', 'windows-latest' ] + os: [ 'ubuntu-18.04', 'macos-10.15', 'windows-latest' ] runs-on: ${{ matrix.os }} steps: @@ -57,7 +57,7 @@ jobs: security import certificate.p12 -k build.keychain -P ${{secrets.MAOS_CERTIFICATE_PWD}} -T /usr/bin/codesign security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k gpgfrontend build.keychain security set-keychain-settings -lut 3600 - if: matrix.os == 'macos-latest' + if: matrix.os == 'macos-10.15' - name: Install Dependence (macOS) run: | @@ -67,7 +67,7 @@ jobs: brew link qt@5 brew link gcc brew link openssl --force - if: matrix.os == 'macos-latest' + if: matrix.os == 'macos-10.15' - name: Cache Qt id: cache-qt @@ -122,7 +122,7 @@ jobs: ./configure --enable-maintainer-mode --enable-static=yes --enable-languages=cpp && make -j2 sudo make install cd ${{github.workspace}} - if: matrix.os == 'ubuntu-18.04' || matrix.os == 'macos-latest' + if: matrix.os == 'ubuntu-18.04' || matrix.os == 'macos-10.15' - name: Build GpgME (Windows) shell: msys2 {0} @@ -138,12 +138,12 @@ jobs: # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DEXECUTABLE_OUTPUT_PATH=${{env.EXECUTABLE_OUTPUT_PATH}} - if: matrix.os == 'ubuntu-18.04' || matrix.os == 'macos-latest' + if: matrix.os == 'ubuntu-18.04' || matrix.os == 'macos-10.15' - name: Build GpgFrontend # Build your program with the given configuration run: cmake --build ${{github.workspace}}/build --config $env.BUILD_TYPE}} -- -j 2 - if: matrix.os == 'ubuntu-18.04' || matrix.os == 'macos-latest' + if: matrix.os == 'ubuntu-18.04' || matrix.os == 'macos-10.15' - name: Build & Sign App Bundle (macOS) run: | @@ -151,7 +151,7 @@ jobs: macdeployqt ${{github.workspace}}/build/release/GpgFrontend.app codesign --deep --force --options=runtime -s "Developer ID Application: Yu Hu (4279AWUL3X)" ${{github.workspace}}/build/release/GpgFrontend.app -v mkdir ${{github.workspace}}/build/tmp/ - if: matrix.os == 'macos-latest' + if: matrix.os == 'macos-10.15' - name: Package & Sign App Bundle (macOS) run: | @@ -161,12 +161,12 @@ jobs: hdiutil convert ${{github.workspace}}/build/tmp/tmp.dmg -format UDZO -o ${{github.workspace}}/build/artifactOut/GpgFrontend.dmg codesign -s "Developer ID Application: Yu Hu (4279AWUL3X)" ${{github.workspace}}/build/artifactOut/GpgFrontend.dmg mv ${{github.workspace}}/build/artifactOut/GpgFrontend.dmg ${{github.workspace}}/build/artifactOut/GpgFrontend-${{steps.vars.outputs.sha_short}}-x86_64.dmg - if: matrix.os == 'macos-latest' + if: matrix.os == 'macos-10.15' - name: Notarize Release Build (macOS) run: | xcrun altool --notarize-app -f ${{github.workspace}}/build/artifactOut/GpgFrontend-${{steps.vars.outputs.sha_short}}-x86_64.dmg --primary-bundle-id pub.gpgfrontend.gpgfrontend -u ${{secrets.APPLE_DEVELOPER_ID}} -p ${{secrets.APPLE_DEVELOPER_ID_SECRET}} - if: matrix.os == 'macos-latest' + if: matrix.os == 'macos-10.15' - name: Package App Image (Linux) run: | @@ -203,7 +203,7 @@ jobs: with: name: gpgfrontend-${{matrix.os}}-${{env.BUILD_TYPE}}-${{steps.vars.outputs.sha_short}} path: ${{github.workspace}}/build/artifactOut/* - if: matrix.os == 'macos-latest' + if: matrix.os == 'macos-10.15' - name: Upload Artifact(Windows) uses: actions/upload-artifact@master diff --git a/CMakeLists.txt b/CMakeLists.txt index d9091340..c73e14ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -256,9 +256,7 @@ elseif (STABLE_APPLICATION_BUILD) set(APPLICATION_BUILD 1) set(BASIC_ENV_CONFIG 1) # MULTI_LANG_SUPPORT now work only on Linux and macOS - if (LINUX OR APPLE) - set(MULTI_LANG_SUPPORT 1) - endif () + set(MULTI_LANG_SUPPORT 1) elseif (TEST_BUILD) message(STATUS "Build Test Cases") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9ec83bc8..0c75be69 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -83,17 +83,16 @@ if (MULTI_LANG_SUPPORT) GET_FILENAME_COMPONENT(_poFileName ${_poFile} NAME) string(REGEX REPLACE "\\.[^.]*$" "" _langName ${_poFileName}) message(STATUS "_poFileName ${_langName}") - make_directory(${CMAKE_SOURCE_DIR}/resource/locale/out/${_langName}/LC_MESSAGES) + make_directory(${RESOURCE_OUTPUT_DIRECTORY}/locales) + make_directory(${RESOURCE_OUTPUT_DIRECTORY}/locales/${_langName}/LC_MESSAGES) add_custom_command( TARGET translations COMMAND echo Processing po LANG ${_langName} ) add_custom_command( TARGET translations - COMMAND msgfmt --check --verbose --output-file ${CMAKE_SOURCE_DIR}/resource/locale/out/${_langName}/LC_MESSAGES/GpgFrontend.mo ${_poFile} + COMMAND msgfmt --check --verbose --output-file ${RESOURCE_OUTPUT_DIRECTORY}/locales/${_langName}/LC_MESSAGES/GpgFrontend.mo ${_poFile} ) - add_custom_command(TARGET translations - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/resource/locale/out/ ${RESOURCE_OUTPUT_DIRECTORY}/locales) endforeach () endif () @@ -109,10 +108,6 @@ if (APPLICATION_BUILD) # Copy Resource Files file(COPY ${CMAKE_SOURCE_DIR}/resource/css DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN) file(COPY ${CMAKE_SOURCE_DIR}/resource/icons DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN) - if (MULTI_LANG_SUPPORT) - make_directory(${RESOURCE_OUTPUT_DIRECTORY}/locales) - file(COPY ${CMAKE_SOURCE_DIR}/resource/locale/out/ DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/locales FOLLOW_SYMLINK_CHAIN) - endif () file(COPY ${CMAKE_SOURCE_DIR}/TRANSLATORS DESTINATION ${RESOURCE_OUTPUT_DIRECTORY} FOLLOW_SYMLINK_CHAIN) endif () diff --git a/src/main.cpp b/src/main.cpp index f4739767..1dbf1d5e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,6 +42,11 @@ int main(int argc, char* argv[]) { QApplication app(argc, argv); QApplication::setWindowIcon(QIcon(":gpgfrontend.png")); +#ifdef MACOS + // support retina screen + QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); +#endif + // logging system init_logging(); @@ -55,7 +60,7 @@ int main(int argc, char* argv[]) { // unicode in source QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf-8")); -#ifdef WINDOWS +#if !defined(RELEASE) // css QFile file(RESOURCE_DIR(qApp->applicationDirPath()) + "/css/default.qss"); file.open(QFile::ReadOnly); @@ -142,13 +147,13 @@ void init_locale() { .GetLocaleDir() .c_str(); +#ifndef WINDOWS if (!lang.empty()) { std::string lc = lang.empty() ? "" : lang + ".UTF-8"; // set LC_ALL auto* locale_name = setlocale(LC_ALL, lc.c_str()); if (locale_name == nullptr) LOG(WARNING) << "set LC_ALL failed" << lc; -#ifndef WINDOWS auto language = getenv("LANGUAGE"); // set LANGUAGE std::string language_env = language == nullptr ? "en" : language; @@ -157,13 +162,32 @@ void init_locale() { if (setenv("LANGUAGE", language_env.c_str(), 1)) { LOG(WARNING) << "set LANGUAGE failed" << language_env; }; -#endif } +#else + if (!lang.empty()) { + std::string lc = lang.empty() ? "" : lang; + + // set LC_ALL + auto* locale_name = setlocale(LC_ALL, lc.c_str()); + if (locale_name == nullptr) LOG(WARNING) << "set LC_ALL failed" << lc; + + auto language = getenv("LANGUAGE"); + // set LANGUAGE + std::string language_env = language == nullptr ? "en" : language; + language_env.insert(0, lang + ":"); + language_env.insert(0, "LANGUAGE="); + LOG(INFO) << "language env" << language_env; + if (putenv(language_env.c_str())) { + LOG(WARNING) << "set LANGUAGE failed" << language_env; + }; + } +#endif bindtextdomain(PROJECT_NAME, GpgFrontend::UI::GlobalSettingStation::GetInstance() .GetLocaleDir() .string() .c_str()); + bind_textdomain_codeset(PROJECT_NAME, "utf-8"); textdomain(PROJECT_NAME); } diff --git a/src/ui/widgets/FilePage.cpp b/src/ui/widgets/FilePage.cpp index d031114a..c51e0c76 100644 --- a/src/ui/widgets/FilePage.cpp +++ b/src/ui/widgets/FilePage.cpp @@ -112,12 +112,17 @@ FilePage::FilePage(QWidget* parent) : QWidget(parent) { &FilePage::onCustomContextMenu); connect(pathEdit, &QLineEdit::textChanged, [=]() { - auto dir = QDir(pathEdit->text()); - if (dir.isReadable()) { + auto path = pathEdit->text(); + auto dir = QDir(path); + if (path.endsWith("/") && dir.isReadable()) { auto dir_list = dir.entryInfoList(QDir::AllEntries); QStringList paths; - for (int i = 1; i < dir_list.size(); i++) - paths.append(dir_list.at(i).filePath()); + for (int i = 1; i < dir_list.size(); i++) { + const auto file_path = dir_list.at(i).filePath(); + const auto file_name = dir_list.at(i).fileName(); + if (file_name == "." || file_name == "..") continue; + paths.append(file_path); + } pathCompleteModel->setStringList(paths); } }); |