~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to libs/plasmagenericshell/wallpaperpreview.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2008  Petri Damsten <damu@iki.fi>
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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/>.
 
16
 */
 
17
 
 
18
#include "wallpaperpreview.h"
 
19
#include <QPainter>
 
20
#include <QPaintEvent>
 
21
#include <Plasma/Wallpaper>
 
22
#include <Plasma/Svg>
 
23
 
 
24
WallpaperPreview::WallpaperPreview(QWidget *parent) : QWidget(parent), m_wallpaper(0)
 
25
{
 
26
    m_wallpaperOverlay = new Plasma::Svg(this);
 
27
    m_wallpaperOverlay->setImagePath("widgets/monitor");
 
28
    m_wallpaperOverlay->setContainsMultipleImages(true);
 
29
}
 
30
 
 
31
WallpaperPreview::~WallpaperPreview()
 
32
{
 
33
}
 
34
 
 
35
void WallpaperPreview::setWallpaper(Plasma::Wallpaper* wallpaper)
 
36
{
 
37
    m_wallpaper = wallpaper;
 
38
    if (m_wallpaper) {
 
39
        connect(m_wallpaper, SIGNAL(update(const QRectF &)),
 
40
                this, SLOT(updateRect(const QRectF &)));
 
41
        resizeEvent(0);
 
42
    }
 
43
}
 
44
 
 
45
void WallpaperPreview::resizeEvent(QResizeEvent* event)
 
46
{
 
47
    Q_UNUSED(event)
 
48
    if (m_wallpaper) {
 
49
        m_wallpaper->setBoundingRect(contentsRect());
 
50
    }
 
51
}
 
52
 
 
53
void WallpaperPreview::updateRect(const QRectF& rect)
 
54
{
 
55
    update(rect.toRect());
 
56
}
 
57
 
 
58
void WallpaperPreview::paintEvent(QPaintEvent* event)
 
59
{
 
60
    QPainter painter(this);
 
61
    if (m_wallpaper) {
 
62
        m_wallpaper->paint(&painter, event->rect());
 
63
        m_wallpaperOverlay->paint(&painter, QRect(QPoint(0,0), size()), "glass");
 
64
    }
 
65
}
 
66
 
 
67
#include "wallpaperpreview.moc"