From f688bcd1f14175f1624e2abcc6452882448467c0 Mon Sep 17 00:00:00 2001 From: "Martin T. H. Sandsmark" Date: Wed, 13 Jul 2016 00:29:15 +0200 Subject: Fix scrolling on hidpi screens Scrolling with libinput was unbearably slow. QScrollBar is much better at scrolling than us, so let it handle it. REVIEW: 128432 BUG: 357618 --- src/kitemviews/private/kitemlistsmoothscroller.cpp | 25 +++++----------------- src/kitemviews/private/kitemlistsmoothscroller.h | 12 +++++------ 2 files changed, 10 insertions(+), 27 deletions(-) (limited to 'src/kitemviews/private') diff --git a/src/kitemviews/private/kitemlistsmoothscroller.cpp b/src/kitemviews/private/kitemlistsmoothscroller.cpp index c89d3cf8f..6bfdba4c9 100644 --- a/src/kitemviews/private/kitemlistsmoothscroller.cpp +++ b/src/kitemviews/private/kitemlistsmoothscroller.cpp @@ -172,8 +172,7 @@ bool KItemListSmoothScroller::eventFilter(QObject* obj, QEvent* event) break; case QEvent::Wheel: - handleWheelEvent(static_cast(event)); - return true; // eat event so that QScrollBar does not scroll one step more by itself + return false; // we're the ones sending them default: break; @@ -196,25 +195,11 @@ void KItemListSmoothScroller::handleWheelEvent(QWheelEvent* event) const bool previous = m_smoothScrolling; m_smoothScrolling = true; - int numPixels; - if (!event->pixelDelta().isNull()) { - numPixels = event->pixelDelta().y(); - } else { - const int numDegrees = event->angleDelta().y() / 8; - const int numSteps = qApp->wheelScrollLines() * numDegrees / 15; - numPixels = numSteps * m_scrollBar->pageStep() / 12; - } - int value = m_scrollBar->value(); - if (event->modifiers().testFlag(Qt::ShiftModifier)) { - const int scrollingDirection = numPixels > 0 ? 1 : -1; - value -= m_scrollBar->pageStep() * scrollingDirection; - } else { - value -= numPixels; - } - m_scrollBar->setValue(value); - m_smoothScrolling = previous; + QWheelEvent copy = *event; + QApplication::sendEvent(m_scrollBar, ©); + event->setAccepted(copy.isAccepted()); - event->accept(); + m_smoothScrolling = previous; } diff --git a/src/kitemviews/private/kitemlistsmoothscroller.h b/src/kitemviews/private/kitemlistsmoothscroller.h index fca4b0c53..a3576a3fd 100644 --- a/src/kitemviews/private/kitemlistsmoothscroller.h +++ b/src/kitemviews/private/kitemlistsmoothscroller.h @@ -77,6 +77,11 @@ public: // stable. bool requestScrollBarUpdate(int newMaximum); + /** + * Forwards wheel events to the scrollbar, ensuring smooth and proper scrolling + */ + void handleWheelEvent(QWheelEvent* event); + protected: virtual bool eventFilter(QObject* obj, QEvent* event); @@ -84,13 +89,6 @@ private slots: void slotAnimationStateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State oldState); -private: - /** - * Results into a smooth-scrolling of the target dependent on the direction - * of the wheel event. - */ - void handleWheelEvent(QWheelEvent* event); - private: bool m_scrollBarPressed; bool m_smoothScrolling; -- cgit v1.3.1 From 676cdcbbdbea031c1bec56230561bf8a0efcd0f6 Mon Sep 17 00:00:00 2001 From: "Martin T. H. Sandsmark" Date: Sat, 6 Aug 2016 13:03:48 +0200 Subject: Fix some low-hanging warning fruits --- src/kitemviews/kitemlistwidget.cpp | 4 ++-- src/kitemviews/private/kbaloorolesprovider.h | 2 +- src/panels/places/placesitemlistgroupheader.h | 2 +- src/panels/places/placespanel.h | 2 +- src/tests/kfileitemmodeltest.cpp | 2 +- src/views/dolphinview.cpp | 4 ---- src/views/tooltips/filemetadatatooltip.cpp | 4 +--- 7 files changed, 7 insertions(+), 13 deletions(-) (limited to 'src/kitemviews/private') diff --git a/src/kitemviews/kitemlistwidget.cpp b/src/kitemviews/kitemlistwidget.cpp index b834e951f..9c31155b3 100644 --- a/src/kitemviews/kitemlistwidget.cpp +++ b/src/kitemviews/kitemlistwidget.cpp @@ -516,10 +516,10 @@ void KItemListWidget::clearHoverCache() void KItemListWidget::drawItemStyleOption(QPainter* painter, QWidget* widget, QStyle::State styleState) { - QStyleOptionViewItemV4 viewItemOption; + QStyleOptionViewItem viewItemOption; viewItemOption.initFrom(widget); viewItemOption.state = styleState; - viewItemOption.viewItemPosition = QStyleOptionViewItemV4::OnlyOne; + viewItemOption.viewItemPosition = QStyleOptionViewItem::OnlyOne; viewItemOption.showDecorationSelected = true; viewItemOption.rect = selectionRect().toRect(); widget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget); diff --git a/src/kitemviews/private/kbaloorolesprovider.h b/src/kitemviews/private/kbaloorolesprovider.h index 9673bff4f..a9bd2e8ef 100644 --- a/src/kitemviews/private/kbaloorolesprovider.h +++ b/src/kitemviews/private/kbaloorolesprovider.h @@ -82,7 +82,7 @@ private: QSet m_roles; QHash m_roleForProperty; - friend class KBalooRolesProviderSingleton; + friend struct KBalooRolesProviderSingleton; }; #endif diff --git a/src/panels/places/placesitemlistgroupheader.h b/src/panels/places/placesitemlistgroupheader.h index 7daaba602..ec845e0ae 100644 --- a/src/panels/places/placesitemlistgroupheader.h +++ b/src/panels/places/placesitemlistgroupheader.h @@ -33,7 +33,7 @@ public: protected: virtual void paintSeparator(QPainter* painter, const QColor& color) Q_DECL_OVERRIDE; - virtual QPalette::ColorRole normalTextColorRole() const; + virtual QPalette::ColorRole normalTextColorRole() const Q_DECL_OVERRIDE; }; #endif diff --git a/src/panels/places/placespanel.h b/src/panels/places/placespanel.h index 81aeedb28..0c8b5f7f2 100644 --- a/src/panels/places/placespanel.h +++ b/src/panels/places/placespanel.h @@ -52,7 +52,7 @@ protected: virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE; public slots: - virtual void readSettings(); + virtual void readSettings() Q_DECL_OVERRIDE; private slots: void slotItemActivated(int index); diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp index eba32e1e1..6c45e114b 100644 --- a/src/tests/kfileitemmodeltest.cpp +++ b/src/tests/kfileitemmodeltest.cpp @@ -1674,7 +1674,7 @@ void KFileItemModelTest::testCollapseFolderWhileLoading() const KFileItem fileItemC1 = m_model->fileItem(2); KFileItem fileItemC2 = fileItemC1; QUrl urlC2 = fileItemC2.url(); - urlC2.adjusted(QUrl::RemoveFilename); + urlC2 = urlC2.adjusted(QUrl::RemoveFilename); urlC2.setPath(urlC2.path() + "c2.txt"); fileItemC2.setUrl(urlC2); diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 5466fd38e..a737dd0a6 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -75,10 +75,6 @@ #endif #include -namespace { - const int MaxModeEnum = DolphinView::CompactView; -} - DolphinView::DolphinView(const QUrl& url, QWidget* parent) : QWidget(parent), m_active(true), diff --git a/src/views/tooltips/filemetadatatooltip.cpp b/src/views/tooltips/filemetadatatooltip.cpp index 8fbca290d..0d58717d4 100644 --- a/src/views/tooltips/filemetadatatooltip.cpp +++ b/src/views/tooltips/filemetadatatooltip.cpp @@ -48,7 +48,7 @@ FileMetaDataToolTip::FileMetaDataToolTip(QWidget* parent) : m_fileMetaDataWidget(0) { setAttribute(Qt::WA_TranslucentBackground); - setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint); + setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint); // Create widget for file preview m_preview = new QLabel(this); @@ -174,8 +174,6 @@ void FileMetaDataToolTip::paintEvent(QPaintEvent* event) void FileMetaDataToolTip::showEvent(QShowEvent *) { -#pragma message("TODO: port Plasma::WindowEffects::overrideShadow") - //Plasma::WindowEffects::overrideShadow(winId(), true); KWindowEffects::enableBlurBehind(winId(), true, mask()); } -- cgit v1.3.1