LocationCompleterView: Delay resizing popup to reduce flicker

remotes/origin/Falkon/3.0
David Rosca 8 years ago
parent 09ee6007e9
commit 99ceda4324
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
  1. 27
      src/lib/navigation/completer/locationcompleterview.cpp
  2. 3
      src/lib/navigation/completer/locationcompleterview.h

@ -123,7 +123,32 @@ void LocationCompleterView::setOriginalText(const QString &originalText)
void LocationCompleterView::adjustSize()
{
const int maxItemsCount = 12;
m_view->setFixedHeight(m_view->sizeHintForRow(0) * qMin(maxItemsCount, model()->rowCount()) + 2 * m_view->frameWidth());
const int newHeight = m_view->sizeHintForRow(0) * qMin(maxItemsCount, model()->rowCount()) + 2 * m_view->frameWidth();
if (!m_resizeTimer) {
m_resizeTimer = new QTimer(this);
m_resizeTimer->setInterval(200);
connect(m_resizeTimer, &QTimer::timeout, this, [this]() {
if (m_resizeHeight > 0) {
m_view->setFixedHeight(m_resizeHeight);
setFixedHeight(sizeHint().height());
}
m_resizeHeight = -1;
});
}
if (newHeight == m_view->height() || newHeight == m_resizeHeight) {
return;
}
if (newHeight < m_view->height()) {
m_resizeHeight = newHeight;
m_resizeTimer->start();
return;
}
m_resizeHeight = -1;
m_view->setFixedHeight(newHeight);
setFixedHeight(sizeHint().height());
}

@ -25,6 +25,7 @@
class LoadRequest;
class LocationCompleterDelegate;
class QTimer;
class QHBoxLayout;
class FALKON_EXPORT LocationCompleterView : public QWidget
@ -67,6 +68,8 @@ private:
LocationCompleterDelegate *m_delegate;
QHBoxLayout *m_searchEnginesLayout;
QString m_originalText;
int m_resizeHeight = -1;
QTimer *m_resizeTimer = nullptr;
};
#endif // LOCATIONCOMPLETERVIEW_H

Loading…
Cancel
Save