From kde-commits Mon Aug 31 23:39:38 2009 From: Marco Martin Date: Mon, 31 Aug 2009 23:39:38 +0000 To: kde-commits Subject: playground/base/plasma/netbook/containments/sal Message-Id: <1251761978.381980.4197.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=125176198503479 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(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(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(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