diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 5e8f8eb..64ddafd 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -47,15 +47,14 @@ jobs: uses: actions/cache@v4 with: path: 'fcitx5/**/*.tar.*' - key: ${{ runner.os }}-${{ hashFiles('fcitx5/src/modules/spell/CMakeLists.txt') - }} + key: ${{ runner.os }}-${{ hashFiles('fcitx5/src/modules/spell/CMakeLists.txt') }} - name: Build and Install fcitx5 uses: fcitx/github-actions@cmake with: path: fcitx5 cmake-option: >- -DENABLE_KEYBOARD=Off -DENABLE_X11=Off -DENABLE_WAYLAND=Off -DENABLE_ENCHANT=Off - -DENABLE_DBUS=Off -DENABLE_SERVER=Off -DENABLE_EMOJI=Off -DUSE_SYSTEMD=Off + -DENABLE_DBUS=Off -DENABLE_SERVER=Off -DENABLE_EMOJI=Off -DUSE_SYSTEMD=Off -DENABLE_TEST=Off - uses: actions/checkout@v4 with: repository: fcitx/fcitx5-qt diff --git a/CMakeLists.txt b/CMakeLists.txt index 53b05a9..a12d158 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ include(ECMUninstallTarget) include(FeatureSummary) find_package(PkgConfig REQUIRED) -find_package(Fcitx5Core 5.0.6 REQUIRED) +find_package(Fcitx5Core 5.1.12 REQUIRED) find_package(Gettext REQUIRED) pkg_check_modules(GObject2 IMPORTED_TARGET "gobject-2.0" REQUIRED) find_package(LibSKK REQUIRED) diff --git a/src/skk.cpp b/src/skk.cpp index 2909ff1..5af6288 100644 --- a/src/skk.cpp +++ b/src/skk.cpp @@ -501,6 +501,12 @@ void SkkEngine::loadDictionary() { continue; } if (mode == 1) { + std::string_view partialpath = path; + if (stringutils::consumePrefix(partialpath, + "$XDG_DATA_DIRS/")) { + path = StandardPath::global().locate( + StandardPath::Type::Data, std::string(partialpath)); + } if (stringutils::endsWith(path, ".cdb")) { SkkCdbDict *dict = skk_cdb_dict_new(path.data(), encoding.data(), nullptr); @@ -517,19 +523,18 @@ void SkkEngine::loadDictionary() { } } } else { - constexpr char configDir[] = "$FCITX_CONFIG_DIR/"; - constexpr auto len = sizeof(configDir) - 1; - std::string realpath = path; - if (stringutils::startsWith(path, configDir)) { - realpath = stringutils::joinPath( + std::string_view partialpath = path; + if (stringutils::consumePrefix(partialpath, + "$FCITX_CONFIG_DIR/")) { + path = stringutils::joinPath( StandardPath::global().userDirectory( StandardPath::Type::PkgData), - path.substr(len)); + partialpath); } - SkkUserDict *userdict = skk_user_dict_new( - realpath.data(), encoding.data(), nullptr); + SkkUserDict *userdict = + skk_user_dict_new(path.data(), encoding.data(), nullptr); if (userdict) { - SKK_DEBUG() << "Adding user dict: " << realpath; + SKK_DEBUG() << "Adding user dict: " << path; dictionaries_.emplace_back(SKK_DICT(userdict)); } }