forked from openkylin/ukui-search
fix(inputbox): Position of icon in inputbox is incorrect.
Description: 修复输入框图标位置有误的问题 Log: 修复输入框图标位置有误的问题 Bug: -
This commit is contained in:
parent
1a7f52b85c
commit
862f9bae71
|
@ -119,6 +119,20 @@ void SearchBarHLayout::initUI()
|
|||
});
|
||||
}
|
||||
|
||||
void SearchBarHLayout::focusIn() {
|
||||
m_queryLineEdit->setFocus();
|
||||
}
|
||||
|
||||
void SearchBarHLayout::focusOut() {
|
||||
m_queryLineEdit->clearFocus();
|
||||
if (! m_queryText->parent()) {
|
||||
m_queryWidget->layout()->addWidget(m_queryText);
|
||||
m_queryText->adjustSize();
|
||||
}
|
||||
m_queryWidget->setGeometry(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 15)) / 2 - 10, 0,
|
||||
m_queryIcon->width() + m_queryText->width() + 10, 35)); //使图标回到初始位置
|
||||
}
|
||||
|
||||
void SearchBarHLayout::clearText() {
|
||||
m_queryLineEdit->setText("");
|
||||
}
|
||||
|
@ -133,8 +147,7 @@ bool SearchBarHLayout::eventFilter(QObject *watched, QEvent *event)
|
|||
if (event->type()==QEvent::FocusIn) {
|
||||
if (m_queryLineEdit->text().isEmpty()) {
|
||||
m_animation->stop();
|
||||
m_animation->setStartValue(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0,
|
||||
m_queryIcon->width() + m_queryText->width() + 10, 35));
|
||||
m_animation->setStartValue(m_queryWidget->geometry());
|
||||
m_animation->setEndValue(QRect(0, 0, m_queryIcon->width() + 5, 35));
|
||||
m_animation->setEasingCurve(QEasingCurve::OutQuad);
|
||||
m_animation->start();
|
||||
|
|
|
@ -34,6 +34,8 @@ public:
|
|||
~SearchBarHLayout();
|
||||
void clearText();
|
||||
QString text();
|
||||
void focusIn();
|
||||
void focusOut();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
|
|
@ -244,6 +244,7 @@ void MainWindow::bootOptionsFilter(QString opt)
|
|||
*/
|
||||
void MainWindow::clearSearchResult() {
|
||||
m_searchLayout->clearText();
|
||||
m_searchLayout->focusOut();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue