1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
5 * KWorship is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
10 * KWorship is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with KWorship. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
21 * @file KwBackgroundManager.cpp
22 * @brief Background manager.
23 * @author James Hogan <james@albanarts.com>
26 #include "KwBackgroundManager.h"
27 #include "KwDisplayStyles.h"
29 #include "KwImageLayer.h"
30 #include "KwVideoLayer.h"
32 #include <phonon/mediaobject.h>
33 #include <phonon/audiooutput.h>
36 * Constructors + destructors
39 /// Default constructor.
40 KwBackgroundManager::KwBackgroundManager(KwMediaManager
* mediaManager
)
41 : KwAbstractDisplayManager()
42 , m_mediaManager(mediaManager
)
49 KwBackgroundManager::~KwBackgroundManager()
58 /// Apply the styles in a scope.
59 void KwBackgroundManager::applyStyles(KwCssScope
* scope
)
61 KwResourceLink image
= KwDisplayStyles::background::image::src(scope
);
64 // Set background if applicable
65 setPlain(KwDisplayStyles::background::brush(scope
));
69 /// @todo Get the actual file from resource link instead of assuming its a url.
70 setImage(QPixmap(image
.url().toLocalFile()));
74 /// Clear the background.
75 void KwBackgroundManager::clear()
77 m_display
.clearLayers();
84 /// Set background to a brush.
85 void KwBackgroundManager::setPlain(QBrush brush
)
88 m_imageLayer
= new KwImageLayer(brush
);
89 m_display
.setLayer(0, m_imageLayer
, true);
92 /// Set the background to an image.
93 void KwBackgroundManager::setImage(const QPixmap
& pixmap
)
96 m_imageLayer
= new KwImageLayer(pixmap
);
97 m_display
.setLayer(0, m_imageLayer
, true);
100 /// Set the background up for video.
101 void KwBackgroundManager::setVideo()
103 // Make sure the background video layer is set up
104 if (0 == m_videoLayer
)
107 m_videoLayer
= new KwVideoLayer(m_mediaManager
);
108 m_display
.setLayer(0, m_videoLayer
, true);