mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
Fix slow scrolling in dock panels
Commit f688bcd1f1
fixed slow scrolling with xf86-input-libinput on DolphinView.
However the commit also exposed a bug in the Dolphin scrolling
algorithm, which was previously hidden. This resulted in slow
scrolling in dock panels (Places and Folders), with both
xf86-input-evdev and xf86-input-libinput drivers, as well as libinput on
Wayland.
KItemListContainer::updateScrollOffsetScrollBar() relied on the view's
itemSize() method to compute the scrollbar's singleStep, but this QSize
was invalid for the dock panels' views.
We use a new itemSizeHint() method instead, which is always valid and
also adapts to the current icon size set in the view.
BUG: 365968
FIXED-IN: 16.12.0
REVIEW: 129409
This commit is contained in:
parent
3187c511c4
commit
90beb4a5e3
|
@ -265,7 +265,7 @@ void KItemListContainer::updateScrollOffsetScrollBar()
|
|||
if (view->scrollOrientation() == Qt::Vertical) {
|
||||
smoothScroller = m_verticalSmoothScroller;
|
||||
scrollOffsetScrollBar = verticalScrollBar();
|
||||
singleStep = view->itemSize().height();
|
||||
singleStep = view->itemSizeHint().height();
|
||||
// We cannot use view->size().height() because this height might
|
||||
// include the header widget, which is not part of the scrolled area.
|
||||
pageStep = view->verticalPageStep();
|
||||
|
|
|
@ -344,6 +344,11 @@ QSizeF KItemListView::itemSize() const
|
|||
return m_itemSize;
|
||||
}
|
||||
|
||||
QSizeF KItemListView::itemSizeHint() const
|
||||
{
|
||||
return m_sizeHintResolver->maxSizeHint();
|
||||
}
|
||||
|
||||
const KItemListStyleOption& KItemListView::styleOption() const
|
||||
{
|
||||
return m_styleOption;
|
||||
|
|
|
@ -154,10 +154,15 @@ public:
|
|||
|
||||
/**
|
||||
* @return The basic size of all items. The size of an item may be larger than
|
||||
* the basic size (see KItemListView::itemSizeHint() and KItemListView::itemRect()).
|
||||
* the basic size (see KItemListView::itemRect()).
|
||||
*/
|
||||
QSizeF itemSize() const;
|
||||
|
||||
/**
|
||||
* @return The size hint of all items. It is provided by the KItemListSizeHintResolver.
|
||||
*/
|
||||
QSizeF itemSizeHint() const;
|
||||
|
||||
const KItemListStyleOption& styleOption() const;
|
||||
|
||||
virtual void setGeometry(const QRectF& rect) Q_DECL_OVERRIDE;
|
||||
|
|
|
@ -25,6 +25,7 @@ KItemListSizeHintResolver::KItemListSizeHintResolver(const KItemListView* itemLi
|
|||
m_itemListView(itemListView),
|
||||
m_logicalHeightHintCache(),
|
||||
m_logicalWidthHint(0.0),
|
||||
m_logicalHeightHint(0.0),
|
||||
m_needsResolving(false)
|
||||
{
|
||||
}
|
||||
|
@ -33,6 +34,12 @@ KItemListSizeHintResolver::~KItemListSizeHintResolver()
|
|||
{
|
||||
}
|
||||
|
||||
QSizeF KItemListSizeHintResolver::maxSizeHint()
|
||||
{
|
||||
updateCache();
|
||||
return QSizeF(m_logicalWidthHint, m_logicalHeightHint);
|
||||
}
|
||||
|
||||
QSizeF KItemListSizeHintResolver::sizeHint(int index)
|
||||
{
|
||||
updateCache();
|
||||
|
@ -149,6 +156,12 @@ void KItemListSizeHintResolver::updateCache()
|
|||
{
|
||||
if (m_needsResolving) {
|
||||
m_itemListView->calculateItemSizeHints(m_logicalHeightHintCache, m_logicalWidthHint);
|
||||
// Set logical height as the max cached height (if the cache is not empty).
|
||||
if (m_logicalHeightHintCache.isEmpty()) {
|
||||
m_logicalHeightHint = 0.0;
|
||||
} else {
|
||||
m_logicalHeightHint = *std::max_element(m_logicalHeightHintCache.begin(), m_logicalHeightHintCache.end());
|
||||
}
|
||||
m_needsResolving = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ class DOLPHIN_EXPORT KItemListSizeHintResolver
|
|||
public:
|
||||
KItemListSizeHintResolver(const KItemListView* itemListView);
|
||||
virtual ~KItemListSizeHintResolver();
|
||||
QSizeF maxSizeHint();
|
||||
QSizeF sizeHint(int index);
|
||||
|
||||
void itemsInserted(const KItemRangeList& itemRanges);
|
||||
|
@ -50,6 +51,7 @@ private:
|
|||
const KItemListView* m_itemListView;
|
||||
mutable QVector<qreal> m_logicalHeightHintCache;
|
||||
mutable qreal m_logicalWidthHint;
|
||||
mutable qreal m_logicalHeightHint;
|
||||
bool m_needsResolving;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue