[libkwineffects] Drop AniData constructor that receives QString

Summary:
This code has several bugs, it's untested, it's not used anywhere, it
adds unnecessary complexity -> delete it.

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16099
This commit is contained in:
Vlad Zagorodniy 2018-10-10 11:37:26 +03:00
parent 48002ab7fe
commit 2569768074
2 changed files with 0 additions and 116 deletions

View file

@ -72,99 +72,6 @@ AniData::AniData(AnimationEffect::Attribute a, int meta_, int ms, const FPx2 &to
{ {
} }
static FPx2 fpx2(const QString &s, AnimationEffect::Attribute a)
{
bool ok; float f1, f2;
const QVector<QStringRef> floats = s.splitRef(u',');
f1 = floats.at(0).toFloat(&ok);
if (!ok || (f1 < 0.0 && !( a == AnimationEffect::Position ||
a == AnimationEffect::Translation ||
a == AnimationEffect::Size ||
a == AnimationEffect::Rotation)) ) {
if (ok)
qCDebug(LIBKWINEFFECTS) << "Invalid value (must not be negative)" << s;
return FPx2();
}
bool forced_align = (floats.count() < 2);
if (forced_align)
f2 = f1;
else {
f2 = floats.at(1).toFloat(&ok);
if ( (forced_align = !ok || (f2 < 0.0 && !( a == AnimationEffect::Position ||
a == AnimationEffect::Translation ||
a == AnimationEffect::Size ||
a == AnimationEffect::Rotation))) )
f2 = f1;
}
if ( forced_align && a >= AnimationEffect::NonFloatBase )
qCDebug(LIBKWINEFFECTS) << "Generic Animations, WARNING: had to align second dimension of non-onedimensional attribute" << a;
return FPx2(f1, f2);
}
AniData::AniData(const QString &str) // format: WindowMask:Attribute:Meta:Duration:To:Shape:Delay:From
: customCurve(0) // Linear
, time(0)
, duration(1) // invalidate
{
const QVector<QStringRef> animation = str.splitRef(u':');
if (animation.count() < 5)
return; // at least window type, attribute, metadata, time and target is required
windowType = (NET::WindowTypeMask)animation.at(0).toUInt();
if (animation.at(1) == QLatin1String("Opacity")) attribute = AnimationEffect::Opacity;
else if (animation.at(1) == QLatin1String("Brightness")) attribute = AnimationEffect::Brightness;
else if (animation.at(1) == QLatin1String("Saturation")) attribute = AnimationEffect::Saturation;
else if (animation.at(1) == QLatin1String("Scale")) attribute = AnimationEffect::Scale;
else if (animation.at(1) == QLatin1String("Translation")) attribute = AnimationEffect::Translation;
else if (animation.at(1) == QLatin1String("Rotation")) attribute = AnimationEffect::Rotation;
else if (animation.at(1) == QLatin1String("Position")) attribute = AnimationEffect::Position;
else if (animation.at(1) == QLatin1String("Size")) attribute = AnimationEffect::Size;
else if (animation.at(1) == QLatin1String("Clip")) attribute = AnimationEffect::Clip;
else {
qCDebug(LIBKWINEFFECTS) << "Invalid attribute" << animation.at(1);
return;
}
meta = animation.at(2).toUInt();
bool ok;
duration = animation.at(3).toInt(&ok);
if (!ok || duration < 0) {
qCDebug(LIBKWINEFFECTS) << "Invalid duration" << animation.at(3);
duration = 0;
return;
}
to = fpx2(animation.at(4).toString(), attribute);
if (animation.count() > 5) {
customCurve = animation.at(5).toInt();
if (customCurve < QEasingCurve::Custom)
curve.setType((QEasingCurve::Type)customCurve);
else if (customCurve == Gaussian)
curve.setCustomType(AnimationEffect::qecGaussian);
else
qCDebug(LIBKWINEFFECTS) << "Unknown curve type" << customCurve; // remains default, ie. linear
if (animation.count() > 6) {
int t = animation.at(6).toInt();
if (t < 0)
qCDebug(LIBKWINEFFECTS) << "Delay can not be negative" << animation.at(6);
else
time = t;
if (animation.count() > 7)
from = fpx2(animation.at(7).toString(), attribute);
}
}
if (!(from.isValid() || to.isValid())) {
duration = -1; // invalidate
return;
}
}
static QString attributeString(KWin::AnimationEffect::Attribute attribute) static QString attributeString(KWin::AnimationEffect::Attribute attribute)
{ {
switch (attribute) { switch (attribute) {
@ -181,26 +88,6 @@ static QString attributeString(KWin::AnimationEffect::Attribute attribute)
} }
} }
QList<AniData> AniData::list(const QString &str)
{
QList<AniData> newList;
foreach (const QString &astr, str.split(u';', QString::SkipEmptyParts)) {
newList << AniData(astr);
if (newList.last().duration < 0)
newList.removeLast();
}
return newList;
}
QString AniData::toString() const
{
QString ret = QString::number((uint)windowType) + QLatin1Char(':') + attributeString(attribute) + QLatin1Char(':') +
QString::number(meta) + QLatin1Char(':') + QString::number(duration) + QLatin1Char(':') +
to.toString() + QLatin1Char(':') + QString::number(customCurve) + QLatin1Char(':') +
QString::number(time) + QLatin1Char(':') + from.toString();
return ret;
}
QString AniData::debugInfo() const QString AniData::debugInfo() const
{ {
return QLatin1String("Animation: ") + attributeString(attribute) + return QLatin1String("Animation: ") + attributeString(attribute) +

View file

@ -45,15 +45,12 @@ public:
AniData(); AniData();
AniData(AnimationEffect::Attribute a, int meta, int ms, const FPx2 &to, AniData(AnimationEffect::Attribute a, int meta, int ms, const FPx2 &to,
QEasingCurve curve, int delay, const FPx2 &from, bool waitAtSource, bool keepAtTarget = false, FullScreenEffectLockPtr=FullScreenEffectLockPtr()); QEasingCurve curve, int delay, const FPx2 &from, bool waitAtSource, bool keepAtTarget = false, FullScreenEffectLockPtr=FullScreenEffectLockPtr());
explicit AniData(const QString &str);
inline void addTime(int t) { time += t; } inline void addTime(int t) { time += t; }
inline bool isOneDimensional() const { inline bool isOneDimensional() const {
return from[0] == from[1] && to[0] == to[1]; return from[0] == from[1] && to[0] == to[1];
} }
quint64 id{0}; quint64 id{0};
static QList<AniData> list(const QString &str);
QString toString() const;
QString debugInfo() const; QString debugInfo() const;
AnimationEffect::Attribute attribute; AnimationEffect::Attribute attribute;
QEasingCurve curve; QEasingCurve curve;