From af3ea26b0a21818834cd5b17ab2144980e1a13f8 Mon Sep 17 00:00:00 2001 From: baijunjie Date: Wed, 16 Feb 2022 17:12:48 +0800 Subject: [PATCH] Fix the incorrectly display of the ToolTip. --- libsearch/appsearch/app-search-plugin.cpp | 2 ++ libsearch/index/file-search-plugin.cpp | 18 ++++++++++++------ libsearch/mailsearch/mail-search-plugin.cpp | 2 ++ libsearch/notesearch/note-search-plugin.cpp | 2 ++ .../settingsearch/settings-search-plugin.cpp | 2 ++ 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/libsearch/appsearch/app-search-plugin.cpp b/libsearch/appsearch/app-search-plugin.cpp index 39142a5..a52ebf0 100644 --- a/libsearch/appsearch/app-search-plugin.cpp +++ b/libsearch/appsearch/app-search-plugin.cpp @@ -109,6 +109,8 @@ QWidget *AppSearchPlugin::detailPage(const ResultInfo &ri) m_nameLabel->setText(FileUtils::setAllTextBold(showname)); if(QString::compare(showname, ri.name)) { m_nameLabel->setToolTip(ri.name); + } else { + m_nameLabel->setToolTip(""); } m_pluginLabel->setText(tr("Application")); if(ri.type == 1) { diff --git a/libsearch/index/file-search-plugin.cpp b/libsearch/index/file-search-plugin.cpp index d76c93d..259c14a 100644 --- a/libsearch/index/file-search-plugin.cpp +++ b/libsearch/index/file-search-plugin.cpp @@ -94,9 +94,11 @@ QWidget *FileSearchPlugin::detailPage(const ResultInfo &ri) QFontMetrics fontMetrics = m_nameLabel->fontMetrics(); QString showname = fontMetrics.elidedText(ri.name, Qt::ElideRight, 215); //当字体长度超过215时显示为省略号 m_nameLabel->setText(FileUtils::setAllTextBold(showname)); - //if(QString::compare(showname, ri.name)) { + if(QString::compare(showname, ri.name)) { m_nameLabel->setToolTip(ri.name); - //} + } else { + m_nameLabel->setToolTip(""); + } m_pluginLabel->setText(tr("File")); m_pathLabel2->setText(m_pathLabel2->fontMetrics().elidedText(m_currentActionKey, Qt::ElideRight, m_pathLabel2->width())); @@ -292,9 +294,11 @@ QWidget *DirSearchPlugin::detailPage(const ResultInfo &ri) QFontMetrics fontMetrics = m_nameLabel->fontMetrics(); QString showname = fontMetrics.elidedText(ri.name, Qt::ElideRight, 215); //当字体长度超过215时显示为省略号 m_nameLabel->setText(FileUtils::setAllTextBold(showname)); - //if(QString::compare(showname, ri.name)) { + if(QString::compare(showname, ri.name)) { m_nameLabel->setToolTip(ri.name); - //} + } else { + m_nameLabel->setToolTip(""); + } m_pluginLabel->setText(tr("directory")); m_pathLabel2->setText(m_pathLabel2->fontMetrics().elidedText(m_currentActionKey, Qt::ElideRight, m_pathLabel2->width())); @@ -474,9 +478,11 @@ QWidget *FileContengSearchPlugin::detailPage(const ResultInfo &ri) QFontMetrics fontMetrics = m_nameLabel->fontMetrics(); QString showname = fontMetrics.elidedText(ri.name, Qt::ElideRight, 215); //当字体长度超过215时显示为省略号 m_nameLabel->setText(FileUtils::setAllTextBold(showname)); - //if(QString::compare(showname, ri.name)) { + if(QString::compare(showname, ri.name)) { m_nameLabel->setToolTip(ri.name); - //} + } else { + m_nameLabel->setToolTip(""); + } m_snippetLabel->setText(getHtmlText(wrapData(m_snippetLabel,ri.description.at(0).value), m_keyWord)); m_pathLabel2->setText(m_pathLabel2->fontMetrics().elidedText(m_currentActionKey, Qt::ElideRight, m_pathLabel2->width())); diff --git a/libsearch/mailsearch/mail-search-plugin.cpp b/libsearch/mailsearch/mail-search-plugin.cpp index e4df9e1..3e494ec 100644 --- a/libsearch/mailsearch/mail-search-plugin.cpp +++ b/libsearch/mailsearch/mail-search-plugin.cpp @@ -98,6 +98,8 @@ QWidget *MailSearchPlugin::detailPage(const SearchPluginIface::ResultInfo &ri) m_senderFieldsLabel->setText(FileUtils::escapeHtml(senderName)); if (QString::compare(senderName, ri.description.at(0).value)) { m_senderFieldsLabel->setToolTip(ri.description.at(0).value); + } else { + m_nameLabel->setToolTip(""); } m_timeLabel->setText(ri.description.at(1).key); diff --git a/libsearch/notesearch/note-search-plugin.cpp b/libsearch/notesearch/note-search-plugin.cpp index 161a655..caee694 100644 --- a/libsearch/notesearch/note-search-plugin.cpp +++ b/libsearch/notesearch/note-search-plugin.cpp @@ -74,6 +74,8 @@ QWidget *NoteSearchPlugin::detailPage(const SearchPluginIface::ResultInfo &ri) m_nameLabel->setText(FileUtils::setAllTextBold(showname)); if(QString::compare(showname, ri.name)) { m_nameLabel->setToolTip(ri.name); + } else { + m_nameLabel->setToolTip(""); } m_pluginLabel->setText(tr("Application")); QString showDesc = fontMetrics.elidedText(/*ri.description.at(0).key + " " + */ri.description.at(0).value, Qt::ElideRight, m_descLabel->width() * 2); //当字体长度超过215时显示为省略号 diff --git a/libsearch/settingsearch/settings-search-plugin.cpp b/libsearch/settingsearch/settings-search-plugin.cpp index fbe665c..a4018f3 100644 --- a/libsearch/settingsearch/settings-search-plugin.cpp +++ b/libsearch/settingsearch/settings-search-plugin.cpp @@ -80,6 +80,8 @@ QWidget *SettingsSearchPlugin::detailPage(const ResultInfo &ri) m_nameLabel->setText(FileUtils::setAllTextBold(showname)); if(QString::compare(showname, ri.name)) { m_nameLabel->setToolTip(ri.name); + } else { + m_nameLabel->setToolTip(""); } return m_detailPage; }