workaround on textarea input breaking
this makes sure if there is an item with focus in the applet, it and all its parent are removed the focus when the applet is deleted. otherwise when there is an item with focus that loses its qquickwindow, it will never be able to gain it again it's a workaround but i'm not sure how should be fixed in qquickitem, or if is even appropriate Change-Id: I72c8f01d4557003604c4261ca5a9ab49dd136b02
This commit is contained in:
parent
bb0bd0a4c5
commit
b54e328304
@ -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();
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user