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); this, &AppletInterface::statusChanged);
connect(applet(), &Plasma::Applet::destroyedChanged, connect(applet(), &Plasma::Applet::destroyedChanged,
this, [=] () { this, &AppletInterface::destroyedChanged);
setVisible(!applet()->destroyed());
});
connect(applet(), &Plasma::Applet::activated, connect(applet(), &Plasma::Applet::activated,
this, &AppletInterface::activated); this, &AppletInterface::activated);
@ -132,9 +130,7 @@ AppletInterface::AppletInterface(Plasma::Applet *a, const QVariantList &args, QQ
this, &AppletInterface::statusChanged); this, &AppletInterface::statusChanged);
connect(applet(), &Plasma::Applet::destroyedChanged, connect(applet(), &Plasma::Applet::destroyedChanged,
[=] () { this, &AppletInterface::destroyedChanged);
setVisible(!applet()->destroyed());
});
connect(appletScript(), &DeclarativeAppletScript::formFactorChanged, connect(appletScript(), &DeclarativeAppletScript::formFactorChanged,
this, &AppletInterface::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 Plasma::Types::FormFactor AppletInterface::formFactor() const
{ {
return applet()->formFactor(); return applet()->formFactor();

View File

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