they beginning of keyboard focus possibilities; hardly works at the moment, but this is the groundwork

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=797091
This commit is contained in:
Aaron J. Seigo 2008-04-14 21:50:41 +00:00
parent 4e7e2cb345
commit 4381fdfafa
4 changed files with 36 additions and 7 deletions

View File

@ -145,6 +145,7 @@ public:
// WARNING: do not access config() OR globalConfig() in this method!
// that requires a scene, which is not available at this point
applet->setAcceptsHoverEvents(true);
applet->setFlag(QGraphicsItem::ItemIsFocusable, true);
if (!appletDescription.isValid()) {
applet->setFailedToLaunch(true, i18n("Invalid applet description"));
@ -1232,6 +1233,17 @@ void Applet::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
}
void Applet::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
setFocus(Qt::MouseFocusReason);
QGraphicsWidget::mousePressEvent(event);
}
void Applet::focusInEvent(QFocusEvent * event)
{
kDebug() << "FOCUS! FOCUS! FOCUS!";
QGraphicsWidget::focusInEvent(event);
}
void Applet::showConfigurationInterface()
{

View File

@ -384,10 +384,10 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
**/
QString name() const;
/**
* @return the font currently set for this widget
**/
QFont font() const;
/**
* @return the font currently set for this widget
**/
QFont font() const;
/**
* Returns the plugin name for the applet
@ -442,7 +442,7 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
**/
void setDrawStandardBackground(bool drawBackground);
void paintWindowFrame ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget);
void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
/**
* If for some reason, the applet fails to get up on its feet (the
@ -532,13 +532,13 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
*/
bool isContainment() const;
/**
/**
* Sets the geometry of this Plasma::Applet. Should not be used directly by
* applet subclasses.
* @param geometry the geometry to apply to this Plasma::Applet.
*/
void setGeometry(const QRectF &geometry);
/**
* Causes this applet to raise above all other applets.
*/
@ -717,6 +717,11 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
*/
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
/**
* @internal manage the mouse movement to drag the applet around
*/
void mousePressEvent(QGraphicsSceneMouseEvent *event);
/**
* Reimplemented from QGraphicsItem
*/

View File

@ -1173,6 +1173,17 @@ void Containment::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Q_UNUSED(event)
}
void Containment::keyPressEvent(QKeyEvent *event)
{
kDebug() << "keyPressEvent with" << event->key() << "and hoping and wishing for a" << Qt::Key_Tab;
if (event->key() == Qt::Key_Tab) { // && event->modifiers() == 0) {
kDebug() << "let's give focus to...." << (QObject*)d->applets.first();
if (!d->applets.isEmpty()) {
d->applets.first()->setFocus(Qt::TabFocusReason);
}
}
}
bool Containment::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
{
Applet *applet = qgraphicsitem_cast<Applet*>(watched);

View File

@ -414,6 +414,7 @@ class PLASMA_EXPORT Containment : public Applet
void contextMenuEvent(QGraphicsSceneContextMenuEvent * event);
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void keyPressEvent(QKeyEvent *event);
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
QVariant itemChange(GraphicsItemChange change, const QVariant &value);