perf(plugins):use process manager to open applications.
This commit is contained in:
parent
8d4126ee6b
commit
1bcf2922c0
|
@ -468,20 +468,20 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event)
|
|||
|
||||
void MainWindow::openSearchSettings() {
|
||||
bool res(false);
|
||||
QDBusInterface* appLaunchInterface = new QDBusInterface("com.kylin.AppManager",
|
||||
"/com/kylin/AppManager",
|
||||
"com.kylin.AppManager",
|
||||
QDBusInterface* appLaunchInterface = new QDBusInterface(QStringLiteral("com.kylin.ProcessManager"),
|
||||
QStringLiteral("/com/kylin/ProcessManager/AppLauncher"),
|
||||
QStringLiteral("com.kylin.ProcessManager.AppLauncher"),
|
||||
QDBusConnection::sessionBus());
|
||||
if(!appLaunchInterface->isValid()) {
|
||||
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
||||
res = false;
|
||||
} else {
|
||||
appLaunchInterface->setTimeout(10000);
|
||||
QDBusReply<bool> reply = appLaunchInterface->call("LaunchAppWithArguments", "ukui-control-center.desktop", QStringList() << "-m" << "search");
|
||||
QDBusReply<void> reply = appLaunchInterface->call("LaunchAppWithArguments", "/usr/share/applications/ukui-control-center.desktop", QStringList{"-m", "search"});
|
||||
if(reply.isValid()) {
|
||||
res = reply;
|
||||
res = true;
|
||||
} else {
|
||||
qWarning() << "SoftWareCenter dbus called failed!";
|
||||
qWarning() << "ProcessManager dbus called failed!" << reply.error();
|
||||
res = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -285,20 +285,20 @@ bool AppSearchPlugin::launch(const QString &path)
|
|||
invokeActions(InvokableAction::HideUI);
|
||||
}
|
||||
bool res(false);
|
||||
QDBusInterface * appLaunchInterface = new QDBusInterface("com.kylin.AppManager",
|
||||
"/com/kylin/AppManager",
|
||||
"com.kylin.AppManager",
|
||||
QDBusInterface * appLaunchInterface = new QDBusInterface(QStringLiteral("com.kylin.ProcessManager"),
|
||||
QStringLiteral("/com/kylin/ProcessManager/AppLauncher"),
|
||||
QStringLiteral("com.kylin.ProcessManager.AppLauncher"),
|
||||
QDBusConnection::sessionBus());
|
||||
if(!appLaunchInterface->isValid()) {
|
||||
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
||||
res = false;
|
||||
} else {
|
||||
appLaunchInterface->setTimeout(10000);
|
||||
QDBusReply<bool> reply = appLaunchInterface->call("LaunchApp", path);
|
||||
QDBusReply<void> reply = appLaunchInterface->call("LaunchApp", path);
|
||||
if(reply.isValid()) {
|
||||
res = reply;
|
||||
res = true;
|
||||
} else {
|
||||
qWarning() << "AppManager dbus called failed!";
|
||||
qWarning() << "ProcessManager dbus called failed!" << reply.error();
|
||||
res = false;
|
||||
}
|
||||
}
|
||||
|
@ -366,20 +366,20 @@ bool AppSearchPlugin::installAppAction(const QString & name)
|
|||
} else {
|
||||
//软件商店未打开,打开软件商店下载此软件
|
||||
qDebug() << "Softwarecenter has not been launched, now launch it." << name;
|
||||
QDBusInterface * appLaunchInterface = new QDBusInterface("com.kylin.AppManager",
|
||||
"/com/kylin/AppManager",
|
||||
"com.kylin.AppManager",
|
||||
QDBusInterface * appLaunchInterface = new QDBusInterface(QStringLiteral("com.kylin.ProcessManager"),
|
||||
QStringLiteral("/com/kylin/ProcessManager/AppLauncher"),
|
||||
QStringLiteral("com.kylin.ProcessManager.AppLauncher"),
|
||||
QDBusConnection::sessionBus());
|
||||
if(!appLaunchInterface->isValid()) {
|
||||
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
||||
res = false;
|
||||
} else {
|
||||
appLaunchInterface->setTimeout(10000);
|
||||
QDBusReply<bool> reply = appLaunchInterface->call("LaunchAppWithArguments", "kylin-software-center.desktop", QStringList() << "-find" << name);
|
||||
QDBusReply<void> reply = appLaunchInterface->call("LaunchAppWithArguments", "/usr/share/applications/kylin-software-center.desktop", QStringList() << "-find" << name);
|
||||
if(reply.isValid()) {
|
||||
res = reply;
|
||||
res = true;
|
||||
} else {
|
||||
qWarning() << "SoftWareCenter dbus called failed!";
|
||||
qWarning() << "ProcessManager dbus called failed!" << reply.error();
|
||||
res = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -661,8 +661,8 @@ int FileUtils::openFile(QString &path, bool openInDir)
|
|||
}
|
||||
}
|
||||
|
||||
GError *error = NULL;
|
||||
GAppInfo *info = NULL;
|
||||
GError *error = nullptr;
|
||||
GAppInfo *info = nullptr;
|
||||
/*
|
||||
* g_app_info_get_default_for_type function get wrong default app, so we get the
|
||||
* default app info from mimeapps.list, and chose the right default app for mimeType file
|
||||
|
@ -677,7 +677,7 @@ int FileUtils::openFile(QString &path, bool openInDir)
|
|||
g_error_free(error);
|
||||
} else {
|
||||
gchar *desktopApp = g_key_file_get_string(keyfile, "Default Applications", mimeType.toUtf8(), &error);
|
||||
if (NULL != desktopApp) {
|
||||
if (nullptr != desktopApp) {
|
||||
info = (GAppInfo*)g_desktop_app_info_new(desktopApp);
|
||||
g_free (desktopApp);
|
||||
} else {
|
||||
|
@ -689,27 +689,28 @@ int FileUtils::openFile(QString &path, bool openInDir)
|
|||
res = -1;
|
||||
} else {
|
||||
bool isSuccess(false);
|
||||
QDBusInterface * appLaunchInterface = new QDBusInterface("com.kylin.AppManager",
|
||||
"/com/kylin/AppManager",
|
||||
"com.kylin.AppManager",
|
||||
QDBusInterface * appLaunchInterface = new QDBusInterface(QStringLiteral("com.kylin.ProcessManager"),
|
||||
QStringLiteral("/com/kylin/ProcessManager/AppLauncher"),
|
||||
QStringLiteral("com.kylin.ProcessManager.AppLauncher"),
|
||||
QDBusConnection::sessionBus());
|
||||
if (!appLaunchInterface->isValid()) {
|
||||
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
||||
isSuccess = false;
|
||||
} else {
|
||||
appLaunchInterface->setTimeout(10000);
|
||||
QDBusReply<bool> reply = appLaunchInterface->call("LaunchDefaultAppWithUrl", QUrl::fromLocalFile(path).toString());
|
||||
QDBusReply<void> reply = appLaunchInterface->call("LaunchDefaultAppWithUrl", QUrl::fromLocalFile(path).toString());
|
||||
if(reply.isValid()) {
|
||||
isSuccess = reply;
|
||||
isSuccess = true;
|
||||
} else {
|
||||
qWarning() << "SoftWareCenter dbus called failed!";
|
||||
qWarning() << "ProcessManager dbus called failed!" << reply.error();
|
||||
isSuccess = false;
|
||||
}
|
||||
}
|
||||
if (appLaunchInterface) {
|
||||
delete appLaunchInterface;
|
||||
}
|
||||
appLaunchInterface = NULL;
|
||||
appLaunchInterface = nullptr;
|
||||
|
||||
if (!isSuccess){
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
||||
}
|
||||
|
|
|
@ -83,27 +83,27 @@ void NoteSearchPlugin::openAction(int actionkey, QString key, int type)
|
|||
{
|
||||
DataCollecter::collectLaunchEvent(QStringLiteral("Note Search"), QStringLiteral("open"));
|
||||
bool res(false);
|
||||
QDBusInterface * appLaunchInterface = new QDBusInterface("com.kylin.AppManager",
|
||||
"/com/kylin/AppManager",
|
||||
"com.kylin.AppManager",
|
||||
QDBusInterface * appLaunchInterface = new QDBusInterface(QStringLiteral("com.kylin.ProcessManager"),
|
||||
QStringLiteral("/com/kylin/ProcessManager/AppLauncher"),
|
||||
QStringLiteral("com.kylin.ProcessManager.AppLauncher"),
|
||||
QDBusConnection::sessionBus());
|
||||
if(!appLaunchInterface->isValid()) {
|
||||
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
||||
res = false;
|
||||
} else {
|
||||
appLaunchInterface->setTimeout(10000);
|
||||
QDBusReply<bool> reply = appLaunchInterface->call("LaunchAppWithArguments", "ukui-notebook.desktop", QStringList() << "--show" << key);
|
||||
QDBusReply<void> reply = appLaunchInterface->call("LaunchAppWithArguments", "/usr/share/applications/ukui-notebook.desktop", QStringList() << "--show" << key);
|
||||
if(reply.isValid()) {
|
||||
res = reply;
|
||||
res = true;
|
||||
} else {
|
||||
qWarning() << "SoftWareCenter dbus called failed!";
|
||||
qWarning() << "ProcessManager dbus called failed!" << reply.error();
|
||||
res = false;
|
||||
}
|
||||
}
|
||||
if(appLaunchInterface) {
|
||||
delete appLaunchInterface;
|
||||
}
|
||||
appLaunchInterface = NULL;
|
||||
appLaunchInterface = nullptr;
|
||||
if (res)
|
||||
break;
|
||||
QProcess process;
|
||||
|
|
|
@ -71,27 +71,27 @@ void SettingsSearchPlugin::openAction(int actionkey, QString key, int type)
|
|||
{
|
||||
DataCollecter::collectLaunchEvent(QStringLiteral("Settings Search"), QStringLiteral("open"));
|
||||
bool res(false);
|
||||
QDBusInterface * appLaunchInterface = new QDBusInterface("com.kylin.AppManager",
|
||||
"/com/kylin/AppManager",
|
||||
"com.kylin.AppManager",
|
||||
QDBusInterface * appLaunchInterface = new QDBusInterface(QStringLiteral("com.kylin.ProcessManager"),
|
||||
QStringLiteral("/com/kylin/ProcessManager/AppLauncher"),
|
||||
QStringLiteral("com.kylin.ProcessManager.AppLauncher"),
|
||||
QDBusConnection::sessionBus());
|
||||
if(!appLaunchInterface->isValid()) {
|
||||
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
||||
res = false;
|
||||
} else {
|
||||
appLaunchInterface->setTimeout(10000);
|
||||
QDBusReply<bool> reply = appLaunchInterface->call("LaunchAppWithArguments", "ukui-control-center.desktop", QStringList() << "-m" << key.toLower());
|
||||
QDBusReply<void> reply = appLaunchInterface->call("LaunchAppWithArguments", "/usr/share/applications/ukui-control-center.desktop", QStringList() << "-m" << key.toLower());
|
||||
if(reply.isValid()) {
|
||||
res = reply;
|
||||
res = true;
|
||||
} else {
|
||||
qWarning() << "SoftWareCenter dbus called failed!";
|
||||
qWarning() << "ProcessManager dbus called failed!" << reply.error();
|
||||
res = false;
|
||||
}
|
||||
}
|
||||
if (appLaunchInterface) {
|
||||
delete appLaunchInterface;
|
||||
}
|
||||
appLaunchInterface = NULL;
|
||||
appLaunchInterface = nullptr;
|
||||
if (res)
|
||||
break;
|
||||
//打开控制面板对应页面
|
||||
|
|
|
@ -97,27 +97,27 @@ void UkuiSearch::WebSearchPlugin::openAction(int actionkey, QString key, int typ
|
|||
address = "http://baidu.com/s?word=" + m_keyWord ; //百度
|
||||
}
|
||||
bool res(false);
|
||||
QDBusInterface * appLaunchInterface = new QDBusInterface("com.kylin.AppManager",
|
||||
"/com/kylin/AppManager",
|
||||
"com.kylin.AppManager",
|
||||
QDBusInterface * appLaunchInterface = new QDBusInterface(QStringLiteral("com.kylin.ProcessManager"),
|
||||
QStringLiteral("/com/kylin/ProcessManager/AppLauncher"),
|
||||
QStringLiteral("com.kylin.ProcessManager.AppLauncher"),
|
||||
QDBusConnection::sessionBus());
|
||||
if(!appLaunchInterface->isValid()) {
|
||||
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
||||
res = false;
|
||||
} else {
|
||||
appLaunchInterface->setTimeout(10000);
|
||||
QDBusReply<bool> reply = appLaunchInterface->call("LaunchDefaultAppWithUrl", address);
|
||||
QDBusReply<void> reply = appLaunchInterface->call("LaunchDefaultAppWithUrl", address);
|
||||
if(reply.isValid()) {
|
||||
res = reply;
|
||||
res = true;
|
||||
} else {
|
||||
qWarning() << "SoftWareCenter dbus called failed!";
|
||||
qWarning() << "ProcessManager dbus called failed!" << reply.error();
|
||||
res = false;
|
||||
}
|
||||
}
|
||||
if (appLaunchInterface) {
|
||||
delete appLaunchInterface;
|
||||
}
|
||||
appLaunchInterface = NULL;
|
||||
appLaunchInterface = nullptr;
|
||||
if (res)
|
||||
return;
|
||||
QDesktopServices::openUrl(address);
|
||||
|
|
Loading…
Reference in New Issue