fix(websearch):解决偶现找不到浏览器图标的问题
This commit is contained in:
parent
9313bb7678
commit
807cdb6cc8
|
@ -54,19 +54,30 @@ void UkuiSearch::WebSearchPlugin::KeywordSearch(QString keyword, DataQueue<UkuiS
|
|||
resultInfo.name = m_keyWord;
|
||||
resultInfo.type = 0;
|
||||
|
||||
QByteArray ba = QString(DESKTOPPATH + getDefaultAppId(BROWSERTYPE)).toUtf8();
|
||||
GDesktopAppInfo * textinfo = g_desktop_app_info_new_from_filename(ba.constData());
|
||||
char *iconname = g_icon_to_string(g_app_info_get_icon(G_APP_INFO(textinfo)));
|
||||
QIcon appicon;
|
||||
appicon = IconLoader::loadIconQt(QString(QLatin1String(iconname)),
|
||||
QIcon(QString("/usr/share/pixmaps/"+QString(QLatin1String(iconname))
|
||||
+".png")));
|
||||
g_free(iconname);
|
||||
resultInfo.icon = QIcon(appicon);
|
||||
|
||||
QIcon appIcon;
|
||||
GAppInfo * app = g_app_info_get_default_for_type(BROWSERTYPE, false);
|
||||
if(app) {
|
||||
GIcon *gIcon = g_app_info_get_icon(app);
|
||||
if(G_IS_ICON(gIcon)) {
|
||||
const gchar* const* iconNames = g_themed_icon_get_names(G_THEMED_ICON(gIcon));
|
||||
if(iconNames) {
|
||||
auto p = iconNames;
|
||||
while(*p) {
|
||||
appIcon = IconLoader::loadIconXdg(*p);
|
||||
if(appIcon.isNull()) {
|
||||
p++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
g_object_unref(gIcon);
|
||||
g_object_unref(app);
|
||||
}
|
||||
resultInfo.icon = appIcon.isNull()? IconLoader::loadIconQt("unknown", QIcon(":/res/icons/unknown.svg")) : appIcon;
|
||||
resultInfo.actionKey = m_keyWord;
|
||||
searchResult->enqueue(resultInfo);
|
||||
g_object_unref(textinfo);
|
||||
}
|
||||
|
||||
void WebSearchPlugin::stopSearch()
|
||||
|
|
Loading…
Reference in New Issue