Enable IME support in AppImage (#116)

* Linux package: add fcitx5-qt to AppImage build environment

* Linux package: add static link to ime plugins
This commit is contained in:
Cyano Hao 2023-07-03 14:06:10 +08:00 committed by GitHub
parent b571e5f535
commit c7a95d9eab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 47 additions and 5 deletions

1
.gitattributes vendored
View File

@ -6,6 +6,7 @@
/packages/appimage/01-in-docker.sh eol=lf
# text files to be packed
/packages/appimage/AppRun.sh eol=lf
/platform/linux/install.sh eol=lf
/platform/linux/redpandaide.desktop.in eol=lf
/platform/linux/redpandaide.svg eol=lf

View File

@ -13,12 +13,14 @@
# Linux
- Install gcc and qt5
- Optionally install fcitx5-qt for building with static version of Qt
- Open `Red_Panda_CPP.pro` with Qt Creator
qmake variables:
- `PREFIX`: default to `/usr/local`. It should be set to `/usr` or `/opt/redpanda-cpp` when packaging.
- `LIBEXECDIR`: directory for auxiliary executables, default to `$PREFIX/libexec`. Arch Linux uses `/usr/lib`.
- `XDG_ADAPTIVE_ICON=ON`: install the icon file following [freedesktop.org Icon Theme Specification](https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html) for adaptiveness to themes and sizes. Required by AppImage; recommended for Linux packaging if `PREFIX` set to `/usr`.
- `LINUX_STATIC_IME_PLUGIN=ON` (make phase): link to static ime plugin. Recommended for building with static version of Qt; **DO NOT** set for dynamic version of Qt.
## Ubuntu

View File

@ -16,12 +16,14 @@
步骤:
- 安装 gcc 和 qt5开发相关包
- 如果使用静态版本的 Qt 编译,还要安装 fcitx5-qt
- 使用qtcreator打开Red_Panda_CPP.pro文件
qmake 变量:
- `PREFIX`:默认值是 `/usr/local`。打包时应该定义为 `/usr``/opt/redpanda-cpp`
- `LIBEXECDIR`:辅助程序的路径,默认值是 `$PREFIX/libexec`。Arch Linux 使用 `/usr/lib`
- `XDG_ADAPTIVE_ICON=ON`:遵循 [freedesktop.org 图标主题规范](https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html)安装图标以适应不同的主题和尺寸。AppImage 需要启用此项Linux 打包 `PREFIX=/usr` 时推荐启用此项。
- `LINUX_STATIC_IME_PLUGIN=ON`make 阶段):静态链接输入法插件。推荐在使用静态版本的 Qt 编译时启用;**不要**在使用动态版本的 Qt 编译时启用。
## Ubuntu

View File

