forked from openkylin/ukui-search
Merge branch 'new-frontend' into 'new-frontend'
Add keep selected result visible; Click not clear selection; See merge request kylin-desktop/ukui-search!98
This commit is contained in:
commit
edba38a5ba
|
@ -172,6 +172,7 @@ void ResultArea::pressDown()
|
|||
m_webSearchLable->setStyleSheet("background-color: #3790FA");//#3790FA选中颜色;
|
||||
m_selectedPluginID = m_WebTitleLabel->text();
|
||||
m_is_selected = true;
|
||||
this->ensureWidgetVisible(m_webSearchLable);
|
||||
}
|
||||
if (findNextWidget){
|
||||
break;
|
||||
|
@ -286,16 +287,31 @@ bool ResultArea::getSelectedState()
|
|||
|
||||
void ResultArea::sendKeyPressSignal(QString &pluginID)
|
||||
{
|
||||
if (m_detail_open_state) {
|
||||
int height(0);
|
||||
if (pluginID == m_bestListWidget->getWidgetName()) {
|
||||
QModelIndex index = m_bestListWidget->getCurrentSelection();
|
||||
height = index.row() == 0 ? 0 : index.row() * 35 + 30;//35为modol单个结果高度,30为title高度
|
||||
height = (height - 35) < 0 ? 0 : height - 35;
|
||||
this->ensureVisible(0, height, 0, 0);
|
||||
if (m_detail_open_state) {
|
||||
Q_EMIT this->keyPressChanged(m_bestListWidget->getPluginInfo(index), m_bestListWidget->getIndexResultInfo(index));
|
||||
}
|
||||
} else {
|
||||
height += m_bestListWidget->height();
|
||||
for (ResultWidget *plugin : m_widget_list) {
|
||||
if (pluginID == plugin->pluginId()) {
|
||||
QModelIndex index = plugin->getCurrentSelection();
|
||||
height += index.row() == 0 ? 0 : index.row() * 35 + 30;//35为modol单个结果高度,30为title高度
|
||||
int moreHeight = index.row() == 0 ? (30 + 35 * 2) : (35 * 2);
|
||||
this->ensureVisible(0, height + moreHeight, 0, 0);
|
||||
height = (height - 35) < 0 ? 0 : height - 35;
|
||||
this->ensureVisible(0, height, 0, 0);
|
||||
if (m_detail_open_state) {
|
||||
Q_EMIT this->keyPressChanged(m_selectedPluginID, plugin->getIndexResultInfo(index));
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
height += plugin->height();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -364,7 +380,6 @@ void ResultArea::initUi()
|
|||
m_mainLyt->setContentsMargins(RESULT_LAYOUT_MARGINS);
|
||||
this->widget()->setContentsMargins(0,0,0,0);
|
||||
m_mainLyt->setSpacing(0);
|
||||
|
||||
}
|
||||
|
||||
void ResultArea::initConnections()
|
||||
|
|
|
@ -251,7 +251,9 @@ void ResultView::onItemListChanged(const int &count)
|
|||
|
||||
void ResultView::setExpanded(const bool &is_expanded)
|
||||
{
|
||||
QModelIndex index = this->currentIndex();
|
||||
m_model->setExpanded(is_expanded);
|
||||
this->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
const bool &ResultView::isExpanded()
|
||||
|
@ -274,25 +276,6 @@ void ResultView::onMenuTriggered(QAction *action)
|
|||
}
|
||||
}
|
||||
|
||||
void ResultView::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
// if (event->button() == Qt::RightButton) {
|
||||
// //加一点点延时,等待列表先被选中
|
||||
// QTimer::singleShot(10, this, [ = ] {
|
||||
// QMenu * menu = new QMenu(this);
|
||||
// QStringList actions = m_model->getActions(this->currentIndex());
|
||||
// Q_FOREACH (QString action, actions) {
|
||||
// menu->addAction(new QAction(action, this));
|
||||
// }
|
||||
// menu->move(cursor().pos());
|
||||
// menu->show();
|
||||
// connect(menu, &QMenu::triggered, this, &ResultView::onMenuTriggered);
|
||||
// });
|
||||
// }
|
||||
// Q_EMIT this->rowClicked();
|
||||
return QTreeView::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void ResultView::initConnections()
|
||||
{
|
||||
connect(this, &ResultView::startSearch, [ = ](const QString &keyword) {
|
||||
|
|
|
@ -33,9 +33,6 @@ public Q_SLOTS:
|
|||
const bool &isExpanded();
|
||||
void onMenuTriggered(QAction *);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
|
||||
private:
|
||||
void initConnections();
|
||||
SearchResultModel * m_model = nullptr;
|
||||
|
@ -78,11 +75,11 @@ public Q_SLOTS:
|
|||
void onListLengthChanged(const int &);
|
||||
|
||||
private:
|
||||
QString m_plugin_id;
|
||||
bool m_enabled = true;
|
||||
|
||||
void initUi();
|
||||
void initConnections();
|
||||
|
||||
QString m_plugin_id;
|
||||
bool m_enabled = true;
|
||||
QVBoxLayout * m_mainLyt = nullptr;
|
||||
TitleLabel * m_titleLabel = nullptr;
|
||||
ResultView * m_resultView = nullptr;
|
||||
|
|
Loading…
Reference in New Issue