Hi,
I'm relatively new to KDE, and I would like to contribute, if I could.
As a first try I made a patch which allows automatic scroll in
application tab of kickoff, because it's really hard to navigate in long
lists without a mouse wheel. I don't know whether such an automatic
scrolling suits in to the usability concept.
Regards,
Andras
Index: flipscrollview.cpp
===================================================================
--- flipscrollview.cpp (revision 896189)
+++ flipscrollview.cpp (working copy)
@@ -44,12 +44,14 @@
: q(view)
, backArrowHover(false)
, flipAnimTimeLine(new QTimeLine())
+ , autoScrollTimeLine( new QTimeLine())
, animLeftToRight(true)
, itemHeight(-1) {
}
~Private() {
delete flipAnimTimeLine;
+ delete autoScrollTimeLine;
}
QModelIndex currentRoot() const {
@@ -231,16 +233,44 @@
q->verticalScrollBar()->setSingleStep(itemH);
}
+ void startAutoScrollUp() {
+ int frames = q->currentIndex().row();
+ qreal duration = qreal(frames * SCROLL_ANIM_DURATION) ;
+ scrollUp = true;
+ autoScrollTimeLine->setFrameRange(0, frames);
+ autoScrollTimeLine->setDuration(duration);
+ autoScrollTimeLine->setCurrentTime(1);
+ autoScrollTimeLine->start();
+ }
+
+ void startAutoScrollDown() {
+ scrollUp = false;
+ const int rows = q->model()->rowCount(currentRootIndex);
+ int frames = rows - 1 - q->currentIndex().row();
+ qreal duration = qreal(frames * SCROLL_ANIM_DURATION) ;
+ autoScrollTimeLine->setFrameRange(0, frames);
+ autoScrollTimeLine->setDuration(duration);
+ autoScrollTimeLine->setCurrentTime(1);
+ autoScrollTimeLine->start();
+ }
+
+ void stopAutoScroll() {
+ autoScrollTimeLine->stop();
+ }
+
FlipScrollView * const q;
bool backArrowHover;
QPersistentModelIndex hoveredIndex;
QPersistentModelIndex watchedIndexForDrag;
QTimeLine *flipAnimTimeLine;
+ QTimeLine *autoScrollTimeLine;
bool animLeftToRight;
-
+ bool scrollUp;
+
int itemHeight;
static const int FLIP_ANIM_DURATION = 200;
+ static const int SCROLL_ANIM_DURATION = 150;
private:
QPersistentModelIndex currentRootIndex;
@@ -254,6 +284,7 @@
{
connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(openItem(QModelIndex)));
connect(d->flipAnimTimeLine, SIGNAL(valueChanged(qreal)), this, SLOT(updateFlipAnimation(qreal)));
+ connect(d->autoScrollTimeLine, SIGNAL(frameChanged(int)), this, SLOT(autoScroll(int)));
d->flipAnimTimeLine->setDuration(Private::FLIP_ANIM_DURATION);
d->flipAnimTimeLine->setCurrentTime(Private::FLIP_ANIM_DURATION);
setIconSize(QSize(KIconLoader::SizeMedium, KIconLoader::SizeMedium));
@@ -514,7 +545,21 @@
d->hoveredIndex = itemUnderMouse;
setCurrentIndex(d->hoveredIndex);
}
-
+ else if (event->pos().y() < itemHeight() / 2) {
+ if (currentIndex().row() > 0 &&
+ d->autoScrollTimeLine->state()!=QTimeLine::Running ) {
+ d->startAutoScrollUp();
+ }
+ }
+ else if ( event->pos().y() > height() - (itemHeight() / 2)) {
+ if (currentIndex().row() < model()->rowCount(d->currentRoot()) - 1 &&
+ d->autoScrollTimeLine->state()!=QTimeLine::Running) {
+ d->startAutoScrollDown();
+ }
+ }
+ else if (d->autoScrollTimeLine->state()==QTimeLine::Running) {
+ d->stopAutoScroll();
+ }
QAbstractItemView::mouseMoveEvent(event);
}
}
@@ -720,4 +765,21 @@
setDirtyRegion(rect());
}
+void FlipScrollView::autoScroll(int frame) {
+ if (frame==0) return;
+ QModelIndex sibling;
+ if (d->scrollUp) {
+ sibling = currentIndex().sibling(currentIndex().row() - 1, currentIndex().column());
+ }
+ else {
+ sibling = currentIndex().sibling(currentIndex().row() + 1, currentIndex().column());
+ }
+ setCurrentIndex(sibling);
+ if (d->hoveredIndex!=sibling) {
+ update(d->hoveredIndex);
+ d->hoveredIndex = sibling;
+ }
+ setDirtyRegion(rect());
+}
+
#include "flipscrollview.moc"
Index: flipscrollview.h
===================================================================
--- flipscrollview.h (revision 896189)
+++ flipscrollview.h (working copy)
@@ -82,6 +82,7 @@
private Q_SLOTS:
void openItem(const QModelIndex& index);
void updateFlipAnimation(qreal value);
+ void autoScroll(int);
private:
void paintItems(QPainter &painter, QPaintEvent *event, QModelIndex &index);
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel