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

feat: launch the application by AM in actionInvoke #337

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions dde-osd/src/notification/bubbletool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,21 @@ const QString BubbleTool::getDeepinAppName(const QString &name)
return desktop.localizedValue("Name", localKey, "Desktop Entry", name);
}

const QString BubbleTool::getDesktopPath(const QString &desktopName)
{
QString desktopPath;

for (const auto dataPath : DStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation)) {
auto path = QStringList{ dataPath, desktopName }.join(QDir::separator());
if (QFile::exists(path)) {
desktopPath = path;
break;
}
}

return desktopPath;
}

void BubbleTool::actionInvoke(const QString &actionId, EntityPtr entity)
{
qDebug() << "actionId:" << actionId;
Expand All @@ -215,6 +230,15 @@ void BubbleTool::actionInvoke(const QString &actionId, EntityPtr entity)
args.removeFirst();
if (i.key() == "x-deepin-action-" + actionId) {
QProcess::startDetached(cmd, args); //执行相关命令
} else if(i.key() == "x-deepin-action-" + "_openbydesktop") {
auto desktopPath = getDesktopPath(cmd);
QDBusConnection conn = QDBusConnection::sessionBus();
QDBusMessage msg = QDBusMessage::createMethodCall("org.deepin.dde.StartManager1",
"/org/deepin/dde/StartManager1",
"org.deepin.dde.StartManager1",
"LaunchApp");
msg << desktopPath << 0 << args;
conn.sessionBus().call(msg, QDBus::NoBlock);
}
}
++i;
Expand Down
1 change: 1 addition & 0 deletions dde-osd/src/notification/bubbletool.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class BubbleTool
static void actionInvoke(const QString &actionId, EntityPtr entity);//从entity提取出命令信息,执行命令产生相应动作
static void register_wm_state(WId winid);//保持气泡窗口置顶
static const QString getDeepinAppName(const QString &name);//获取应用名称
static const QString getDeepinDesktopPath(const QString &name);//获取desktop文件路径

private:
/*!
Expand Down