// // C++ Implementation: ucd_desktop // // Description: // // // Author: <>, (C) 2007 // // Copyright: See COPYING file that comes with this distribution // // #include "ucd_desktop.h" #include "plasma/corona.h" #include #include #include #include #include UCD_Desktop::UCD_Desktop(QObject *parent,const QStringList &args) : Plasma::Applet(parent, args), m_tutorialTheme("widgets/background", this), m_tutorialIcon("document") { // First we create the objects to hold the icon and // background image // TIP: Read the section about setDrawStandardBackground(true) // m_tutorialTheme = new Plasma::Svg("widgets/background",this); // m_tutorialIcon = new KsIcon("document"); // Tell the Plasma/Svg object to use the whole image, instead // of parts of it. m_tutorialTheme.setContentType(Plasma::Svg::SingleImage); // A small demonstration of the setFailedToLaunch function bool Armageddon = false; if (Armageddon) { setFailedToLaunch(true, "No world to say hello"); } } UCD_Desktop::~UCD_Desktop() { if (failedToLaunch()) { // Do some cleanup here } else { // Save settings } } QRectF UCD_Desktop::boundingRect() const { // In this tutorial we use a fixed size return QRectF(0,0,128,128); } void UCD_Desktop::paintInterface(QPainter *p,const QStyleOptionGraphicsItem *option, QWidget *widget) { // Now we draw the applet, starting with the background m_tutorialTheme.resize(boundingRect().width(), boundingRect().height()); m_tutorialTheme.paint(p, boundingRect().left(), boundingRect().top()); // The we place the icon and text p->drawPixmap(20, 0, m_tutorialIcon.pixmap(boundingRect().width() - 40)); p->save(); p->setPen(Qt::white); p->drawText(boundingRect(), Qt::AlignBottom+Qt::AlignHCenter, "Hello UCD"); p->restore(); //this->setPos(1000,10); } void UCD_Desktop::foo(QGraphicsSceneEvent * event) { this->moveBy(10,10); } void UCD_Desktop::mouseDoubleClickEvent( QGraphicsSceneMouseEvent * event ) { applet = static_cast(scene())->addApplet("plasma_applet_ucd_item"); connect(applet,SIGNAL(dragEnterEvent(QGraphicsSceneDragDropEvent *event)),this,SLOT(foo(QGraphicsSceneEvent *event))); connect(applet,SIGNAL(dragLeaveEvent(QGraphicsSceneDragDropEvent *event)),this,SLOT(foo(QGraphicsSceneEvent *event))); connect(applet,SIGNAL(dropEvent(QGraphicsSceneDragDropEvent *event)),this,SLOT(foo(QGraphicsSceneEvent *event))); connect(applet,SIGNAL(hoverEnterEvent(QGraphicsSceneHoverEvent * event)),this,SLOT(foo(QGraphicsSceneEvent * event))); connect(applet,SIGNAL(hoverLeaveEvent(QGraphicsSceneHoverEvent * event)),this,SLOT(foo(QGraphicsSceneEvent * event))); connect(applet,SIGNAL(mousePressEventSig(QGraphicsSceneMouseEvent * event)),this,SLOT(foo(QGraphicsSceneEvent * event))); //connect(applet,SIGNAL(mouseMoveEventSig(QGraphicsSceneMouseEvent * event)),this,SLOT(foo(QGraphicsSceneEvent * event))); connect(applet,SIGNAL(mouseReleaseEventSig(QGraphicsSceneMouseEvent * event)),this,SLOT(foo(QGraphicsSceneEvent * event))); //applet->desktop = this; this->moveBy(10,0); } #include "ucd_desktop.moc"