From 3b16876d4a0e87c50e6926d8d3bc49e805aba601 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Sun, 28 Feb 2010 16:11:48 +0000 Subject: [PATCH] full popupapplet support svn path=/trunk/KDE/kdebase/runtime/; revision=1097178 --- .../simplebindings/appletinterface.cpp | 35 +++++++++++++++++++ .../simplebindings/appletinterface.h | 11 ++++++ .../javascript/simplejavascriptapplet.cpp | 11 ++++++ .../javascript/simplejavascriptapplet.h | 1 + 4 files changed, 58 insertions(+) diff --git a/scriptengines/javascript/simplebindings/appletinterface.cpp b/scriptengines/javascript/simplebindings/appletinterface.cpp index 939f94ffe..62f49fb43 100644 --- a/scriptengines/javascript/simplebindings/appletinterface.cpp +++ b/scriptengines/javascript/simplebindings/appletinterface.cpp @@ -389,4 +389,39 @@ void PopupAppletInterface::setPopupIconByName(const QString &name) return popupApplet()->setPopupIcon(name); } +void PopupAppletInterface::setPassivePopup(bool passive) +{ + popupApplet()->setPassivePopup(passive); +} + +bool PopupAppletInterface::isPassivePopup() const +{ + return popupApplet()->isPassivePopup(); +} + +void PopupAppletInterface::togglePopup() +{ + popupApplet()->togglePopup(); +} + +void PopupAppletInterface::hidePopup() +{ + popupApplet()->hidePopup(); +} + +void PopupAppletInterface::showPopup() +{ + popupApplet()->showPopup(); +} + +void PopupAppletInterface::setPopupWidget(QGraphicsWidget *widget) +{ + popupApplet()->setGraphicsWidget(widget); +} + +QGraphicsWidget *PopupAppletInterface::popupWidget() +{ + return popupApplet()->graphicsWidget(); +} + #include "appletinterface.moc" diff --git a/scriptengines/javascript/simplebindings/appletinterface.h b/scriptengines/javascript/simplebindings/appletinterface.h index e4ca0d6f6..fa414ea79 100644 --- a/scriptengines/javascript/simplebindings/appletinterface.h +++ b/scriptengines/javascript/simplebindings/appletinterface.h @@ -282,6 +282,8 @@ class PopupAppletInterface : public AppletInterface { Q_OBJECT Q_PROPERTY(QIcon popupIcon READ popupIcon WRITE setPopupIcon) + Q_PROPERTY(bool passivePopup READ isPassivePopup WRITE setPassivePopup) + Q_PROPERTY(QGraphicsWidget *popupWidget READ popupWidget WRITE setPopupWidget) public: PopupAppletInterface(SimpleJavaScriptApplet *parent); @@ -291,8 +293,17 @@ public: inline Plasma::PopupApplet *popupApplet() const { return static_cast(m_appletScriptEngine->applet()); } + void setPassivePopup(bool passive); + bool isPassivePopup() const; + + void setPopupWidget(QGraphicsWidget *widget); + QGraphicsWidget *popupWidget(); + public Q_SLOTS: void setPopupIconByName(const QString &name); + void togglePopup(); + void hidePopup(); + void showPopup(); }; #endif diff --git a/scriptengines/javascript/simplejavascriptapplet.cpp b/scriptengines/javascript/simplejavascriptapplet.cpp index faa7107a7..8bfe456dd 100644 --- a/scriptengines/javascript/simplejavascriptapplet.cpp +++ b/scriptengines/javascript/simplejavascriptapplet.cpp @@ -183,6 +183,13 @@ void SimpleJavaScriptApplet::extenderItemRestored(Plasma::ExtenderItem* item) callFunction("initExtenderItem", args); } +void SimpleJavaScriptApplet::popupEvent(bool popped) +{ + QScriptValueList args; + args << popped; + callFunction("popupEvent", args); +} + void SimpleJavaScriptApplet::executeAction(const QString &name) { //callFunction("action_" + name); @@ -330,6 +337,10 @@ void SimpleJavaScriptApplet::setupObjects() m_self.setScope(global); global.setProperty("plasmoid", m_self); + if (isPopupApplet) { + connect(applet(), SIGNAL(popupEvent(bool)), this, SLOT(popupEvent(bool))); + } + QScriptValue args = m_engine->newArray(); int i = 0; foreach (const QVariant &arg, applet()->startupArguments()) { diff --git a/scriptengines/javascript/simplejavascriptapplet.h b/scriptengines/javascript/simplejavascriptapplet.h index 26dd3c6ac..8a86bb12a 100644 --- a/scriptengines/javascript/simplejavascriptapplet.h +++ b/scriptengines/javascript/simplejavascriptapplet.h @@ -64,6 +64,7 @@ public Q_SLOTS: void executeAction(const QString &name); void collectGarbage(); void extenderItemRestored(Plasma::ExtenderItem* item); + void popupEvent(bool popped); private Q_SLOTS: void engineReportsError(ScriptEnv *engine, bool fatal);