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

Plasma

wallpaperpreview.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 2008  Petri Damsten <damu@iki.fi>
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License as
00006  * published by the Free Software Foundation; either version 2 of
00007  * the License, or (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 General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #include "wallpaperpreview.h"
00019 #include <QPainter>
00020 #include <QPaintEvent>
00021 #include <Plasma/Wallpaper>
00022 #include <Plasma/Svg>
00023 
00024 WallpaperPreview::WallpaperPreview(QWidget *parent) : QWidget(parent), m_wallpaper(0)
00025 {
00026     m_wallpaperOverlay = new Plasma::Svg(this);
00027     m_wallpaperOverlay->setImagePath("widgets/monitor");
00028     m_wallpaperOverlay->setContainsMultipleImages(true);
00029 }
00030 
00031 WallpaperPreview::~WallpaperPreview()
00032 {
00033 }
00034 
00035 void WallpaperPreview::setWallpaper(Plasma::Wallpaper* wallpaper)
00036 {
00037     m_wallpaper = wallpaper;
00038     if (m_wallpaper) {
00039         connect(m_wallpaper, SIGNAL(update(const QRectF &)),
00040                 this, SLOT(updateRect(const QRectF &)));
00041         resizeEvent(0);
00042     }
00043 }
00044 
00045 void WallpaperPreview::resizeEvent(QResizeEvent* event)
00046 {
00047     Q_UNUSED(event)
00048     if (m_wallpaper) {
00049         m_wallpaper->setBoundingRect(contentsRect());
00050     }
00051 }
00052 
00053 void WallpaperPreview::updateRect(const QRectF& rect)
00054 {
00055     update(rect.toRect());
00056 }
00057 
00058 void WallpaperPreview::paintEvent(QPaintEvent* event)
00059 {
00060     QPainter painter(this);
00061     if (m_wallpaper) {
00062         m_wallpaper->paint(&painter, event->rect());
00063         m_wallpaperOverlay->paint(&painter, QRect(QPoint(0,0), size()), "glass");
00064     }
00065 }
00066 
00067 #include "wallpaperpreview.moc"

Plasma

Skip menu "Plasma"
  • 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