Plasma
dashboardapplet.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "dashboardapplet.h"
00023
00024 #include <QGraphicsSceneMouseEvent>
00025 #include <kstandarddirs.h>
00026
00027 #include <QApplication>
00028 #include <QPainter>
00029 #include <qdebug.h>
00030 #include <QtNetwork>
00031 #include <math.h>
00032
00033 #include <plasma/applet.h>
00034 #include <plasma/package.h>
00035
00036 static inline QByteArray dataFor(const QString &str)
00037 {
00038 QFile f(str);
00039 f.open(QIODevice::ReadOnly);
00040 QByteArray data = f.readAll();
00041 f.close();
00042 return data;
00043 }
00044
00045 DashboardApplet::DashboardApplet(QObject *parent, const QVariantList &args)
00046 : WebApplet(parent, args)
00047 {
00048 }
00049
00050 DashboardApplet::~DashboardApplet()
00051 {
00052 }
00053
00054 bool DashboardApplet::init()
00055 {
00056 WebApplet::init();
00057
00058 applet()->setAcceptsHoverEvents(true);
00059
00060
00061 QString webpage = package()->filePath("webpage");
00062
00063
00064 if (webpage.isEmpty()) {
00065 return false;
00066 }
00067
00068
00069 setHtml(dataFor(webpage), QUrl(package()->path()));
00070 return true;
00071 }
00072
00073 #include "dashboardapplet.moc"