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

Applets

monitoricon.cpp

Go to the documentation of this file.
00001 /*
00002  *   Copyright (C) 2007 Petri Damsten <damu@iki.fi>
00003  *
00004  *   This program is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU Library General Public License as
00006  *   published by the Free Software Foundation; either version 2, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details
00013  *
00014  *   You should have received a copy of the GNU Library General Public
00015  *   License along with this program; if not, write to the
00016  *   Free Software Foundation, Inc.,
00017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018  */
00019 
00020 #include "monitoricon.h"
00021 #include <kdebug.h>
00022 #include <QPainter>
00023 #include <KIcon>
00024 #include <KIconLoader>
00025 
00026 #define MARGIN 5
00027 
00028 class MonitorIcon::Private
00029 {
00030     public:
00031         Private() : imageSize(22, 22) { }
00032 
00033         QSizeF imageSize;
00034         QString image;
00035         QStringList overlays;
00036 };
00037 
00038 MonitorIcon::MonitorIcon(QGraphicsItem *parent) :
00039         QGraphicsWidget(parent),
00040         d(new Private)
00041 {
00042     setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
00043     setPreferredSize(d->imageSize.width() + 2 * MARGIN, d->imageSize.height() + 2 * MARGIN);
00044 }
00045 
00046 MonitorIcon::~MonitorIcon()
00047 {
00048     delete d;
00049 }
00050 
00051 QString MonitorIcon::image() const
00052 {
00053     return d->image;
00054 }
00055 
00056 void MonitorIcon::setImage(const QString &image)
00057 {
00058     d->image = image;
00059     update();
00060 }
00061 
00062 QStringList MonitorIcon::overlays() const
00063 {
00064     return d->overlays;
00065 }
00066 
00067 void MonitorIcon::setOverlays( const QStringList & overlays )
00068 {
00069     d->overlays = overlays;
00070     update();
00071 }
00072 
00073 void MonitorIcon::paint(QPainter *p,
00074                         const QStyleOptionGraphicsItem *option,
00075                         QWidget *widget)
00076 {
00077     Q_UNUSED(option)
00078     Q_UNUSED(widget)
00079 
00080     p->drawPixmap(QPointF((size().width() - d->imageSize.width()) / 2,
00081                           (size().height() - d->imageSize.height()) / 2),
00082                   KIcon(d->image, KIconLoader::global(),
00083                         d->overlays).pixmap(d->imageSize.toSize()));
00084 }
00085 
00086 #include "monitoricon.moc"

Applets

Skip menu "Applets"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
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