新增应用管理启动接口;
This commit is contained in:
parent
cfd2a644ad
commit
9c81e40c3a
|
@ -18,6 +18,7 @@
|
||||||
* Authors: jixiaoxu <jixiaoxu@kylinos.cn>
|
* Authors: jixiaoxu <jixiaoxu@kylinos.cn>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
#include <QDBusReply>
|
||||||
#include "web-search-view.h"
|
#include "web-search-view.h"
|
||||||
#define MAIN_MARGINS 0,0,0,0
|
#define MAIN_MARGINS 0,0,0,0
|
||||||
#define MAIN_SPACING 0
|
#define MAIN_SPACING 0
|
||||||
|
@ -97,6 +98,30 @@ void WebSearchView::LaunchBrowser()
|
||||||
} else { //默认值
|
} else { //默认值
|
||||||
address = "http://baidu.com/s?word=" + m_keyWord ; //百度
|
address = "http://baidu.com/s?word=" + m_keyWord ; //百度
|
||||||
}
|
}
|
||||||
|
bool res(false);
|
||||||
|
QDBusInterface * appLaunchInterface = new QDBusInterface("com.kylin.AppManager",
|
||||||
|
"/com/kylin/AppManager",
|
||||||
|
"com.kylin.AppManager",
|
||||||
|
QDBusConnection::sessionBus());
|
||||||
|
if(!appLaunchInterface->isValid()) {
|
||||||
|
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
||||||
|
res = false;
|
||||||
|
} else {
|
||||||
|
appLaunchInterface->setTimeout(10000);
|
||||||
|
QDBusReply<bool> reply = appLaunchInterface->call("LaunchDefaultAppWithUrl", address);
|
||||||
|
if(reply.isValid()) {
|
||||||
|
res = reply;
|
||||||
|
} else {
|
||||||
|
qWarning() << "SoftWareCenter dbus called failed!";
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(appLaunchInterface) {
|
||||||
|
delete appLaunchInterface;
|
||||||
|
}
|
||||||
|
appLaunchInterface = NULL;
|
||||||
|
if (res)
|
||||||
|
return;
|
||||||
QDesktopServices::openUrl(address);
|
QDesktopServices::openUrl(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -218,8 +218,33 @@ void AppSearchPlugin::initDetailPage()
|
||||||
|
|
||||||
bool AppSearchPlugin::launch(const QString &path)
|
bool AppSearchPlugin::launch(const QString &path)
|
||||||
{
|
{
|
||||||
|
bool res(false);
|
||||||
|
QDBusInterface * appLaunchInterface = new QDBusInterface("com.kylin.AppManager",
|
||||||
|
"/com/kylin/AppManager",
|
||||||
|
"com.kylin.AppManager",
|
||||||
|
QDBusConnection::sessionBus());
|
||||||
|
if(!appLaunchInterface->isValid()) {
|
||||||
|
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
||||||
|
res = false;
|
||||||
|
} else {
|
||||||
|
appLaunchInterface->setTimeout(10000);
|
||||||
|
QDBusReply<bool> reply = appLaunchInterface->call("LaunchApp", path);
|
||||||
|
if(reply.isValid()) {
|
||||||
|
res = reply;
|
||||||
|
} else {
|
||||||
|
qWarning() << "SoftWareCenter dbus called failed!";
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(appLaunchInterface) {
|
||||||
|
delete appLaunchInterface;
|
||||||
|
}
|
||||||
|
appLaunchInterface = NULL;
|
||||||
|
if (res)
|
||||||
|
return true;
|
||||||
|
|
||||||
GDesktopAppInfo * desktopAppInfo = g_desktop_app_info_new_from_filename(path.toLocal8Bit().data());
|
GDesktopAppInfo * desktopAppInfo = g_desktop_app_info_new_from_filename(path.toLocal8Bit().data());
|
||||||
bool res = static_cast<bool>(g_app_info_launch(G_APP_INFO(desktopAppInfo), nullptr, nullptr, nullptr));
|
res = static_cast<bool>(g_app_info_launch(G_APP_INFO(desktopAppInfo), nullptr, nullptr, nullptr));
|
||||||
g_object_unref(desktopAppInfo);
|
g_object_unref(desktopAppInfo);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -270,6 +295,30 @@ bool AppSearchPlugin::installAppAction(const QString & name) {
|
||||||
} else {
|
} else {
|
||||||
//软件商店未打开,打开软件商店下载此软件
|
//软件商店未打开,打开软件商店下载此软件
|
||||||
qDebug() << "Softwarecenter has not been launched, now launch it." << name;
|
qDebug() << "Softwarecenter has not been launched, now launch it." << name;
|
||||||
|
bool res(false);
|
||||||
|
QDBusInterface * appLaunchInterface = new QDBusInterface("com.kylin.AppManager",
|
||||||
|
"/com/kylin/AppManager",
|
||||||
|
"com.kylin.AppManager",
|
||||||
|
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);
|
||||||
|
if(reply.isValid()) {
|
||||||
|
res = reply;
|
||||||
|
} else {
|
||||||
|
qWarning() << "SoftWareCenter dbus called failed!";
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(appLaunchInterface) {
|
||||||
|
delete appLaunchInterface;
|
||||||
|
}
|
||||||
|
appLaunchInterface = NULL;
|
||||||
|
if (res)
|
||||||
|
return true;
|
||||||
QProcess process;
|
QProcess process;
|
||||||
return process.startDetached(QString("kylin-software-center -find %1").arg(name));
|
return process.startDetached(QString("kylin-software-center -find %1").arg(name));
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
#include <QDBusMessage>
|
#include <QDBusMessage>
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QDomDocument>
|
#include <QDomDocument>
|
||||||
|
#include <QDBusInterface>
|
||||||
|
#include <QDBusReply>
|
||||||
#include "gobject-template.h"
|
#include "gobject-template.h"
|
||||||
#include "pinyinmanager.h"
|
#include "pinyinmanager.h"
|
||||||
|
|
||||||
|
@ -829,7 +831,31 @@ int FileUtils::openFile(QString &path, bool openInDir)
|
||||||
if(!G_IS_APP_INFO(info)) {
|
if(!G_IS_APP_INFO(info)) {
|
||||||
res = -1;
|
res = -1;
|
||||||
} else {
|
} else {
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
bool isSuccess(false);
|
||||||
|
QDBusInterface * appLaunchInterface = new QDBusInterface("com.kylin.AppManager",
|
||||||
|
"/com/kylin/AppManager",
|
||||||
|
"com.kylin.AppManager",
|
||||||
|
QDBusConnection::sessionBus());
|
||||||
|
if(!appLaunchInterface->isValid()) {
|
||||||
|
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
||||||
|
isSuccess = false;
|
||||||
|
} else {
|
||||||
|
appLaunchInterface->setTimeout(10000);
|
||||||
|
QDBusReply<bool> reply = appLaunchInterface->call("LaunchDefaultAppWithUrl", "file:"+(path));
|
||||||
|
if(reply.isValid()) {
|
||||||
|
isSuccess = reply;
|
||||||
|
} else {
|
||||||
|
qWarning() << "SoftWareCenter dbus called failed!";
|
||||||
|
isSuccess = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(appLaunchInterface) {
|
||||||
|
delete appLaunchInterface;
|
||||||
|
}
|
||||||
|
appLaunchInterface = NULL;
|
||||||
|
if (!isSuccess){
|
||||||
|
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
||||||
|
}
|
||||||
res = 0;
|
res = 0;
|
||||||
}
|
}
|
||||||
g_object_unref(info);
|
g_object_unref(info);
|
||||||
|
|
|
@ -55,11 +55,37 @@ QList<SearchPluginIface::Actioninfo> NoteSearchPlugin::getActioninfo(int type)
|
||||||
|
|
||||||
void NoteSearchPlugin::openAction(int actionkey, QString key, int type)
|
void NoteSearchPlugin::openAction(int actionkey, QString key, int type)
|
||||||
{
|
{
|
||||||
QProcess process;
|
|
||||||
switch (actionkey) {
|
switch (actionkey) {
|
||||||
case 0:
|
case 0:
|
||||||
|
{
|
||||||
|
bool res(false);
|
||||||
|
QDBusInterface * appLaunchInterface = new QDBusInterface("com.kylin.AppManager",
|
||||||
|
"/com/kylin/AppManager",
|
||||||
|
"com.kylin.AppManager",
|
||||||
|
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);
|
||||||
|
if(reply.isValid()) {
|
||||||
|
res = reply;
|
||||||
|
} else {
|
||||||
|
qWarning() << "SoftWareCenter dbus called failed!";
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(appLaunchInterface) {
|
||||||
|
delete appLaunchInterface;
|
||||||
|
}
|
||||||
|
appLaunchInterface = NULL;
|
||||||
|
if (res)
|
||||||
|
break;
|
||||||
|
QProcess process;
|
||||||
process.startDetached(QString("ukui-notebook --show %1").arg(key.toInt()));
|
process.startDetached(QString("ukui-notebook --show %1").arg(key.toInt()));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
#include <QDomDocument>
|
#include <QDomDocument>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QDBusInterface>
|
||||||
|
#include <QDBusReply>
|
||||||
#include "settings-search-plugin.h"
|
#include "settings-search-plugin.h"
|
||||||
#include "file-utils.h"
|
#include "file-utils.h"
|
||||||
|
|
||||||
|
@ -59,13 +61,38 @@ QList<SearchPluginIface::Actioninfo> SettingsSearchPlugin::getActioninfo(int typ
|
||||||
void SettingsSearchPlugin::openAction(int actionkey, QString key, int type)
|
void SettingsSearchPlugin::openAction(int actionkey, QString key, int type)
|
||||||
{
|
{
|
||||||
//TODO add some return message here.
|
//TODO add some return message here.
|
||||||
QProcess process;
|
|
||||||
switch (actionkey) {
|
switch (actionkey) {
|
||||||
case 0:
|
case 0:
|
||||||
|
{
|
||||||
|
bool res(false);
|
||||||
|
QDBusInterface * appLaunchInterface = new QDBusInterface("com.kylin.AppManager",
|
||||||
|
"/com/kylin/AppManager",
|
||||||
|
"com.kylin.AppManager",
|
||||||
|
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());
|
||||||
|
if(reply.isValid()) {
|
||||||
|
res = reply;
|
||||||
|
} else {
|
||||||
|
qWarning() << "SoftWareCenter dbus called failed!";
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(appLaunchInterface) {
|
||||||
|
delete appLaunchInterface;
|
||||||
|
}
|
||||||
|
appLaunchInterface = NULL;
|
||||||
|
if (res)
|
||||||
|
break;
|
||||||
//打开控制面板对应页面
|
//打开控制面板对应页面
|
||||||
|
QProcess process;
|
||||||
process.startDetached(QString("ukui-control-center -m %1").arg(key.toLower()));
|
process.startDetached(QString("ukui-control-center -m %1").arg(key.toLower()));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <QDBusReply>
|
||||||
#include "web-search-plugin.h"
|
#include "web-search-plugin.h"
|
||||||
#include "global-settings.h"
|
#include "global-settings.h"
|
||||||
#define WEB_ENGINE_KEY "webEngine"
|
#define WEB_ENGINE_KEY "webEngine"
|
||||||
|
@ -75,6 +76,30 @@ void UkuiSearch::WebSearchPlugin::openAction(int actionkey, QString key, int typ
|
||||||
} else { //默认值
|
} else { //默认值
|
||||||
address = "http://baidu.com/s?word=" + m_keyWord ; //百度
|
address = "http://baidu.com/s?word=" + m_keyWord ; //百度
|
||||||
}
|
}
|
||||||
|
bool res(false);
|
||||||
|
QDBusInterface * appLaunchInterface = new QDBusInterface("com.kylin.AppManager",
|
||||||
|
"/com/kylin/AppManager",
|
||||||
|
"com.kylin.AppManager",
|
||||||
|
QDBusConnection::sessionBus());
|
||||||
|
if(!appLaunchInterface->isValid()) {
|
||||||
|
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
||||||
|
res = false;
|
||||||
|
} else {
|
||||||
|
appLaunchInterface->setTimeout(10000);
|
||||||
|
QDBusReply<bool> reply = appLaunchInterface->call("LaunchDefaultAppWithUrl", address);
|
||||||
|
if(reply.isValid()) {
|
||||||
|
res = reply;
|
||||||
|
} else {
|
||||||
|
qWarning() << "SoftWareCenter dbus called failed!";
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(appLaunchInterface) {
|
||||||
|
delete appLaunchInterface;
|
||||||
|
}
|
||||||
|
appLaunchInterface = NULL;
|
||||||
|
if (res)
|
||||||
|
return;
|
||||||
QDesktopServices::openUrl(address);
|
QDesktopServices::openUrl(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue