fix(frontend):解决偶现搜索后无法自动选中最佳匹配第一项的问题

This commit is contained in:
iaom 2024-01-25 09:31:19 +08:00
parent 4e89fe8b50
commit 7a48ae6a61
2 changed files with 4 additions and 1 deletions

View File

@ -370,6 +370,7 @@ void ResultArea::setSelectionInfo(QString &pluginID)
m_selectedPluginID = pluginID;
if (m_selectedPluginID != m_bestListWidget->getWidgetName()) {
m_bestListWidget->clearResultSelection();
m_isClicked = true;
}
}
@ -464,11 +465,12 @@ void ResultArea::initConnections()
m_detail_open_state = false;
m_isSelected = false;
m_selectedPluginID = "";
m_isClicked = false;
});
connect(m_bestListWidget, &BestListWidget::sizeChanged, this, &ResultArea::onWidgetSizeChanged);
connect(m_bestListWidget, &BestListWidget::sizeChanged, this, [=] () {
QModelIndex index = m_bestListWidget->getModlIndex(0, 0);
if (index.isValid() && (m_selectedPluginID == m_bestListWidget->getWidgetName() || m_selectedPluginID.isEmpty())) {
if (index.isValid() && !m_isClicked) {
m_bestListWidget->setResultSelection(index);
m_selectedPluginID = m_bestListWidget->getWidgetName();
m_isSelected = true;

View File

@ -94,6 +94,7 @@ private:
bool m_isSelected = false;
QString m_selectedPluginID;
QPoint m_pressPoint;
bool m_isClicked =false;
Q_SIGNALS:
void startSearch(const QString &);