add more spacing
[personal-kdebase.git] / workspace / plasma / scriptengines / webkit / dashboardjs.cpp
blobd41252e8eb54c605d1c69d0257cdd26e37ca99a8
1 /*
2 Copyright (c) 2008 Beat Wolf <asraniel@fryx.ch>
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 THE SOFTWARE.
21 */
23 #include "dashboardjs.h"
24 #include <kdebug.h>
26 #include <KRun>
27 #include <KConfigGroup>
29 #include <QPainter>
30 #include <QStyleOptionGraphicsItem>
31 #include <QWidget>
33 #include <QGraphicsItem>
34 #include <QEvent>
35 #include <QGraphicsScene>
37 DashboardJs::DashboardJs(QWebFrame *frame, QObject *parent, Plasma::Applet *applet)
38 : QObject(parent)
40 m_applet = applet;
41 m_frame = frame;
44 DashboardJs::~DashboardJs()
46 if(m_frame){
47 kDebug() << "deconstructor calles javascript: " << m_onremove;
48 m_frame->evaluateJavaScript(m_onremove);
52 void DashboardJs::openApplication(QString name)
54 //STUB
55 kDebug() << "not implemented: open application" << name;
57 //WARNING: this might be dangerous and exploited (or not)
58 /* create list of applications:
59 * com.apple.ical
60 * com.RealNetworks.RealPlayer
64 void DashboardJs::openURL(QString name)
66 //TODO: this could be dangerous(really?). filter valid urls
67 new KRun(name, 0);
70 QVariant DashboardJs::preferenceForKey(QString key)
72 KConfigGroup conf = m_applet->config();
74 if (!conf.hasKey(key)) {
75 return QVariant();
78 return conf.readEntry(key,"");
81 void DashboardJs::prepareForTransition(QString transition)
83 //STUB
84 kDebug() << "not implemented: transition with name" << transition;
85 //TODO:freeze widget drawing. possible?
86 //not really needed for things to work, but would be prettier
89 void DashboardJs::performTransition()
91 //STUB
92 //TODO: enable widget drawing again, perform nice animation.
93 kDebug() << "not implemented: perform transition";
94 //not really needed for things to work, but would be prettier
97 void DashboardJs::setCloseBoxOffset(int x, int y)
99 //STUB, not needed, plasma has its own close box
100 kDebug() << "not implemented: close box offset" << x << y;
103 void DashboardJs::setPreferenceForKey(QString value, QString key)
105 kDebug() << "save key" << key << value;
106 KConfigGroup conf = m_applet->config();
107 conf.writeEntry(key, value);
110 void DashboardJs::system(QString command, QString handler)
112 //WARNING: this might be dangerous and exploited.
113 //STUB
114 kDebug() << "not implemented: system command:" << command << handler;
117 //Property sets and gets
118 QString DashboardJs::identifier() const
120 return QString::number(m_applet->id());
123 QString DashboardJs::onshow() const
125 return m_onshow;
128 void DashboardJs::setOnshow(const QString &value)
130 m_onshow = value;
133 QString DashboardJs::onhide() const
135 return m_onhide;
138 void DashboardJs::setOnhide(const QString &value)
140 m_onhide = value;
143 QString DashboardJs::onremove() const
145 return m_onremove;
148 void DashboardJs::setOnremove(const QString &value)
150 m_onremove = value;
154 QString DashboardJs::ondragstart() const
156 return m_ondragstart;
159 void DashboardJs::setOndragstart(const QString &value)
161 m_ondragstart = value;
164 QString DashboardJs::ondragstop() const
166 return m_ondragstop;
169 void DashboardJs::setOndragstop(const QString &value)
171 m_ondragstop = value;
173 //only for testing purpose
174 //TODO: remove when not needed anymore
175 void DashboardJs::hello(int test)
177 kDebug() << "hello world" << test;