the widgets that accept input sets their applet status as accepting input as well.

it pretty ugly and duplicated code but doing it at this level is the only way to reliably set the proper status

svn path=/trunk/KDE/kdelibs/; revision=1128660
This commit is contained in:
Marco Martin 2010-05-19 21:45:08 +00:00
parent fcd713f149
commit 913d891b8a
8 changed files with 133 additions and 1 deletions

View File

@ -29,6 +29,7 @@
#include <plasma/private/style_p.h>
#include <plasma/private/focusindicator_p.h>
#include "applet.h"
#include "theme.h"
#include "framesvg.h"
#include "animator.h"
@ -268,7 +269,18 @@ void ComboBox::focusInEvent(QFocusEvent *event)
void ComboBox::focusOutEvent(QFocusEvent *event)
{
QGraphicsProxyWidget::focusInEvent(event);
QGraphicsWidget *widget = parentWidget();
Plasma::Applet *applet = qobject_cast<Plasma::Applet *>(widget);
while (!applet && widget) {
widget = widget->parentWidget();
applet = qobject_cast<Plasma::Applet *>(widget);
}
if (applet) {
applet->setStatus(Plasma::UnknownStatus);
}
QGraphicsProxyWidget::focusOutEvent(event);
}
void ComboBox::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
@ -293,6 +305,22 @@ void ComboBox::changeEvent(QEvent *event)
QGraphicsProxyWidget::changeEvent(event);
}
void ComboBox::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
QGraphicsWidget *widget = parentWidget();
Plasma::Applet *applet = qobject_cast<Plasma::Applet *>(widget);
while (!applet && widget) {
widget = widget->parentWidget();
applet = qobject_cast<Plasma::Applet *>(widget);
}
if (applet) {
applet->setStatus(Plasma::AcceptingInputStatus);
}
QGraphicsProxyWidget::mousePressEvent(event);
}
} // namespace Plasma
#include <combobox.moc>

View File

@ -112,6 +112,7 @@ protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void changeEvent(QEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
private:

View File

@ -29,6 +29,7 @@
#include <plasma/private/style_p.h>
#include <plasma/private/focusindicator_p.h>
#include "applet.h"
#include "theme.h"
#include "svg.h"
#include "framesvg.h"
@ -179,6 +180,38 @@ void LineEdit::changeEvent(QEvent *event)
QGraphicsProxyWidget::changeEvent(event);
}
void LineEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
QGraphicsWidget *widget = parentWidget();
Plasma::Applet *applet = qobject_cast<Plasma::Applet *>(widget);
while (!applet && widget) {
widget = widget->parentWidget();
applet = qobject_cast<Plasma::Applet *>(widget);
}
if (applet) {
applet->setStatus(Plasma::AcceptingInputStatus);
}
QGraphicsProxyWidget::mousePressEvent(event);
}
void LineEdit::focusOutEvent(QFocusEvent *event)
{
QGraphicsWidget *widget = parentWidget();
Plasma::Applet *applet = qobject_cast<Plasma::Applet *>(widget);
while (!applet && widget) {
widget = widget->parentWidget();
applet = qobject_cast<Plasma::Applet *>(widget);
}
if (applet) {
applet->setStatus(Plasma::UnknownStatus);
}
QGraphicsProxyWidget::focusOutEvent(event);
}
} // namespace Plasma
#include <lineedit.moc>

View File

@ -104,6 +104,8 @@ protected:
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void changeEvent(QEvent *event);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void focusOutEvent(QFocusEvent *event);
Q_SIGNALS:
void editingFinished();

View File

@ -27,6 +27,7 @@
#include <knuminput.h>
#include <kmimetype.h>
#include <plasma/applet.h>
#include <plasma/theme.h>
#include <plasma/framesvg.h>
#include <plasma/private/style_p.h>
@ -198,7 +199,37 @@ void SpinBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
QGraphicsProxyWidget::paint(painter, option, widget);
}
void SpinBox::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
QGraphicsWidget *widget = parentWidget();
Plasma::Applet *applet = qobject_cast<Plasma::Applet *>(widget);
while (!applet && widget) {
widget = widget->parentWidget();
applet = qobject_cast<Plasma::Applet *>(widget);
}
if (applet) {
applet->setStatus(Plasma::AcceptingInputStatus);
}
QGraphicsProxyWidget::mousePressEvent(event);
}
void SpinBox::focusOutEvent(QFocusEvent *event)
{
QGraphicsWidget *widget = parentWidget();
Plasma::Applet *applet = qobject_cast<Plasma::Applet *>(widget);
while (!applet && widget) {
widget = widget->parentWidget();
applet = qobject_cast<Plasma::Applet *>(widget);
}
if (applet) {
applet->setStatus(Plasma::UnknownStatus);
}
QGraphicsProxyWidget::focusOutEvent(event);
}
} // namespace Plasma

View File

@ -90,6 +90,8 @@ protected:
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void resizeEvent(QGraphicsSceneResizeEvent *event);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void focusOutEvent(QFocusEvent *event);
public Q_SLOTS:
/**

View File

@ -27,6 +27,7 @@
#include <kmimetype.h>
#include <ktextedit.h>
#include "applet.h"
#include "theme.h"
#include "svg.h"
#include "private/style_p.h"
@ -184,6 +185,38 @@ void TextEdit::changeEvent(QEvent *event)
QGraphicsProxyWidget::changeEvent(event);
}
void TextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
QGraphicsWidget *widget = parentWidget();
Plasma::Applet *applet = qobject_cast<Plasma::Applet *>(widget);
while (!applet && widget) {
widget = widget->parentWidget();
applet = qobject_cast<Plasma::Applet *>(widget);
}
if (applet) {
applet->setStatus(Plasma::AcceptingInputStatus);
}
QGraphicsProxyWidget::mousePressEvent(event);
}
void TextEdit::focusOutEvent(QFocusEvent *event)
{
QGraphicsWidget *widget = parentWidget();
Plasma::Applet *applet = qobject_cast<Plasma::Applet *>(widget);
while (!applet && widget) {
widget = widget->parentWidget();
applet = qobject_cast<Plasma::Applet *>(widget);
}
if (applet) {
applet->setStatus(Plasma::UnknownStatus);
}
QGraphicsProxyWidget::focusOutEvent(event);
}
} // namespace Plasma
#include <textedit.moc>

View File

@ -116,6 +116,8 @@ protected:
void resizeEvent(QGraphicsSceneResizeEvent *event);
void changeEvent(QEvent *event);
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void focusOutEvent(QFocusEvent *event);
private:
TextEditPrivate * const d;