Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated fcitx required for supporting various input methods #218

Open
maichaide opened this issue Oct 3, 2022 · 14 comments
Open

Updated fcitx required for supporting various input methods #218

maichaide opened this issue Oct 3, 2022 · 14 comments
Labels
linux Related specifically to Linux-based OSs

Comments

@maichaide
Copy link

If possible, please consider supporting input methods under linux, such as fcitx and ibus, which can't input Chinese at present.

@dail8859
Copy link
Owner

dail8859 commented Oct 3, 2022

I'm not familiar with fcitx, ibus, or dealing with any types of input methods. Not sure if this is something that needs adjusted in Qt or Scintilla currently.

@NichtsHsu
Copy link

我印象中这是 Qt 的问题,如果是 fcitx,需要把 libfcitxplatforminputcontextplugin.so 放在某个目录去加载。具体的细节不太记得了

@dail8859
Copy link
Owner

dail8859 commented Oct 9, 2022

@NichtsHsu Thanks for the info. Scintilla seems to have some sort of support for IME events, but not sure myself how to test it. Hopefully someone more familiar with it can give it a shot.

@imkos
Copy link

imkos commented Oct 10, 2022

try https://aur.archlinux.org/packages/fcitx5-qt6-git, I succeeded. use fcitx5 replace fcitx

@dail8859
Copy link
Owner

@imkos Thanks for looking into this! There isn't much information about fcitx and Qt, but the only thing I found was exactly what you suggested, and that is to update fcitx.

So I guess the question is now is if this project is able to do anything to address this? Or best to leave it up to the user (and possibly document the solution somewhere).

@NichtsHsu
Copy link

NichtsHsu commented Oct 21, 2022

Hi everybody, here is a way to build NotepadNext with fcitx support.

  1. Clone fcitx-qt5.

  2. Install extra-cmake-modules package.

  3. export your Qt toolkit to $PATH, in my case, it means:

    export PATH=~/Qt/6.4.0/gcc_64/bin:~/Qt/Tools/CMake/bin:$PATH
  4. Enter fcitx-qt5 folder.

  5. If you are using Qt6 like me, modify the CMakeLists.txt as following:

    diff --git a/CMakeLists.txt b/CMakeLists.txt
    index f9c95af..9358528 100644
    --- a/CMakeLists.txt
    +++ b/CMakeLists.txt
    @@ -10,8 +10,8 @@ find_package(ECM 1.4.0 REQUIRED NO_MODULE)
    
     set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} 
    ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
    
    -option(ENABLE_QT5 "Enable Qt5" On)
    -option(ENABLE_QT6 "Enable Qt6 im module" Off)
    +option(ENABLE_QT5 "Enable Qt5" off)
    +option(ENABLE_QT6 "Enable Qt6 im module" on)
     option(ENABLE_LIBRARY "Qt library" On)
    
     include(GNUInstallDirs)
  6. Build it:

    mkdir build && cd build
    cmake ../
    make -j8
  7. Copy the fcitx-qt5/build/qt6/platforminputcontext/libfcitxplatforminputcontextplugin-qt6.so to ~/Qt/6.4.0/gcc_64/plugins/platforminputcontexts/ in my case. Should be similar in Qt5.

  8. Open Qt Creator, build NotepadNext, now you can use fcitx to input Chinese or others.

    image

@NichtsHsu
Copy link

I think packaging this library in Appimage allows NotepadNext to support fcitx easily.

@dail8859
Copy link
Owner

@NichtsHsu Thanks! If/when this project moves to cmake then this might be the best solution.

So what is the root cause of the need to package fcitx manually? Do Linux OSs just not have an up-to-date fcitx installed by default?

@NichtsHsu
Copy link

@dail8859 I guess it might be related with how the AppImage is packaged and executed.

On Ubuntu, fcitx-qt5 is included in the package fcitx5-frontend-qt5. After installing this package, the library file libfcitxplatforminputcontextplugin.so will be installed in the /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/ directory. At this point, use Qt5 to compile NotepadNext in Qt Creator, and you can input Chinese normally when running program. However, when running your AppImage, fcitx is still not responding.

I observed several Qt programs on my PC and found that some of them installed this library file in their own directory:

$ locate libfcitxplatforminputcontextplugin.so
/opt/kingsoft/wps-office/office6/qt/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so
/opt/zoom/platforminputcontexts/libfcitxplatforminputcontextplugin.so

