feat(app): 不支持传送门的环境只提示一次并保持待命

- --daemon 启动时检测 org.gxde.Portal,缺失则发一次桌面通知
- 记录 warned/unsupportedEnv,避免 gxde-k9 反复拉起时重复提示
This commit is contained in:
2026-10-30 20:17:25 +08:00
parent 07f215bb34
commit d69326bc6f
2 changed files with 25 additions and 0 deletions
+22
View File
@@ -11,6 +11,8 @@
#include "todo/todowindow.h"
#include "ui/portalpanel.h"
#include <QDBusConnection>
#include <QDBusMessage>
#include <QLocalServer>
#include <QTimer>
#include <QLocalSocket>
@@ -60,6 +62,26 @@ bool App::init(bool daemon, bool forceShow, bool showTodo, bool showChat)
m_model = new StagingModel(this);
/* gxde-k9 keeps restarting us; when the compositor has no portal support we
* warn once and then stay idle instead of exiting (which would make k9
* relaunch us every few seconds). */
if (daemon && !PortalClient::instance()->available() &&
!Config::instance()->getBool(QStringLiteral("warned/unsupportedEnv"), false)) {
QDBusMessage notification = QDBusMessage::createMethodCall(
QStringLiteral("org.freedesktop.Notifications"),
QStringLiteral("/org/freedesktop/Notifications"),
QStringLiteral("org.freedesktop.Notifications"), QStringLiteral("Notify"));
notification << QStringLiteral("gxde-ai-see") << 0u
<< QStringLiteral("gxde-ai-see")
<< tr("小埃同学")
<< tr("当前桌面不支持传送门(需要 GXDE Wayland 合成器)。"
"小埃同学会继续在后台待命,暂存区、内容工厂和对话仍然可用。")
<< QStringList() << QVariantMap() << 6000;
QDBusConnection::sessionBus().send(notification);
Config::instance()->set(QStringLiteral("warned/unsupportedEnv"), true);
Config::instance()->sync();
}
PortalClient *portal = PortalClient::instance();
connect(portal, &PortalClient::dragStarted, this, [this](const QString &mimeTypes) {
if (!PortalClient::mimeInteresting(mimeTypes)) {