NotepadNext icon indicating copy to clipboard operation
NotepadNext copied to clipboard

Updated fcitx required for supporting various input methods

Open maichaide opened this issue 3 years ago • 16 comments

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

maichaide avatar Oct 03 '22 15:10 maichaide

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.

dail8859 avatar Oct 03 '22 16:10 dail8859

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

NichtsHsu avatar Oct 08 '22 08:10 NichtsHsu

@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.

dail8859 avatar Oct 09 '22 01:10 dail8859

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

imkos avatar Oct 10 '22 06:10 imkos

@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).

dail8859 avatar Oct 10 '22 11:10 dail8859

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 avatar Oct 21 '22 05:10 NichtsHsu

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

NichtsHsu avatar Oct 21 '22 05:10 NichtsHsu

@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?

dail8859 avatar Oct 24 '22 12:10 dail8859

@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.

NichtsHsu avatar Oct 25 '22 05:10 NichtsHsu

@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 avatar Oct 25 '22 12:10 dail8859

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

wineee avatar Feb 02 '23 14:02 wineee

The method mentioned by @NichtsHsu is the right direction.

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

https://github.com/xiaoyifang/goldendict-ng/pull/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 avatar Jun 03 '23 10:06 shenlebantongying

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).

shenlebantongying avatar Jun 03 '23 10:06 shenlebantongying

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

aohanhongzhi avatar Jan 19 '24 12:01 aohanhongzhi