• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

kalzium

didyouknow.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002     copyright            : (C) 2008 by Carsten Niehaus
00003     email                : cniehaus@kde.org
00004  ***************************************************************************/
00005 /***************************************************************************
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  ***************************************************************************/
00013 #include "didyouknow.h"
00014 
00015 #include <QDebug>
00016 #include <QPainter>
00017 #include <QPen>
00018 
00019 KalziumDidyouknow::KalziumDidyouknow(QObject *parent, const QVariantList &args)
00020     : Plasma::Applet(parent, args)
00021 {
00022     m_theme.setImagePath("widgets/chalkboard");
00023     // init random sequence
00024     m_random = new KRandomSequence( QDateTime::currentDateTime().toTime_t() );
00025 
00026     m_engine = dataEngine("kalzium");
00027     m_label1 = 0;
00028     setHasConfigurationInterface(false);
00029     setAcceptDrops(false);
00030     setAcceptsHoverEvents(true);
00031 //     setDrawStandardBackground(false);
00032 
00033     resize(512,256);
00034 }
00035 
00036 void KalziumDidyouknow::init()
00037 {
00038     qDebug() << "initializing DidYouKnow-Applet";
00039 
00040     m_engine->connectSource( "Fact" , this, 1000);
00041 
00042     m_theme.setContainsMultipleImages(false);
00043 
00044     m_label1 = new QGraphicsTextItem(this);
00045     m_label1->setPos( m_theme.elementRect( "canvas" ).topLeft() );
00046     m_label1->setDefaultTextColor( Qt::white );
00047 }
00048 
00049 void KalziumDidyouknow::constraintsUpdated(Plasma::Constraints constraints)
00050 {
00051 //     setDrawStandardBackground(false);
00052     prepareGeometryChange();
00053     if (constraints & Plasma::SizeConstraint) {
00054          m_theme.resize(size());
00055     }
00056     
00057     m_label1->setPos( m_theme.elementRect( "canvas" ).topLeft() );
00058 }
00059 
00060 KalziumDidyouknow::~KalziumDidyouknow()
00061 {
00062     delete m_random;
00063 }
00064 
00065 void KalziumDidyouknow::dataUpdated(const QString& source, const Plasma::DataEngine::Data &data)
00066 {
00067     qDebug() << "entering dataUpdated()";
00068     Q_UNUSED(source);
00069 
00070     if (m_label1)  {
00071 //      m_label1->setAlignment(Qt::AlignLeft);
00072         m_label1->setPlainText( data["fact"].toString() );
00073     }
00074 }
00075 
00076 
00077 void KalziumDidyouknow::paintInterface(QPainter *p,
00078                        const QStyleOptionGraphicsItem *option,
00079                        const QRect &contentsRect)
00080 {
00081     Q_UNUSED(option);
00082 
00083     p->setRenderHint(QPainter::SmoothPixmapTransform);
00084     p->setRenderHint(QPainter::Antialiasing);
00085 
00086     // Now we draw the applet, starting with our svg
00087     m_theme.resize(size());
00088     m_theme.paint(p, 0, 0 );
00089 }
00090 
00091 #include "didyouknow.moc"

kalzium

Skip menu "kalzium"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeedu

Skip menu "kdeedu"
  • kalzium
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  •   docs
  •   src
  • parley
  •   stepcore
Generated for kdeedu by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal