From 9ff607afe15429db7f4c752c4f441e286ab22d65 Mon Sep 17 00:00:00 2001 From: iaom Date: Wed, 20 Dec 2023 15:51:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(search-iface):=E8=A7=A3=E5=86=B3=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=90=9C=E7=B4=A2=E6=8F=92=E4=BB=B6=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E4=B8=AD=E5=90=AB=E6=9C=89=E6=8D=A2=E8=A1=8C?= =?UTF-8?q?=E7=AC=A6=E6=97=B6UI=E6=98=BE=E7=A4=BA=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/model/search-result-model.cpp | 2 +- libsearch/appsearch/app-search-plugin.cpp | 1 + libsearch/index/search-manager.cpp | 3 ++- libsearch/notesearch/note-search-plugin.cpp | 4 +++- libsearch/plugininterface/search-plugin-iface.h | 14 +++++++++++--- libsearch/settingsearch/settings-search-plugin.cpp | 2 +- libsearch/websearch/web-search-plugin.cpp | 1 + 7 files changed, 20 insertions(+), 7 deletions(-) diff --git a/frontend/model/search-result-model.cpp b/frontend/model/search-result-model.cpp index 50f3540..474770f 100644 --- a/frontend/model/search-result-model.cpp +++ b/frontend/model/search-result-model.cpp @@ -69,7 +69,7 @@ QVariant SearchResultModel::data(const QModelIndex &index, int role) const return m_items.at(index.row()).name; } case Qt::ToolTipRole: { - return m_items.at(index.row()).name; + return m_items.at(index.row()).toolTip; } default: return QVariant(); diff --git a/libsearch/appsearch/app-search-plugin.cpp b/libsearch/appsearch/app-search-plugin.cpp index 9d29e4c..1df092d 100644 --- a/libsearch/appsearch/app-search-plugin.cpp +++ b/libsearch/appsearch/app-search-plugin.cpp @@ -192,6 +192,7 @@ void AppSearchPlugin::run() SearchPluginIface::ResultInfo ri; ri.name = data.value(SearchProperty::SearchResultProperty::ApplicationLocalName).toString(); + ri.toolTip = ri.name; ri.icon = IconLoader::loadIconXdg(data.value(SearchProperty::SearchResultProperty::ApplicationIconName).toString(), QIcon(":/res/icons/unknown.svg")); SearchPluginIface::DescriptionInfo description; description.key = QString(tr("Application Description:")); diff --git a/libsearch/index/search-manager.cpp b/libsearch/index/search-manager.cpp index 7ef9bc9..9a88da8 100644 --- a/libsearch/index/search-manager.cpp +++ b/libsearch/index/search-manager.cpp @@ -65,7 +65,8 @@ bool SearchManager::creatResultInfo(SearchPluginIface::ResultInfo &ri, const QSt return false; } ri.icon = FileUtils::getFileIcon(QUrl::fromLocalFile(path).toString(), false); - ri.name = info.fileName(); + ri.name = info.fileName().replace("\r", " ").replace("\n", " "); + ri.toolTip = info.fileName(); ri.description = QVector() \ << SearchPluginIface::DescriptionInfo{tr("Path:"), path} \ << SearchPluginIface::DescriptionInfo{tr("Modified time:"), info.lastModified().toString("yyyy/MM/dd hh:mm:ss")}; diff --git a/libsearch/notesearch/note-search-plugin.cpp b/libsearch/notesearch/note-search-plugin.cpp index 3c7d460..0d39aef 100644 --- a/libsearch/notesearch/note-search-plugin.cpp +++ b/libsearch/notesearch/note-search-plugin.cpp @@ -233,9 +233,11 @@ void NoteSearch::run() { } dbusArgs.endArray(); qDebug() << str; + QString name = str.length() > 2? str.at(1) : ""; SearchPluginIface::ResultInfo ri( IconLoader::loadIconQt("kylin-notebook", QIcon(":/res/icons/desktop.png")), - str.at(1), + name.replace("\r", " ").replace("\n", " "), + name, QVector() << SearchPluginIface::DescriptionInfo { key : QString(tr("Note Description:")), value : str.at(0) diff --git a/libsearch/plugininterface/search-plugin-iface.h b/libsearch/plugininterface/search-plugin-iface.h index cb30d01..96c1eba 100644 --- a/libsearch/plugininterface/search-plugin-iface.h +++ b/libsearch/plugininterface/search-plugin-iface.h @@ -20,7 +20,10 @@ #ifndef SEARCHPLUGINIFACE_H #define SEARCHPLUGINIFACE_H #define SearchPluginIface_iid "org.ukui.ukui-search.plugin-iface.SearchPluginInterface" -#define SEARCH_PLUGIN_IFACE_VERSION "1.1.0" +/** + * changelog:1.2.0 增加toolTip + */ +#define SEARCH_PLUGIN_IFACE_VERSION "1.2.0" #include #include @@ -58,14 +61,19 @@ public: { QIcon icon; QString name; + QString toolTip; QVector description; QString actionKey; int type; - ResultInfo(const QIcon &iconToSet = QIcon(), const QString &nameToSet = QString(), + ResultInfo(const QIcon &iconToSet = QIcon(), + const QString &nameToSet = QString(), + const QString &toolTipToSet = QString(), const QVector &descriptionToSet = QVector(), - const QString &actionKeyToSet = QString(), const int &typeToSet = 0) { + const QString &actionKeyToSet = QString(), + const int &typeToSet = 0) { icon = iconToSet; name = nameToSet; + toolTip = toolTipToSet; description = descriptionToSet; actionKey = actionKeyToSet; type = typeToSet; diff --git a/libsearch/settingsearch/settings-search-plugin.cpp b/libsearch/settingsearch/settings-search-plugin.cpp index 27d6f90..79f9bb9 100644 --- a/libsearch/settingsearch/settings-search-plugin.cpp +++ b/libsearch/settingsearch/settings-search-plugin.cpp @@ -459,7 +459,7 @@ void SettingsMatch::createResultInfo(SearchPluginIface::ResultInfo &resultInfo, resultInfo.name.prepend("--"); resultInfo.name.prepend(ql.language() == QLocale::English ? topInfo.at(0) : topInfo.at(1)); } - + resultInfo.toolTip = resultInfo.name; resultInfo.icon = FileUtils::getSettingIcon(); resultInfo.actionKey = path.section("/", 1, 1); } diff --git a/libsearch/websearch/web-search-plugin.cpp b/libsearch/websearch/web-search-plugin.cpp index b40fc20..c307df5 100644 --- a/libsearch/websearch/web-search-plugin.cpp +++ b/libsearch/websearch/web-search-plugin.cpp @@ -50,6 +50,7 @@ void UkuiSearch::WebSearchPlugin::KeywordSearch(QString keyword, DataQueue