plugin/hypr: fix updating keyboards
This commit is contained in:
parent
d3fac6805f
commit
423ca87181
1 changed files with 10 additions and 5 deletions
|
|
@ -93,13 +93,18 @@ bool HyprDevices::updateLastIpcObject(QJsonObject object) {
|
||||||
const auto val = object.value("keyboards").toArray();
|
const auto val = object.value("keyboards").toArray();
|
||||||
bool dirty = false;
|
bool dirty = false;
|
||||||
|
|
||||||
for (const auto& keyboard : std::as_const(m_keyboards)) {
|
for (auto it = m_keyboards.begin(); it != m_keyboards.end();) {
|
||||||
if (std::find_if(val.begin(), val.end(), [keyboard](const QJsonValue& object) {
|
auto* const keyboard = *it;
|
||||||
return object.toObject().value("address").toString() == keyboard->address();
|
const auto inNewValues = std::any_of(val.begin(), val.end(), [keyboard](const QJsonValue& object) {
|
||||||
}) == val.end()) {
|
return object.toObject().value("address").toString() == keyboard->address();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!inNewValues) {
|
||||||
dirty = true;
|
dirty = true;
|
||||||
m_keyboards.removeAll(keyboard);
|
it = m_keyboards.erase(it);
|
||||||
keyboard->deleteLater();
|
keyboard->deleteLater();
|
||||||
|
} else {
|
||||||
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue