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

List:       kde-commits
Subject:    playground/base/plasma/netbook/containments/sal
From:       Marco Martin <notmart () gmail ! com>
Date:       2009-08-31 23:39:38
Message-ID: 1251761978.381980.4197.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1017942 by mart:

navigate with keyboard


 M  +17 -9     stripwidget.cpp  
 M  +1 -0      stripwidget.h  


--- trunk/playground/base/plasma/netbook/containments/sal/stripwidget.cpp \
#1017941:1017942 @@ -37,7 +37,8 @@
     : QGraphicsWidget(parent),
       m_runnermg(rm),
       m_shownIcons(5),
-      m_offset(0)
+      m_offset(0),
+      m_currentIconIndex(-1)
 {
     m_background = new Plasma::Frame();
     m_background->setFrameShadow(Plasma::Frame::Raised);
@@ -55,6 +56,7 @@
     m_hoverIndicator->hide();
     m_hoverIndicator->setZValue(-100);
     setAcceptHoverEvents(true);
+    setFocusPolicy(Qt::StrongFocus);
 
     m_leftArrow = new Plasma::PushButton(this);
     m_leftArrow->nativeWidget()->setIcon(KIcon("arrow-left"));
@@ -307,16 +309,20 @@
 void StripWidget::keyPressEvent(QKeyEvent *event)
 {
     switch (event->key()) {
-    case Qt::Key_Left:
-        focusNextPrevChild(false);
+    case Qt::Key_Left: {
+        m_currentIconIndex = (m_stripLayout->count() + m_currentIconIndex - 1) % \
m_stripLayout->count(); +        QGraphicsWidget *currentIcon = \
static_cast<QGraphicsWidget *>(m_stripLayout->itemAt(m_currentIconIndex)); +        \
currentIcon->setFocus(); +        m_hoverIndicator->setTargetItem(currentIcon);
         break;
-    case Qt::Key_Right:
-        focusNextPrevChild(true);
+    }
+    case Qt::Key_Right: {
+        m_currentIconIndex = (m_currentIconIndex + 1) % m_stripLayout->count();
+        QGraphicsWidget *currentIcon = static_cast<QGraphicsWidget \
*>(m_stripLayout->itemAt(m_currentIconIndex)); +        currentIcon->setFocus();
+        m_hoverIndicator->setTargetItem(currentIcon);
         break;
-    case Qt::Key_Enter:
-    case Qt::Key_Return:
-        //TODO;
-        break;
+    }
     default:
         break;
     }
@@ -332,11 +338,13 @@
     Plasma::IconWidget *icon = \
static_cast<Plasma::IconWidget*>(m_stripLayout->itemAt(m_stripLayout->count()-1));  \
show();  m_hoverIndicator->setTargetItem(icon);
+    m_currentIconIndex = 0;
 }
 
 void StripWidget::focusOutEvent(QFocusEvent *event)
 {
     m_hoverIndicator->hide();
+    m_currentIconIndex = -1;
 }
 
 void StripWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
--- trunk/playground/base/plasma/netbook/containments/sal/stripwidget.h \
#1017941:1017942 @@ -86,6 +86,7 @@
     Plasma::ItemBackground *m_hoverIndicator;
     int m_shownIcons;
     int m_offset;
+    int m_currentIconIndex;
 };
 
 #endif


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

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