mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
Revert "plasma: drop animations support"
This reverts commit ff0eb06a56
.
This commit is contained in:
parent
e19bbb94c0
commit
b05003a731
16 changed files with 257 additions and 6 deletions
|
@ -23,6 +23,7 @@
|
|||
#include "iconview.h"
|
||||
|
||||
#include <Plasma/PaintUtils>
|
||||
#include <Plasma/Animator>
|
||||
#include <Plasma/Svg>
|
||||
|
||||
#include <QPainter>
|
||||
|
@ -156,6 +157,17 @@ ActionOverlay::ActionOverlay(AbstractItemView* parent)
|
|||
m_hideActionOverlayIconTimer->setInterval(500);
|
||||
m_hideActionOverlayIconTimer->setSingleShot(true);
|
||||
|
||||
fadeIn = Plasma::Animator::create(Plasma::Animator::FadeAnimation, this);
|
||||
fadeIn->setProperty("startOpacity", 0);
|
||||
fadeIn->setProperty("targetOpacity", 1);
|
||||
fadeIn->setTargetWidget(this);
|
||||
|
||||
fadeOut = Plasma::Animator::create(Plasma::Animator::FadeAnimation, this);
|
||||
fadeOut->setProperty("startOpacity", 1);
|
||||
fadeOut->setProperty("targetOpacity", 0);
|
||||
fadeOut->setTargetWidget(this);
|
||||
connect(fadeOut, SIGNAL(finished()), SLOT(close()));
|
||||
|
||||
hide();
|
||||
}
|
||||
|
||||
|
@ -200,6 +212,8 @@ void ActionOverlay::entered(const QModelIndex &index)
|
|||
show();
|
||||
if (m_hoverIndex != index) {
|
||||
m_toggleButton->update();
|
||||
fadeOut->stop();
|
||||
fadeIn->start();
|
||||
}
|
||||
m_hoverIndex = index;
|
||||
IconView *iview = qobject_cast<IconView*>(view);
|
||||
|
@ -230,8 +244,9 @@ void ActionOverlay::timeout()
|
|||
// allow the animation to restart after hiding the ActionOverlayIcon even if m_hoverIndex didn't change
|
||||
m_hoverIndex = QPersistentModelIndex();
|
||||
|
||||
if (isVisible()) {
|
||||
close();
|
||||
if (isVisible() && (fadeOut->state() != QAbstractAnimation::Running)) {
|
||||
fadeIn->stop();
|
||||
fadeOut->start();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include "abstractitemview.h"
|
||||
|
||||
#include <Plasma/Animation>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QGraphicsWidget>
|
||||
#include <QtCore/qabstractitemmodel.h>
|
||||
|
@ -96,6 +98,8 @@ private:
|
|||
ActionIcon *m_openButton;
|
||||
QPersistentModelIndex m_hoverIndex;
|
||||
QTimer *m_hideActionOverlayIconTimer;
|
||||
Plasma::Animation *fadeIn;
|
||||
Plasma::Animation *fadeOut;
|
||||
bool m_showFolderButton;
|
||||
bool m_showSelectionButton;
|
||||
QGraphicsGridLayout * m_layout;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
|
||||
#include <Plasma/Containment>
|
||||
#include <Plasma/Animator>
|
||||
|
||||
#include "desktoplayout.h"
|
||||
|
||||
|
|
|
@ -105,6 +105,8 @@ void DesktopCorona::init()
|
|||
connect(this, SIGNAL(availableScreenRegionChanged()), m_delayedUpdateTimer, SLOT(start()));
|
||||
connect(m_delayedUpdateTimer, SIGNAL(timeout()), this, SLOT(update()));
|
||||
|
||||
mapAnimation(Plasma::Animator::AppearAnimation, Plasma::Animator::ZoomAnimation);
|
||||
mapAnimation(Plasma::Animator::DisappearAnimation, Plasma::Animator::ZoomAnimation);
|
||||
kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "DesktopCorona init end" << "(line:" << __LINE__ << ")";
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <KDebug>
|
||||
#include <KIconLoader>
|
||||
|
||||
#include <Plasma/Animation>
|
||||
#include <Plasma/Applet>
|
||||
#include <Plasma/Containment>
|
||||
#include <Plasma/FrameSvg>
|
||||
|
@ -479,6 +480,11 @@ void DesktopToolBox::showToolBox()
|
|||
|
||||
m_toolBacker->setOpacity(0);
|
||||
m_toolBacker->show();
|
||||
Plasma::Animation *fadeAnim = Plasma::Animator::create(Plasma::Animator::FadeAnimation, m_toolBacker);
|
||||
fadeAnim->setTargetWidget(m_toolBacker);
|
||||
fadeAnim->setProperty("startOpacity", 0);
|
||||
fadeAnim->setProperty("targetOpacity", 1);
|
||||
fadeAnim->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
highlight(true);
|
||||
setFocus();
|
||||
}
|
||||
|
@ -666,7 +672,12 @@ void DesktopToolBox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
void DesktopToolBox::hideToolBox()
|
||||
{
|
||||
if (m_toolBacker) {
|
||||
hideToolBacker();
|
||||
Plasma::Animation *fadeAnim = Plasma::Animator::create(Plasma::Animator::FadeAnimation, m_toolBacker);
|
||||
connect(fadeAnim, SIGNAL(finished()), this, SLOT(hideToolBacker()));
|
||||
fadeAnim->setTargetWidget(m_toolBacker);
|
||||
fadeAnim->setProperty("startOpacity", 1);
|
||||
fadeAnim->setProperty("targetOpacity", 0);
|
||||
fadeAnim->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
}
|
||||
|
||||
highlight(false);
|
||||
|
@ -684,6 +695,32 @@ void DesktopToolBox::highlight(bool highlighting)
|
|||
}
|
||||
|
||||
m_hovering = highlighting;
|
||||
|
||||
QPropertyAnimation *anim = m_anim.data();
|
||||
if (m_hovering) {
|
||||
if (anim) {
|
||||
anim->stop();
|
||||
m_anim.clear();
|
||||
}
|
||||
anim = new QPropertyAnimation(this, "highlight", this);
|
||||
m_anim = anim;
|
||||
}
|
||||
|
||||
if (anim->state() != QAbstractAnimation::Stopped) {
|
||||
anim->stop();
|
||||
}
|
||||
|
||||
anim->setDuration(250);
|
||||
anim->setStartValue(0);
|
||||
anim->setEndValue(1);
|
||||
|
||||
if (m_hovering) {
|
||||
anim->start();
|
||||
} else {
|
||||
anim->setDirection(QAbstractAnimation::Backward);
|
||||
anim->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopToolBox::setHighlight(qreal progress)
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <KIcon>
|
||||
|
||||
#include <Plasma/Animator>
|
||||
#include <Plasma/IconWidget>
|
||||
|
||||
#include "internaltoolbox.h"
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
#include <KIcon>
|
||||
|
||||
#include <Plasma/Animator>
|
||||
|
||||
#include "internaltoolbox.h"
|
||||
|
||||
class Widget;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include <plasma/theme.h>
|
||||
#include <plasma/framesvg.h>
|
||||
#include <plasma/animator.h>
|
||||
#include <plasma/paintutils.h>
|
||||
#include <Plasma/ComboBox>
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include <kwebwallet.h>
|
||||
#include <KStandardDirs>
|
||||
|
||||
#include <Plasma/Animation>
|
||||
#include <Plasma/IconWidget>
|
||||
#include <Plasma/WebView>
|
||||
#include <Plasma/TreeView>
|
||||
|
@ -150,6 +151,10 @@ QGraphicsWidget *WebBrowser::graphicsWidget()
|
|||
m_removeBookmarkAction = new QAction(KIcon("list-remove"), QString(), this);
|
||||
m_organizeBookmarks = addTool("bookmarks-organize", m_statusbarLayout);
|
||||
|
||||
m_bookmarksViewAnimation = Plasma::Animator::create(Plasma::Animator::FadeAnimation, this);
|
||||
m_bookmarksViewAnimation->setTargetWidget(m_bookmarksView);
|
||||
connect(m_bookmarksViewAnimation, SIGNAL(finished()), this, SLOT(bookmarksAnimationFinished()));
|
||||
|
||||
m_stop = addTool("process-stop", m_statusbarLayout);
|
||||
|
||||
QGraphicsWidget *spacer = new QGraphicsWidget(this);
|
||||
|
@ -459,12 +464,16 @@ void WebBrowser::removeBookmark()
|
|||
void WebBrowser::bookmarksToggle()
|
||||
{
|
||||
if (m_bookmarksView->isVisible()) {
|
||||
bookmarksAnimationFinished();
|
||||
m_bookmarksViewAnimation->setProperty("startOpacity", 1);
|
||||
m_bookmarksViewAnimation->setProperty("targetOpacity", 0);
|
||||
m_bookmarksViewAnimation->start();
|
||||
} else {
|
||||
m_bookmarksView->show();
|
||||
m_bookmarksView->setOpacity(0);
|
||||
updateOverlaysGeometry();
|
||||
bookmarksAnimationFinished();
|
||||
m_bookmarksViewAnimation->setProperty("startOpacity", 0);
|
||||
m_bookmarksViewAnimation->setProperty("targetOpacity", 1);
|
||||
m_bookmarksViewAnimation->start();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -130,6 +130,7 @@ private:
|
|||
KBookmarkManager *m_bookmarkManager;
|
||||
QStandardItemModel *m_bookmarkModel;
|
||||
Plasma::TreeView *m_bookmarksView;
|
||||
Plasma::Animation *m_bookmarksViewAnimation;
|
||||
|
||||
QTimer *m_autoRefreshTimer;
|
||||
bool m_autoRefresh;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "desktop.h"
|
||||
|
||||
#include <QtGui/qgraphicssceneevent.h>
|
||||
#include <QtGui/qgraphicssceneevent.h>
|
||||
|
||||
#include <KDebug>
|
||||
|
|
|
@ -27,8 +27,10 @@
|
|||
#include <QParallelAnimationGroup>
|
||||
#include <QTimer>
|
||||
|
||||
|
||||
#include <KIconLoader>
|
||||
|
||||
#include <plasma/animations/animation.h>
|
||||
#include <plasma/applet.h>
|
||||
#include <plasma/svg.h>
|
||||
#include <plasma/theme.h>
|
||||
|
@ -50,6 +52,11 @@ AppletTitleBar::AppletTitleBar(Plasma::Applet *applet)
|
|||
|
||||
setZValue(10000);
|
||||
|
||||
|
||||
m_pulse =
|
||||
Plasma::Animator::create(Plasma::Animator::PulseAnimation);
|
||||
m_pulse->setTargetWidget(applet);
|
||||
|
||||
m_maximizeButtonRect = m_configureButtonRect = m_closeButtonRect = QRect(0, 0, KIconLoader::SizeSmallMedium, KIconLoader::SizeSmallMedium);
|
||||
|
||||
m_icons = new Plasma::Svg(this);
|
||||
|
@ -82,6 +89,8 @@ AppletTitleBar::AppletTitleBar(Plasma::Applet *applet)
|
|||
|
||||
AppletTitleBar::~AppletTitleBar()
|
||||
{
|
||||
delete m_pulse;
|
||||
delete m_animations.data();
|
||||
}
|
||||
|
||||
void AppletTitleBar::setButtonsVisible(bool visible)
|
||||
|
@ -91,6 +100,28 @@ void AppletTitleBar::setButtonsVisible(bool visible)
|
|||
}
|
||||
|
||||
m_buttonsVisible = visible;
|
||||
|
||||
if (visible) {
|
||||
if (!m_animations) {
|
||||
initAnimations();
|
||||
|
||||
m_animations.data()->start();
|
||||
m_animations.data()->setCurrentTime(0);
|
||||
} else {
|
||||
QParallelAnimationGroup *group = m_animations.data();
|
||||
|
||||
group->stop();
|
||||
group->setCurrentTime(0);
|
||||
group->setDirection(QAbstractAnimation::Forward);
|
||||
|
||||
group->start();
|
||||
}
|
||||
} else {
|
||||
initAnimations();
|
||||
QParallelAnimationGroup *group = m_animations.data();
|
||||
group->setDirection(QAbstractAnimation::Backward);
|
||||
group->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
}
|
||||
}
|
||||
|
||||
bool AppletTitleBar::buttonsVisible() const
|
||||
|
@ -113,6 +144,36 @@ bool AppletTitleBar::isActive() const
|
|||
return m_active;
|
||||
}
|
||||
|
||||
void AppletTitleBar::initAnimations()
|
||||
{
|
||||
if (m_animations) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_animations = new QParallelAnimationGroup(this);
|
||||
QParallelAnimationGroup *group = m_animations.data();
|
||||
|
||||
if (m_applet->hasValidAssociatedApplication()) {
|
||||
Plasma::Animation *maximizeAnim =
|
||||
Plasma::Animator::create(Plasma::Animator::PixmapTransitionAnimation);
|
||||
maximizeAnim->setProperty("targetPixmap", m_icons->pixmap("maximize"));
|
||||
maximizeAnim->setTargetWidget(this);
|
||||
group->addAnimation(maximizeAnim);
|
||||
}
|
||||
|
||||
Plasma::Animation *confAnim =
|
||||
Plasma::Animator::create(Plasma::Animator::PixmapTransitionAnimation);
|
||||
Plasma::Animation *closeAnim =
|
||||
Plasma::Animator::create(Plasma::Animator::PixmapTransitionAnimation);
|
||||
confAnim->setProperty("targetPixmap", m_icons->pixmap("configure"));
|
||||
confAnim->setTargetWidget(this);
|
||||
|
||||
closeAnim->setProperty("targetPixmap", m_icons->pixmap("close"));
|
||||
closeAnim->setTargetWidget(this);
|
||||
group->addAnimation(confAnim);
|
||||
group->addAnimation(closeAnim);
|
||||
}
|
||||
|
||||
void AppletTitleBar::syncMargins()
|
||||
{
|
||||
const int extraMargin = 2;
|
||||
|
@ -236,6 +297,7 @@ void AppletTitleBar::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
{
|
||||
if (m_pressedButton == MaximizeButton && m_maximizeButtonRect.contains(event->pos())) {
|
||||
if (m_applet->hasValidAssociatedApplication()) {
|
||||
m_pulse->start();
|
||||
m_applet->runAssociatedApplication();
|
||||
}
|
||||
} else if (m_pressedButton == ConfigureButton && m_configureButtonRect.contains(event->pos())) {
|
||||
|
@ -292,7 +354,7 @@ void AppletTitleBar::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
|||
QParallelAnimationGroup *group = m_animations.data();
|
||||
|
||||
int i = 0;
|
||||
// TODO: revisit
|
||||
|
||||
if (m_applet->hasValidAssociatedApplication()) {
|
||||
if (group) {
|
||||
if (group->state() == QAbstractAnimation::Running) {
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include <QParallelAnimationGroup>
|
||||
#include <QtCore/qsharedpointer.h>
|
||||
|
||||
#include <plasma/animations/animation.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
class Applet;
|
||||
|
@ -83,6 +85,8 @@ private:
|
|||
Plasma::Svg *m_separator;
|
||||
Plasma::FrameSvg *m_background;
|
||||
|
||||
Plasma::Animation *m_pulse;
|
||||
|
||||
qreal m_savedAppletTopMargin;
|
||||
bool m_underMouse;
|
||||
bool m_buttonsVisible;
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include <KLocale>
|
||||
#include <KRun>
|
||||
|
||||
#include <Plasma/Animation>
|
||||
#include <Plasma/Applet>
|
||||
#include <Plasma/Extender>
|
||||
#include <Plasma/ExtenderItem>
|
||||
|
@ -94,6 +95,7 @@ QScriptValue constructTimerClass(QScriptEngine *engine);
|
|||
void registerSimpleAppletMetaTypes(QScriptEngine *engine);
|
||||
|
||||
KSharedPtr<UiLoader> SimpleJavaScriptApplet::s_widgetLoader;
|
||||
QHash<QString, Plasma::Animator::Animation> SimpleJavaScriptApplet::s_animationDefs;
|
||||
|
||||
SimpleJavaScriptApplet::SimpleJavaScriptApplet(QObject *parent, const QVariantList &args)
|
||||
: AbstractJsAppletScript(parent),
|
||||
|
@ -284,6 +286,20 @@ bool SimpleJavaScriptApplet::include(const QString &path)
|
|||
return m_env->include(path);
|
||||
}
|
||||
|
||||
void SimpleJavaScriptApplet::populateAnimationsHash()
|
||||
{
|
||||
if (s_animationDefs.isEmpty()) {
|
||||
s_animationDefs.insert("fade", Plasma::Animator::FadeAnimation);
|
||||
s_animationDefs.insert("geometry", Plasma::Animator::GeometryAnimation);
|
||||
s_animationDefs.insert("grow", Plasma::Animator::GrowAnimation);
|
||||
s_animationDefs.insert("pulse", Plasma::Animator::PulseAnimation);
|
||||
s_animationDefs.insert("rotate", Plasma::Animator::RotationAnimation);
|
||||
s_animationDefs.insert("rotateStacked", Plasma::Animator::RotationStackedAnimation);
|
||||
s_animationDefs.insert("slide", Plasma::Animator::SlideAnimation);
|
||||
s_animationDefs.insert("zoom", Plasma::Animator::ZoomAnimation);
|
||||
}
|
||||
}
|
||||
|
||||
bool SimpleJavaScriptApplet::init()
|
||||
{
|
||||
connect(applet(), SIGNAL(extenderItemRestored(Plasma::ExtenderItem*)),
|
||||
|
@ -480,6 +496,11 @@ void SimpleJavaScriptApplet::setupObjects()
|
|||
{
|
||||
QScriptValue global = m_engine->globalObject();
|
||||
|
||||
// Bindings for animations
|
||||
global.setProperty("animation", m_engine->newFunction(SimpleJavaScriptApplet::animation));
|
||||
global.setProperty("AnimationGroup", m_engine->newFunction(SimpleJavaScriptApplet::animationGroup));
|
||||
global.setProperty("ParallelAnimationGroup", m_engine->newFunction(SimpleJavaScriptApplet::parallelAnimationGroup));
|
||||
|
||||
QScriptValue v = m_engine->newVariant(QVariant::fromValue(*applet()->package()));
|
||||
global.setProperty("__plasma_package", v,
|
||||
QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
|
||||
|
@ -614,6 +635,76 @@ QScriptValue SimpleJavaScriptApplet::loadService(QScriptContext *context, QScrip
|
|||
return engine->newQObject(service, QScriptEngine::AutoOwnership);
|
||||
}
|
||||
|
||||
QScriptValue SimpleJavaScriptApplet::animation(QScriptContext *context, QScriptEngine *engine)
|
||||
{
|
||||
if (context->argumentCount() != 1) {
|
||||
return context->throwError(i18n("animation() takes one argument"));
|
||||
}
|
||||
|
||||
populateAnimationsHash();
|
||||
QString name = context->argument(0).toString();
|
||||
QString animName = name.toLower();
|
||||
const bool isPause = animName == "pause";
|
||||
const bool isProperty = animName == "property";
|
||||
|
||||
bool parentIsApplet = false;
|
||||
QGraphicsWidget *parent = extractParent(context, engine, 0, &parentIsApplet);
|
||||
QAbstractAnimation *anim = 0;
|
||||
Plasma::Animation *plasmaAnim = 0;
|
||||
if (isPause) {
|
||||
anim = new QPauseAnimation(parent);
|
||||
} else if (isProperty) {
|
||||
anim = new QPropertyAnimation(parent);
|
||||
} else if (s_animationDefs.contains(animName)) {
|
||||
plasmaAnim = Plasma::Animator::create(s_animationDefs.value(animName), parent);
|
||||
} else {
|
||||
SimpleJavaScriptApplet *jsApplet = qobject_cast<SimpleJavaScriptApplet *>(engine->parent());
|
||||
if (jsApplet) {
|
||||
//kDebug() << "trying to load it from the package";
|
||||
plasmaAnim = jsApplet->loadAnimationFromPackage(name, parent);
|
||||
}
|
||||
|
||||
if (!plasmaAnim) {
|
||||
plasmaAnim = Plasma::Animator::create(animName, parent);
|
||||
}
|
||||
}
|
||||
|
||||
if (plasmaAnim) {
|
||||
if (!parentIsApplet) {
|
||||
plasmaAnim->setTargetWidget(parent);
|
||||
}
|
||||
anim = plasmaAnim;
|
||||
}
|
||||
|
||||
if (anim) {
|
||||
QScriptValue value = engine->newQObject(anim);
|
||||
ScriptEnv::registerEnums(value, *anim->metaObject());
|
||||
return value;
|
||||
}
|
||||
|
||||
context->throwError(i18n("%1 is not a known animation type", animName));
|
||||
|
||||
ScriptEnv *env = ScriptEnv::findScriptEnv(engine);
|
||||
if (env) {
|
||||
env->checkForErrors(false);
|
||||
}
|
||||
return engine->undefinedValue();
|
||||
}
|
||||
|
||||
QScriptValue SimpleJavaScriptApplet::animationGroup(QScriptContext *context, QScriptEngine *engine)
|
||||
{
|
||||
QGraphicsWidget *parent = extractParent(context, engine);
|
||||
SequentialAnimationGroup *group = new SequentialAnimationGroup(parent);
|
||||
return engine->newQObject(group);
|
||||
}
|
||||
|
||||
QScriptValue SimpleJavaScriptApplet::parallelAnimationGroup(QScriptContext *context, QScriptEngine *engine)
|
||||
{
|
||||
QGraphicsWidget *parent = extractParent(context, engine);
|
||||
ParallelAnimationGroup *group = new ParallelAnimationGroup(parent);
|
||||
return engine->newQObject(group);
|
||||
}
|
||||
|
||||
QScriptValue SimpleJavaScriptApplet::loadui(QScriptContext *context, QScriptEngine *engine)
|
||||
{
|
||||
if (context->argumentCount() != 1) {
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <QScriptValue>
|
||||
|
||||
#include <Plasma/Animator>
|
||||
#include <Plasma/DataEngine>
|
||||
|
||||
#include "simplebindings/uiloader.h"
|
||||
|
@ -81,6 +82,9 @@ private:
|
|||
static void populateAnimationsHash();
|
||||
|
||||
static QString findSvg(QScriptContext *context, QScriptEngine *engine, const QString &file);
|
||||
static QScriptValue animation(QScriptContext *context, QScriptEngine *engine);
|
||||
static QScriptValue animationGroup(QScriptContext *context, QScriptEngine *engine);
|
||||
static QScriptValue parallelAnimationGroup(QScriptContext *context, QScriptEngine *engine);
|
||||
static QScriptValue jsi18n(QScriptContext *context, QScriptEngine *engine);
|
||||
static QScriptValue jsi18nc(QScriptContext *context, QScriptEngine *engine);
|
||||
static QScriptValue jsi18np(QScriptContext *context, QScriptEngine *engine);
|
||||
|
@ -104,6 +108,7 @@ private:
|
|||
|
||||
private:
|
||||
static KSharedPtr<UiLoader> s_widgetLoader;
|
||||
static QHash<QString, Plasma::Animator::Animation> s_animationDefs;
|
||||
ScriptEnv *m_env;
|
||||
QScriptEngine *m_engine;
|
||||
QScriptValue m_self;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <QScriptEngine>
|
||||
|
||||
#include <Plasma/Applet>
|
||||
#include <Plasma/Animation>
|
||||
#include <Plasma/Extender>
|
||||
#include <Plasma/VideoWidget>
|
||||
|
||||
|
@ -28,6 +29,7 @@
|
|||
Q_DECLARE_METATYPE(QGraphicsWidget*)
|
||||
Q_DECLARE_METATYPE(QGraphicsLayout*)
|
||||
|
||||
Q_DECLARE_METATYPE(Plasma::Animation*)
|
||||
Q_DECLARE_METATYPE(Plasma::Applet*)
|
||||
Q_DECLARE_METATYPE(Plasma::Extender*)
|
||||
Q_DECLARE_METATYPE(Plasma::VideoWidget::Controls)
|
||||
|
@ -67,6 +69,18 @@ void controlsFromScriptValue(const QScriptValue& obj, Plasma::VideoWidget::Contr
|
|||
}
|
||||
}
|
||||
|
||||
typedef Plasma::Animation* AnimationPtr;
|
||||
QScriptValue qScriptValueFromAnimation(QScriptEngine *engine, const AnimationPtr &anim)
|
||||
{
|
||||
return engine->newQObject(const_cast<Plasma::Animation *>(anim), QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject);
|
||||
}
|
||||
|
||||
void abstractAnimationFromQScriptValue(const QScriptValue &scriptValue, AnimationPtr &anim)
|
||||
{
|
||||
QObject *obj = scriptValue.toQObject();
|
||||
anim = static_cast<Plasma::Animation *>(obj);
|
||||
}
|
||||
|
||||
typedef QGraphicsWidget * QGraphicsWidgetPtr;
|
||||
QScriptValue qScriptValueFromQGraphicsWidget(QScriptEngine *engine, const QGraphicsWidgetPtr &anim)
|
||||
{
|
||||
|
@ -124,6 +138,7 @@ void registerSimpleAppletMetaTypes(QScriptEngine *engine)
|
|||
qScriptRegisterMetaType<Plasma::Svg*>(engine, qScriptValueFromSvg, svgFromQScriptValue);
|
||||
|
||||
qScriptRegisterSequenceMetaType<QList<double> >(engine);
|
||||
qScriptRegisterMetaType<Plasma::Animation *>(engine, qScriptValueFromAnimation, abstractAnimationFromQScriptValue);
|
||||
qScriptRegisterMetaType<Plasma::Extender *>(engine, qScriptValueFromExtender, extenderFromQScriptValue);
|
||||
qScriptRegisterMetaType<Plasma::VideoWidget::Controls>(engine, qScriptValueFromControls, controlsFromScriptValue, QScriptValue());
|
||||
qScriptRegisterMetaType<Qt::MouseButton>(engine, qScriptValueFromMouseButton, mouseButtonFromScriptValue);
|
||||
|
|
Loading…
Add table
Reference in a new issue