Update XDG desktop integration (#222)

* add XDG MIME support

* force XDG icon spec

With the addition of MIME support, it is no longer possible to integrate with desktop environment by simply moving desktop file to standard location. Now force XDG_ADAPTIVE_ICON=ON.

If you build Red Panda C++ with non-standard PREFIX, you will move all desktop integration components to standard location.
This commit is contained in:
Cyano Hao 2024-02-26 10:51:15 +08:00 committed by GitHub
parent b59342a602
commit f291470f5b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 32 additions and 24 deletions

View File

@ -253,9 +253,8 @@ qmake-based build steps:
```
qmake variables:
- `PREFIX`: default to `/usr/local`. It should be set to `/usr` or `/opt/redpanda-cpp` when packaging.
- `PREFIX`: default to `/usr/local`. It should be set to `/usr` 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.
xmake-based build steps:

View File

@ -253,9 +253,8 @@ qmake 变量:
```
qmake 变量:
- `PREFIX`:默认值是 `/usr/local`。打包时应该定义为 `/usr``/opt/redpanda-cpp`
- `PREFIX`:默认值是 `/usr/local`。打包时应该定义为 `/usr`
- `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 编译时启用。
基于 xmake 构建:

View File

@ -35,7 +35,7 @@ SUBDIRS += \
RedPandaIDE.depends += redpanda-git-askpass
}
linux: {
unix:!macos: {
isEmpty(PREFIX) {
PREFIX = /usr/local
}
@ -55,21 +55,17 @@ linux: {
docs.files += LICENSE
INSTALLS += docs
equals(XDG_ADAPTIVE_ICON, "ON") {
xdgicons.path = $${PREFIX}/share/icons/hicolor/scalable/apps/
xdgicons.files += platform/linux/redpandaide.svg
REDPANDA_ICON_PATH = redpandaide
INSTALLS += xdgicons
} else {
pixmaps.path = $${PREFIX}/share/pixmaps
pixmaps.files += platform/linux/redpandaide.png
REDPANDA_ICON_PATH = $${PREFIX}/share/pixmaps/redpandaide.png
INSTALLS += pixmaps
}
desktop.path = $${PREFIX}/share/applications
desktop.files += platform/linux/redpandaide.desktop
INSTALLS += desktop
mime.path = $${PREFIX}/share/mime/packages
mime.files = platform/linux/redpandaide.xml
INSTALLS += mime
}
win32: {

View File

@ -17,7 +17,6 @@ build() {
cd "$srcdir/redpanda-build"
qmake-qt5 \
PREFIX='/usr' \
XDG_ADAPTIVE_ICON=ON \
"$srcdir/$_pkgname/Red_Panda_CPP.pro"
make
}

View File

@ -10,7 +10,7 @@ RUNTIME_SIZE=$(wc -c <$RUNTIME_FILE)
# build RedPanda C++
mkdir -p /build/redpanda-build
cd /build/redpanda-build
qmake PREFIX='/usr' XDG_ADAPTIVE_ICON=ON /build/RedPanda-CPP/Red_Panda_CPP.pro
qmake PREFIX='/usr' /build/RedPanda-CPP/Red_Panda_CPP.pro
make LINUX_STATIC_IME_PLUGIN=ON -j$(nproc)
# install RedPanda C++ to AppDir

View File

@ -48,7 +48,6 @@ build() {
qmake \
PREFIX='/usr' \
LIBEXECDIR='/usr/lib' \
XDG_ADAPTIVE_ICON=ON \
"$srcdir/$_pkgname/Red_Panda_CPP.pro"
make
}

View File

@ -27,7 +27,6 @@ mkdir -p %{name}
cd %{name}
qmake-qt5 \
PREFIX=/usr \
XDG_ADAPTIVE_ICON=ON \
"%{_builddir}/RedPanda-CPP/Red_Panda_CPP.pro"
make %{_smp_mflags}
@ -42,5 +41,6 @@ make INSTALL_ROOT="%{buildroot}" install
/usr/share/doc/RedPandaCPP/*
/usr/share/applications/redpandaide.desktop
/usr/share/icons/hicolor/scalable/apps/redpandaide.svg
/usr/share/mime/packages/redpandaide.xml
%changelog

View File

@ -27,7 +27,6 @@ mkdir -p %{name}
cd %{name}
qmake-qt5 \
PREFIX=/usr \
XDG_ADAPTIVE_ICON=ON \
"%{_builddir}/RedPanda-CPP/Red_Panda_CPP.pro"
make %{_smp_mflags}
@ -42,5 +41,6 @@ make INSTALL_ROOT="%{buildroot}" install
/usr/share/doc/RedPandaCPP/*
/usr/share/applications/redpandaide.desktop
/usr/share/icons/hicolor/scalable/apps/redpandaide.svg
/usr/share/mime/packages/redpandaide.xml
%changelog

View File

@ -4,12 +4,12 @@ Comment[zh_CN]=基于QT的轻量级C/C++集成开发环境
Exec=RedPandaIDE %F
GenericName=Red Panda C++
GenericName[zh_CN]=小熊猫C++
MimeType=application/pdf;
MimeType=text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-devcpp-project;
Name=Red Panda C++
Name[zh_CN]=小熊猫C++
StartupNotify=false
Terminal=false
Type=Application
Categories=Development;Qt;
Icon=$${REDPANDA_ICON_PATH}
Icon=redpandaide
Path=$${PREFIX}/bin

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="text/x-devcpp-project">
<comment>Red Panda C++ project</comment>
<comment xml:lang="pt_BR">Projeto do Red Panda C++</comment>
<comment xml:lang="zh_CN">小熊猫 C++ 项目</comment>
<comment xml:lang="zh_TW">小熊貓 C++ 專案</comment>
<sub-class-of type="text/plain"/>
<glob pattern="*.dev"/>
</mime-type>
</mime-info>

View File

@ -233,12 +233,17 @@ target("resources")
pattern = "$${(.-)}",
variables = {
PREFIX = get_config("prefix"),
REDPANDA_ICON_PATH = "redpandaide",
},
})
add_installfiles("$(buildir)/redpandaide.desktop", {prefixdir = "$(prefix)/share/applications"})
end
-- mime type
if is_xdg() then
add_installfiles("platform/linux/redpandaide.xml", {prefixdir = "$(prefix)/share/mime/packages"})
end
-- qt.conf
if is_os("windows") then