I'm not sure why, but they should have a reason for doing so.

@dail8859
Copy link
Owner

@NichtsHsu Thanks for the excellent info as always!

I'm not sure why, but they should have a reason for doing so.

Agreed. This would seem to indicate that they've ran into this issue before and came to the same conclusion.

@dail8859 dail8859 changed the title support input methods, pls Updated fcitx required for supporting various input methods Oct 29, 2022
@wineee
Copy link

wineee commented Feb 2, 2023

I'm not sure why, but they should have a reason for doing so.

wps use vendor libraries, they can't install libfcitxplatforminputcontextplugin.so to /usr/lib,otherwise it will conflict with fcitx-qt5

wps will set QT_PLUGIN_PATH environment variable when startup,to use this library
export QT_PLUGIN_PATH=/opt/kingsoft/wps-office/office6/qt/plugins

@dail8859 dail8859 added the linux Related specifically to Linux-based OSs label Mar 29, 2023
@shenlebantongying
Copy link

The method mentioned by @NichtsHsu is the right direction.

I added fcitx's support to another Qt6 app and it works:

xiaoyifang/goldendict-ng#802


linuxdeployqt will scan the qt's platforminputcontexts folder.

https://github.com/probonopd/linuxdeployqt/blob/8428c59318b250058e6cf93353e2871072bbf7f9/tools/linuxdeployqt/shared.cpp#L1379-L1381

Just install the libfcitx5platforminputcontextplugin.so to the corresponding qt's dir, and let linuxdeployqt to do the rest.


If AppDir/usr/plugins/platforminputcontexts/libfcitx5platforminputcontextplugin.so exist in the built appimage, then fcitx should work.

P.S. I googled related problems and I somehow came to this issue. I don't even know what is this project. Hopefully, my PR can be a reference if someone wants to add related code to this project's build script :)

@shenlebantongying
Copy link

shenlebantongying commented Jun 3, 2023

So what is the root cause of the need to package fcitx manually?

No, not bundle fcitx entirely, just an im (input method) plugin (which I don't know in great detail, the app needs to load it so that the fcitx on the host system can communicate with the app?)

There is probably already an ibus plugin under AppDir/usr/plugins/platforminputcontexts/.

Do Linux OSs just not have an up-to-date fcitx installed by default?

Yes, they have, but appimage needs the lowest version possible, and ubuntu20.04 don't have fcitx's qt6 plugin, so we have to build one manually (or bump the ubuntu version to 22.10 and just sudo apt-get install fcitx5-frontend-qt6 in the CI).

@aohanhongzhi
Copy link

Hi everybody, here is a way to build NotepadNext with fcitx support.

  1. Clone fcitx-qt5.
  2. Install extra-cmake-modules package.
  3. export your Qt toolkit to $PATH, in my case, it means:
    export PATH=~/Qt/6.4.0/gcc_64/bin:~/Qt/Tools/CMake/bin:$PATH
  4. Enter fcitx-qt5 folder.
  5. If you are using Qt6 like me, modify the CMakeLists.txt as following:
    diff --git a/CMakeLists.txt b/CMakeLists.txt
    index f9c95af..9358528 100644
    --- a/CMakeLists.txt
    +++ b/CMakeLists.txt
    @@ -10,8 +10,8 @@ find_package(ECM 1.4.0 REQUIRED NO_MODULE)
    
     set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} 
    ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
    
    -option(ENABLE_QT5 "Enable Qt5" On)
    -option(ENABLE_QT6 "Enable Qt6 im module" Off)
    +option(ENABLE_QT5 "Enable Qt5" off)
    +option(ENABLE_QT6 "Enable Qt6 im module" on)
     option(ENABLE_LIBRARY "Qt library" On)
    
     include(GNUInstallDirs)
  6. Build it:
    mkdir build && cd build
    cmake ../
    make -j8
  7. Copy the fcitx-qt5/build/qt6/platforminputcontext/libfcitxplatforminputcontextplugin-qt6.so to ~/Qt/6.4.0/gcc_64/plugins/platforminputcontexts/ in my case. Should be similar in Qt5.
  8. Open Qt Creator, build NotepadNext, now you can use fcitx to input Chinese or others.
    image

pls add the code and PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linux Related specifically to Linux-based OSs
Projects
None yet
Development

No branches or pull requests

7 participants