// // 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::mousePressEvent( QGraphicsSceneMouseEvent * event ) { // this->items->push_back(new UCD_Item()); //(this->scene())->addItem(items->at(items->size()-1)); applet = static_cast(scene())->addApplet("plasma_applet_ucd_item"); //applet->mousePressEvent(event); items->push_back(applet); } #include "ucd_desktop.moc"