Merge "workaround on textarea input breaking"

This commit is contained in:
Marco Martin 2014-11-04 15:14:11 +01:00 committed by Gerrit Code Review
commit 36cd79b590
2 changed files with 35 additions and 6 deletions

View File

@ -75,9 +75,7 @@ AppletInterface::AppletInterface(DeclarativeAppletScript *script, const QVariant
this, &AppletInterface::statusChanged);
connect(applet(), &Plasma::Applet::destroyedChanged,
this, [=] () {
setVisible(!applet()->destroyed());
});
this, &AppletInterface::destroyedChanged);
connect(applet(), &Plasma::Applet::activated,
this, &AppletInterface::activated);
@ -132,9 +130,7 @@ AppletInterface::AppletInterface(Plasma::Applet *a, const QVariantList &args, QQ
this, &AppletInterface::statusChanged);
connect(applet(), &Plasma::Applet::destroyedChanged,
[=] () {
setVisible(!applet()->destroyed());
});
this, &AppletInterface::destroyedChanged);
connect(appletScript(), &DeclarativeAppletScript::formFactorChanged,
this, &AppletInterface::formFactorChanged);
@ -187,6 +183,36 @@ void AppletInterface::init()
}
}
void AppletInterface::destroyedChanged(bool destroyed)
{
//if an item loses its scene before losing the focus, will never
//be able to gain focus again
if (destroyed && window() && window()->activeFocusItem()) {
QQuickItem *focus = window()->activeFocusItem();
QQuickItem *candidate = focus;
bool isAncestor = false;
//search if the current focus item is a child or granchild of the applet
while (candidate) {
if (candidate == this) {
isAncestor = true;
break;
}
candidate = candidate->parentItem();
}
//Found? remove focus for the whole hyerarchy
candidate = focus;
while (candidate && candidate != this) {
candidate->setFocus(false);
candidate = candidate->parentItem();
}
}
setVisible(!destroyed);
}
Plasma::Types::FormFactor AppletInterface::formFactor() const
{
return applet()->formFactor();

View File

@ -353,6 +353,9 @@ protected Q_SLOTS:
protected:
bool eventFilter(QObject *watched, QEvent *event);
private Q_SLOTS:
void destroyedChanged(bool destroyed);
private:
QStringList m_actions;