Merge branch 'Plasma/5.12' into Plasma/5.13
This commit is contained in:
commit
d6bce8d79e
1 changed files with 24 additions and 21 deletions
|
@ -84,7 +84,9 @@ inline Effect *createHelper()
|
|||
return new T();
|
||||
}
|
||||
|
||||
static const QVector<EffectData> s_effectData = {
|
||||
static const QVector<EffectData> &effectData()
|
||||
{
|
||||
static const QVector<EffectData> s_effectData = {
|
||||
{
|
||||
QString(),
|
||||
QString(),
|
||||
|
@ -683,7 +685,9 @@ EFFECT_FALLBACK
|
|||
#endif
|
||||
EFFECT_FALLBACK
|
||||
}
|
||||
};
|
||||
};
|
||||
return s_effectData;
|
||||
}
|
||||
|
||||
static inline int index(BuiltInEffect effect)
|
||||
{
|
||||
|
@ -692,21 +696,21 @@ static inline int index(BuiltInEffect effect)
|
|||
|
||||
Effect *create(BuiltInEffect effect)
|
||||
{
|
||||
const EffectData &effectData = s_effectData.at(index(effect));
|
||||
if (effectData.createFunction == nullptr) {
|
||||
const EffectData &data = effectData(effect);
|
||||
if (data.createFunction == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return effectData.createFunction();
|
||||
return data.createFunction();
|
||||
}
|
||||
|
||||
bool available(const QString &name)
|
||||
{
|
||||
auto it = std::find_if(s_effectData.begin(), s_effectData.end(),
|
||||
auto it = std::find_if(effectData().begin(), effectData().end(),
|
||||
[name](const EffectData &data) {
|
||||
return data.name == name;
|
||||
}
|
||||
);
|
||||
return it != s_effectData.end();
|
||||
return it != effectData().end();
|
||||
}
|
||||
|
||||
bool supported(BuiltInEffect effect)
|
||||
|
@ -714,11 +718,11 @@ bool supported(BuiltInEffect effect)
|
|||
if (effect == BuiltInEffect::Invalid) {
|
||||
return false;
|
||||
}
|
||||
const EffectData &effectData = s_effectData.at(index(effect));
|
||||
if (effectData.supportedFunction == nullptr) {
|
||||
const EffectData &data = effectData(effect);
|
||||
if (data.supportedFunction == nullptr) {
|
||||
return true;
|
||||
}
|
||||
return effectData.supportedFunction();
|
||||
return data.supportedFunction();
|
||||
}
|
||||
|
||||
bool checkEnabledByDefault(BuiltInEffect effect)
|
||||
|
@ -726,23 +730,22 @@ bool checkEnabledByDefault(BuiltInEffect effect)
|
|||
if (effect == BuiltInEffect::Invalid) {
|
||||
return false;
|
||||
}
|
||||
const EffectData &effectData = s_effectData.at(index(effect));
|
||||
if (effectData.enabledFunction == nullptr) {
|
||||
const EffectData &data = effectData(effect);
|
||||
if (data.enabledFunction == nullptr) {
|
||||
return true;
|
||||
}
|
||||
return effectData.enabledFunction();
|
||||
return data.enabledFunction();
|
||||
}
|
||||
|
||||
bool enabledByDefault(BuiltInEffect effect)
|
||||
{
|
||||
const EffectData &effectData = s_effectData.at(index(effect));
|
||||
return effectData.enabled;
|
||||
return effectData(effect).enabled;
|
||||
}
|
||||
|
||||
QStringList availableEffectNames()
|
||||
{
|
||||
QStringList result;
|
||||
for (const EffectData &data : s_effectData) {
|
||||
for (const EffectData &data : effectData()) {
|
||||
if (data.name.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -762,25 +765,25 @@ QList< BuiltInEffect > availableEffects()
|
|||
|
||||
BuiltInEffect builtInForName(const QString &name)
|
||||
{
|
||||
auto it = std::find_if(s_effectData.begin(), s_effectData.end(),
|
||||
auto it = std::find_if(effectData().begin(), effectData().end(),
|
||||
[name](const EffectData &data) {
|
||||
return data.name == name;
|
||||
}
|
||||
);
|
||||
if (it == s_effectData.end()) {
|
||||
if (it == effectData().end()) {
|
||||
return BuiltInEffect::Invalid;
|
||||
}
|
||||
return BuiltInEffect(std::distance(s_effectData.begin(), it));
|
||||
return BuiltInEffect(std::distance(effectData().begin(), it));
|
||||
}
|
||||
|
||||
QString nameForEffect(BuiltInEffect effect)
|
||||
{
|
||||
return s_effectData.at(index(effect)).name;
|
||||
return effectData(effect).name;
|
||||
}
|
||||
|
||||
const EffectData &effectData(BuiltInEffect effect)
|
||||
{
|
||||
return s_effectData.at(index(effect));
|
||||
return effectData().at(index(effect));
|
||||
}
|
||||
|
||||
} // BuiltInEffects
|
||||
|
|
Loading…
Reference in a new issue