Skip to content

Commit

Permalink
Merge pull request #95 from dobey/plugin-fixups
Browse files Browse the repository at this point in the history
Fix some issues with the language plugins
  • Loading branch information
dobey authored Feb 9, 2022
2 parents fd8f95d + 1fc4cce commit 54e5d03
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
23 changes: 15 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ set(WESTERNSUPPORT_SOURCES
plugins/westernsupport/westernlanguagesplugin.h
plugins/westernsupport/westernsupport.cpp
plugins/westernsupport/westernsupport.h
plugins/westernsupport/westernsupport_global.h
src/lib/logic/abstractlanguageplugin.cpp
src/lib/logic/abstractlanguageplugin.h)
plugins/westernsupport/westernsupport_global.h)

# TODO install logic/languageplugininterface.h and logic/abstractplugininterface.h as HEADERS

Expand Down Expand Up @@ -207,21 +205,29 @@ target_include_directories(westernsupport PUBLIC src/lib/logic plugins/westernsu
target_compile_definitions(westernsupport PRIVATE ${maliit-keyboard-definitions})

function(language_plugin _language _full_language _ebook)
# To support layout style variations such as en@dv we need to avoid using
# the @ character in variables, so split and replace it with _
set(_target ${_language})
if(${_language} MATCHES "^(.*)\@(.*)$")
set(_target ${CMAKE_MATCH_1}_${CMAKE_MATCH_2})
endif()

set(PLUGIN_SOURCES
plugins/${_language}/src/${_full_language}plugin.h
plugins/${_language}/src/${_full_language}plugin.json)
if(enable-presage)
add_ngram(TEXT plugins/${_language}/src/${_ebook} DATABASE database_${_language}.db)
list(APPEND PLUGIN_SOURCES database_${_language}.db)
endif()
add_library(${_language}plugin MODULE ${PLUGIN_SOURCES})
target_link_libraries(${_language}plugin westernsupport)
add_library(${_target}plugin MODULE ${PLUGIN_SOURCES})
set_target_properties(${_target}plugin PROPERTIES OUTPUT_NAME ${_language}plugin)
target_link_libraries(${_target}plugin maliit-keyboard-common westernsupport)
install(FILES plugins/${_language}/qml/Keyboard_${_language}.qml
plugins/${_language}/qml/Keyboard_${_language}_email.qml
plugins/${_language}/qml/Keyboard_${_language}_url.qml
plugins/${_language}/qml/Keyboard_${_language}_url_search.qml
DESTINATION ${MALIIT_KEYBOARD_LANGUAGES_DIR}/${_language})
install(TARGETS ${_language}plugin
install(TARGETS ${_target}plugin
LIBRARY DESTINATION ${MALIIT_KEYBOARD_LANGUAGES_DIR}/${_language})
if(enable-presage)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/database_${_language}.db
Expand Down Expand Up @@ -279,7 +285,8 @@ function(abstract_language_plugin _language _full_language)
list(APPEND PLUGIN_SOURCES database_${_language}.db)
endif()
add_library(${_target}plugin MODULE ${PLUGIN_SOURCES})
target_link_libraries(${_target}plugin Qt5::Core Maliit::Plugins ${abstract_language_plugin_LIBRARIES})
set_target_properties(${_target}plugin PROPERTIES OUTPUT_NAME ${_language}plugin)
target_link_libraries(${_target}plugin Qt5::Core Maliit::Plugins maliit-keyboard-common ${abstract_language_plugin_LIBRARIES})
target_include_directories(${_target}plugin PRIVATE src/lib/logic ${abstract_language_plugin_INCLUDE_DIRS})
target_compile_definitions(${_target}plugin PRIVATE ${abstract_language_plugin_DEFINITIONS})
install(TARGETS ${_target}plugin
Expand Down Expand Up @@ -344,7 +351,7 @@ abstract_language_plugin(en@dv englishdvorak
FILES src/overrides.csv
LIBRARIES westernsupport)
abstract_language_plugin(fr-ch french LIBRARIES westernsupport)
abstract_language_plugin(th thai LIBRARIES westernsupport DIRECTORY qml/keys)
abstract_language_plugin(th thai DIRECTORY qml/keys)

if(Anthy_FOUND)
abstract_language_plugin(ja japanese ABSTRACT_LANGUAGE_PLUGIN
Expand Down
5 changes: 2 additions & 3 deletions src/plugin/inputmethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,9 +773,8 @@ bool InputMethod::languageIsSupported(const QString plugin) {
void InputMethod::onLanguageChanged(const QString &language) {
Q_D(InputMethod);
for (const auto& languagePath : std::as_const(d->languagesPaths)) {
QPluginLoader languagePlugin(QStringLiteral("%1/%2/lib%2plugin.so").arg(languagePath, language));
const auto& metaData = languagePlugin.metaData();
if (metaData.value(u8"IID").toString() == QLatin1String("io.maliit.keyboard.LanguagePlugin.1")) {
QFile languagePlugin(languagePath + QDir::separator() + language + QDir::separator() + QStringLiteral("lib%1plugin.so").arg(language));
if (languagePlugin.exists()) {
Q_EMIT languagePluginChanged(languagePlugin.fileName(), language);
return;
}
Expand Down

0 comments on commit 54e5d03

Please sign in to comment.