[libkwineffects] Use more std::transform in implementation part
Summary: These two should have been in D13821 but I missed them somehow. Test Plan: * Ran `qdbus org.kde.KWin /Effects loadedEffects` * Ran the following Python script ```lang=python import dbus bus = dbus.SessionBus() effects_object = bus.get_object('org.kde.KWin', '/Effects') effects_iface = dbus.Interface( effects_object, dbus_interface='org.kde.kwin.Effects' ) names = ( 'slide', 'pizza', 'cube' ) supported_statuses = effects_iface.areEffectsSupported(names) for name, supported in zip(names, supported_statuses): print("%s: %s" % (name, supported)) ``` Got the following output: ``` slide: 1 pizza: 0 cube: 1 ``` Reviewers: #kwin, mart Reviewed By: #kwin, mart Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D14002
This commit is contained in:
parent
81d851f6aa
commit
91e69e3fbd
1 changed files with 12 additions and 8 deletions
20
effects.cpp
20
effects.cpp
|
@ -1310,9 +1310,10 @@ void EffectsHandlerImpl::toggleEffect(const QString& name)
|
|||
QStringList EffectsHandlerImpl::loadedEffects() const
|
||||
{
|
||||
QStringList listModules;
|
||||
for (QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
|
||||
listModules << (*it).first;
|
||||
}
|
||||
listModules.reserve(loaded_effects.count());
|
||||
std::transform(loaded_effects.constBegin(), loaded_effects.constEnd(),
|
||||
std::back_inserter(listModules),
|
||||
[](const EffectPair &pair) { return pair.first; });
|
||||
return listModules;
|
||||
}
|
||||
|
||||
|
@ -1389,12 +1390,15 @@ bool EffectsHandlerImpl::isEffectSupported(const QString &name)
|
|||
|
||||
}
|
||||
|
||||
QList< bool > EffectsHandlerImpl::areEffectsSupported(const QStringList &names)
|
||||
QList<bool> EffectsHandlerImpl::areEffectsSupported(const QStringList &names)
|
||||
{
|
||||
QList< bool > retList;
|
||||
for (const QString &name : names) {
|
||||
retList << isEffectSupported(name);
|
||||
}
|
||||
QList<bool> retList;
|
||||
retList.reserve(names.count());
|
||||
std::transform(names.constBegin(), names.constEnd(),
|
||||
std::back_inserter(retList),
|
||||
[this](const QString &name) {
|
||||
return isEffectSupported(name);
|
||||
});
|
||||
return retList;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue