2 * Copyright 2008 Petri Damsten <damu@iki.fi>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "wallpaperpreview.h"
20 #include <QPaintEvent>
21 #include <Plasma/Wallpaper>
24 WallpaperPreview::WallpaperPreview(QWidget
*parent
) : QWidget(parent
), m_wallpaper(0)
26 m_wallpaperOverlay
= new Plasma::Svg(this);
27 m_wallpaperOverlay
->setImagePath("widgets/monitor");
28 m_wallpaperOverlay
->setContainsMultipleImages(true);
31 WallpaperPreview::~WallpaperPreview()
35 void WallpaperPreview::setWallpaper(Plasma::Wallpaper
* wallpaper
)
37 m_wallpaper
= wallpaper
;
39 connect(m_wallpaper
, SIGNAL(update(const QRectF
&)),
40 this, SLOT(updateRect(const QRectF
&)));
45 void WallpaperPreview::resizeEvent(QResizeEvent
* event
)
49 m_wallpaper
->setBoundingRect(contentsRect());
53 void WallpaperPreview::updateRect(const QRectF
& rect
)
55 update(rect
.toRect());
58 void WallpaperPreview::paintEvent(QPaintEvent
* event
)
60 QPainter
painter(this);
62 m_wallpaper
->paint(&painter
, event
->rect());
63 m_wallpaperOverlay
->paint(&painter
, QRect(QPoint(0,0), size()), "glass");
67 #include "wallpaperpreview.moc"