feat: 增加LaunchAppWithOptions和RunCommand接口
无 Log: 无 Influence: 无 Task: https://pms.uniontech.com/task-view-220801.html Change-Id: I8f6998a95a21dd70093746946b57c6c3be57bf3a
This commit is contained in:
parent
f1ac5f9f00
commit
12d08de069
@ -27,6 +27,17 @@
|
||||
<arg type='s' name='action' direction='in' />
|
||||
<arg type='u' name='timestamp' direction='in' />
|
||||
</method>
|
||||
<method name="LaunchAppWithOptions">
|
||||
<arg name="desktopFile" type="s" direction="in"></arg>
|
||||
<arg name="timestamp" type="u" direction="in"></arg>
|
||||
<arg name="files" type="as" direction="in"></arg>
|
||||
<arg name="options" type="a{sv}" direction="in"></arg>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In3" value="QVariantMap"/>
|
||||
</method>
|
||||
<method name="RunCommand">
|
||||
<arg name="exe" type="s" direction="in"></arg>
|
||||
<arg name="args" type="as" direction="in"></arg>
|
||||
</method>
|
||||
<signal name='AutostartChanged'>
|
||||
<arg type='s' name='status' />
|
||||
<arg type='s' name='filePath' />
|
||||
|
@ -117,7 +117,7 @@ bool StartManager::launchApp(const QString &desktopFile)
|
||||
|
||||
bool StartManager::launchApp(QString desktopFile, uint32_t timestamp, QStringList files)
|
||||
{
|
||||
return doLaunchAppWithOptions(desktopFile, timestamp, files, QMap<QString, QString>());
|
||||
return doLaunchAppWithOptions(desktopFile, timestamp, files, QVariantMap());
|
||||
}
|
||||
|
||||
bool StartManager::launchAppAction(QString desktopFile, QString actionSection, uint32_t timestamp)
|
||||
@ -153,7 +153,7 @@ bool StartManager::launchAppAction(QString desktopFile, QString actionSection, u
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StartManager::launchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options)
|
||||
bool StartManager::launchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QVariantMap options)
|
||||
{
|
||||
return doLaunchAppWithOptions(desktopFile, timestamp, files, options);
|
||||
}
|
||||
@ -350,7 +350,7 @@ bool StartManager::doLaunchAppWithOptions(const QString &desktopFile)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StartManager::doLaunchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options)
|
||||
bool StartManager::doLaunchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QVariantMap options)
|
||||
{
|
||||
// launchApp
|
||||
DesktopInfo info(desktopFile.toStdString());
|
||||
@ -360,11 +360,11 @@ bool StartManager::doLaunchAppWithOptions(QString desktopFile, uint32_t timestam
|
||||
}
|
||||
|
||||
if (options.find("path") != options.end()) {
|
||||
info.getKeyFile()->setKey(MainSection, KeyPath, options["path"].toStdString());
|
||||
info.getKeyFile()->setKey(MainSection, KeyPath, options["path"].toString().toStdString());
|
||||
}
|
||||
|
||||
if (options.find("desktop-override-exec") != options.end()) {
|
||||
info.setDesktopOverrideExec(options["desktop-override-exec"].toStdString());
|
||||
info.setDesktopOverrideExec(options["desktop-override-exec"].toString().toStdString());
|
||||
}
|
||||
|
||||
if (info.getCommandLine().empty()) {
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
bool launchApp(const QString &desktopFile);
|
||||
bool launchApp(QString desktopFile, uint32_t timestamp, QStringList files);
|
||||
bool launchAppAction(QString desktopFile, QString actionSection, uint32_t timestamp);
|
||||
bool launchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options);
|
||||
bool launchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QVariantMap options);
|
||||
bool runCommand(QString exe, QStringList args);
|
||||
bool runCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options);
|
||||
|
||||
@ -59,7 +59,7 @@ public Q_SLOTS:
|
||||
private:
|
||||
bool setAutostart(const QString &fileName, const bool value);
|
||||
bool doLaunchAppWithOptions(const QString &desktopFile);
|
||||
bool doLaunchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options);
|
||||
bool doLaunchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QVariantMap options);
|
||||
bool launch(DesktopInfo *info, QString cmdLine, uint32_t timestamp, QStringList files);
|
||||
bool doRunCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options);
|
||||
void waitCmd(DesktopInfo *info, QProcess *process, QString cmdName);
|
||||
|
@ -384,7 +384,7 @@ void ApplicationManager::LaunchAppAction(const QString &desktopFile, const QStri
|
||||
}
|
||||
}
|
||||
|
||||
void ApplicationManager::LaunchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options)
|
||||
void ApplicationManager::LaunchAppWithOptions(const QString &desktopFile, uint32_t timestamp, const QStringList &files, QVariantMap options)
|
||||
{
|
||||
Q_D(ApplicationManager);
|
||||
if (!d->checkDMsgUid()) {
|
||||
@ -403,6 +403,25 @@ void ApplicationManager::LaunchAppWithOptions(QString desktopFile, uint32_t time
|
||||
}
|
||||
}
|
||||
|
||||
void ApplicationManager::RunCommand(const QString &exe, const QStringList &args)
|
||||
{
|
||||
Q_D(ApplicationManager);
|
||||
if (!d->checkDMsgUid()) {
|
||||
if (calledFromDBus())
|
||||
sendErrorReply(QDBusError::Failed, "The call failed");
|
||||
|
||||
qWarning() << "check msg failed...";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!d->startManager->runCommand(exe, args)) {
|
||||
if (calledFromDBus())
|
||||
sendErrorReply(QDBusError::InvalidArgs, "invalid arguments");
|
||||
|
||||
qWarning() << "invalid arguments";
|
||||
}
|
||||
}
|
||||
|
||||
void ApplicationManager::RunCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options)
|
||||
{
|
||||
Q_D(ApplicationManager);
|
||||
|
@ -74,6 +74,8 @@ public Q_SLOTS:
|
||||
void Launch(const QString &desktopFile, bool withMsgCheck = true);
|
||||
void LaunchApp(const QString &desktopFile, uint32_t timestamp, const QStringList &files, bool withMsgCheck = true);
|
||||
void LaunchAppAction(const QString &desktopFile, const QString &action, uint32_t timestamp, bool withMsgCheck = true);
|
||||
void LaunchAppWithOptions(const QString &desktopFile, uint32_t timestamp, const QStringList &files, QVariantMap options);
|
||||
void RunCommand(const QString &exe, const QStringList &args);
|
||||
|
||||
protected:
|
||||
ApplicationManager(QObject *parent = nullptr);
|
||||
@ -83,7 +85,6 @@ protected:
|
||||
QList<QDBusObjectPath> list() const;
|
||||
QDBusObjectPath GetInformation(const QString &id);
|
||||
QList<QDBusObjectPath> GetInstances(const QString &id);
|
||||
void LaunchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options);
|
||||
void RunCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options);
|
||||
bool IsProcessExist(uint32_t pid);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user