[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/workspace/plasma/applets/kickoff/ui
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2007-10-24 4:46:08
Message-ID: 1193201168.776210.5681.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 728736 by aseigo:

make this keyboard nav friendly again .. now that left/right always switches active \
view, Enter/Escape (or alt/ctrl left/right) flips through the menu structure.

also fix a bug where when going up the menu hierarchy, the current index was still \
set to the submenu (so, press up or down and hit enter and a very surprising thing \
would happen: an app in the submenu would launch)


 M  +34 -7     flipscrollview.cpp  


--- trunk/KDE/kdebase/workspace/plasma/applets/kickoff/ui/flipscrollview.cpp \
#728735:728736 @@ -346,6 +346,7 @@
                 if (d->currentRoot().isValid()) {
                     index = d->currentRoot();
                     d->setCurrentRoot(d->currentRoot().parent());
+                    setCurrentIndex(index);
                 }
             break;
         case MoveRight:
@@ -361,13 +362,14 @@
     }
 
     // clear the hovered index
-        update(d->hoveredIndex);
-        d->hoveredIndex = QModelIndex();
-    
+    update(d->hoveredIndex);
+    d->hoveredIndex = index;
+
      //qDebug() << "New index after move" << index.data(Qt::DisplayRole);
 
     return index;
 }
+
 void FlipScrollView::setModel(QAbstractItemModel *model)
 {
     QAbstractItemView::setModel(model);
@@ -375,6 +377,7 @@
         setCurrentIndex(model->index(0,0));
     }
 }
+
 void FlipScrollView::setSelection(const QRect& rect , \
QItemSelectionModel::SelectionFlags flags)  {
     QItemSelection selection;
@@ -384,8 +387,9 @@
 
 void FlipScrollView::openItem(const QModelIndex& index)
 {
-    if (model()->canFetchMore(index))
+    if (model()->canFetchMore(index)) {
         model()->fetchMore(index);
+    }
 
     bool hasChildren = model()->hasChildren(index);
 
@@ -396,10 +400,12 @@
         //TODO Emit a signal to open/execute the item
     }
 }
+
 void FlipScrollView::resizeEvent(QResizeEvent*)
 {
     d->updateScrollBarRange();
 }
+
 void FlipScrollView::mouseReleaseEvent(QMouseEvent *event)
 {
     if (d->backArrowRect().contains(event->pos()) && d->currentRoot().isValid()) {
@@ -410,6 +416,7 @@
         QAbstractItemView::mouseReleaseEvent(event);
     }
 }
+
 void FlipScrollView::mouseMoveEvent(QMouseEvent *event) 
 {
     bool mouseOverBackArrow = d->backArrowRect().contains(event->pos());
@@ -422,15 +429,34 @@
         if (itemUnderMouse != d->hoveredIndex && itemUnderMouse.isValid()) {
             update(itemUnderMouse);
             update(d->hoveredIndex);
-        
+
             d->hoveredIndex = itemUnderMouse;
-
             setCurrentIndex(d->hoveredIndex);
         }
 
         QAbstractItemView::mouseMoveEvent(event);
-    } 
+    }
 }
+
+void FlipScrollView::keyPressEvent(QKeyEvent *event)
+{
+    if (event->key() == Qt::Key_Enter ||
+        event->key() == Qt::Key_Return) {
+        moveCursor(MoveRight, event->modifiers());
+        event->accept();
+        return;
+    }
+
+    if (event->key() == Qt::Key_Escape &&
+        d->currentRoot().isValid()) {
+        moveCursor(MoveLeft, event->modifiers());
+        event->accept();
+        return;
+    }
+
+    QAbstractItemView::keyPressEvent(event);
+}
+
 void FlipScrollView::paintEvent(QPaintEvent * event)
 {
     QPainter painter(viewport());
@@ -539,6 +565,7 @@
         painter.restore();
     }
 }
+
 void FlipScrollView::updateFlipAnimation(qreal)
 {
     setDirtyRegion(rect());


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic