搜索引擎跟随控制面板图标
This commit is contained in:
parent
47af66e682
commit
f356ca340a
|
@ -1,5 +1,8 @@
|
||||||
#include "web-search-plugin.h"
|
#include "web-search-plugin.h"
|
||||||
#include "global-settings.h"
|
#include "global-settings.h"
|
||||||
|
#define WEB_ENGINE_KEY "webEngine"
|
||||||
|
#define BROWSERTYPE "x-scheme-handler/http"
|
||||||
|
#define DESKTOPPATH "/usr/share/applications/"
|
||||||
|
|
||||||
using namespace UkuiSearch;
|
using namespace UkuiSearch;
|
||||||
WebSearchPlugin::WebSearchPlugin(QObject *parent) : QObject(parent)
|
WebSearchPlugin::WebSearchPlugin(QObject *parent) : QObject(parent)
|
||||||
|
@ -30,9 +33,22 @@ void UkuiSearch::WebSearchPlugin::KeywordSearch(QString keyword, DataQueue<UkuiS
|
||||||
ResultInfo resultInfo;
|
ResultInfo resultInfo;
|
||||||
resultInfo.name = m_keyWord;
|
resultInfo.name = m_keyWord;
|
||||||
resultInfo.type = 0;
|
resultInfo.type = 0;
|
||||||
resultInfo.icon = QIcon(":/res/icons/search-web-icon.svg");
|
|
||||||
|
|
||||||
|
|
||||||
|
QString defaultwebengines(getDefaultAppId(BROWSERTYPE));
|
||||||
|
QByteArray ba = QString(DESKTOPPATH + defaultwebengines).toUtf8();
|
||||||
|
GDesktopAppInfo * textinfo = g_desktop_app_info_new_from_filename(ba.constData());
|
||||||
|
const char * iconname = g_icon_to_string(g_app_info_get_icon(G_APP_INFO(textinfo)));
|
||||||
|
QIcon appicon;
|
||||||
|
appicon = QIcon::fromTheme(QString(QLatin1String(iconname)),
|
||||||
|
QIcon(QString("/usr/share/pixmaps/"+QString(QLatin1String(iconname))
|
||||||
|
+".png")));
|
||||||
|
resultInfo.icon = QIcon(appicon);
|
||||||
|
|
||||||
resultInfo.actionKey = m_keyWord;
|
resultInfo.actionKey = m_keyWord;
|
||||||
searchResult->enqueue(resultInfo);
|
searchResult->enqueue(resultInfo);
|
||||||
|
g_object_unref(textinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebSearchPlugin::stopSearch()
|
void WebSearchPlugin::stopSearch()
|
||||||
|
@ -112,3 +128,16 @@ void UkuiSearch::WebSearchPlugin::initDetailPage()
|
||||||
openAction(0, m_currentActionKey, 0);
|
openAction(0, m_currentActionKey, 0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString WebSearchPlugin::getDefaultAppId(const char *contentType)
|
||||||
|
{
|
||||||
|
GAppInfo * app = g_app_info_get_default_for_type(contentType, false);
|
||||||
|
if(app != NULL){
|
||||||
|
const char * id = g_app_info_get_id(app);
|
||||||
|
QString strId(id);
|
||||||
|
g_object_unref(app);
|
||||||
|
return strId;
|
||||||
|
} else {
|
||||||
|
return QString("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -12,8 +12,10 @@
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include "action-label.h"
|
#include "action-label.h"
|
||||||
#include "search-plugin-iface.h"
|
#include "search-plugin-iface.h"
|
||||||
|
#include <gio/gdesktopappinfo.h>
|
||||||
|
|
||||||
namespace UkuiSearch {
|
namespace UkuiSearch {
|
||||||
|
|
||||||
class LIBSEARCH_EXPORT WebSearchPlugin : public QObject, public SearchPluginIface
|
class LIBSEARCH_EXPORT WebSearchPlugin : public QObject, public SearchPluginIface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -48,6 +50,8 @@ private:
|
||||||
|
|
||||||
bool m_enable = true;
|
bool m_enable = true;
|
||||||
QList<WebSearchPlugin::Actioninfo> m_actionInfo;
|
QList<WebSearchPlugin::Actioninfo> m_actionInfo;
|
||||||
|
|
||||||
|
QString getDefaultAppId(const char * contentType);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // WEBSEARCHPLUGIN_H
|
#endif // WEBSEARCHPLUGIN_H
|
||||||
|
|
Loading…
Reference in New Issue