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.name = m_keyWord;
|
||||||
resultInfo.type = 0;
|
resultInfo.type = 0;
|
||||||
|
|
||||||
QByteArray ba = QString(DESKTOPPATH + getDefaultAppId(BROWSERTYPE)).toUtf8();
|
QIcon appIcon;
|
||||||
GDesktopAppInfo * textinfo = g_desktop_app_info_new_from_filename(ba.constData());
|
GAppInfo * app = g_app_info_get_default_for_type(BROWSERTYPE, false);
|
||||||
char *iconname = g_icon_to_string(g_app_info_get_icon(G_APP_INFO(textinfo)));
|
if(app) {
|
||||||
QIcon appicon;
|
GIcon *gIcon = g_app_info_get_icon(app);
|
||||||
appicon = IconLoader::loadIconQt(QString(QLatin1String(iconname)),
|
if(G_IS_ICON(gIcon)) {
|
||||||
QIcon(QString("/usr/share/pixmaps/"+QString(QLatin1String(iconname))
|
const gchar* const* iconNames = g_themed_icon_get_names(G_THEMED_ICON(gIcon));
|
||||||
+".png")));
|
if(iconNames) {
|
||||||
g_free(iconname);
|
auto p = iconNames;
|
||||||
resultInfo.icon = QIcon(appicon);
|
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;
|
resultInfo.actionKey = m_keyWord;
|
||||||
searchResult->enqueue(resultInfo);
|
searchResult->enqueue(resultInfo);
|
||||||
g_object_unref(textinfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebSearchPlugin::stopSearch()
|
void WebSearchPlugin::stopSearch()
|
||||||
|
|
Loading…
Reference in New Issue