Skip to content

Commit

Permalink
refact: launching app by dde-am tool
Browse files Browse the repository at this point in the history
Launching app by dde-am tools instead of calling dbus directly.
  • Loading branch information
18202781743 committed Mar 25, 2024
1 parent 4d4971e commit 0c95a70
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions panels/dock/taskmanager/desktopfileamparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ QString DesktopFileAMParser::type()

void DesktopFileAMParser::launch()
{
m_applicationInterface->Launch(QString(), QStringList(), QVariantMap());
return launchByAMTool();
}

void DesktopFileAMParser::launchWithAction(const QString& action)
{
m_applicationInterface->Launch(action, QStringList(), QVariantMap());
return launchByAMTool(action);
}

void DesktopFileAMParser::requestQuit()
Expand All @@ -180,6 +180,19 @@ void DesktopFileAMParser::connectToAmDBusSignal(const QString& signalName, const
);
}

void DesktopFileAMParser::launchByAMTool(const QString &action)
{
QProcess process;
const auto path = m_applicationInterface->path();
process.start("dde-am", {path, action});
process.waitForFinished();
if (process.exitStatus() != QProcess::NormalExit) {
qWarning() << "Failed to launch the application path:" << path << process.errorString();
return;
}
qDebug() << "Launch the application path:" << path;
}

void DesktopFileAMParser::updateActions()
{
m_actions.clear();
Expand Down
1 change: 1 addition & 0 deletions panels/dock/taskmanager/desktopfileamparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class DesktopFileAMParser : public DesktopfileAbstractParser
private:
QString id2dbusPath(const QString& id);
void connectToAmDBusSignal(const QString& propertyName, const char* slot);
void launchByAMTool(const QString &action = QString());

private Q_SLOTS:
void updateActions();
Expand Down

0 comments on commit 0c95a70

Please sign in to comment.