@ -454,6 +454,17 @@ unix: {
linux: {
LIBS+= \
-lrt
_LINUX_STATIC_IME_PLUGIN = $$(LINUX_STATIC_IME_PLUGIN)
equals(_LINUX_STATIC_IME_PLUGIN, "ON") {
SOURCES += \
resources/linux_static_ime_plugin.cpp
QTPLUGIN.platforminputcontexts += \
composeplatforminputcontextplugin \
fcitx5platforminputcontextplugin \
ibusplatforminputcontextplugin
LIBS += -L$$[QT_INSTALL_PLUGINS]/platforminputcontexts
}
}
TRANSLATIONS += \

View File

@ -0,0 +1,8 @@
#include <QtPlugin>
// explicitily reference the symbols for the plugins
// so the linker will pull them in during static linking
Q_IMPORT_PLUGIN(QComposePlatformInputContextPlugin)
Q_IMPORT_PLUGIN(QFcitx5PlatformInputContextPlugin)
Q_IMPORT_PLUGIN(QIbusPlatformInputContextPlugin)

View File

@ -9,7 +9,7 @@ APPIMAGE_FILE=RedPandaIDE-$VERSION-$CARCH.AppImage
mkdir -p /build/redpanda-build
cd /build/redpanda-build
qmake PREFIX='/usr' XDG_ADAPTIVE_ICON=ON /build/RedPanda-CPP/Red_Panda_CPP.pro
make -j$(nproc)
make LINUX_STATIC_IME_PLUGIN=ON -j$(nproc)
# install RedPanda C++ to AppDir
make install INSTALL_ROOT=/build/RedPandaIDE.AppDir

View File

@ -7,7 +7,7 @@ RUN sed -i 's|ports.ubuntu.com|mirrors.ustc.edu.cn|g' /etc/apt/sources.list && \
export DEBIAN_FRONTEND=noninteractive && \
apt update && \
apt upgrade -y && \
apt install --no-install-recommends -y ca-certificates cargo curl cmake file gcc g++ make \
apt install --no-install-recommends -y ca-certificates cargo curl cmake extra-cmake-modules file gcc g++ make \
libatspi2.0-dev libdbus-1-dev libfontconfig1-dev libfreetype6-dev libgl1-mesa-dev libxkbcommon-x11-dev
# AppImageKit
@ -17,7 +17,9 @@ RUN curl -L -o /usr/local/bin/appimagetool 'https://github.com/AppImage/AppImage
# Qt 5
RUN mkdir -p /build/qt5 && \
cd /build/qt5 && \
curl -O 'https://mirrors.ustc.edu.cn/qtproject/archive/qt/5.12/5.12.12/submodules/qt{base,svg,tools}-everywhere-src-5.12.12.tar.xz' && \
curl -O 'https://download.qt.io/archive/qt/5.12/5.12.12/submodules/qt{base,svg,tools}-everywhere-src-5.12.12.tar.xz' && \
# fcitx5-qt 5.0.6 is the last version compatible with ubuntu 18.04s cmake 3.10
curl -L -o fcitx5-qt-5.0.6.tar.gz 'https://github.com/fcitx/fcitx5-qt/archive/refs/tags/5.0.6.tar.gz' && \
tar xf qtbase-everywhere-src-5.12.12.tar.xz && \
cd qtbase-everywhere-src-5.12.12 && \
./configure \
@ -42,6 +44,14 @@ RUN mkdir -p /build/qt5 && \
qmake . && \
make -j$(nproc) && \
make install && \
# fcitx5 package
cd /build/qt5 && \
tar xf fcitx5-qt-5.0.6.tar.gz && \
cd fcitx5-qt-5.0.6 && \
cmake . -Bbuild -DCMAKE_MODULE_PATH=/usr/local/lib/cmake -DCMAKE_PREFIX_PATH=/usr/local -DCMAKE_BUILD_TYPE=Release -DENABLE_QT4=Off -DENABLE_QT5=On -DENABLE_QT6=Off -DBUILD_ONLY_PLUGIN=On -DBUILD_STATIC_PLUGIN=On && \
# cmake 3.10 is too old to build with `--parallel` option
cmake --build build -- -j$(nproc) && \
cmake --install build && \
# cleanup
cd / && \
rm -r /build/qt5

View File

@ -8,7 +8,7 @@ RUN sed -i 's|^mirrorlist=|#mirrorlist=|g; s|^#baseurl=http://mirror.centos.org/
sed -i 's|^mirrorlist=|#mirrorlist=|g; s|^#baseurl=http://mirror.centos.org/centos|baseurl=https://mirrors.ustc.edu.cn/centos|g' /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo && \
sed -i 's|^metalink=|#metalink=|g; s|^#baseurl=https\?://download.fedoraproject.org/pub/epel/|baseurl=https://mirrors.ustc.edu.cn/epel/|g' /etc/yum.repos.d/epel.repo && \
yum upgrade -y && \
yum install -y cargo cmake3 file make which \
yum install -y cargo cmake3 extra-cmake-modules file make which \
at-spi2-core-devel dbus-devel fontconfig-devel freetype-devel glib2-devel libXrender-devel libxcb-devel libxkbcommon-devel libxkbcommon-x11-devel mesa-libGL-devel xcb-util-devel \
devtoolset-7-gcc devtoolset-7-gcc-c++
@ -23,7 +23,8 @@ RUN curl -L -o /usr/local/bin/appimagetool 'https://github.com/AppImage/AppImage
# Qt 5
RUN mkdir -p /build/qt5 && \
cd /build/qt5 && \
curl -O 'https://mirrors.ustc.edu.cn/qtproject/archive/qt/5.12/5.12.12/submodules/qt{base,svg,tools}-everywhere-src-5.12.12.tar.xz' && \
curl -O 'https://download.qt.io/archive/qt/5.12/5.12.12/submodules/qt{base,svg,tools}-everywhere-src-5.12.12.tar.xz' && \
curl -L -o fcitx5-qt-5.0.17.tar.gz 'https://github.com/fcitx/fcitx5-qt/archive/refs/tags/5.0.17.tar.gz' && \
tar xf qtbase-everywhere-src-5.12.12.tar.xz && \
cd qtbase-everywhere-src-5.12.12 && \
./configure \
@ -48,6 +49,13 @@ RUN mkdir -p /build/qt5 && \
qmake . && \
make -j$(nproc) && \
make install && \
# fcitx5 package
cd /build/qt5 && \
tar xf fcitx5-qt-5.0.17.tar.gz && \
cd fcitx5-qt-5.0.17 && \
cmake3 . -Bbuild -DCMAKE_MODULE_PATH=/usr/local/lib/cmake -DCMAKE_PREFIX_PATH=/usr/local -DCMAKE_BUILD_TYPE=Release -DENABLE_QT4=Off -DENABLE_QT5=On -DENABLE_QT6=Off -DBUILD_ONLY_PLUGIN=On -DBUILD_STATIC_PLUGIN=On && \
cmake3 --build build --parallel && \
cmake3 --install build && \
# cleanup
cd / && \
rm -r /build/qt5