2 * This file is part of jSpeed.
4 * jSpeed is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * jSpeed is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with jSpeed. If not, see <http://www.gnu.org/licenses/>.
19 #include <QtCore/QString>
20 #include <QtCore/QDebug>
21 #include <QtCore/QTimer>
22 #include <QtGui/QGraphicsItem>
24 #include "flickereffect.h"
25 #include "graphicselement.h"
29 Effect::AttributeDetails ATTRIBUTES[FlickerEffect::ATTRIBUTE_COUNT] =
35 FlickerEffect::FlickerEffect(): QObject(0), Effect(), interval_(500), timer_(0), item_(0)
39 FlickerEffect::~FlickerEffect()
44 bool FlickerEffect::setAttribute(QString const& name, QString const& value)
49 if((attrId = getAttribute(name, value, ATTRIBUTES, ATTRIBUTE_COUNT, realVal)) != -1)
51 Attribute attr = static_cast<Attribute>(attrId);
56 interval_ = round(realVal);
59 qDebug() << "Unknown attribute: " << attr;
71 void FlickerEffect::apply(GraphicsElement* item)
77 timer_->setInterval(interval_);
78 connect(timer_, SIGNAL(timeout()), this, SLOT(updateVisibility()));
83 void FlickerEffect::updateVisibility()
85 if(item_ && item_->canBeVisible())
87 item_->getElement()->setVisible(!item_->getElement()->isVisible());